CORD-73 Change the way we configure host learning in segment routing
hostLearning config
- true: enable host learning
- false or not provided: disable host learning
suppressHost config
- all connect points listed here will be ignored
- no effect if hostLearning is false
- accept all hosts if this config is not provided
Change-Id: Id4a60bd47cac1f226ab8ba5391931ad2fb798529
diff --git a/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java b/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
index d95efd2..4474fb2 100644
--- a/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
+++ b/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
@@ -113,7 +113,10 @@
cfgService.getSubjects(ConnectPoint.class, InterfaceConfig.class);
portSubjects.forEach(subject -> {
// Do not process excluded ports
- if (suppressSubnet().contains(subject)) {
+ SegmentRoutingAppConfig appConfig =
+ cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
+ if (appConfig != null && appConfig.suppressSubnet().contains(subject)) {
+ log.info("Ignore suppressed port {}", subject);
return;
}
@@ -498,28 +501,6 @@
}
/**
- * Gets connect points for which segment routing does not install subnet rules.
- *
- * @return set of connect points
- */
- public Set<ConnectPoint> suppressSubnet() {
- SegmentRoutingAppConfig appConfig =
- cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
- return (appConfig != null) ? appConfig.suppressSubnet() : ImmutableSet.of();
- }
-
- /**
- * Gets connect points for which segment routing does not install host rules.
- *
- * @return set of connect points
- */
- public Set<ConnectPoint> suppressHost() {
- SegmentRoutingAppConfig appConfig =
- cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
- return (appConfig != null) ? appConfig.suppressHost() : ImmutableSet.of();
- }
-
- /**
* Add subnet to specific connect point.
*
* @param cp connect point
diff --git a/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java b/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
index 640fd92..9bbcaa6 100644
--- a/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
+++ b/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
@@ -38,10 +38,12 @@
private static final String VROUTER_ID = "vRouterId";
private static final String SUPPRESS_SUBNET = "suppressSubnet";
private static final String SUPPRESS_HOST = "suppressHost";
+ private static final String HOST_LEARNING = "hostLearning";
@Override
public boolean isValid() {
- return hasOnlyFields(VROUTER_MACS, VROUTER_ID, SUPPRESS_SUBNET, SUPPRESS_HOST) &&
+ return hasOnlyFields(VROUTER_MACS, VROUTER_ID, SUPPRESS_SUBNET,
+ SUPPRESS_HOST, HOST_LEARNING) &&
vRouterMacs() != null && vRouterId() != null &&
suppressSubnet() != null && suppressHost() != null;
}
@@ -225,6 +227,26 @@
return this;
}
+ /**
+ * Gets whether host learning is enabled or not.
+ *
+ * @return true if enabled. false if disabled or not configured
+ */
+ public boolean hostLearning() {
+ return object.has(HOST_LEARNING) && object.path(HOST_LEARNING).asBoolean();
+ }
+
+ /**
+ * Sets whether host learning is enabled or not.
+ *
+ * @param enabled true if enabled
+ * @return this {@link SegmentRoutingAppConfig}
+ */
+ public SegmentRoutingAppConfig setHostLearning(boolean enabled) {
+ object.put(HOST_LEARNING, enabled);
+ return this;
+ }
+
@Override
public String toString() {
return toStringHelper(this)
@@ -232,6 +254,7 @@
.add("vRouterId", vRouterId())
.add("suppressSubnet", suppressSubnet())
.add("suppressHost", suppressHost())
+ .add("hostLearning", hostLearning())
.toString();
}
}