Cosmetic refactoring for vRouter to bring CPRM and SSFI closer together.
Change-Id: I86836adff041195fae0dca5dec1a45d94444e10b
diff --git a/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java b/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
index 4d4141b..b55dba6 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
@@ -172,7 +172,7 @@
asyncDeviceFetcher = AsyncDeviceFetcher.create(deviceService);
- updateConfig();
+ processRouterConfig();
// FIXME: There can be an issue when this component is deactivated before vRouter.
// This will be addressed in CORD-710.
@@ -181,15 +181,6 @@
log.info("Started");
}
- private RouterInterfaceManager createRouter(DeviceId deviceId, Set<String> configuredInterfaces) {
- return new RouterInterfaceManager(deviceId,
- configuredInterfaces,
- interfaceService,
- intf -> processIntfFilter(true, intf),
- intf -> processIntfFilter(false, intf)
- );
- }
-
@Deactivate
protected void deactivate() {
// FIXME: This will also remove flows when an instance goes down.
@@ -217,22 +208,7 @@
log.info("routeToNextHop set to {}", routeToNextHop);
}
- //remove filtering objectives and routes before deactivate.
- private void cleanUp() {
- //remove the route listener
- routeService.removeListener(routeListener);
-
- //clean up the routes.
- for (Map.Entry<IpPrefix, IpAddress> routes: prefixToNextHop.entrySet()) {
- deleteRoute(new ResolvedRoute(routes.getKey(), null, null, null));
- }
-
- if (interfaceManager != null) {
- interfaceManager.cleanup();
- }
- }
-
- private void updateConfig() {
+ private void processRouterConfig() {
RouterConfig routerConfig =
networkConfigService.getConfig(routerAppId, RoutingService.ROUTER_CONFIG_CLASS);
@@ -258,6 +234,31 @@
}
}
+ /*
+ * Removes filtering objectives and routes before deactivate.
+ */
+ private void cleanUp() {
+ //remove the route listener
+ routeService.removeListener(routeListener);
+
+ //clean up the routes.
+ for (Map.Entry<IpPrefix, IpAddress> routes: prefixToNextHop.entrySet()) {
+ deleteRoute(new ResolvedRoute(routes.getKey(), null, null, null));
+ }
+
+ if (interfaceManager != null) {
+ interfaceManager.cleanup();
+ }
+ }
+
+ private RouterInterfaceManager createRouter(DeviceId deviceId, Set<String> configuredInterfaces) {
+ return new RouterInterfaceManager(deviceId,
+ configuredInterfaces,
+ interfaceService,
+ this::provisionInterface,
+ this::unprovisionInterface);
+ }
+
private void updateRoute(ResolvedRoute route) {
addNextHop(route);
@@ -411,14 +412,32 @@
return group;
}*/
- //process filtering objective for interface add/remove.
- private void processIntfFilter(boolean install, Interface intf) {
- createFilteringObjective(install, intf);
- createMcastFilteringObjective(install, intf);
+ private void provisionInterface(Interface intf) {
+ updateInterfaceFilters(intf, true);
}
- //create filtering objective for interface
- private void createFilteringObjective(boolean install, Interface intf) {
+ private void unprovisionInterface(Interface intf) {
+ updateInterfaceFilters(intf, false);
+ }
+
+ /**
+ * Installs or removes flow objectives relating to an interface.
+ *
+ * @param intf interface to update objectives for
+ * @param install true to install the objectives, false to remove them
+ */
+ private void updateInterfaceFilters(Interface intf, boolean install) {
+ updateFilteringObjective(intf, install);
+ updateMcastFilteringObjective(intf, install);
+ }
+
+ /**
+ * Installs or removes unicast filtering objectives relating to an interface.
+ *
+ * @param intf interface to update objectives for
+ * @param install true to install the objectives, false to remove them
+ */
+ private void updateFilteringObjective(Interface intf, boolean install) {
VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ?
VlanId.vlanId(ASSIGNED_VLAN) :
egressVlan();
@@ -444,8 +463,13 @@
}
}
- //create filtering objective for multicast traffic
- private void createMcastFilteringObjective(boolean install, Interface intf) {
+ /**
+ * Installs or removes multicast filtering objectives relating to an interface.
+ *
+ * @param intf interface to update objectives for
+ * @param install true to install the objectives, false to remove them
+ */
+ private void updateMcastFilteringObjective(Interface intf, boolean install) {
VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ?
VlanId.vlanId(ASSIGNED_VLAN) :
egressVlan();
@@ -490,6 +514,9 @@
return (mcastConfig != null) ? mcastConfig.egressVlan() : VlanId.NONE;
}
+ /**
+ * Listener for route changes.
+ */
private class InternalRouteListener implements RouteListener {
@Override
public void event(RouteEvent event) {
@@ -518,7 +545,7 @@
switch (event.type()) {
case CONFIG_ADDED:
case CONFIG_UPDATED:
- updateConfig();
+ processRouterConfig();
break;
case CONFIG_REGISTERED:
break;