ONOS-2812 Refactored the link code in search of a defect; the root cause was old…
… OVS-based switch which is wrongly forwarding LLDP frames. ONOS can fix this later by tracking links to be pruned using port pairs. Change-Id: Ia79ec69946daff80636f5ab4b75a3dcdba91465d
Showing
2 changed files
with
13 additions
and
20 deletions
... | @@ -275,6 +275,10 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -275,6 +275,10 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
275 | packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId); | 275 | packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId); |
276 | } | 276 | } |
277 | 277 | ||
278 | + private LinkDiscovery createLinkDiscovery(Device device) { | ||
279 | + return new LinkDiscovery(device, packetService, masterService, | ||
280 | + providerService, useBDDP); | ||
281 | + } | ||
278 | 282 | ||
279 | private class InternalRoleListener implements MastershipListener { | 283 | private class InternalRoleListener implements MastershipListener { |
280 | 284 | ||
... | @@ -297,11 +301,8 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -297,11 +301,8 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
297 | synchronized (discoverers) { | 301 | synchronized (discoverers) { |
298 | if (!discoverers.containsKey(deviceId)) { | 302 | if (!discoverers.containsKey(deviceId)) { |
299 | // ideally, should never reach here | 303 | // ideally, should never reach here |
300 | - log.debug("Device mastership changed ({}) {}", | 304 | + log.debug("Device mastership changed ({}) {}", event.type(), deviceId); |
301 | - event.type(), deviceId); | 305 | + discoverers.put(deviceId, createLinkDiscovery(device)); |
302 | - discoverers.put(deviceId, new LinkDiscovery(device, | ||
303 | - packetService, masterService, providerService, | ||
304 | - useBDDP)); | ||
305 | } | 306 | } |
306 | } | 307 | } |
307 | } | 308 | } |
... | @@ -331,15 +332,11 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -331,15 +332,11 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
331 | log.debug("LinkDiscovery from {} disabled by configuration", device.id()); | 332 | log.debug("LinkDiscovery from {} disabled by configuration", device.id()); |
332 | return; | 333 | return; |
333 | } | 334 | } |
334 | - log.debug("Device added ({}) {}", event.type(), | 335 | + log.debug("Device added ({}) {}", event.type(), deviceId); |
335 | - deviceId); | 336 | + discoverers.put(deviceId, createLinkDiscovery(device)); |
336 | - discoverers.put(deviceId, new LinkDiscovery(device, | ||
337 | - packetService, masterService, | ||
338 | - providerService, useBDDP)); | ||
339 | } else { | 337 | } else { |
340 | if (ld.isStopped()) { | 338 | if (ld.isStopped()) { |
341 | - log.debug("Device restarted ({}) {}", event.type(), | 339 | + log.debug("Device restarted ({}) {}", event.type(), deviceId); |
342 | - deviceId); | ||
343 | ld.start(); | 340 | ld.start(); |
344 | } | 341 | } |
345 | } | 342 | } |
... | @@ -363,15 +360,13 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -363,15 +360,13 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
363 | } | 360 | } |
364 | } else { | 361 | } else { |
365 | log.debug("Port down {}", port); | 362 | log.debug("Port down {}", port); |
366 | - ConnectPoint point = new ConnectPoint(deviceId, | 363 | + ConnectPoint point = new ConnectPoint(deviceId, port.number()); |
367 | - port.number()); | ||
368 | providerService.linksVanished(point); | 364 | providerService.linksVanished(point); |
369 | } | 365 | } |
370 | break; | 366 | break; |
371 | case PORT_REMOVED: | 367 | case PORT_REMOVED: |
372 | log.debug("Port removed {}", port); | 368 | log.debug("Port removed {}", port); |
373 | - ConnectPoint point = new ConnectPoint(deviceId, | 369 | + ConnectPoint point = new ConnectPoint(deviceId, port.number()); |
374 | - port.number()); | ||
375 | providerService.linksVanished(point); | 370 | providerService.linksVanished(point); |
376 | 371 | ||
377 | break; | 372 | break; |
... | @@ -411,8 +406,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -411,8 +406,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
411 | if (context == null) { | 406 | if (context == null) { |
412 | return; | 407 | return; |
413 | } | 408 | } |
414 | - LinkDiscovery ld = discoverers.get( | 409 | + LinkDiscovery ld = discoverers.get(context.inPacket().receivedFrom().deviceId()); |
415 | - context.inPacket().receivedFrom().deviceId()); | ||
416 | if (ld == null) { | 410 | if (ld == null) { |
417 | return; | 411 | return; |
418 | } | 412 | } |
... | @@ -441,8 +435,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -441,8 +435,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
441 | synchronized (discoverers) { | 435 | synchronized (discoverers) { |
442 | LinkDiscovery discoverer = discoverers.get(did); | 436 | LinkDiscovery discoverer = discoverers.get(did); |
443 | if (discoverer == null) { | 437 | if (discoverer == null) { |
444 | - discoverer = new LinkDiscovery(dev, packetService, | 438 | + discoverer = createLinkDiscovery(dev); |
445 | - masterService, providerService, useBDDP); | ||
446 | discoverers.put(did, discoverer); | 439 | discoverers.put(did, discoverer); |
447 | } | 440 | } |
448 | 441 | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment