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);
......