Implemented VLAN-to-VLAN routing support for SDN-IP.
SDN-IP can now support peering and routing between hosts that are connected
on VLANs.
Changes include:
* Updated NetworkConfigReader app to read (optional) VLAN configuration
* Updated VlanId to support the 'VLAN present' value - in a match this means
that a VLAN tag must be present, but it can contain any value.
* Updated SDN-IP to set destination VLAN tag values if appropriate
* Updated FlowModBuilder and FlowEntryBuilder to support 'VLAN present' value
* Slew of test updates.
Change-Id: Ief48cede5c1fd50e1efa851da5a97fb4a8edda29
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/Router.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/Router.java
index d34a395..2b2213a 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/Router.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/Router.java
@@ -30,10 +30,11 @@
import org.apache.commons.lang3.tuple.Pair;
import org.onlab.packet.Ethernet;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Host;
@@ -272,7 +273,7 @@
* or IPv6.
*
* @param prefix the prefix to use
- * @return true if the rotue was found and removed, otherwise false
+ * @return true if the route was found and removed, otherwise false
*/
boolean removeRibRoute(IpPrefix prefix) {
if (prefix.version() == Ip4Address.VERSION) {
@@ -455,25 +456,26 @@
}
// Match the destination IP prefix at the first hop
- TrafficSelector selector;
+ TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
if (prefix.version() == Ip4Address.VERSION) {
- selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchIPDst(prefix)
- .build();
+ selector.matchEthType(Ethernet.TYPE_IPV4);
} else {
- selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV6)
- .matchIPDst(prefix)
- .build();
+ selector.matchEthType(Ethernet.TYPE_IPV6);
}
+ selector.matchIPDst(prefix);
// Rewrite the destination MAC address
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setEthDst(nextHopMacAddress)
- .build();
+ TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
+ .setEthDst(nextHopMacAddress);
+ if (!egressInterface.vlan().equals(VlanId.NONE)) {
+ treatment.setVlanId(egressInterface.vlan());
+ // If we set VLAN ID, we have to make sure a VLAN tag exists.
+ // TODO support no VLAN -> VLAN routing
+ selector.matchVlanId(VlanId.ANY);
+ }
- return new MultiPointToSinglePointIntent(appId, selector, treatment,
+ return new MultiPointToSinglePointIntent(appId, selector.build(),
+ treatment.build(),
ingressPorts, egressPort);
}
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/config/Interface.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/config/Interface.java
index 7ddf0ae..b495f07 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/config/Interface.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/config/Interface.java
@@ -19,6 +19,7 @@
import java.util.Set;
import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.host.InterfaceIpAddress;
import org.onosproject.net.host.PortAddresses;
@@ -34,6 +35,7 @@
private final ConnectPoint connectPoint;
private final Set<InterfaceIpAddress> ipAddresses;
private final MacAddress macAddress;
+ private final VlanId vlan;
/**
* Creates an Interface based on a connection point, a set of interface
@@ -45,10 +47,11 @@
*/
public Interface(ConnectPoint connectPoint,
Set<InterfaceIpAddress> ipAddresses,
- MacAddress macAddress) {
+ MacAddress macAddress, VlanId vlan) {
this.connectPoint = connectPoint;
this.ipAddresses = Sets.newHashSet(ipAddresses);
this.macAddress = macAddress;
+ this.vlan = vlan;
}
/**
@@ -60,6 +63,7 @@
connectPoint = portAddresses.connectPoint();
ipAddresses = Sets.newHashSet(portAddresses.ipAddresses());
macAddress = portAddresses.mac();
+ vlan = portAddresses.vlan();
}
/**
@@ -76,18 +80,27 @@
*
* @return the set of interface IP addresses
*/
- public Set<InterfaceIpAddress> ipAddresses() {
+ public Set<InterfaceIpAddress> ipAddresses() {
return ipAddresses;
}
- /**
- * Retrieves the MAC address that is assigned to the interface.
- *
- * @return the MAC address
- */
- public MacAddress mac() {
- return macAddress;
- }
+ /**
+ * Retrieves the MAC address that is assigned to the interface.
+ *
+ * @return the MAC address
+ */
+ public MacAddress mac() {
+ return macAddress;
+ }
+
+ /**
+ * Retrieves the VLAN ID that is assigned to the interface.
+ *
+ * @return the VLAN ID
+ */
+ public VlanId vlan() {
+ return vlan;
+ }
@Override
public boolean equals(Object other) {
@@ -99,12 +112,13 @@
return connectPoint.equals(otherInterface.connectPoint) &&
ipAddresses.equals(otherInterface.ipAddresses) &&
- macAddress.equals(otherInterface.macAddress);
+ macAddress.equals(otherInterface.macAddress) &&
+ vlan.equals(otherInterface.vlan);
}
@Override
public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress);
+ return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
}
@Override
@@ -113,6 +127,7 @@
.add("connectPoint", connectPoint)
.add("ipAddresses", ipAddresses)
.add("macAddress", macAddress)
+ .add("vlan", vlan)
.toString();
}
}
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/HostToInterfaceAdaptorTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/HostToInterfaceAdaptorTest.java
index d63581f..096e63c 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/HostToInterfaceAdaptorTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/HostToInterfaceAdaptorTest.java
@@ -29,6 +29,10 @@
import org.junit.Before;
import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
@@ -36,9 +40,6 @@
import org.onosproject.net.host.InterfaceIpAddress;
import org.onosproject.net.host.PortAddresses;
import org.onosproject.sdnip.config.Interface;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -76,7 +77,8 @@
IpPrefix.valueOf("192.168.1.0/24"));
createPortAddressesAndInterface(CP1,
Sets.newHashSet(ia11),
- MacAddress.valueOf("00:00:00:00:00:01"));
+ MacAddress.valueOf("00:00:00:00:00:01"),
+ VlanId.NONE);
// Two addresses in the same subnet
InterfaceIpAddress ia21 =
@@ -87,7 +89,8 @@
IpPrefix.valueOf("192.168.2.0/24"));
createPortAddressesAndInterface(CP2,
Sets.newHashSet(ia21, ia22),
- MacAddress.valueOf("00:00:00:00:00:02"));
+ MacAddress.valueOf("00:00:00:00:00:02"),
+ VlanId.vlanId((short) 4));
// Two addresses in different subnets
InterfaceIpAddress ia31 =
@@ -98,7 +101,8 @@
IpPrefix.valueOf("192.168.4.0/24"));
createPortAddressesAndInterface(CP3,
Sets.newHashSet(ia31, ia41),
- MacAddress.valueOf("00:00:00:00:00:03"));
+ MacAddress.valueOf("00:00:00:00:00:03"),
+ VlanId.NONE);
expect(hostService.getAddressBindings()).andReturn(portAddresses).anyTimes();
@@ -114,16 +118,17 @@
* @param cp the connect point
* @param ipAddresses the set of interface IP addresses
* @param mac the MAC address
+ * @param vlan the VLAN ID
*/
private void createPortAddressesAndInterface(
ConnectPoint cp, Set<InterfaceIpAddress> ipAddresses,
- MacAddress mac) {
- PortAddresses pa = new PortAddresses(cp, ipAddresses, mac);
+ MacAddress mac, VlanId vlan) {
+ PortAddresses pa = new PortAddresses(cp, ipAddresses, mac, vlan);
portAddresses.add(pa);
expect(hostService.getAddressBindingsForPort(cp)).andReturn(
Collections.singleton(pa)).anyTimes();
- Interface intf = new Interface(cp, ipAddresses, mac);
+ Interface intf = new Interface(cp, ipAddresses, mac, vlan);
interfaces.put(cp, intf);
}
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
index 0868582..9960481 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
@@ -36,6 +36,13 @@
import org.junit.Test;
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultHost;
@@ -59,13 +66,6 @@
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.sdnip.config.Interface;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
import com.google.common.collect.Sets;
import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
@@ -135,7 +135,8 @@
IpAddress.valueOf("192.168.10.101"),
IpPrefix.valueOf("192.168.10.0/24")));
Interface sw1Eth1 = new Interface(SW1_ETH1,
- interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"));
+ interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
+ VlanId.NONE);
interfaces.add(sw1Eth1);
Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
@@ -143,7 +144,8 @@
IpAddress.valueOf("192.168.20.101"),
IpPrefix.valueOf("192.168.20.0/24")));
Interface sw2Eth1 = new Interface(SW2_ETH1,
- interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"));
+ interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
+ VlanId.NONE);
interfaces.add(sw2Eth1);
Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
@@ -151,7 +153,8 @@
IpAddress.valueOf("192.168.30.101"),
IpPrefix.valueOf("192.168.30.0/24")));
Interface sw3Eth1 = new Interface(SW3_ETH1,
- interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"));
+ interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
+ VlanId.NONE);
interfaces.add(sw3Eth1);
expect(interfaceService.getInterface(SW1_ETH1)).andReturn(
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
index 2ce9956..e542eb0 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
@@ -38,6 +38,7 @@
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
@@ -189,7 +190,8 @@
IpPrefix.valueOf("192.168.10.0/24"));
Interface intfsw1eth1 = new Interface(s1Eth1,
Collections.singleton(ia1),
- MacAddress.valueOf("00:00:00:00:00:01"));
+ MacAddress.valueOf("00:00:00:00:00:01"),
+ VlanId.NONE);
configuredInterfaces.put(interfaceSw1Eth1, intfsw1eth1);
String interfaceSw2Eth1 = "s2-eth1";
@@ -198,7 +200,8 @@
IpPrefix.valueOf("192.168.20.0/24"));
Interface intfsw2eth1 = new Interface(s2Eth1,
Collections.singleton(ia2),
- MacAddress.valueOf("00:00:00:00:00:02"));
+ MacAddress.valueOf("00:00:00:00:00:02"),
+ VlanId.NONE);
configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1);
interfaceService = createMock(InterfaceService.class);
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterAsyncArpTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterAsyncArpTest.java
index f8db770..80fb578 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterAsyncArpTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterAsyncArpTest.java
@@ -35,6 +35,13 @@
import org.junit.Test;
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultHost;
@@ -50,24 +57,17 @@
import org.onosproject.net.host.HostEvent;
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.InterfaceIpAddress;
+import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentOperations;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.sdnip.IntentSynchronizer.IntentKey;
import org.onosproject.sdnip.Router.InternalHostListener;
import org.onosproject.sdnip.config.BgpPeer;
import org.onosproject.sdnip.config.Interface;
import org.onosproject.sdnip.config.SdnIpConfigurationService;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
import com.google.common.collect.Sets;
import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
@@ -168,7 +168,8 @@
IpAddress.valueOf("192.168.10.101"),
IpPrefix.valueOf("192.168.10.0/24")));
Interface sw1Eth1 = new Interface(SW1_ETH1,
- interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"));
+ interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
+ VlanId.NONE);
interfaces.add(sw1Eth1);
Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
@@ -176,7 +177,8 @@
IpAddress.valueOf("192.168.20.101"),
IpPrefix.valueOf("192.168.20.0/24")));
Interface sw2Eth1 = new Interface(SW2_ETH1,
- interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"));
+ interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
+ VlanId.NONE);
interfaces.add(sw2Eth1);
Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
@@ -184,7 +186,8 @@
IpAddress.valueOf("192.168.30.101"),
IpPrefix.valueOf("192.168.30.0/24")));
Interface sw3Eth1 = new Interface(SW3_ETH1,
- interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"));
+ interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
+ VlanId.NONE);
interfaces.add(sw3Eth1);
expect(interfaceService.getInterface(SW1_ETH1)).andReturn(sw1Eth1).anyTimes();
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterTest.java
index 9ef1f69..6c98efb 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/RouterTest.java
@@ -36,10 +36,10 @@
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
@@ -95,6 +95,10 @@
DeviceId.deviceId("of:0000000000000003"),
PortNumber.portNumber(1));
+ private static final ConnectPoint SW4_ETH1 = new ConnectPoint(
+ DeviceId.deviceId("of:0000000000000004"),
+ PortNumber.portNumber(1));
+
private static final ApplicationId APPID = new ApplicationId() {
@Override
public short id() {
@@ -146,6 +150,10 @@
peers.put(IpAddress.valueOf(peer2Sw2Eth1),
new BgpPeer("00:00:00:00:00:00:00:02", 1, peer2Sw2Eth1));
+ String peer1Sw4Eth1 = "192.168.40.1";
+ peers.put(IpAddress.valueOf(peer1Sw4Eth1),
+ new BgpPeer("00:00:00:00:00:00:00:04", 1, peer1Sw4Eth1));
+
sdnIpConfigService = createMock(SdnIpConfigurationService.class);
expect(sdnIpConfigService.getBgpPeers()).andReturn(peers).anyTimes();
replay(sdnIpConfigService);
@@ -166,7 +174,8 @@
IpPrefix.valueOf("192.168.10.0/24"));
Interface sw1Eth1 = new Interface(SW1_ETH1,
Sets.newHashSet(ia1),
- MacAddress.valueOf("00:00:00:00:00:01"));
+ MacAddress.valueOf("00:00:00:00:00:01"),
+ VlanId.NONE);
expect(interfaceService.getInterface(SW1_ETH1)).andReturn(sw1Eth1).anyTimes();
interfaces.add(sw1Eth1);
@@ -176,7 +185,8 @@
IpPrefix.valueOf("192.168.20.0/24"));
Interface sw2Eth1 = new Interface(SW2_ETH1,
Sets.newHashSet(ia2),
- MacAddress.valueOf("00:00:00:00:00:02"));
+ MacAddress.valueOf("00:00:00:00:00:02"),
+ VlanId.NONE);
expect(interfaceService.getInterface(SW2_ETH1)).andReturn(sw2Eth1).anyTimes();
interfaces.add(sw2Eth1);
@@ -186,11 +196,23 @@
IpPrefix.valueOf("192.168.30.0/24"));
Interface sw3Eth1 = new Interface(SW3_ETH1,
Sets.newHashSet(ia3),
- MacAddress.valueOf("00:00:00:00:00:03"));
+ MacAddress.valueOf("00:00:00:00:00:03"),
+ VlanId.NONE);
expect(interfaceService.getInterface(SW3_ETH1)).andReturn(sw3Eth1).anyTimes();
interfaces.add(sw3Eth1);
+ InterfaceIpAddress ia4 =
+ new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"),
+ IpPrefix.valueOf("192.168.40.0/24"));
+ Interface sw4Eth1 = new Interface(SW4_ETH1,
+ Sets.newHashSet(ia4),
+ MacAddress.valueOf("00:00:00:00:00:04"),
+ VlanId.vlanId((short) 1));
+
+ expect(interfaceService.getInterface(SW4_ETH1)).andReturn(sw4Eth1).anyTimes();
+ interfaces.add(sw4Eth1);
+
expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
replay(interfaceService);
@@ -228,6 +250,18 @@
hostService.startMonitoringIp(host2Address);
expectLastCall().anyTimes();
+ // Next hop on a VLAN
+ IpAddress host3Address = IpAddress.valueOf("192.168.40.1");
+ Host host3 = new DefaultHost(ProviderId.NONE, HostId.NONE,
+ MacAddress.valueOf("00:00:00:00:00:03"), VlanId.vlanId((short) 1),
+ new HostLocation(SW4_ETH1, 1),
+ Sets.newHashSet(host3Address));
+
+ expect(hostService.getHostsByIp(host3Address))
+ .andReturn(Sets.newHashSet(host3)).anyTimes();
+ hostService.startMonitoringIp(host3Address);
+ expectLastCall().anyTimes();
+
replay(hostService);
}
@@ -255,6 +289,7 @@
Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
ingressPoints.add(SW2_ETH1);
ingressPoints.add(SW3_ETH1);
+ ingressPoints.add(SW4_ETH1);
MultiPointToSinglePointIntent intent =
new MultiPointToSinglePointIntent(APPID,
@@ -290,6 +325,66 @@
}
/**
+ * This method tests adding a route entry.
+ */
+ @Test
+ public void testRouteAddWithVlan() throws TestUtilsException {
+ // Construct a route entry
+ RouteEntry routeEntry = new RouteEntry(
+ Ip4Prefix.valueOf("3.3.3.0/24"),
+ Ip4Address.valueOf("192.168.40.1"));
+
+ // Construct a MultiPointToSinglePointIntent intent
+ TrafficSelector.Builder selectorBuilder =
+ DefaultTrafficSelector.builder();
+ selectorBuilder.matchEthType(Ethernet.TYPE_IPV4)
+ .matchIPDst(routeEntry.prefix())
+ .matchVlanId(VlanId.ANY);
+
+ TrafficTreatment.Builder treatmentBuilder =
+ DefaultTrafficTreatment.builder();
+ treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:03"))
+ .setVlanId(VlanId.vlanId((short) 1));
+
+ Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
+ ingressPoints.add(SW1_ETH1);
+ ingressPoints.add(SW2_ETH1);
+ ingressPoints.add(SW3_ETH1);
+
+ MultiPointToSinglePointIntent intent =
+ new MultiPointToSinglePointIntent(APPID,
+ selectorBuilder.build(), treatmentBuilder.build(),
+ ingressPoints, SW4_ETH1);
+
+ // Set up test expectation
+ reset(intentService);
+ // Setup the expected intents
+ IntentOperations.Builder builder = IntentOperations.builder(APPID);
+ builder.addSubmitOperation(intent);
+ intentService.execute(TestIntentServiceHelper.eqExceptId(
+ builder.build()));
+ replay(intentService);
+
+ // Call the processRouteUpdates() method in Router class
+ intentSynchronizer.leaderChanged(true);
+ TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
+ RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
+ routeEntry);
+ router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
+
+ // Verify
+ assertEquals(router.getRoutes4().size(), 1);
+ assertTrue(router.getRoutes4().contains(routeEntry));
+ assertEquals(intentSynchronizer.getRouteIntents().size(), 1);
+ Intent firstIntent =
+ intentSynchronizer.getRouteIntents().iterator().next();
+ IntentKey firstIntentKey = new IntentKey(firstIntent);
+ IntentKey intentKey = new IntentKey(intent);
+ assertTrue(firstIntentKey.equals(intentKey));
+ verify(intentService);
+ }
+
+ /**
* This method tests updating a route entry.
*
* @throws TestUtilsException
@@ -321,6 +416,7 @@
Set<ConnectPoint> ingressPointsNew = new HashSet<ConnectPoint>();
ingressPointsNew.add(SW1_ETH1);
ingressPointsNew.add(SW3_ETH1);
+ ingressPointsNew.add(SW4_ETH1);
MultiPointToSinglePointIntent intentNew =
new MultiPointToSinglePointIntent(APPID,
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpTest.java
index 0100c39..36bd3b7 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpTest.java
@@ -42,6 +42,13 @@
import org.onlab.junit.IntegrationTest;
import org.onlab.junit.TestUtils;
import org.onlab.junit.TestUtils.TestUtilsException;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
@@ -52,18 +59,12 @@
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.InterfaceIpAddress;
+import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.sdnip.config.BgpPeer;
import org.onosproject.sdnip.config.Interface;
import org.onosproject.sdnip.config.SdnIpConfigurationService;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.MacAddress;
import com.google.common.collect.Sets;
@@ -148,7 +149,8 @@
IpAddress.valueOf("192.168.10.101"),
IpPrefix.valueOf("192.168.10.0/24")));
Interface sw1Eth1 = new Interface(SW1_ETH1,
- interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"));
+ interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
+ VlanId.NONE);
interfaces.add(sw1Eth1);
Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
@@ -156,7 +158,8 @@
IpAddress.valueOf("192.168.20.101"),
IpPrefix.valueOf("192.168.20.0/24")));
Interface sw2Eth1 = new Interface(SW2_ETH1,
- interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"));
+ interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
+ VlanId.NONE);
interfaces.add(sw2Eth1);
Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
@@ -164,7 +167,8 @@
IpAddress.valueOf("192.168.30.101"),
IpPrefix.valueOf("192.168.30.0/24")));
Interface sw3Eth1 = new Interface(SW3_ETH1,
- interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"));
+ interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
+ VlanId.NONE);
interfaces.add(sw3Eth1);
expect(interfaceService.getInterface(SW1_ETH1)).andReturn(
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
index 9aaa6fb..b01e1ae 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.sdnip;
+import static org.easymock.EasyMock.reportMatcher;
+
import java.util.LinkedList;
import java.util.List;
@@ -26,8 +28,6 @@
import org.onosproject.net.intent.IntentOperations;
import org.onosproject.sdnip.IntentSynchronizer.IntentKey;
-import static org.easymock.EasyMock.reportMatcher;
-
/**
* Helper class for testing operations submitted to the IntentService.
*/
@@ -187,7 +187,7 @@
* @param submitIntents the SUBMIT intents
* @param withdrawIntentIds the WITHDRAW intents IDs
* @param replaceIntents the REPLACE intents
- * @param updateIntents the UPDATE intens
+ * @param updateIntents the UPDATE intents
*/
private void extractIntents(IntentOperations intentOperations,
List<IntentKey> submitIntents,