alshabib
Committed by Gerrit Code Review

support addition and removal of mcast sinks

vlan mcast rules are now optional

Change-Id: Icb7022089a6e139970040d8cdea97df0cdc8dc7c
......@@ -246,7 +246,7 @@ public class IgmpSnoop {
.withMeta(DefaultTrafficTreatment.builder()
.setOutput(PortNumber.CONTROLLER).build())
.fromApp(appId)
.withPriority(1000)
.withPriority(10000)
.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
......@@ -417,6 +417,7 @@ public class IgmpSnoop {
private class InternalDeviceListener implements DeviceListener {
@Override
public void event(DeviceEvent event) {
DeviceId devId = event.subject().id();
switch (event.type()) {
case DEVICE_ADDED:
......@@ -427,11 +428,15 @@ public class IgmpSnoop {
case PORT_STATS_UPDATED:
break;
case PORT_ADDED:
if (event.port().isEnabled()) {
if (!oltData.get(devId).uplink().equals(event.port().number()) &&
event.port().isEnabled()) {
processFilterObjective(event.subject().id(), event.port(), false);
}
break;
case PORT_UPDATED:
if (oltData.get(devId).uplink().equals(event.port().number())) {
break;
}
if (event.port().isEnabled()) {
processFilterObjective(event.subject().id(), event.port(), false);
} else {
......
......@@ -15,13 +15,10 @@
*/
package org.onosproject.store.serializers;
import com.esotericsoftware.kryo.serializers.JavaSerializer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.onlab.packet.ChassisId;
import org.onlab.packet.EthType;
import org.onlab.packet.Ip4Address;
......@@ -90,8 +87,8 @@ import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.device.DefaultPortStatistics;
import org.onosproject.net.device.OchPortDescription;
import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.OtuPortDescription;
import org.onosproject.net.device.OmsPortDescription;
import org.onosproject.net.device.OtuPortDescription;
import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.flow.CompletedBatchOperation;
import org.onosproject.net.flow.DefaultFlowEntry;
......@@ -257,12 +254,11 @@ public final class KryoNamespaces {
.register(HashMap.class)
.register(ConcurrentHashMap.class)
.register(CopyOnWriteArraySet.class)
.register(new JavaSerializer(), Sets.newConcurrentHashSet().getClass())
.register(ArrayList.class,
LinkedList.class,
HashSet.class,
LinkedHashSet.class
)
)
.register(Maps.immutableEntry("a", "b").getClass())
.register(new ArraysAsListSerializer(), Arrays.asList().getClass())
.register(Collections.singletonList(1).getClass())
......@@ -541,5 +537,6 @@ public final class KryoNamespaces {
// not to be instantiated
private KryoNamespaces() {}
private KryoNamespaces() {
}
}
......
......@@ -25,6 +25,7 @@ import org.apache.commons.lang3.tuple.Pair;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.packet.EthType;
import org.onlab.packet.IPv4;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.VlanId;
import org.onlab.util.KryoNamespace;
import org.onosproject.core.ApplicationId;
......@@ -47,6 +48,7 @@ import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.criteria.EthTypeCriterion;
import org.onosproject.net.flow.criteria.IPCriterion;
import org.onosproject.net.flow.criteria.IPProtocolCriterion;
import org.onosproject.net.flow.criteria.PortCriterion;
import org.onosproject.net.flow.criteria.VlanIdCriterion;
......@@ -99,6 +101,7 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
private DeviceId deviceId;
private ApplicationId appId;
private IpPrefix mcastPrefix = IpPrefix.valueOf("224.0.0.0/4");
protected FlowObjectiveStore flowObjectiveStore;
......@@ -253,26 +256,33 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment);
GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
GroupDescription groupDesc =
new DefaultGroupDescription(deviceId,
GroupDescription.Type.ALL,
new GroupBuckets(Collections.singletonList(bucket)),
key,
null,
nextObjective.appId());
pendingGroups.put(key, nextObjective);
switch (nextObjective.op()) {
case ADD:
GroupDescription groupDesc =
new DefaultGroupDescription(deviceId,
GroupDescription.Type.ALL,
new GroupBuckets(Collections.singletonList(bucket)),
key,
null,
nextObjective.appId());
groupService.addGroup(groupDesc);
break;
case REMOVE:
groupService.removeGroup(deviceId, key, nextObjective.appId());
break;
case ADD_TO_EXISTING:
groupService.addBucketsToGroup(deviceId, key,
new GroupBuckets(Collections.singletonList(bucket)),
key, nextObjective.appId());
break;
case REMOVE_FROM_EXISTING:
//TODO: handle addition to group when caller signals it.
groupService.removeBucketsFromGroup(deviceId, key,
new GroupBuckets(Collections.singletonList(bucket)),
key, nextObjective.appId());
break;
default:
log.warn("Unknown next objective operation: {}", nextObjective.op());
......@@ -287,14 +297,14 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
fail(fwd, ObjectiveError.BADPARAMS);
}
OLTPipelineGroup next = getGroupForNextObjective(fwd.nextId());
GroupKey key = getGroupForNextObjective(fwd.nextId());
if (next == null) {
if (key == null) {
log.error("Group for forwarding objective missing: {}", fwd);
fail(fwd, ObjectiveError.GROUPMISSING);
}
Group group = groupService.getGroup(deviceId, next.key());
Group group = groupService.getGroup(deviceId, key);
TrafficTreatment treatment =
buildTreatment(Instructions.createGroup(group.id()));
......@@ -330,16 +340,20 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
private boolean checkForMulticast(ForwardingObjective fwd) {
VlanIdCriterion vlan = (VlanIdCriterion) filterForCriterion(fwd.selector().criteria(),
Criterion.Type.VLAN_VID);
IPCriterion ip = (IPCriterion) filterForCriterion(fwd.selector().criteria(),
Criterion.Type.IPV4_DST);
if (ip == null) {
return false;
}
return (vlan != null && vlan.vlanId().equals(VlanId.vlanId(MCAST_VLAN)));
return mcastPrefix.contains(ip.ip());
}
private OLTPipelineGroup getGroupForNextObjective(Integer nextId) {
private GroupKey getGroupForNextObjective(Integer nextId) {
NextGroup next = flowObjectiveStore.getNextGroup(nextId);
return (OLTPipelineGroup) appKryo.deserialize(next.data());
return appKryo.deserialize(next.data());
}
......
......@@ -54,12 +54,12 @@ public class DistributedMcastStore extends AbstractStore<McastEvent, McastStoreD
mcastRib = storageService.<McastRoute, MulticastData>consistentMapBuilder()
.withName(MCASTRIB)
.withSerializer(Serializer.using(KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(
MulticastData.class,
McastRoute.class,
McastRoute.Type.class
).build()))
.register(KryoNamespaces.API)
.register(
MulticastData.class,
McastRoute.class,
McastRoute.Type.class
).build()))
//.withRelaxedReadConsistency()
.build();
......
......@@ -66,9 +66,9 @@ public final class MulticastData {
sinks.put(sink, true);
}
public boolean removeSink(ConnectPoint sink) {
public void removeSink(ConnectPoint sink) {
checkNotNull(sink);
return sinks.remove(sink);
sinks.remove(sink);
}
public boolean isEmpty() {
......