Committed by
Gerrit Code Review
Changed ProxyArpManager to make use of EdgeManager.
Change-Id: I05193146490aba6736c1815bf0d9022df8628973
Showing
3 changed files
with
76 additions
and
163 deletions
... | @@ -174,6 +174,8 @@ public class EdgeManager implements EdgePortService { | ... | @@ -174,6 +174,8 @@ public class EdgeManager implements EdgePortService { |
174 | } | 174 | } |
175 | }); | 175 | }); |
176 | } else { | 176 | } else { |
177 | + //FIXME special case of preexisting edgeport & no triggerless events could cause this to never hit and | ||
178 | + //never discover an edgeport that should have been discovered. | ||
177 | loadAllEdgePorts(); | 179 | loadAllEdgePorts(); |
178 | } | 180 | } |
179 | } | 181 | } |
... | @@ -198,6 +200,7 @@ public class EdgeManager implements EdgePortService { | ... | @@ -198,6 +200,7 @@ public class EdgeManager implements EdgePortService { |
198 | 200 | ||
199 | // Processes a device event by adding or removing its end-points in our cache. | 201 | // Processes a device event by adding or removing its end-points in our cache. |
200 | private void processDeviceEvent(DeviceEvent event) { | 202 | private void processDeviceEvent(DeviceEvent event) { |
203 | + //FIXME handle the case where a device is suspended, this may or may not come up | ||
201 | DeviceEvent.Type type = event.type(); | 204 | DeviceEvent.Type type = event.type(); |
202 | DeviceId id = event.subject().id(); | 205 | DeviceId id = event.subject().id(); |
203 | 206 | ... | ... |
... | @@ -15,9 +15,6 @@ | ... | @@ -15,9 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.proxyarp.impl; | 16 | package org.onosproject.net.proxyarp.impl; |
17 | 17 | ||
18 | -import com.google.common.collect.HashMultimap; | ||
19 | -import com.google.common.collect.Lists; | ||
20 | -import com.google.common.collect.Multimap; | ||
21 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
22 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
23 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -38,22 +35,15 @@ import org.onlab.packet.ndp.NeighborDiscoveryOptions; | ... | @@ -38,22 +35,15 @@ import org.onlab.packet.ndp.NeighborDiscoveryOptions; |
38 | import org.onlab.packet.ndp.NeighborSolicitation; | 35 | import org.onlab.packet.ndp.NeighborSolicitation; |
39 | import org.onosproject.core.Permission; | 36 | import org.onosproject.core.Permission; |
40 | import org.onosproject.net.ConnectPoint; | 37 | import org.onosproject.net.ConnectPoint; |
41 | -import org.onosproject.net.Device; | ||
42 | import org.onosproject.net.Host; | 38 | import org.onosproject.net.Host; |
43 | import org.onosproject.net.HostId; | 39 | import org.onosproject.net.HostId; |
44 | -import org.onosproject.net.Link; | ||
45 | -import org.onosproject.net.Port; | ||
46 | -import org.onosproject.net.PortNumber; | ||
47 | -import org.onosproject.net.device.DeviceEvent; | ||
48 | -import org.onosproject.net.device.DeviceListener; | ||
49 | import org.onosproject.net.device.DeviceService; | 40 | import org.onosproject.net.device.DeviceService; |
41 | +import org.onosproject.net.edge.EdgePortService; | ||
50 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 42 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
51 | import org.onosproject.net.flow.TrafficTreatment; | 43 | import org.onosproject.net.flow.TrafficTreatment; |
52 | import org.onosproject.net.host.HostService; | 44 | import org.onosproject.net.host.HostService; |
53 | import org.onosproject.net.host.InterfaceIpAddress; | 45 | import org.onosproject.net.host.InterfaceIpAddress; |
54 | import org.onosproject.net.host.PortAddresses; | 46 | import org.onosproject.net.host.PortAddresses; |
55 | -import org.onosproject.net.link.LinkEvent; | ||
56 | -import org.onosproject.net.link.LinkListener; | ||
57 | import org.onosproject.net.link.LinkService; | 47 | import org.onosproject.net.link.LinkService; |
58 | import org.onosproject.net.packet.DefaultOutboundPacket; | 48 | import org.onosproject.net.packet.DefaultOutboundPacket; |
59 | import org.onosproject.net.packet.InboundPacket; | 49 | import org.onosproject.net.packet.InboundPacket; |
... | @@ -64,14 +54,13 @@ import org.slf4j.Logger; | ... | @@ -64,14 +54,13 @@ import org.slf4j.Logger; |
64 | 54 | ||
65 | import java.nio.ByteBuffer; | 55 | import java.nio.ByteBuffer; |
66 | import java.util.HashSet; | 56 | import java.util.HashSet; |
67 | -import java.util.List; | ||
68 | -import java.util.Map.Entry; | ||
69 | import java.util.Set; | 57 | import java.util.Set; |
58 | +import java.util.stream.Collectors; | ||
70 | 59 | ||
71 | import static com.google.common.base.Preconditions.checkArgument; | 60 | import static com.google.common.base.Preconditions.checkArgument; |
72 | import static com.google.common.base.Preconditions.checkNotNull; | 61 | import static com.google.common.base.Preconditions.checkNotNull; |
73 | -import static org.slf4j.LoggerFactory.getLogger; | ||
74 | import static org.onosproject.security.AppGuard.checkPermission; | 62 | import static org.onosproject.security.AppGuard.checkPermission; |
63 | +import static org.slf4j.LoggerFactory.getLogger; | ||
75 | 64 | ||
76 | 65 | ||
77 | @Component(immediate = true) | 66 | @Component(immediate = true) |
... | @@ -87,6 +76,9 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -87,6 +76,9 @@ public class ProxyArpManager implements ProxyArpService { |
87 | private static final String NOT_ARP_REPLY = "ARP is not a reply."; | 76 | private static final String NOT_ARP_REPLY = "ARP is not a reply."; |
88 | 77 | ||
89 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 78 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
79 | + protected EdgePortService edgeService; | ||
80 | + | ||
81 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
90 | protected HostService hostService; | 82 | protected HostService hostService; |
91 | 83 | ||
92 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 84 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
... | @@ -98,29 +90,18 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -98,29 +90,18 @@ public class ProxyArpManager implements ProxyArpService { |
98 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 90 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
99 | protected DeviceService deviceService; | 91 | protected DeviceService deviceService; |
100 | 92 | ||
101 | - private final Multimap<Device, PortNumber> internalPorts = HashMultimap.create(); | ||
102 | - private final Multimap<Device, PortNumber> externalPorts = HashMultimap.create(); | ||
103 | - | ||
104 | - private final DeviceListener deviceListener = new InternalDeviceListener(); | ||
105 | - private final InternalLinkListener linkListener = new InternalLinkListener(); | ||
106 | - | ||
107 | /** | 93 | /** |
108 | * Listens to both device service and link service to determine | 94 | * Listens to both device service and link service to determine |
109 | * whether a port is internal or external. | 95 | * whether a port is internal or external. |
110 | */ | 96 | */ |
111 | @Activate | 97 | @Activate |
112 | public void activate() { | 98 | public void activate() { |
113 | - deviceService.addListener(deviceListener); | ||
114 | - linkService.addListener(linkListener); | ||
115 | - determinePortLocations(); | ||
116 | log.info("Started"); | 99 | log.info("Started"); |
117 | } | 100 | } |
118 | 101 | ||
119 | 102 | ||
120 | @Deactivate | 103 | @Deactivate |
121 | public void deactivate() { | 104 | public void deactivate() { |
122 | - deviceService.removeListener(deviceListener); | ||
123 | - linkService.removeListener(linkListener); | ||
124 | log.info("Stopped"); | 105 | log.info("Stopped"); |
125 | } | 106 | } |
126 | 107 | ||
... | @@ -303,6 +284,7 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -303,6 +284,7 @@ public class ProxyArpManager implements ProxyArpService { |
303 | Ethernet ndpReply = buildNdpReply(targetAddress, dst.mac(), eth); | 284 | Ethernet ndpReply = buildNdpReply(targetAddress, dst.mac(), eth); |
304 | sendTo(ndpReply, inPort); | 285 | sendTo(ndpReply, inPort); |
305 | } | 286 | } |
287 | + //TODO checkpoint | ||
306 | 288 | ||
307 | /** | 289 | /** |
308 | * Outputs the given packet out the given port. | 290 | * Outputs the given packet out the given port. |
... | @@ -311,8 +293,7 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -311,8 +293,7 @@ public class ProxyArpManager implements ProxyArpService { |
311 | * @param outPort the port to send it out | 293 | * @param outPort the port to send it out |
312 | */ | 294 | */ |
313 | private void sendTo(Ethernet packet, ConnectPoint outPort) { | 295 | private void sendTo(Ethernet packet, ConnectPoint outPort) { |
314 | - if (internalPorts.containsEntry( | 296 | + if (!edgeService.isEdgePoint(outPort)) { |
315 | - deviceService.getDevice(outPort.deviceId()), outPort.port())) { | ||
316 | // Sanity check to make sure we don't send the packet out an | 297 | // Sanity check to make sure we don't send the packet out an |
317 | // internal port and create a loop (could happen due to | 298 | // internal port and create a loop (could happen due to |
318 | // misconfiguration). | 299 | // misconfiguration). |
... | @@ -332,13 +313,10 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -332,13 +313,10 @@ public class ProxyArpManager implements ProxyArpService { |
332 | * @return a set of PortAddresses describing ports in the subnet | 313 | * @return a set of PortAddresses describing ports in the subnet |
333 | */ | 314 | */ |
334 | private Set<PortAddresses> findPortsInSubnet(IpAddress target) { | 315 | private Set<PortAddresses> findPortsInSubnet(IpAddress target) { |
335 | - Set<PortAddresses> result = new HashSet<PortAddresses>(); | 316 | + Set<PortAddresses> result = new HashSet<>(); |
336 | for (PortAddresses addresses : hostService.getAddressBindings()) { | 317 | for (PortAddresses addresses : hostService.getAddressBindings()) { |
337 | - for (InterfaceIpAddress ia : addresses.ipAddresses()) { | 318 | + result.addAll(addresses.ipAddresses().stream().filter(ia -> ia.subnetAddress().contains(target)). |
338 | - if (ia.subnetAddress().contains(target)) { | 319 | + map(ia -> addresses).collect(Collectors.toList())); |
339 | - result.add(addresses); | ||
340 | - } | ||
341 | - } | ||
342 | } | 320 | } |
343 | return result; | 321 | return result; |
344 | } | 322 | } |
... | @@ -438,58 +416,17 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -438,58 +416,17 @@ public class ProxyArpManager implements ProxyArpService { |
438 | TrafficTreatment.Builder builder = null; | 416 | TrafficTreatment.Builder builder = null; |
439 | ByteBuffer buf = ByteBuffer.wrap(request.serialize()); | 417 | ByteBuffer buf = ByteBuffer.wrap(request.serialize()); |
440 | 418 | ||
441 | - synchronized (externalPorts) { | 419 | + for (ConnectPoint connectPoint : edgeService.getEdgePoints()) { |
442 | - for (Entry<Device, PortNumber> entry : externalPorts.entries()) { | 420 | + if (isOutsidePort(connectPoint) || connectPoint.equals(inPort)) { |
443 | - ConnectPoint cp = new ConnectPoint(entry.getKey().id(), entry.getValue()); | ||
444 | - if (isOutsidePort(cp) || cp.equals(inPort)) { | ||
445 | continue; | 421 | continue; |
446 | } | 422 | } |
447 | 423 | ||
448 | builder = DefaultTrafficTreatment.builder(); | 424 | builder = DefaultTrafficTreatment.builder(); |
449 | - builder.setOutput(entry.getValue()); | 425 | + builder.setOutput(connectPoint.port()); |
450 | - packetService.emit(new DefaultOutboundPacket(entry.getKey().id(), | 426 | + packetService.emit(new DefaultOutboundPacket(connectPoint.deviceId(), |
451 | builder.build(), buf)); | 427 | builder.build(), buf)); |
452 | } | 428 | } |
453 | - } | ||
454 | - } | ||
455 | 429 | ||
456 | - /** | ||
457 | - * Determines the location of all known ports in the system. | ||
458 | - */ | ||
459 | - private void determinePortLocations() { | ||
460 | - Iterable<Device> devices = deviceService.getDevices(); | ||
461 | - Iterable<Link> links = null; | ||
462 | - List<PortNumber> ports = null; | ||
463 | - for (Device d : devices) { | ||
464 | - ports = buildPortNumberList(deviceService.getPorts(d.id())); | ||
465 | - links = linkService.getLinks(); | ||
466 | - for (Link l : links) { | ||
467 | - // for each link, mark the concerned ports as internal | ||
468 | - // and the remaining ports are therefore external. | ||
469 | - if (l.src().deviceId().equals(d.id()) | ||
470 | - && ports.contains(l.src().port())) { | ||
471 | - ports.remove(l.src().port()); | ||
472 | - internalPorts.put(d, l.src().port()); | ||
473 | - } | ||
474 | - if (l.dst().deviceId().equals(d.id()) | ||
475 | - && ports.contains(l.dst().port())) { | ||
476 | - ports.remove(l.dst().port()); | ||
477 | - internalPorts.put(d, l.dst().port()); | ||
478 | - } | ||
479 | - } | ||
480 | - synchronized (externalPorts) { | ||
481 | - externalPorts.putAll(d, ports); | ||
482 | - } | ||
483 | - } | ||
484 | - | ||
485 | - } | ||
486 | - | ||
487 | - private List<PortNumber> buildPortNumberList(List<Port> ports) { | ||
488 | - List<PortNumber> portNumbers = Lists.newLinkedList(); | ||
489 | - for (Port p : ports) { | ||
490 | - portNumbers.add(p.number()); | ||
491 | - } | ||
492 | - return portNumbers; | ||
493 | } | 430 | } |
494 | 431 | ||
495 | /** | 432 | /** |
... | @@ -531,84 +468,4 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -531,84 +468,4 @@ public class ProxyArpManager implements ProxyArpService { |
531 | eth.setPayload(ipv6); | 468 | eth.setPayload(ipv6); |
532 | return eth; | 469 | return eth; |
533 | } | 470 | } |
534 | - | ||
535 | - public class InternalLinkListener implements LinkListener { | ||
536 | - | ||
537 | - @Override | ||
538 | - public void event(LinkEvent event) { | ||
539 | - Link link = event.subject(); | ||
540 | - Device src = deviceService.getDevice(link.src().deviceId()); | ||
541 | - Device dst = deviceService.getDevice(link.dst().deviceId()); | ||
542 | - switch (event.type()) { | ||
543 | - case LINK_ADDED: | ||
544 | - synchronized (externalPorts) { | ||
545 | - externalPorts.remove(src, link.src().port()); | ||
546 | - externalPorts.remove(dst, link.dst().port()); | ||
547 | - internalPorts.put(src, link.src().port()); | ||
548 | - internalPorts.put(dst, link.dst().port()); | ||
549 | - } | ||
550 | - | ||
551 | - break; | ||
552 | - case LINK_REMOVED: | ||
553 | - synchronized (externalPorts) { | ||
554 | - externalPorts.put(src, link.src().port()); | ||
555 | - externalPorts.put(dst, link.dst().port()); | ||
556 | - internalPorts.remove(src, link.src().port()); | ||
557 | - internalPorts.remove(dst, link.dst().port()); | ||
558 | - } | ||
559 | - | ||
560 | - break; | ||
561 | - case LINK_UPDATED: | ||
562 | - // don't care about links being updated. | ||
563 | - break; | ||
564 | - default: | ||
565 | - break; | ||
566 | - } | ||
567 | - | ||
568 | - } | ||
569 | - | ||
570 | - } | ||
571 | - | ||
572 | - public class InternalDeviceListener implements DeviceListener { | ||
573 | - | ||
574 | - @Override | ||
575 | - public void event(DeviceEvent event) { | ||
576 | - Device device = event.subject(); | ||
577 | - switch (event.type()) { | ||
578 | - case DEVICE_ADDED: | ||
579 | - case DEVICE_AVAILABILITY_CHANGED: | ||
580 | - case DEVICE_SUSPENDED: | ||
581 | - case DEVICE_UPDATED: | ||
582 | - // nothing to do in these cases; handled when links get reported | ||
583 | - break; | ||
584 | - case DEVICE_REMOVED: | ||
585 | - synchronized (externalPorts) { | ||
586 | - externalPorts.removeAll(device); | ||
587 | - internalPorts.removeAll(device); | ||
588 | - } | ||
589 | - break; | ||
590 | - case PORT_ADDED: | ||
591 | - case PORT_UPDATED: | ||
592 | - synchronized (externalPorts) { | ||
593 | - if (event.port().isEnabled()) { | ||
594 | - externalPorts.put(device, event.port().number()); | ||
595 | - internalPorts.remove(device, event.port().number()); | ||
596 | - } | ||
597 | - } | ||
598 | - break; | ||
599 | - case PORT_REMOVED: | ||
600 | - synchronized (externalPorts) { | ||
601 | - externalPorts.remove(device, event.port().number()); | ||
602 | - internalPorts.remove(device, event.port().number()); | ||
603 | - } | ||
604 | - break; | ||
605 | - default: | ||
606 | - break; | ||
607 | - | ||
608 | - } | ||
609 | - | ||
610 | - } | ||
611 | - | ||
612 | - } | ||
613 | - | ||
614 | } | 471 | } | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.proxyarp.impl; | 16 | package org.onosproject.net.proxyarp.impl; |
17 | 17 | ||
18 | +import com.google.common.collect.Lists; | ||
18 | import com.google.common.collect.Sets; | 19 | import com.google.common.collect.Sets; |
19 | import org.junit.Before; | 20 | import org.junit.Before; |
20 | import org.junit.Test; | 21 | import org.junit.Test; |
... | @@ -36,6 +37,7 @@ import org.onosproject.net.Port; | ... | @@ -36,6 +37,7 @@ import org.onosproject.net.Port; |
36 | import org.onosproject.net.PortNumber; | 37 | import org.onosproject.net.PortNumber; |
37 | import org.onosproject.net.device.DeviceListener; | 38 | import org.onosproject.net.device.DeviceListener; |
38 | import org.onosproject.net.device.DeviceService; | 39 | import org.onosproject.net.device.DeviceService; |
40 | +import org.onosproject.net.edgeservice.impl.EdgeManager; | ||
39 | import org.onosproject.net.flow.instructions.Instruction; | 41 | import org.onosproject.net.flow.instructions.Instruction; |
40 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; | 42 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; |
41 | import org.onosproject.net.host.HostService; | 43 | import org.onosproject.net.host.HostService; |
... | @@ -53,8 +55,14 @@ import java.util.Comparator; | ... | @@ -53,8 +55,14 @@ import java.util.Comparator; |
53 | import java.util.List; | 55 | import java.util.List; |
54 | import java.util.Set; | 56 | import java.util.Set; |
55 | 57 | ||
56 | -import static org.easymock.EasyMock.*; | 58 | +import static org.easymock.EasyMock.anyObject; |
57 | -import static org.junit.Assert.*; | 59 | +import static org.easymock.EasyMock.createMock; |
60 | +import static org.easymock.EasyMock.expect; | ||
61 | +import static org.easymock.EasyMock.replay; | ||
62 | +import static org.junit.Assert.assertArrayEquals; | ||
63 | +import static org.junit.Assert.assertEquals; | ||
64 | +import static org.junit.Assert.assertFalse; | ||
65 | +import static org.junit.Assert.assertTrue; | ||
58 | 66 | ||
59 | /** | 67 | /** |
60 | * Tests for the {@link ProxyArpManager} class. | 68 | * Tests for the {@link ProxyArpManager} class. |
... | @@ -85,6 +93,11 @@ public class ProxyArpManagerTest { | ... | @@ -85,6 +93,11 @@ public class ProxyArpManagerTest { |
85 | private static final HostLocation LOC2 = new HostLocation(DID2, P1, 123L); | 93 | private static final HostLocation LOC2 = new HostLocation(DID2, P1, 123L); |
86 | private static final byte[] ZERO_MAC_ADDRESS = MacAddress.ZERO.toBytes(); | 94 | private static final byte[] ZERO_MAC_ADDRESS = MacAddress.ZERO.toBytes(); |
87 | 95 | ||
96 | + //Return values used for various functions of the TestPacketService inner class. | ||
97 | + private boolean isEdgePointReturn; | ||
98 | + private List<ConnectPoint> getEdgePointsNoArg; | ||
99 | + | ||
100 | + | ||
88 | private ProxyArpManager proxyArp; | 101 | private ProxyArpManager proxyArp; |
89 | 102 | ||
90 | private TestPacketService packetService; | 103 | private TestPacketService packetService; |
... | @@ -98,6 +111,8 @@ public class ProxyArpManagerTest { | ... | @@ -98,6 +111,8 @@ public class ProxyArpManagerTest { |
98 | packetService = new TestPacketService(); | 111 | packetService = new TestPacketService(); |
99 | proxyArp.packetService = packetService; | 112 | proxyArp.packetService = packetService; |
100 | 113 | ||
114 | + proxyArp.edgeService = new TestEdgePortService(); | ||
115 | + | ||
101 | // Create a host service mock here. Must be replayed by tests once the | 116 | // Create a host service mock here. Must be replayed by tests once the |
102 | // expectations have been set up | 117 | // expectations have been set up |
103 | hostService = createMock(HostService.class); | 118 | hostService = createMock(HostService.class); |
... | @@ -112,7 +127,7 @@ public class ProxyArpManagerTest { | ... | @@ -112,7 +127,7 @@ public class ProxyArpManagerTest { |
112 | 127 | ||
113 | /** | 128 | /** |
114 | * Creates a fake topology to feed into the ARP module. | 129 | * Creates a fake topology to feed into the ARP module. |
115 | - * <p/> | 130 | + * <p> |
116 | * The default topology is a unidirectional ring topology. Each switch has | 131 | * The default topology is a unidirectional ring topology. Each switch has |
117 | * 3 ports. Ports 2 and 3 have the links to neighbor switches, and port 1 | 132 | * 3 ports. Ports 2 and 3 have the links to neighbor switches, and port 1 |
118 | * is free (edge port). | 133 | * is free (edge port). |
... | @@ -266,6 +281,9 @@ public class ProxyArpManagerTest { | ... | @@ -266,6 +281,9 @@ public class ProxyArpManagerTest { |
266 | */ | 281 | */ |
267 | @Test | 282 | @Test |
268 | public void testReplyKnown() { | 283 | public void testReplyKnown() { |
284 | + //Set the return value of isEdgePoint from the edgemanager. | ||
285 | + isEdgePointReturn = true; | ||
286 | + | ||
269 | Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(4), | 287 | Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(4), |
270 | Collections.singleton(IP1)); | 288 | Collections.singleton(IP1)); |
271 | 289 | ||
... | @@ -294,6 +312,8 @@ public class ProxyArpManagerTest { | ... | @@ -294,6 +312,8 @@ public class ProxyArpManagerTest { |
294 | */ | 312 | */ |
295 | @Test | 313 | @Test |
296 | public void testReplyUnknown() { | 314 | public void testReplyUnknown() { |
315 | + isEdgePointReturn = true; | ||
316 | + | ||
297 | Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5), | 317 | Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5), |
298 | Collections.singleton(IP2)); | 318 | Collections.singleton(IP2)); |
299 | 319 | ||
... | @@ -301,10 +321,16 @@ public class ProxyArpManagerTest { | ... | @@ -301,10 +321,16 @@ public class ProxyArpManagerTest { |
301 | .andReturn(Collections.<Host>emptySet()); | 321 | .andReturn(Collections.<Host>emptySet()); |
302 | expect(hostService.getHost(HID2)).andReturn(requestor); | 322 | expect(hostService.getHost(HID2)).andReturn(requestor); |
303 | 323 | ||
324 | + | ||
304 | replay(hostService); | 325 | replay(hostService); |
305 | 326 | ||
306 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1); | 327 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1); |
307 | 328 | ||
329 | + //Setup the set of edge ports to be used in the reply method | ||
330 | + getEdgePointsNoArg = Lists.newLinkedList(); | ||
331 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("5"), PortNumber.portNumber(1))); | ||
332 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("4"), PortNumber.portNumber(1))); | ||
333 | + | ||
308 | proxyArp.reply(arpRequest, getLocation(6)); | 334 | proxyArp.reply(arpRequest, getLocation(6)); |
309 | 335 | ||
310 | verifyFlood(arpRequest); | 336 | verifyFlood(arpRequest); |
... | @@ -318,6 +344,7 @@ public class ProxyArpManagerTest { | ... | @@ -318,6 +344,7 @@ public class ProxyArpManagerTest { |
318 | */ | 344 | */ |
319 | @Test | 345 | @Test |
320 | public void testReplyDifferentVlan() { | 346 | public void testReplyDifferentVlan() { |
347 | + | ||
321 | Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN2, getLocation(4), | 348 | Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN2, getLocation(4), |
322 | Collections.singleton(IP1)); | 349 | Collections.singleton(IP1)); |
323 | 350 | ||
... | @@ -332,6 +359,10 @@ public class ProxyArpManagerTest { | ... | @@ -332,6 +359,10 @@ public class ProxyArpManagerTest { |
332 | 359 | ||
333 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1); | 360 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1); |
334 | 361 | ||
362 | + //Setup for flood test | ||
363 | + getEdgePointsNoArg = Lists.newLinkedList(); | ||
364 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("5"), PortNumber.portNumber(1))); | ||
365 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("4"), PortNumber.portNumber(1))); | ||
335 | proxyArp.reply(arpRequest, getLocation(6)); | 366 | proxyArp.reply(arpRequest, getLocation(6)); |
336 | 367 | ||
337 | verifyFlood(arpRequest); | 368 | verifyFlood(arpRequest); |
... | @@ -352,7 +383,7 @@ public class ProxyArpManagerTest { | ... | @@ -352,7 +383,7 @@ public class ProxyArpManagerTest { |
352 | replay(hostService); | 383 | replay(hostService); |
353 | 384 | ||
354 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, theirIp, ourFirstIp); | 385 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, theirIp, ourFirstIp); |
355 | - | 386 | + isEdgePointReturn = true; |
356 | proxyArp.reply(arpRequest, LOC1); | 387 | proxyArp.reply(arpRequest, LOC1); |
357 | 388 | ||
358 | assertEquals(1, packetService.packets.size()); | 389 | assertEquals(1, packetService.packets.size()); |
... | @@ -402,8 +433,10 @@ public class ProxyArpManagerTest { | ... | @@ -402,8 +433,10 @@ public class ProxyArpManagerTest { |
402 | // This is a request from something inside our network (like a BGP | 433 | // This is a request from something inside our network (like a BGP |
403 | // daemon) to an external host. | 434 | // daemon) to an external host. |
404 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, ourMac, null, ourIp, theirIp); | 435 | Ethernet arpRequest = buildArp(ARP.OP_REQUEST, ourMac, null, ourIp, theirIp); |
405 | - proxyArp.reply(arpRequest, getLocation(5)); | 436 | + //Ensure the packet is allowed through (it is not to an internal port) |
437 | + isEdgePointReturn = true; | ||
406 | 438 | ||
439 | + proxyArp.reply(arpRequest, getLocation(5)); | ||
407 | assertEquals(1, packetService.packets.size()); | 440 | assertEquals(1, packetService.packets.size()); |
408 | verifyPacketOut(arpRequest, getLocation(1), packetService.packets.get(0)); | 441 | verifyPacketOut(arpRequest, getLocation(1), packetService.packets.get(0)); |
409 | 442 | ||
... | @@ -448,6 +481,13 @@ public class ProxyArpManagerTest { | ... | @@ -448,6 +481,13 @@ public class ProxyArpManagerTest { |
448 | 481 | ||
449 | Ethernet arpRequest = buildArp(ARP.OP_REPLY, MAC2, MAC1, IP2, IP1); | 482 | Ethernet arpRequest = buildArp(ARP.OP_REPLY, MAC2, MAC1, IP2, IP1); |
450 | 483 | ||
484 | + //populate the list of edges when so that when forward hits flood in the manager it contains the values | ||
485 | + //that should continue on | ||
486 | + getEdgePointsNoArg = Lists.newLinkedList(); | ||
487 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("3"), PortNumber.portNumber(1))); | ||
488 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("5"), PortNumber.portNumber(1))); | ||
489 | + getEdgePointsNoArg.add(new ConnectPoint(DeviceId.deviceId("4"), PortNumber.portNumber(1))); | ||
490 | + | ||
451 | proxyArp.forward(arpRequest, getLocation(6)); | 491 | proxyArp.forward(arpRequest, getLocation(6)); |
452 | 492 | ||
453 | verifyFlood(arpRequest); | 493 | verifyFlood(arpRequest); |
... | @@ -572,4 +612,17 @@ public class ProxyArpManagerTest { | ... | @@ -572,4 +612,17 @@ public class ProxyArpManagerTest { |
572 | } | 612 | } |
573 | 613 | ||
574 | } | 614 | } |
615 | + | ||
616 | + class TestEdgePortService extends EdgeManager { | ||
617 | + | ||
618 | + @Override | ||
619 | + public boolean isEdgePoint(ConnectPoint connectPoint) { | ||
620 | + return isEdgePointReturn; | ||
621 | + } | ||
622 | + | ||
623 | + @Override | ||
624 | + public Iterable<ConnectPoint> getEdgePoints() { | ||
625 | + return getEdgePointsNoArg; | ||
626 | + } | ||
627 | + } | ||
575 | } | 628 | } | ... | ... |
-
Please register or login to post a comment