Jonathan Hart
Committed by Gerrit Code Review

It helps to get IGMP join and leaves the right way round

Change-Id: I7ada6835fa56aefaa421610ae8a303f2751be2b3
......@@ -214,6 +214,10 @@ public class CordMcast {
}
private void unprovisionGroup(McastRouteInfo info) {
if (info.sinks().isEmpty()) {
removeSyncedRoute(info);
}
if (!info.sink().isPresent()) {
log.warn("No sink given after sink removed event: {}", info);
return;
......@@ -242,8 +246,6 @@ public class CordMcast {
});
flowObjectiveService.next(loc.deviceId(), next);
}
private void provisionGroup(McastRouteInfo info) {
......@@ -364,6 +366,21 @@ public class CordMcast {
builder.post(json.toString());
}
private void removeSyncedRoute(McastRouteInfo info) {
if (syncHost == null) {
log.warn("No host configured for synchronization; route will be dropped");
return;
}
log.debug("Removing route from other ONOS: {}", info.route());
WebResource.Builder builder = getClientBuilder(fabricOnosUrl);
ObjectNode json = codecService.getCodec(McastRoute.class)
.encode(info.route(), new AbstractWebResource());
builder.delete(json.toString());
}
private Integer allocateId() {
return channels.getAndIncrement();
}
......
......@@ -275,9 +275,10 @@ public class IgmpSnoop {
IGMPMembership membership = (IGMPMembership) group;
// TODO allow pulling source from IGMP packet
IpAddress source = IpAddress.valueOf("0.0.0.0");
if (ssmTranslateTable.containsKey(group.getGaddr())) {
source = ssmTranslateTable.get(group.getGaddr());
IpAddress source = ssmTranslateTable.get(group.getGaddr());
if (source == null) {
log.warn("No source found in SSM translate table for {}", group.getGaddr());
return;
}
McastRoute route = new McastRoute(source,
......@@ -287,14 +288,13 @@ public class IgmpSnoop {
if (membership.getRecordType() == IGMPMembership.MODE_IS_INCLUDE ||
membership.getRecordType() == IGMPMembership.CHANGE_TO_INCLUDE_MODE) {
multicastService.removeSink(route, location);
// TODO remove route if all sinks are gone
} else if (membership.getRecordType() == IGMPMembership.MODE_IS_EXCLUDE ||
membership.getRecordType() == IGMPMembership.CHANGE_TO_EXCLUDE_MODE) {
multicastService.add(route);
multicastService.addSink(route, location);
} else if (membership.getRecordType() == IGMPMembership.MODE_IS_EXCLUDE ||
membership.getRecordType() == IGMPMembership.CHANGE_TO_EXCLUDE_MODE) {
multicastService.removeSink(route, location);
// TODO remove route if all sinks are gone
}
});
......