[SEBA-636] Modify Segmentrouting to not program multicast tree on unconfigured devices (OLT)
Change-Id: I0a2e46545c9e3d6bc3d3a2b1335af8a39f2cae87
(cherry picked from commit ece19c7d517fb9eae47b4a836455ddec3f0b1484)
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
index f5247af..9db890d 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
@@ -1157,8 +1157,14 @@
// First time someone request this mcast group via this device
portBuilder.add(port);
// New nextObj
- newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan,
- portBuilder.build(), null).add();
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.debug("Passing 0 as nextId for unconfigured device {}", deviceId);
+ newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan,
+ portBuilder.build(), 0).add();
+ } else {
+ newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan,
+ portBuilder.build(), null).add();
+ }
// Store the new port
mcastNextObjStore.put(mcastStoreKey, newNextObj);
} else {
@@ -1194,8 +1200,12 @@
});
ForwardingObjective fwdObj = mcastUtils.fwdObjBuilder(mcastIp, assignedVlan,
newNextObj.id()).add(context);
- srManager.flowObjectiveService.next(deviceId, newNextObj);
- srManager.flowObjectiveService.forward(deviceId, fwdObj);
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.debug("skip next and forward flowobjective addition for device: {}", deviceId);
+ } else {
+ srManager.flowObjectiveService.next(deviceId, newNextObj);
+ srManager.flowObjectiveService.forward(deviceId, fwdObj);
+ }
}
/**
@@ -1260,8 +1270,12 @@
// Let's modify the next objective removing the bucket
newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan,
ImmutableSet.of(port), nextObj.id()).removeFromExisting();
- srManager.flowObjectiveService.next(deviceId, newNextObj);
- srManager.flowObjectiveService.forward(deviceId, fwdObj);
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.debug("skip forward and next flow objectives from adding flows on device: {}", deviceId);
+ } else {
+ srManager.flowObjectiveService.next(deviceId, newNextObj);
+ srManager.flowObjectiveService.forward(deviceId, fwdObj);
+ }
return existingPorts.isEmpty();
}
@@ -1286,8 +1300,12 @@
mcastIp, deviceId, assignedVlan),
(objective, error) -> log.warn("Failed to remove {} on {}, vlan {}: {}",
mcastIp, deviceId, assignedVlan, error));
- ForwardingObjective fwdObj = mcastUtils.fwdObjBuilder(mcastIp, assignedVlan, nextObj.id()).remove(context);
- srManager.flowObjectiveService.forward(deviceId, fwdObj);
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.debug("skip flow changes on unconfigured device: {}", deviceId);
+ } else {
+ ForwardingObjective fwdObj = mcastUtils.fwdObjBuilder(mcastIp, assignedVlan, nextObj.id()).remove(context);
+ srManager.flowObjectiveService.forward(deviceId, fwdObj);
+ }
mcastNextObjStore.remove(mcastStoreKey);
}
@@ -1806,6 +1824,10 @@
}
Set<DeviceId> devicesToProcess = devicesBuilder.build();
devicesToProcess.forEach(deviceId -> {
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.trace("Skipping Bucket corrector for unconfigured device {}", deviceId);
+ return;
+ }
VlanId assignedVlan = mcastUtils.assignedVlan(deviceId.equals(source.deviceId()) ?
source : null);
McastStoreKey currentKey = new McastStoreKey(mcastIp, deviceId, assignedVlan);
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java
index 16f3b94..6d3f938 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java
@@ -141,6 +141,10 @@
void addFilterToDevice(DeviceId deviceId, PortNumber port, VlanId assignedVlan,
IpAddress mcastIp, McastRole mcastRole) {
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.debug("skip update of fitering objective for unconfigured device: {}", deviceId);
+ return;
+ }
MacAddress routerMac = getRouterMac(deviceId, port);
if (MacAddress.NONE.equals(routerMac)) {
@@ -170,6 +174,10 @@
void removeFilterToDevice(DeviceId deviceId, PortNumber port, VlanId assignedVlan,
IpAddress mcastIp, McastRole mcastRole) {
+ if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
+ log.debug("skip update of fitering objective for unconfigured device: {}", deviceId);
+ return;
+ }
MacAddress routerMac = getRouterMac(deviceId, port);
if (MacAddress.NONE.equals(routerMac)) {