Thomas Vachuska
Committed by Gerrit Code Review

Merge "Cleanup and javadocs for SDN-IP code"

1 package org.onlab.onos.sdnip; 1 package org.onlab.onos.sdnip;
2 2
3 +import java.util.List;
4 +
3 import org.onlab.onos.ApplicationId; 5 import org.onlab.onos.ApplicationId;
4 import org.onlab.onos.net.ConnectPoint; 6 import org.onlab.onos.net.ConnectPoint;
5 import org.onlab.onos.net.flow.DefaultTrafficSelector; 7 import org.onlab.onos.net.flow.DefaultTrafficSelector;
...@@ -8,6 +10,7 @@ import org.onlab.onos.net.flow.TrafficSelector; ...@@ -8,6 +10,7 @@ import org.onlab.onos.net.flow.TrafficSelector;
8 import org.onlab.onos.net.flow.TrafficTreatment; 10 import org.onlab.onos.net.flow.TrafficTreatment;
9 import org.onlab.onos.net.intent.IntentService; 11 import org.onlab.onos.net.intent.IntentService;
10 import org.onlab.onos.net.intent.PointToPointIntent; 12 import org.onlab.onos.net.intent.PointToPointIntent;
13 +import org.onlab.onos.sdnip.bgp.BgpConstants;
11 import org.onlab.onos.sdnip.config.BgpPeer; 14 import org.onlab.onos.sdnip.config.BgpPeer;
12 import org.onlab.onos.sdnip.config.BgpSpeaker; 15 import org.onlab.onos.sdnip.config.BgpSpeaker;
13 import org.onlab.onos.sdnip.config.Interface; 16 import org.onlab.onos.sdnip.config.Interface;
...@@ -20,8 +23,6 @@ import org.onlab.packet.IpPrefix; ...@@ -20,8 +23,6 @@ import org.onlab.packet.IpPrefix;
20 import org.slf4j.Logger; 23 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory; 24 import org.slf4j.LoggerFactory;
22 25
23 -import java.util.List;
24 -
25 /** 26 /**
26 * Manages the connectivity requirements between peers. 27 * Manages the connectivity requirements between peers.
27 */ 28 */
...@@ -30,37 +31,44 @@ public class PeerConnectivityManager { ...@@ -30,37 +31,44 @@ public class PeerConnectivityManager {
30 private static final Logger log = LoggerFactory.getLogger( 31 private static final Logger log = LoggerFactory.getLogger(
31 PeerConnectivityManager.class); 32 PeerConnectivityManager.class);
32 33
33 - // TODO these shouldn't be defined here 34 + private final SdnIpConfigService configService;
34 - private static final short BGP_PORT = 179;
35 - private static final int IPV4_BIT_LENGTH = 32;
36 -
37 - private final SdnIpConfigService configInfoService;
38 private final InterfaceService interfaceService; 35 private final InterfaceService interfaceService;
39 private final IntentService intentService; 36 private final IntentService intentService;
40 37
41 private final ApplicationId appId; 38 private final ApplicationId appId;
42 39
40 + /**
41 + * Creates a new PeerConnectivityManager.
42 + *
43 + * @param appId the application ID
44 + * @param configService the SDN-IP config service
45 + * @param interfaceService the interface service
46 + * @param intentService the intent service
47 + */
43 public PeerConnectivityManager(ApplicationId appId, 48 public PeerConnectivityManager(ApplicationId appId,
44 - SdnIpConfigService configInfoService, 49 + SdnIpConfigService configService,
45 InterfaceService interfaceService, 50 InterfaceService interfaceService,
46 IntentService intentService) { 51 IntentService intentService) {
47 this.appId = appId; 52 this.appId = appId;
48 - this.configInfoService = configInfoService; 53 + this.configService = configService;
49 this.interfaceService = interfaceService; 54 this.interfaceService = interfaceService;
50 this.intentService = intentService; 55 this.intentService = intentService;
51 } 56 }
52 57
58 + /**
59 + * Starts the peer connectivity manager.
60 + */
53 public void start() { 61 public void start() {
54 // TODO are any of these errors? 62 // TODO are any of these errors?
55 if (interfaceService.getInterfaces().isEmpty()) { 63 if (interfaceService.getInterfaces().isEmpty()) {
56 64
57 log.warn("The interface in configuration file is empty. " 65 log.warn("The interface in configuration file is empty. "
58 + "Thus, the SDN-IP application can not be started."); 66 + "Thus, the SDN-IP application can not be started.");
59 - } else if (configInfoService.getBgpPeers().isEmpty()) { 67 + } else if (configService.getBgpPeers().isEmpty()) {
60 68
61 log.warn("The BGP peer in configuration file is empty." 69 log.warn("The BGP peer in configuration file is empty."
62 + "Thus, the SDN-IP application can not be started."); 70 + "Thus, the SDN-IP application can not be started.");
63 - } else if (configInfoService.getBgpSpeakers() == null) { 71 + } else if (configService.getBgpSpeakers() == null) {
64 72
65 log.error("The BGP speaker in configuration file is empty. " 73 log.error("The BGP speaker in configuration file is empty. "
66 + "Thus, the SDN-IP application can not be started."); 74 + "Thus, the SDN-IP application can not be started.");
...@@ -79,7 +87,7 @@ public class PeerConnectivityManager { ...@@ -79,7 +87,7 @@ public class PeerConnectivityManager {
79 * for paths from all peers to each BGP speaker. 87 * for paths from all peers to each BGP speaker.
80 */ 88 */
81 private void setupBgpPaths() { 89 private void setupBgpPaths() {
82 - for (BgpSpeaker bgpSpeaker : configInfoService.getBgpSpeakers() 90 + for (BgpSpeaker bgpSpeaker : configService.getBgpSpeakers()
83 .values()) { 91 .values()) {
84 log.debug("Start to set up BGP paths for BGP speaker: {}", 92 log.debug("Start to set up BGP paths for BGP speaker: {}",
85 bgpSpeaker); 93 bgpSpeaker);
...@@ -88,7 +96,7 @@ public class PeerConnectivityManager { ...@@ -88,7 +96,7 @@ public class PeerConnectivityManager {
88 List<InterfaceAddress> interfaceAddresses = 96 List<InterfaceAddress> interfaceAddresses =
89 bgpSpeaker.interfaceAddresses(); 97 bgpSpeaker.interfaceAddresses();
90 98
91 - for (BgpPeer bgpPeer : configInfoService.getBgpPeers().values()) { 99 + for (BgpPeer bgpPeer : configService.getBgpPeers().values()) {
92 100
93 log.debug("Start to set up BGP paths between BGP speaker: {} " 101 log.debug("Start to set up BGP paths between BGP speaker: {} "
94 + "to BGP peer: {}", bgpSpeaker, bgpPeer); 102 + "to BGP peer: {}", bgpSpeaker, bgpPeer);
...@@ -121,16 +129,14 @@ public class PeerConnectivityManager { ...@@ -121,16 +129,14 @@ public class PeerConnectivityManager {
121 129
122 // install intent for BGP path from BGPd to BGP peer matching 130 // install intent for BGP path from BGPd to BGP peer matching
123 // destination TCP port 179 131 // destination TCP port 179
124 -
125 - // TODO: The usage of PacketMatchBuilder will be improved, then we
126 - // only need to new the PacketMatchBuilder once.
127 - // By then, the code here will be improved accordingly.
128 TrafficSelector selector = DefaultTrafficSelector.builder() 132 TrafficSelector selector = DefaultTrafficSelector.builder()
129 .matchEthType(Ethernet.TYPE_IPV4) 133 .matchEthType(Ethernet.TYPE_IPV4)
130 .matchIPProtocol(IPv4.PROTOCOL_TCP) 134 .matchIPProtocol(IPv4.PROTOCOL_TCP)
131 - .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) 135 + .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(),
132 - .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) 136 + IpAddress.MAX_INET_MASK))
133 - .matchTcpDst(BGP_PORT) 137 + .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(),
138 + IpAddress.MAX_INET_MASK))
139 + .matchTcpDst((short) BgpConstants.BGP_PORT)
134 .build(); 140 .build();
135 141
136 TrafficTreatment treatment = DefaultTrafficTreatment.builder() 142 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
...@@ -149,9 +155,11 @@ public class PeerConnectivityManager { ...@@ -149,9 +155,11 @@ public class PeerConnectivityManager {
149 selector = DefaultTrafficSelector.builder() 155 selector = DefaultTrafficSelector.builder()
150 .matchEthType(Ethernet.TYPE_IPV4) 156 .matchEthType(Ethernet.TYPE_IPV4)
151 .matchIPProtocol(IPv4.PROTOCOL_TCP) 157 .matchIPProtocol(IPv4.PROTOCOL_TCP)
152 - .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) 158 + .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(),
153 - .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) 159 + IpAddress.MAX_INET_MASK))
154 - .matchTcpSrc(BGP_PORT) 160 + .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(),
161 + IpAddress.MAX_INET_MASK))
162 + .matchTcpSrc((short) BgpConstants.BGP_PORT)
155 .build(); 163 .build();
156 164
157 PointToPointIntent intentMatchSrcTcpPort = 165 PointToPointIntent intentMatchSrcTcpPort =
...@@ -167,9 +175,11 @@ public class PeerConnectivityManager { ...@@ -167,9 +175,11 @@ public class PeerConnectivityManager {
167 selector = DefaultTrafficSelector.builder() 175 selector = DefaultTrafficSelector.builder()
168 .matchEthType(Ethernet.TYPE_IPV4) 176 .matchEthType(Ethernet.TYPE_IPV4)
169 .matchIPProtocol(IPv4.PROTOCOL_TCP) 177 .matchIPProtocol(IPv4.PROTOCOL_TCP)
170 - .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) 178 + .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(),
171 - .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) 179 + IpAddress.MAX_INET_MASK))
172 - .matchTcpDst(BGP_PORT) 180 + .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(),
181 + IpAddress.MAX_INET_MASK))
182 + .matchTcpDst((short) BgpConstants.BGP_PORT)
173 .build(); 183 .build();
174 184
175 PointToPointIntent reversedIntentMatchDstTcpPort = 185 PointToPointIntent reversedIntentMatchDstTcpPort =
...@@ -185,9 +195,11 @@ public class PeerConnectivityManager { ...@@ -185,9 +195,11 @@ public class PeerConnectivityManager {
185 selector = DefaultTrafficSelector.builder() 195 selector = DefaultTrafficSelector.builder()
186 .matchEthType(Ethernet.TYPE_IPV4) 196 .matchEthType(Ethernet.TYPE_IPV4)
187 .matchIPProtocol(IPv4.PROTOCOL_TCP) 197 .matchIPProtocol(IPv4.PROTOCOL_TCP)
188 - .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) 198 + .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(),
189 - .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) 199 + IpAddress.MAX_INET_MASK))
190 - .matchTcpSrc(BGP_PORT) 200 + .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(),
201 + IpAddress.MAX_INET_MASK))
202 + .matchTcpSrc((short) BgpConstants.BGP_PORT)
191 .build(); 203 .build();
192 204
193 PointToPointIntent reversedIntentMatchSrcTcpPort = 205 PointToPointIntent reversedIntentMatchSrcTcpPort =
...@@ -211,7 +223,7 @@ public class PeerConnectivityManager { ...@@ -211,7 +223,7 @@ public class PeerConnectivityManager {
211 * for paths from all peers to each BGP speaker. 223 * for paths from all peers to each BGP speaker.
212 */ 224 */
213 private void setupIcmpPaths() { 225 private void setupIcmpPaths() {
214 - for (BgpSpeaker bgpSpeaker : configInfoService.getBgpSpeakers() 226 + for (BgpSpeaker bgpSpeaker : configService.getBgpSpeakers()
215 .values()) { 227 .values()) {
216 log.debug("Start to set up ICMP paths for BGP speaker: {}", 228 log.debug("Start to set up ICMP paths for BGP speaker: {}",
217 bgpSpeaker); 229 bgpSpeaker);
...@@ -219,7 +231,7 @@ public class PeerConnectivityManager { ...@@ -219,7 +231,7 @@ public class PeerConnectivityManager {
219 List<InterfaceAddress> interfaceAddresses = bgpSpeaker 231 List<InterfaceAddress> interfaceAddresses = bgpSpeaker
220 .interfaceAddresses(); 232 .interfaceAddresses();
221 233
222 - for (BgpPeer bgpPeer : configInfoService.getBgpPeers().values()) { 234 + for (BgpPeer bgpPeer : configService.getBgpPeers().values()) {
223 235
224 Interface peerInterface = interfaceService.getInterface( 236 Interface peerInterface = interfaceService.getInterface(
225 bgpPeer.connectPoint()); 237 bgpPeer.connectPoint());
...@@ -253,8 +265,10 @@ public class PeerConnectivityManager { ...@@ -253,8 +265,10 @@ public class PeerConnectivityManager {
253 TrafficSelector selector = DefaultTrafficSelector.builder() 265 TrafficSelector selector = DefaultTrafficSelector.builder()
254 .matchEthType(Ethernet.TYPE_IPV4) 266 .matchEthType(Ethernet.TYPE_IPV4)
255 .matchIPProtocol(IPv4.PROTOCOL_ICMP) 267 .matchIPProtocol(IPv4.PROTOCOL_ICMP)
256 - .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) 268 + .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(),
257 - .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) 269 + IpAddress.MAX_INET_MASK))
270 + .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(),
271 + IpAddress.MAX_INET_MASK))
258 .build(); 272 .build();
259 273
260 TrafficTreatment treatment = DefaultTrafficTreatment.builder() 274 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
...@@ -271,8 +285,10 @@ public class PeerConnectivityManager { ...@@ -271,8 +285,10 @@ public class PeerConnectivityManager {
271 selector = DefaultTrafficSelector.builder() 285 selector = DefaultTrafficSelector.builder()
272 .matchEthType(Ethernet.TYPE_IPV4) 286 .matchEthType(Ethernet.TYPE_IPV4)
273 .matchIPProtocol(IPv4.PROTOCOL_ICMP) 287 .matchIPProtocol(IPv4.PROTOCOL_ICMP)
274 - .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) 288 + .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(),
275 - .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) 289 + IpAddress.MAX_INET_MASK))
290 + .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(),
291 + IpAddress.MAX_INET_MASK))
276 .build(); 292 .build();
277 293
278 PointToPointIntent reversedIntent = 294 PointToPointIntent reversedIntent =
......
...@@ -55,8 +55,6 @@ import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; ...@@ -55,8 +55,6 @@ import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
55 /** 55 /**
56 * This class processes BGP route update, translates each update into a intent 56 * This class processes BGP route update, translates each update into a intent
57 * and submits the intent. 57 * and submits the intent.
58 - * <p/>
59 - * TODO: Make it thread-safe.
60 */ 58 */
61 public class Router implements RouteListener { 59 public class Router implements RouteListener {
62 60
...@@ -69,14 +67,13 @@ public class Router implements RouteListener { ...@@ -69,14 +67,13 @@ public class Router implements RouteListener {
69 // Stores all incoming route updates in a queue. 67 // Stores all incoming route updates in a queue.
70 private BlockingQueue<RouteUpdate> routeUpdates; 68 private BlockingQueue<RouteUpdate> routeUpdates;
71 69
72 - // The Ip4Address is the next hop address of each route update. 70 + // The IpAddress is the next hop address of each route update.
73 private SetMultimap<IpAddress, RouteEntry> routesWaitingOnArp; 71 private SetMultimap<IpAddress, RouteEntry> routesWaitingOnArp;
74 private ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent> pushedRouteIntents; 72 private ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent> pushedRouteIntents;
75 73
76 private IntentService intentService; 74 private IntentService intentService;
77 - //private IProxyArpService proxyArp;
78 private HostService hostService; 75 private HostService hostService;
79 - private SdnIpConfigService configInfoService; 76 + private SdnIpConfigService configService;
80 private InterfaceService interfaceService; 77 private InterfaceService interfaceService;
81 78
82 private ExecutorService bgpUpdatesExecutor; 79 private ExecutorService bgpUpdatesExecutor;
...@@ -98,18 +95,19 @@ public class Router implements RouteListener { ...@@ -98,18 +95,19 @@ public class Router implements RouteListener {
98 /** 95 /**
99 * Class constructor. 96 * Class constructor.
100 * 97 *
98 + * @param appId the application ID
101 * @param intentService the intent service 99 * @param intentService the intent service
102 * @param hostService the host service 100 * @param hostService the host service
103 - * @param configInfoService the configuration service 101 + * @param configService the configuration service
104 * @param interfaceService the interface service 102 * @param interfaceService the interface service
105 */ 103 */
106 public Router(ApplicationId appId, IntentService intentService, 104 public Router(ApplicationId appId, IntentService intentService,
107 - HostService hostService, SdnIpConfigService configInfoService, 105 + HostService hostService, SdnIpConfigService configService,
108 InterfaceService interfaceService) { 106 InterfaceService interfaceService) {
109 this.appId = appId; 107 this.appId = appId;
110 this.intentService = intentService; 108 this.intentService = intentService;
111 this.hostService = hostService; 109 this.hostService = hostService;
112 - this.configInfoService = configInfoService; 110 + this.configService = configService;
113 this.interfaceService = interfaceService; 111 this.interfaceService = interfaceService;
114 112
115 bgpRoutes = new ConcurrentInvertedRadixTree<>( 113 bgpRoutes = new ConcurrentInvertedRadixTree<>(
...@@ -172,7 +170,7 @@ public class Router implements RouteListener { ...@@ -172,7 +170,7 @@ public class Router implements RouteListener {
172 170
173 @Override 171 @Override
174 public void update(RouteUpdate routeUpdate) { 172 public void update(RouteUpdate routeUpdate) {
175 - log.debug("Received new route Update: {}", routeUpdate); 173 + log.debug("Received new route update: {}", routeUpdate);
176 174
177 try { 175 try {
178 routeUpdates.put(routeUpdate); 176 routeUpdates.put(routeUpdate);
...@@ -498,9 +496,11 @@ public class Router implements RouteListener { ...@@ -498,9 +496,11 @@ public class Router implements RouteListener {
498 private void executeRouteAdd(RouteEntry routeEntry) { 496 private void executeRouteAdd(RouteEntry routeEntry) {
499 log.debug("Executing route add: {}", routeEntry); 497 log.debug("Executing route add: {}", routeEntry);
500 498
499 + // Monitor the IP address so we'll get notified of updates to the MAC
500 + // address.
501 + hostService.startMonitoringIp(routeEntry.nextHop());
502 +
501 // See if we know the MAC address of the next hop 503 // See if we know the MAC address of the next hop
502 - //MacAddress nextHopMacAddress =
503 - //proxyArp.getMacAddress(routeEntry.getNextHop());
504 MacAddress nextHopMacAddress = null; 504 MacAddress nextHopMacAddress = null;
505 Set<Host> hosts = hostService.getHostsByIp( 505 Set<Host> hosts = hostService.getHostsByIp(
506 routeEntry.nextHop().toPrefix()); 506 routeEntry.nextHop().toPrefix());
...@@ -511,9 +511,6 @@ public class Router implements RouteListener { ...@@ -511,9 +511,6 @@ public class Router implements RouteListener {
511 511
512 if (nextHopMacAddress == null) { 512 if (nextHopMacAddress == null) {
513 routesWaitingOnArp.put(routeEntry.nextHop(), routeEntry); 513 routesWaitingOnArp.put(routeEntry.nextHop(), routeEntry);
514 - //proxyArp.sendArpRequest(routeEntry.getNextHop(), this, true);
515 - // TODO maybe just do this for every prefix anyway
516 - hostService.startMonitoringIp(routeEntry.nextHop());
517 return; 514 return;
518 } 515 }
519 516
...@@ -536,11 +533,11 @@ public class Router implements RouteListener { ...@@ -536,11 +533,11 @@ public class Router implements RouteListener {
536 533
537 // Find the attachment point (egress interface) of the next hop 534 // Find the attachment point (egress interface) of the next hop
538 Interface egressInterface; 535 Interface egressInterface;
539 - if (configInfoService.getBgpPeers().containsKey(nextHopIpAddress)) { 536 + if (configService.getBgpPeers().containsKey(nextHopIpAddress)) {
540 // Route to a peer 537 // Route to a peer
541 log.debug("Route to peer {}", nextHopIpAddress); 538 log.debug("Route to peer {}", nextHopIpAddress);
542 BgpPeer peer = 539 BgpPeer peer =
543 - configInfoService.getBgpPeers().get(nextHopIpAddress); 540 + configService.getBgpPeers().get(nextHopIpAddress);
544 egressInterface = 541 egressInterface =
545 interfaceService.getInterface(peer.connectPoint()); 542 interfaceService.getInterface(peer.connectPoint());
546 } else { 543 } else {
...@@ -593,17 +590,12 @@ public class Router implements RouteListener { ...@@ -593,17 +590,12 @@ public class Router implements RouteListener {
593 } 590 }
594 591
595 // Match the destination IP prefix at the first hop 592 // Match the destination IP prefix at the first hop
596 - //PacketMatchBuilder builder = new PacketMatchBuilder();
597 - //builder.setEtherType(Ethernet.TYPE_IPV4).setDstIpNet(prefix);
598 - //PacketMatch packetMatch = builder.build();
599 TrafficSelector selector = DefaultTrafficSelector.builder() 593 TrafficSelector selector = DefaultTrafficSelector.builder()
600 .matchEthType(Ethernet.TYPE_IPV4) 594 .matchEthType(Ethernet.TYPE_IPV4)
601 .matchIPDst(prefix) 595 .matchIPDst(prefix)
602 .build(); 596 .build();
603 597
604 // Rewrite the destination MAC address 598 // Rewrite the destination MAC address
605 - //ModifyDstMacAction modifyDstMacAction =
606 - //new ModifyDstMacAction(nextHopMacAddress);
607 TrafficTreatment treatment = DefaultTrafficTreatment.builder() 599 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
608 .setEthDst(nextHopMacAddress) 600 .setEthDst(nextHopMacAddress)
609 .build(); 601 .build();
...@@ -635,10 +627,6 @@ public class Router implements RouteListener { ...@@ -635,10 +627,6 @@ public class Router implements RouteListener {
635 log.debug("Processing route delete: {}", routeEntry); 627 log.debug("Processing route delete: {}", routeEntry);
636 IpPrefix prefix = routeEntry.prefix(); 628 IpPrefix prefix = routeEntry.prefix();
637 629
638 - // TODO check the change of logic here - remove doesn't check that
639 - // the route entry was what we expected (and we can't do this
640 - // concurrently)
641 -
642 if (bgpRoutes.remove(RouteEntry.createBinaryString(prefix))) { 630 if (bgpRoutes.remove(RouteEntry.createBinaryString(prefix))) {
643 // 631 //
644 // Only delete flows if an entry was actually removed from the 632 // Only delete flows if an entry was actually removed from the
...@@ -680,17 +668,19 @@ public class Router implements RouteListener { ...@@ -680,17 +668,19 @@ public class Router implements RouteListener {
680 } 668 }
681 669
682 /** 670 /**
683 - * This method handles the prefixes which are waiting for ARP replies for 671 + * Signals the Router that the MAC to IP mapping has potentially been
684 - * MAC addresses of next hops. 672 + * updated. This has the effect of updating the MAC address for any
673 + * installed prefixes if it has changed, as well as installing any pending
674 + * prefixes that were waiting for MAC resolution.
685 * 675 *
686 - * @param ipAddress next hop router IP address, for which we sent ARP 676 + * @param ipAddress the IP address that an event was received for
687 - * request out 677 + * @param macAddress the most recently known MAC address for the IP address
688 - * @param macAddress MAC address which is relative to the ipAddress
689 */ 678 */
690 - //@Override 679 + private void updateMac(IpAddress ipAddress, MacAddress macAddress) {
691 - // TODO change name 680 + log.debug("Received updated MAC info: {} => {}", ipAddress, macAddress);
692 - public void arpResponse(IpAddress ipAddress, MacAddress macAddress) { 681 +
693 - log.debug("Received ARP response: {} => {}", ipAddress, macAddress); 682 + // TODO here we should check whether the next hop for any of our
683 + // installed prefixes has changed, not just prefixes pending installation.
694 684
695 // We synchronize on this to prevent changes to the radix tree 685 // We synchronize on this to prevent changes to the radix tree
696 // while we're pushing intents. If the tree changes, the 686 // while we're pushing intents. If the tree changes, the
...@@ -708,8 +698,6 @@ public class Router implements RouteListener { ...@@ -708,8 +698,6 @@ public class Router implements RouteListener {
708 bgpRoutes.getValueForExactKey(binaryString); 698 bgpRoutes.getValueForExactKey(binaryString);
709 if (foundRouteEntry != null && 699 if (foundRouteEntry != null &&
710 foundRouteEntry.nextHop().equals(routeEntry.nextHop())) { 700 foundRouteEntry.nextHop().equals(routeEntry.nextHop())) {
711 - log.debug("Pushing prefix {} next hop {}",
712 - routeEntry.prefix(), routeEntry.nextHop());
713 // We only push prefix flows if the prefix is still in the 701 // We only push prefix flows if the prefix is still in the
714 // radix tree and the next hop is the same as our 702 // radix tree and the next hop is the same as our
715 // update. 703 // update.
...@@ -717,9 +705,8 @@ public class Router implements RouteListener { ...@@ -717,9 +705,8 @@ public class Router implements RouteListener {
717 // for the ARP, or the next hop could have changed. 705 // for the ARP, or the next hop could have changed.
718 addRouteIntentToNextHop(prefix, ipAddress, macAddress); 706 addRouteIntentToNextHop(prefix, ipAddress, macAddress);
719 } else { 707 } else {
720 - log.debug("Received ARP response, but {}/{} is no longer in" 708 + log.debug("{} has been revoked before the MAC was resolved",
721 - + " the radix tree", routeEntry.prefix(), 709 + routeEntry);
722 - routeEntry.nextHop());
723 } 710 }
724 } 711 }
725 } 712 }
...@@ -769,7 +756,7 @@ public class Router implements RouteListener { ...@@ -769,7 +756,7 @@ public class Router implements RouteListener {
769 event.type() == HostEvent.Type.HOST_UPDATED) { 756 event.type() == HostEvent.Type.HOST_UPDATED) {
770 Host host = event.subject(); 757 Host host = event.subject();
771 for (IpPrefix ip : host.ipAddresses()) { 758 for (IpPrefix ip : host.ipAddresses()) {
772 - arpResponse(ip.toIpAddress(), host.mac()); 759 + updateMac(ip.toIpAddress(), host.mac());
773 } 760 }
774 } 761 }
775 } 762 }
......
...@@ -26,7 +26,7 @@ import org.slf4j.Logger; ...@@ -26,7 +26,7 @@ import org.slf4j.Logger;
26 @Service 26 @Service
27 public class SdnIp implements SdnIpService { 27 public class SdnIp implements SdnIpService {
28 28
29 - private static final String SDN_ID_APP = "org.onlab.onos.sdnip"; 29 + private static final String SDN_IP_APP = "org.onlab.onos.sdnip";
30 30
31 private final Logger log = getLogger(getClass()); 31 private final Logger log = getLogger(getClass());
32 32
...@@ -53,8 +53,10 @@ public class SdnIp implements SdnIpService { ...@@ -53,8 +53,10 @@ public class SdnIp implements SdnIpService {
53 53
54 InterfaceService interfaceService = new HostToInterfaceAdaptor(hostService); 54 InterfaceService interfaceService = new HostToInterfaceAdaptor(hostService);
55 55
56 - ApplicationId appId = coreService.registerApplication(SDN_ID_APP); 56 + ApplicationId appId = coreService.registerApplication(SDN_IP_APP);
57 - peerConnectivity = new PeerConnectivityManager(appId, config, interfaceService, intentService); 57 +
58 + peerConnectivity = new PeerConnectivityManager(appId, config,
59 + interfaceService, intentService);
58 peerConnectivity.start(); 60 peerConnectivity.start();
59 61
60 router = new Router(appId, intentService, hostService, config, interfaceService); 62 router = new Router(appId, intentService, hostService, config, interfaceService);
......
1 package org.onlab.onos.sdnip; 1 package org.onlab.onos.sdnip;
2 2
3 +import static org.easymock.EasyMock.anyObject;
3 import static org.easymock.EasyMock.createMock; 4 import static org.easymock.EasyMock.createMock;
4 import static org.easymock.EasyMock.expect; 5 import static org.easymock.EasyMock.expect;
6 +import static org.easymock.EasyMock.expectLastCall;
5 import static org.easymock.EasyMock.replay; 7 import static org.easymock.EasyMock.replay;
6 import static org.easymock.EasyMock.reset; 8 import static org.easymock.EasyMock.reset;
7 import static org.easymock.EasyMock.verify; 9 import static org.easymock.EasyMock.verify;
...@@ -27,6 +29,7 @@ import org.onlab.onos.net.flow.DefaultTrafficSelector; ...@@ -27,6 +29,7 @@ import org.onlab.onos.net.flow.DefaultTrafficSelector;
27 import org.onlab.onos.net.flow.DefaultTrafficTreatment; 29 import org.onlab.onos.net.flow.DefaultTrafficTreatment;
28 import org.onlab.onos.net.flow.TrafficSelector; 30 import org.onlab.onos.net.flow.TrafficSelector;
29 import org.onlab.onos.net.flow.TrafficTreatment; 31 import org.onlab.onos.net.flow.TrafficTreatment;
32 +import org.onlab.onos.net.host.HostListener;
30 import org.onlab.onos.net.host.HostService; 33 import org.onlab.onos.net.host.HostService;
31 import org.onlab.onos.net.intent.IntentService; 34 import org.onlab.onos.net.intent.IntentService;
32 import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; 35 import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
...@@ -55,10 +58,17 @@ public class RouterTest { ...@@ -55,10 +58,17 @@ public class RouterTest {
55 private IntentService intentService; 58 private IntentService intentService;
56 private HostService hostService; 59 private HostService hostService;
57 60
58 - private Map<IpAddress, BgpPeer> bgpPeers; 61 + private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
59 - private Map<IpAddress, BgpPeer> configuredPeers; 62 + DeviceId.deviceId("of:0000000000000001"),
60 - private Set<Interface> interfaces; 63 + PortNumber.portNumber(1));
61 - private Set<Interface> configuredInterfaces; 64 +
65 + private static final ConnectPoint SW2_ETH1 = new ConnectPoint(
66 + DeviceId.deviceId("of:0000000000000002"),
67 + PortNumber.portNumber(1));
68 +
69 + private static final ConnectPoint SW3_ETH1 = new ConnectPoint(
70 + DeviceId.deviceId("of:0000000000000003"),
71 + PortNumber.portNumber(1));
62 72
63 private static final ApplicationId APPID = new ApplicationId() { 73 private static final ApplicationId APPID = new ApplicationId() {
64 @Override 74 @Override
...@@ -76,55 +86,12 @@ public class RouterTest { ...@@ -76,55 +86,12 @@ public class RouterTest {
76 86
77 @Before 87 @Before
78 public void setUp() throws Exception { 88 public void setUp() throws Exception {
79 - bgpPeers = setUpBgpPeers(); 89 + setUpBgpPeers();
80 - interfaces = setUpInterfaces();
81 - initRouter();
82 - }
83 90
84 - /** 91 + setUpInterfaceService();
85 - * Initializes Router class. 92 + setUpHostService();
86 - */
87 - private void initRouter() {
88 93
89 intentService = createMock(IntentService.class); 94 intentService = createMock(IntentService.class);
90 - hostService = createMock(HostService.class);
91 -
92 - interfaceService = createMock(InterfaceService.class);
93 - expect(interfaceService.getInterfaces()).andReturn(
94 - interfaces).anyTimes();
95 -
96 - Set<IpPrefix> ipAddressesOnSw1Eth1 = new HashSet<IpPrefix>();
97 - ipAddressesOnSw1Eth1.add(IpPrefix.valueOf("192.168.10.0/24"));
98 - Interface expectedInterface =
99 - new Interface(new ConnectPoint(
100 - DeviceId.deviceId("of:0000000000000001"),
101 - PortNumber.portNumber("1")),
102 - ipAddressesOnSw1Eth1,
103 - MacAddress.valueOf("00:00:00:00:00:01"));
104 - ConnectPoint egressPoint = new ConnectPoint(
105 - DeviceId.deviceId("of:0000000000000001"),
106 - PortNumber.portNumber(1));
107 - expect(interfaceService.getInterface(egressPoint)).andReturn(
108 - expectedInterface).anyTimes();
109 -
110 - Set<IpPrefix> ipAddressesOnSw2Eth1 = new HashSet<IpPrefix>();
111 - ipAddressesOnSw2Eth1.add(IpPrefix.valueOf("192.168.20.0/24"));
112 - Interface expectedInterfaceNew =
113 - new Interface(new ConnectPoint(
114 - DeviceId.deviceId("of:0000000000000002"),
115 - PortNumber.portNumber("1")),
116 - ipAddressesOnSw2Eth1,
117 - MacAddress.valueOf("00:00:00:00:00:02"));
118 - ConnectPoint egressPointNew = new ConnectPoint(
119 - DeviceId.deviceId("of:0000000000000002"),
120 - PortNumber.portNumber(1));
121 - expect(interfaceService.getInterface(egressPointNew)).andReturn(
122 - expectedInterfaceNew).anyTimes();
123 - replay(interfaceService);
124 -
125 - sdnIpConfigService = createMock(SdnIpConfigService.class);
126 - expect(sdnIpConfigService.getBgpPeers()).andReturn(bgpPeers).anyTimes();
127 - replay(sdnIpConfigService);
128 95
129 router = new Router(APPID, intentService, 96 router = new Router(APPID, intentService,
130 hostService, sdnIpConfigService, interfaceService); 97 hostService, sdnIpConfigService, interfaceService);
...@@ -132,67 +99,99 @@ public class RouterTest { ...@@ -132,67 +99,99 @@ public class RouterTest {
132 99
133 /** 100 /**
134 * Sets up BGP peers in external networks. 101 * Sets up BGP peers in external networks.
135 - *
136 - * @return configured BGP peers as a Map from peer IP address to BgpPeer
137 */ 102 */
138 - private Map<IpAddress, BgpPeer> setUpBgpPeers() { 103 + private void setUpBgpPeers() {
139 104
140 - configuredPeers = new HashMap<>(); 105 + Map<IpAddress, BgpPeer> peers = new HashMap<>();
141 106
142 String peerSw1Eth1 = "192.168.10.1"; 107 String peerSw1Eth1 = "192.168.10.1";
143 - configuredPeers.put(IpAddress.valueOf(peerSw1Eth1), 108 + peers.put(IpAddress.valueOf(peerSw1Eth1),
144 new BgpPeer("00:00:00:00:00:00:00:01", 1, peerSw1Eth1)); 109 new BgpPeer("00:00:00:00:00:00:00:01", 1, peerSw1Eth1));
145 110
146 // Two BGP peers are connected to switch 2 port 1. 111 // Two BGP peers are connected to switch 2 port 1.
147 String peer1Sw2Eth1 = "192.168.20.1"; 112 String peer1Sw2Eth1 = "192.168.20.1";
148 - configuredPeers.put(IpAddress.valueOf(peer1Sw2Eth1), 113 + peers.put(IpAddress.valueOf(peer1Sw2Eth1),
149 new BgpPeer("00:00:00:00:00:00:00:02", 1, peer1Sw2Eth1)); 114 new BgpPeer("00:00:00:00:00:00:00:02", 1, peer1Sw2Eth1));
150 115
151 String peer2Sw2Eth1 = "192.168.20.2"; 116 String peer2Sw2Eth1 = "192.168.20.2";
152 - configuredPeers.put(IpAddress.valueOf(peer2Sw2Eth1), 117 + peers.put(IpAddress.valueOf(peer2Sw2Eth1),
153 new BgpPeer("00:00:00:00:00:00:00:02", 1, peer2Sw2Eth1)); 118 new BgpPeer("00:00:00:00:00:00:00:02", 1, peer2Sw2Eth1));
154 119
155 - return configuredPeers; 120 + sdnIpConfigService = createMock(SdnIpConfigService.class);
121 + expect(sdnIpConfigService.getBgpPeers()).andReturn(peers).anyTimes();
122 + replay(sdnIpConfigService);
123 +
156 } 124 }
157 125
158 /** 126 /**
159 * Sets up logical interfaces, which emulate the configured interfaces 127 * Sets up logical interfaces, which emulate the configured interfaces
160 * in SDN-IP application. 128 * in SDN-IP application.
161 - *
162 - * @return configured interfaces as a Set
163 */ 129 */
164 - private Set<Interface> setUpInterfaces() { 130 + private void setUpInterfaceService() {
131 + interfaceService = createMock(InterfaceService.class);
165 132
166 - configuredInterfaces = Sets.newHashSet(); 133 + Set<Interface> interfaces = Sets.newHashSet();
167 134
168 - Set<IpPrefix> ipAddressesOnSw1Eth1 = new HashSet<IpPrefix>(); 135 + Interface sw1Eth1 = new Interface(SW1_ETH1,
169 - ipAddressesOnSw1Eth1.add(IpPrefix.valueOf("192.168.10.0/24")); 136 + Sets.newHashSet(IpPrefix.valueOf("192.168.10.101/24")),
170 - configuredInterfaces.add( 137 + MacAddress.valueOf("00:00:00:00:00:01"));
171 - new Interface(new ConnectPoint( 138 +
172 - DeviceId.deviceId("of:0000000000000001"), 139 + expect(interfaceService.getInterface(SW1_ETH1)).andReturn(sw1Eth1).anyTimes();
173 - PortNumber.portNumber(1)), 140 + interfaces.add(sw1Eth1);
174 - ipAddressesOnSw1Eth1, 141 +
175 - MacAddress.valueOf("00:00:00:00:00:01"))); 142 + Interface sw2Eth1 = new Interface(SW2_ETH1,
176 - 143 + Sets.newHashSet(IpPrefix.valueOf("192.168.20.101/24")),
177 - Set<IpPrefix> ipAddressesOnSw2Eth1 = new HashSet<IpPrefix>(); 144 + MacAddress.valueOf("00:00:00:00:00:02"));
178 - ipAddressesOnSw2Eth1.add(IpPrefix.valueOf("192.168.20.0/24")); 145 +
179 - configuredInterfaces.add( 146 + expect(interfaceService.getInterface(SW2_ETH1)).andReturn(sw2Eth1).anyTimes();
180 - new Interface(new ConnectPoint( 147 + interfaces.add(sw2Eth1);
181 - DeviceId.deviceId("of:0000000000000002"), 148 +
182 - PortNumber.portNumber(1)), 149 + Interface sw3Eth1 = new Interface(SW3_ETH1,
183 - ipAddressesOnSw2Eth1, 150 + Sets.newHashSet(IpPrefix.valueOf("192.168.30.101/24")),
184 - MacAddress.valueOf("00:00:00:00:00:02"))); 151 + MacAddress.valueOf("00:00:00:00:00:03"));
185 - 152 +
186 - Set<IpPrefix> ipAddressesOnSw3Eth1 = new HashSet<IpPrefix>(); 153 + expect(interfaceService.getInterface(SW3_ETH1)).andReturn(sw3Eth1).anyTimes();
187 - ipAddressesOnSw3Eth1.add(IpPrefix.valueOf("192.168.30.0/24")); 154 + interfaces.add(sw3Eth1);
188 - configuredInterfaces.add(
189 - new Interface(new ConnectPoint(
190 - DeviceId.deviceId("of:0000000000000003"),
191 - PortNumber.portNumber(1)),
192 - ipAddressesOnSw3Eth1,
193 - MacAddress.valueOf("00:00:00:00:00:03")));
194 155
195 - return configuredInterfaces; 156 + expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
157 +
158 + replay(interfaceService);
159 + }
160 +
161 + /**
162 + * Sets up the host service with details of some hosts.
163 + */
164 + private void setUpHostService() {
165 + hostService = createMock(HostService.class);
166 +
167 + hostService.addListener(anyObject(HostListener.class));
168 + expectLastCall().anyTimes();
169 +
170 + IpPrefix host1Address = IpPrefix.valueOf("192.168.10.1/32");
171 + Host host1 = new DefaultHost(ProviderId.NONE, HostId.NONE,
172 + MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE,
173 + new HostLocation(SW1_ETH1, 1),
174 + Sets.newHashSet(host1Address));
175 +
176 + expect(hostService.getHostsByIp(host1Address))
177 + .andReturn(Sets.newHashSet(host1)).anyTimes();
178 + hostService.startMonitoringIp(host1Address.toIpAddress());
179 + expectLastCall().anyTimes();
180 +
181 +
182 + IpPrefix host2Address = IpPrefix.valueOf("192.168.20.1/32");
183 + Host host2 = new DefaultHost(ProviderId.NONE, HostId.NONE,
184 + MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE,
185 + new HostLocation(SW2_ETH1, 1),
186 + Sets.newHashSet(host2Address));
187 +
188 + expect(hostService.getHostsByIp(host2Address))
189 + .andReturn(Sets.newHashSet(host2)).anyTimes();
190 + hostService.startMonitoringIp(host2Address.toIpAddress());
191 + expectLastCall().anyTimes();
192 +
193 +
194 + replay(hostService);
196 } 195 }
197 196
198 /** 197 /**
...@@ -200,7 +199,6 @@ public class RouterTest { ...@@ -200,7 +199,6 @@ public class RouterTest {
200 */ 199 */
201 @Test 200 @Test
202 public void testProcessRouteAdd() throws TestUtilsException { 201 public void testProcessRouteAdd() throws TestUtilsException {
203 -
204 // Construct a route entry 202 // Construct a route entry
205 RouteEntry routeEntry = new RouteEntry( 203 RouteEntry routeEntry = new RouteEntry(
206 IpPrefix.valueOf("1.1.1.0/24"), 204 IpPrefix.valueOf("1.1.1.0/24"),
...@@ -217,36 +215,13 @@ public class RouterTest { ...@@ -217,36 +215,13 @@ public class RouterTest {
217 treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01")); 215 treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
218 216
219 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>(); 217 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
220 - ingressPoints.add(new ConnectPoint( 218 + ingressPoints.add(SW2_ETH1);
221 - DeviceId.deviceId("of:0000000000000002"), 219 + ingressPoints.add(SW3_ETH1);
222 - PortNumber.portNumber("1")));
223 - ingressPoints.add(new ConnectPoint(
224 - DeviceId.deviceId("of:0000000000000003"),
225 - PortNumber.portNumber("1")));
226 -
227 - ConnectPoint egressPoint = new ConnectPoint(
228 - DeviceId.deviceId("of:0000000000000001"),
229 - PortNumber.portNumber("1"));
230 220
231 MultiPointToSinglePointIntent intent = 221 MultiPointToSinglePointIntent intent =
232 new MultiPointToSinglePointIntent(APPID, 222 new MultiPointToSinglePointIntent(APPID,
233 selectorBuilder.build(), treatmentBuilder.build(), 223 selectorBuilder.build(), treatmentBuilder.build(),
234 - ingressPoints, egressPoint); 224 + ingressPoints, SW1_ETH1);
235 -
236 - // Reset host service
237 - reset(hostService);
238 - Set<Host> hosts = new HashSet<Host>(1);
239 - Set<IpPrefix> ipPrefixes = new HashSet<IpPrefix>();
240 - ipPrefixes.add(IpPrefix.valueOf("192.168.10.1/32"));
241 - hosts.add(new DefaultHost(ProviderId.NONE, HostId.NONE,
242 - MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE,
243 - new HostLocation(
244 - DeviceId.deviceId("of:0000000000000001"),
245 - PortNumber.portNumber(1), 1),
246 - ipPrefixes));
247 - expect(hostService.getHostsByIp(
248 - IpPrefix.valueOf("192.168.10.1/32"))).andReturn(hosts);
249 - replay(hostService);
250 225
251 // Set up test expectation 226 // Set up test expectation
252 reset(intentService); 227 reset(intentService);
...@@ -274,7 +249,6 @@ public class RouterTest { ...@@ -274,7 +249,6 @@ public class RouterTest {
274 */ 249 */
275 @Test 250 @Test
276 public void testRouteUpdate() throws TestUtilsException { 251 public void testRouteUpdate() throws TestUtilsException {
277 -
278 // Firstly add a route 252 // Firstly add a route
279 testProcessRouteAdd(); 253 testProcessRouteAdd();
280 254
...@@ -293,22 +267,14 @@ public class RouterTest { ...@@ -293,22 +267,14 @@ public class RouterTest {
293 DefaultTrafficTreatment.builder(); 267 DefaultTrafficTreatment.builder();
294 treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01")); 268 treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
295 269
296 - ConnectPoint egressPoint = new ConnectPoint(
297 - DeviceId.deviceId("of:0000000000000001"),
298 - PortNumber.portNumber("1"));
299 -
300 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>(); 270 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
301 - ingressPoints.add(new ConnectPoint( 271 + ingressPoints.add(SW2_ETH1);
302 - DeviceId.deviceId("of:0000000000000002"), 272 + ingressPoints.add(SW3_ETH1);
303 - PortNumber.portNumber("1")));
304 - ingressPoints.add(new ConnectPoint(
305 - DeviceId.deviceId("of:0000000000000003"),
306 - PortNumber.portNumber("1")));
307 273
308 MultiPointToSinglePointIntent intent = 274 MultiPointToSinglePointIntent intent =
309 new MultiPointToSinglePointIntent(APPID, 275 new MultiPointToSinglePointIntent(APPID,
310 selectorBuilder.build(), treatmentBuilder.build(), 276 selectorBuilder.build(), treatmentBuilder.build(),
311 - ingressPoints, egressPoint); 277 + ingressPoints, SW1_ETH1);
312 278
313 // Start to construct a new route entry and new intent 279 // Start to construct a new route entry and new intent
314 RouteEntry routeEntryUpdate = new RouteEntry( 280 RouteEntry routeEntryUpdate = new RouteEntry(
...@@ -325,38 +291,16 @@ public class RouterTest { ...@@ -325,38 +291,16 @@ public class RouterTest {
325 DefaultTrafficTreatment.builder(); 291 DefaultTrafficTreatment.builder();
326 treatmentBuilderNew.setEthDst(MacAddress.valueOf("00:00:00:00:00:02")); 292 treatmentBuilderNew.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"));
327 293
328 - ConnectPoint egressPointNew = new ConnectPoint(
329 - DeviceId.deviceId("of:0000000000000002"),
330 - PortNumber.portNumber("1"));
331 294
332 Set<ConnectPoint> ingressPointsNew = new HashSet<ConnectPoint>(); 295 Set<ConnectPoint> ingressPointsNew = new HashSet<ConnectPoint>();
333 - ingressPointsNew.add(new ConnectPoint( 296 + ingressPointsNew.add(SW1_ETH1);
334 - DeviceId.deviceId("of:0000000000000001"), 297 + ingressPointsNew.add(SW3_ETH1);
335 - PortNumber.portNumber("1")));
336 - ingressPointsNew.add(new ConnectPoint(
337 - DeviceId.deviceId("of:0000000000000003"),
338 - PortNumber.portNumber("1")));
339 298
340 MultiPointToSinglePointIntent intentNew = 299 MultiPointToSinglePointIntent intentNew =
341 new MultiPointToSinglePointIntent(APPID, 300 new MultiPointToSinglePointIntent(APPID,
342 selectorBuilderNew.build(), 301 selectorBuilderNew.build(),
343 treatmentBuilderNew.build(), 302 treatmentBuilderNew.build(),
344 - ingressPointsNew, egressPointNew); 303 + ingressPointsNew, SW2_ETH1);
345 -
346 - // Reset host service
347 - reset(hostService);
348 - Set<Host> hosts = new HashSet<Host>(1);
349 - Set<IpPrefix> ipPrefixes = new HashSet<IpPrefix>();
350 - ipPrefixes.add(IpPrefix.valueOf("192.168.20.1/32"));
351 - hosts.add(new DefaultHost(ProviderId.NONE, HostId.NONE,
352 - MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE,
353 - new HostLocation(
354 - DeviceId.deviceId("of:0000000000000002"),
355 - PortNumber.portNumber(1), 1),
356 - ipPrefixes));
357 - expect(hostService.getHostsByIp(
358 - IpPrefix.valueOf("192.168.20.1/32"))).andReturn(hosts);
359 - replay(hostService);
360 304
361 // Set up test expectation 305 // Set up test expectation
362 reset(intentService); 306 reset(intentService);
...@@ -383,7 +327,6 @@ public class RouterTest { ...@@ -383,7 +327,6 @@ public class RouterTest {
383 */ 327 */
384 @Test 328 @Test
385 public void testProcessRouteDelete() throws TestUtilsException { 329 public void testProcessRouteDelete() throws TestUtilsException {
386 -
387 // Firstly add a route 330 // Firstly add a route
388 testProcessRouteAdd(); 331 testProcessRouteAdd();
389 332
...@@ -402,22 +345,14 @@ public class RouterTest { ...@@ -402,22 +345,14 @@ public class RouterTest {
402 DefaultTrafficTreatment.builder(); 345 DefaultTrafficTreatment.builder();
403 treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01")); 346 treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
404 347
405 - ConnectPoint egressPoint = new ConnectPoint(
406 - DeviceId.deviceId("of:0000000000000001"),
407 - PortNumber.portNumber("1"));
408 -
409 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>(); 348 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
410 - ingressPoints.add(new ConnectPoint( 349 + ingressPoints.add(SW2_ETH1);
411 - DeviceId.deviceId("of:0000000000000002"), 350 + ingressPoints.add(SW3_ETH1);
412 - PortNumber.portNumber("1")));
413 - ingressPoints.add(new ConnectPoint(
414 - DeviceId.deviceId("of:0000000000000003"),
415 - PortNumber.portNumber("1")));
416 351
417 MultiPointToSinglePointIntent intent = 352 MultiPointToSinglePointIntent intent =
418 new MultiPointToSinglePointIntent(APPID, 353 new MultiPointToSinglePointIntent(APPID,
419 selectorBuilder.build(), treatmentBuilder.build(), 354 selectorBuilder.build(), treatmentBuilder.build(),
420 - ingressPoints, egressPoint); 355 + ingressPoints, SW1_ETH1);
421 356
422 // Set up expectation 357 // Set up expectation
423 reset(intentService); 358 reset(intentService);
...@@ -442,7 +377,6 @@ public class RouterTest { ...@@ -442,7 +377,6 @@ public class RouterTest {
442 */ 377 */
443 @Test 378 @Test
444 public void testLocalRouteAdd() throws TestUtilsException { 379 public void testLocalRouteAdd() throws TestUtilsException {
445 -
446 // Construct a route entry, the next hop is the local BGP speaker 380 // Construct a route entry, the next hop is the local BGP speaker
447 RouteEntry routeEntry = new RouteEntry( 381 RouteEntry routeEntry = new RouteEntry(
448 IpPrefix.valueOf("1.1.1.0/24"), IpAddress.valueOf("0.0.0.0")); 382 IpPrefix.valueOf("1.1.1.0/24"), IpAddress.valueOf("0.0.0.0"));
......