CORD-512 Support vSG <-> vRouter default route
- Support multiple subnets per port. getIpPort() will only return the first non-/32 and non-/0 subnet
/32 is used as vSG subnet
/0 is used as default gateway
- Support multiple L3 unicast group on a single port
Change the way to generate the group ID and group key
- Special case for 0.0.0.0 host. Push a /0 to IP table instead of /32
- Implement vRouterConfig
Put VR MAC to TMAC table of all leaves when config added
When processEthDst see PortNumber.ANY in key, match ETH_DST only
- For OFDPA, wipe existing instruction before sending to controller
So packet that misses L3 unicast table won't be sent to controller twice
- For SpringOpenTTP, pop VLAN before sending to controller
- Move several constant definitions to SegmentRoutingService
- Add minimum priority for IP rules such that /0 won't collide with zero priority default rules
- Update the config sample
Use VLAN=-1 for hosts
Add example for default route
Change-Id: Id751697ce36a7e5c13b3859350ff21b585c38525
diff --git a/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java b/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java
new file mode 100644
index 0000000..7755059
--- /dev/null
+++ b/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.segmentrouting.config;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.MacAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.TestApplicationId;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.config.ConfigApplyDelegate;
+import org.onosproject.segmentrouting.SegmentRoutingService;
+import java.util.Set;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for class {@link SegmentRoutingAppConfig}.
+ */
+public class SegmentRoutingAppConfigTest {
+ private static final ApplicationId APP_ID =
+ new TestApplicationId(SegmentRoutingService.SR_APP_ID);
+
+ private SegmentRoutingAppConfig config;
+ private MacAddress routerMac1;
+ private MacAddress routerMac2;
+ private MacAddress routerMac3;
+
+ /**
+ * Initialize test related variables.
+ *
+ * @throws Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ String jsonString = "{" +
+ "\"vRouterMacs\" : [" +
+ " \"00:00:00:00:00:01\"," +
+ " \"00:00:00:00:00:02\"" +
+ "]}";
+
+ routerMac1 = MacAddress.valueOf("00:00:00:00:00:01");
+ routerMac2 = MacAddress.valueOf("00:00:00:00:00:02");
+ routerMac3 = MacAddress.valueOf("00:00:00:00:00:03");
+
+ ApplicationId subject = APP_ID;
+ String key = SegmentRoutingService.SR_APP_ID;
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode jsonNode = mapper.readTree(jsonString);
+ ConfigApplyDelegate delegate = new MockDelegate();
+
+ config = new SegmentRoutingAppConfig();
+ config.init(subject, key, jsonNode, mapper, delegate);
+ }
+
+ /**
+ * Tests vRouters getter.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testVRouters() throws Exception {
+ assertTrue(config.isValid());
+
+ Set<MacAddress> vRouters = config.vRouterMacs();
+ assertThat(vRouters.size(), is(2));
+ assertTrue(vRouters.contains(routerMac1));
+ assertTrue(vRouters.contains(routerMac2));
+ }
+
+ /**
+ * Tests vRouters setter.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetVRouters() throws Exception {
+ ImmutableSet.Builder<MacAddress> builder = ImmutableSet.builder();
+ builder.add(routerMac3);
+ config.setVRouterMacs(builder.build());
+
+ Set<MacAddress> macs = config.vRouterMacs();
+ assertThat(macs.size(), is(1));
+ assertTrue(macs.contains(routerMac3));
+ }
+
+ private class MockDelegate implements ConfigApplyDelegate {
+ @Override
+ public void onApply(Config config) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingConfigTest.java b/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java
similarity index 94%
rename from apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingConfigTest.java
rename to apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java
index 3e5daa5..fd661b6 100644
--- a/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingConfigTest.java
+++ b/apps/segmentrouting/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java
@@ -36,10 +36,10 @@
import static org.junit.Assert.assertTrue;
/**
- * Tests for class {@link SegmentRoutingConfig}.
+ * Tests for class {@link SegmentRoutingDeviceConfig}.
*/
-public class SegmentRoutingConfigTest {
- private SegmentRoutingConfig config;
+public class SegmentRoutingDeviceConfigTest {
+ private SegmentRoutingDeviceConfig config;
private Map<Integer, Set<Integer>> adjacencySids1;
private Map<Integer, Set<Integer>> adjacencySids2;
@@ -72,12 +72,12 @@
adjacencySids2.put(300, ports3);
DeviceId subject = DeviceId.deviceId("of:0000000000000001");
- String key = "org.onosproject.segmentrouting";
+ String key = "segmentrouting";
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(jsonString);
ConfigApplyDelegate delegate = new MockDelegate();
- config = new SegmentRoutingConfig();
+ config = new SegmentRoutingDeviceConfig();
config.init(subject, key, jsonNode, mapper, delegate);
}