Committed by
Gerrit Code Review
Include logic for cancelling requests for packets.
Change-Id: I8244b8e417dd2b4c6feae57b810fe750635e87a7
Showing
7 changed files
with
142 additions
and
49 deletions
... | @@ -54,7 +54,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket; | ... | @@ -54,7 +54,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket; |
54 | import org.onosproject.net.packet.InboundPacket; | 54 | import org.onosproject.net.packet.InboundPacket; |
55 | import org.onosproject.net.packet.OutboundPacket; | 55 | import org.onosproject.net.packet.OutboundPacket; |
56 | import org.onosproject.net.packet.PacketContext; | 56 | import org.onosproject.net.packet.PacketContext; |
57 | -import org.onosproject.net.packet.PacketPriority; | ||
58 | import org.onosproject.net.packet.PacketProcessor; | 57 | import org.onosproject.net.packet.PacketProcessor; |
59 | import org.onosproject.net.packet.PacketService; | 58 | import org.onosproject.net.packet.PacketService; |
60 | import org.onosproject.xosintegration.VoltTenantService; | 59 | import org.onosproject.xosintegration.VoltTenantService; |
... | @@ -71,6 +70,7 @@ import java.util.Map; | ... | @@ -71,6 +70,7 @@ import java.util.Map; |
71 | import java.util.Optional; | 70 | import java.util.Optional; |
72 | import java.util.Set; | 71 | import java.util.Set; |
73 | 72 | ||
73 | +import static org.onosproject.net.packet.PacketPriority.CONTROL; | ||
74 | import static org.slf4j.LoggerFactory.getLogger; | 74 | import static org.slf4j.LoggerFactory.getLogger; |
75 | 75 | ||
76 | 76 | ||
... | @@ -130,7 +130,7 @@ public class AAA { | ... | @@ -130,7 +130,7 @@ public class AAA { |
130 | private String radiusIpAddress = DEFAULT_RADIUS_IP; | 130 | private String radiusIpAddress = DEFAULT_RADIUS_IP; |
131 | 131 | ||
132 | @Property(name = "nasIpAddress", value = DEFAULT_NAS_IP, | 132 | @Property(name = "nasIpAddress", value = DEFAULT_NAS_IP, |
133 | - label = "NAP IP Address") | 133 | + label = "NAS IP Address") |
134 | private String nasIpAddress = DEFAULT_NAS_IP; | 134 | private String nasIpAddress = DEFAULT_NAS_IP; |
135 | 135 | ||
136 | @Property(name = "radiusMacAddress", value = RADIUS_MAC_ADDRESS, | 136 | @Property(name = "radiusMacAddress", value = RADIUS_MAC_ADDRESS, |
... | @@ -138,7 +138,7 @@ public class AAA { | ... | @@ -138,7 +138,7 @@ public class AAA { |
138 | private String radiusMacAddress = RADIUS_MAC_ADDRESS; | 138 | private String radiusMacAddress = RADIUS_MAC_ADDRESS; |
139 | 139 | ||
140 | @Property(name = "nasMacAddress", value = NAS_MAC_ADDRESS, | 140 | @Property(name = "nasMacAddress", value = NAS_MAC_ADDRESS, |
141 | - label = "NAP MAC Address") | 141 | + label = "NAS MAC Address") |
142 | private String nasMacAddress = NAS_MAC_ADDRESS; | 142 | private String nasMacAddress = NAS_MAC_ADDRESS; |
143 | 143 | ||
144 | @Property(name = "radiusSecret", value = DEFAULT_RADIUS_SECRET, | 144 | @Property(name = "radiusSecret", value = DEFAULT_RADIUS_SECRET, |
... | @@ -205,12 +205,7 @@ public class AAA { | ... | @@ -205,12 +205,7 @@ public class AAA { |
205 | appId = coreService.registerApplication("org.onosproject.aaa"); | 205 | appId = coreService.registerApplication("org.onosproject.aaa"); |
206 | // register our event handler | 206 | // register our event handler |
207 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); | 207 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); |
208 | - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 208 | + requestIntercepts(); |
209 | - | ||
210 | - selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); | ||
211 | - packetService.requestPackets(selector.build(), | ||
212 | - PacketPriority.CONTROL, appId); | ||
213 | - | ||
214 | // Instantiate the map of the state machines | 209 | // Instantiate the map of the state machines |
215 | stateMachineMap = Collections.synchronizedMap(Maps.newHashMap()); | 210 | stateMachineMap = Collections.synchronizedMap(Maps.newHashMap()); |
216 | 211 | ||
... | @@ -221,16 +216,39 @@ public class AAA { | ... | @@ -221,16 +216,39 @@ public class AAA { |
221 | @Deactivate | 216 | @Deactivate |
222 | public void deactivate() { | 217 | public void deactivate() { |
223 | cfgService.unregisterProperties(getClass(), false); | 218 | cfgService.unregisterProperties(getClass(), false); |
219 | + | ||
220 | + appId = coreService.registerApplication("org.onosproject.aaa"); | ||
221 | + withdrawIntercepts(); | ||
224 | // de-register and null our handler | 222 | // de-register and null our handler |
225 | packetService.removeProcessor(processor); | 223 | packetService.removeProcessor(processor); |
226 | processor = null; | 224 | processor = null; |
227 | } | 225 | } |
228 | 226 | ||
229 | /** | 227 | /** |
228 | + * Request packet in via PacketService. | ||
229 | + */ | ||
230 | + private void requestIntercepts() { | ||
231 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
232 | + selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); | ||
233 | + packetService.requestPackets(selector.build(), | ||
234 | + CONTROL, appId); | ||
235 | + } | ||
236 | + | ||
237 | + /** | ||
238 | + * Cancel request for packet in via PacketService. | ||
239 | + */ | ||
240 | + private void withdrawIntercepts() { | ||
241 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
242 | + selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); | ||
243 | + packetService.cancelPackets(selector.build(), CONTROL, appId); | ||
244 | + } | ||
245 | + | ||
246 | + /** | ||
230 | * Builds an EAPOL packet based on the given parameters. | 247 | * Builds an EAPOL packet based on the given parameters. |
231 | * | 248 | * |
232 | * @param dstMac destination MAC address | 249 | * @param dstMac destination MAC address |
233 | * @param srcMac source MAC address | 250 | * @param srcMac source MAC address |
251 | + * @param vlan vlan identifier | ||
234 | * @param eapolType EAPOL type | 252 | * @param eapolType EAPOL type |
235 | * @param eap EAP payload | 253 | * @param eap EAP payload |
236 | * @return Ethernet frame | 254 | * @return Ethernet frame |
... | @@ -447,7 +465,8 @@ public class AAA { | ... | @@ -447,7 +465,8 @@ public class AAA { |
447 | eapPayload = radiusPacket.decapsulateMessage(); | 465 | eapPayload = radiusPacket.decapsulateMessage(); |
448 | stateMachine.setChallengeInfo(eapPayload.getIdentifier(), challengeState); | 466 | stateMachine.setChallengeInfo(eapPayload.getIdentifier(), challengeState); |
449 | eth = buildEapolResponse(stateMachine.supplicantAddress, | 467 | eth = buildEapolResponse(stateMachine.supplicantAddress, |
450 | - MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET, eapPayload); | 468 | + MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET, |
469 | + eapPayload); | ||
451 | this.sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint); | 470 | this.sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint); |
452 | break; | 471 | break; |
453 | case RADIUS.RADIUS_CODE_ACCESS_ACCEPT: | 472 | case RADIUS.RADIUS_CODE_ACCESS_ACCEPT: |
... | @@ -458,7 +477,8 @@ public class AAA { | ... | @@ -458,7 +477,8 @@ public class AAA { |
458 | eapPayload = new EAP(); | 477 | eapPayload = new EAP(); |
459 | eapPayload = (EAP) eapPayload.deserialize(eapMessage, 0, eapMessage.length); | 478 | eapPayload = (EAP) eapPayload.deserialize(eapMessage, 0, eapMessage.length); |
460 | eth = buildEapolResponse(stateMachine.supplicantAddress, | 479 | eth = buildEapolResponse(stateMachine.supplicantAddress, |
461 | - MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET, eapPayload); | 480 | + MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET, |
481 | + eapPayload); | ||
462 | this.sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint); | 482 | this.sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint); |
463 | 483 | ||
464 | stateMachine.authorizeAccess(); | 484 | stateMachine.authorizeAccess(); | ... | ... |
... | @@ -203,7 +203,7 @@ public class ReactiveForwarding { | ... | @@ -203,7 +203,7 @@ public class ReactiveForwarding { |
203 | } | 203 | } |
204 | 204 | ||
205 | /** | 205 | /** |
206 | - * Request packet in via PacketService. | 206 | + * Cancel request for packet in via PacketService. |
207 | */ | 207 | */ |
208 | private void withdrawIntercepts() { | 208 | private void withdrawIntercepts() { |
209 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 209 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ... | ... |
... | @@ -23,8 +23,6 @@ import org.apache.felix.scr.annotations.Property; | ... | @@ -23,8 +23,6 @@ import org.apache.felix.scr.annotations.Property; |
23 | import org.apache.felix.scr.annotations.Reference; | 23 | import org.apache.felix.scr.annotations.Reference; |
24 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
25 | import org.onlab.packet.Ethernet; | 25 | import org.onlab.packet.Ethernet; |
26 | -import org.onlab.packet.ICMP6; | ||
27 | -import org.onlab.packet.IPv6; | ||
28 | import org.onosproject.cfg.ComponentConfigService; | 26 | import org.onosproject.cfg.ComponentConfigService; |
29 | import org.onosproject.core.ApplicationId; | 27 | import org.onosproject.core.ApplicationId; |
30 | import org.onosproject.core.CoreService; | 28 | import org.onosproject.core.CoreService; |
... | @@ -32,7 +30,6 @@ import org.onosproject.net.flow.DefaultTrafficSelector; | ... | @@ -32,7 +30,6 @@ import org.onosproject.net.flow.DefaultTrafficSelector; |
32 | import org.onosproject.net.flow.TrafficSelector; | 30 | import org.onosproject.net.flow.TrafficSelector; |
33 | import org.onosproject.net.packet.InboundPacket; | 31 | import org.onosproject.net.packet.InboundPacket; |
34 | import org.onosproject.net.packet.PacketContext; | 32 | import org.onosproject.net.packet.PacketContext; |
35 | -import org.onosproject.net.packet.PacketPriority; | ||
36 | import org.onosproject.net.packet.PacketProcessor; | 33 | import org.onosproject.net.packet.PacketProcessor; |
37 | import org.onosproject.net.packet.PacketService; | 34 | import org.onosproject.net.packet.PacketService; |
38 | import org.onosproject.net.proxyarp.ProxyArpService; | 35 | import org.onosproject.net.proxyarp.ProxyArpService; |
... | @@ -42,6 +39,12 @@ import org.slf4j.Logger; | ... | @@ -42,6 +39,12 @@ import org.slf4j.Logger; |
42 | import java.util.Dictionary; | 39 | import java.util.Dictionary; |
43 | 40 | ||
44 | import static com.google.common.base.Strings.isNullOrEmpty; | 41 | import static com.google.common.base.Strings.isNullOrEmpty; |
42 | +import static org.onlab.packet.Ethernet.TYPE_ARP; | ||
43 | +import static org.onlab.packet.Ethernet.TYPE_IPV6; | ||
44 | +import static org.onlab.packet.ICMP6.NEIGHBOR_ADVERTISEMENT; | ||
45 | +import static org.onlab.packet.ICMP6.NEIGHBOR_SOLICITATION; | ||
46 | +import static org.onlab.packet.IPv6.PROTOCOL_ICMP6; | ||
47 | +import static org.onosproject.net.packet.PacketPriority.CONTROL; | ||
45 | import static org.slf4j.LoggerFactory.getLogger; | 48 | import static org.slf4j.LoggerFactory.getLogger; |
46 | 49 | ||
47 | /** | 50 | /** |
... | @@ -86,8 +89,8 @@ public class ProxyArp { | ... | @@ -86,8 +89,8 @@ public class ProxyArp { |
86 | 89 | ||
87 | @Deactivate | 90 | @Deactivate |
88 | public void deactivate() { | 91 | public void deactivate() { |
89 | - // TODO revoke all packet requests when deactivate | ||
90 | cfgService.unregisterProperties(getClass(), false); | 92 | cfgService.unregisterProperties(getClass(), false); |
93 | + withdrawIntercepts(); | ||
91 | packetService.removeProcessor(processor); | 94 | packetService.removeProcessor(processor); |
92 | processor = null; | 95 | processor = null; |
93 | log.info("Stopped"); | 96 | log.info("Stopped"); |
... | @@ -95,7 +98,6 @@ public class ProxyArp { | ... | @@ -95,7 +98,6 @@ public class ProxyArp { |
95 | 98 | ||
96 | @Modified | 99 | @Modified |
97 | public void modified(ComponentContext context) { | 100 | public void modified(ComponentContext context) { |
98 | - // TODO revoke unnecessary packet requests when config being modified | ||
99 | readComponentConfiguration(context); | 101 | readComponentConfiguration(context); |
100 | requestPackests(); | 102 | requestPackests(); |
101 | } | 103 | } |
... | @@ -106,27 +108,58 @@ public class ProxyArp { | ... | @@ -106,27 +108,58 @@ public class ProxyArp { |
106 | private void requestPackests() { | 108 | private void requestPackests() { |
107 | TrafficSelector.Builder selectorBuilder = | 109 | TrafficSelector.Builder selectorBuilder = |
108 | DefaultTrafficSelector.builder(); | 110 | DefaultTrafficSelector.builder(); |
109 | - selectorBuilder.matchEthType(Ethernet.TYPE_ARP); | 111 | + selectorBuilder.matchEthType(TYPE_ARP); |
110 | packetService.requestPackets(selectorBuilder.build(), | 112 | packetService.requestPackets(selectorBuilder.build(), |
111 | - PacketPriority.CONTROL, appId); | 113 | + CONTROL, appId); |
112 | 114 | ||
115 | + selectorBuilder = DefaultTrafficSelector.builder(); | ||
116 | + selectorBuilder.matchEthType(TYPE_IPV6); | ||
117 | + selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6); | ||
118 | + selectorBuilder.matchIcmpv6Type(NEIGHBOR_SOLICITATION); | ||
113 | if (ipv6NeighborDiscovery) { | 119 | if (ipv6NeighborDiscovery) { |
114 | // IPv6 Neighbor Solicitation packet. | 120 | // IPv6 Neighbor Solicitation packet. |
115 | - selectorBuilder = DefaultTrafficSelector.builder(); | ||
116 | - selectorBuilder.matchEthType(Ethernet.TYPE_IPV6); | ||
117 | - selectorBuilder.matchIPProtocol(IPv6.PROTOCOL_ICMP6); | ||
118 | - selectorBuilder.matchIcmpv6Type(ICMP6.NEIGHBOR_SOLICITATION); | ||
119 | packetService.requestPackets(selectorBuilder.build(), | 121 | packetService.requestPackets(selectorBuilder.build(), |
120 | - PacketPriority.CONTROL, appId); | 122 | + CONTROL, appId); |
123 | + } else { | ||
124 | + packetService.cancelPackets(selectorBuilder.build(), | ||
125 | + CONTROL, appId); | ||
126 | + } | ||
121 | 127 | ||
122 | // IPv6 Neighbor Advertisement packet. | 128 | // IPv6 Neighbor Advertisement packet. |
123 | selectorBuilder = DefaultTrafficSelector.builder(); | 129 | selectorBuilder = DefaultTrafficSelector.builder(); |
124 | - selectorBuilder.matchEthType(Ethernet.TYPE_IPV6); | 130 | + selectorBuilder.matchEthType(TYPE_IPV6); |
125 | - selectorBuilder.matchIPProtocol(IPv6.PROTOCOL_ICMP6); | 131 | + selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6); |
126 | - selectorBuilder.matchIcmpv6Type(ICMP6.NEIGHBOR_ADVERTISEMENT); | 132 | + selectorBuilder.matchIcmpv6Type(NEIGHBOR_ADVERTISEMENT); |
133 | + if (ipv6NeighborDiscovery) { | ||
127 | packetService.requestPackets(selectorBuilder.build(), | 134 | packetService.requestPackets(selectorBuilder.build(), |
128 | - PacketPriority.CONTROL, appId); | 135 | + CONTROL, appId); |
136 | + } else { | ||
137 | + packetService.cancelPackets(selectorBuilder.build(), | ||
138 | + CONTROL, appId); | ||
139 | + } | ||
140 | + | ||
141 | + | ||
129 | } | 142 | } |
143 | + | ||
144 | + /** | ||
145 | + * Cancel requested packet in via packet service. | ||
146 | + */ | ||
147 | + private void withdrawIntercepts() { | ||
148 | + TrafficSelector.Builder selectorBuilder = | ||
149 | + DefaultTrafficSelector.builder(); | ||
150 | + selectorBuilder.matchEthType(TYPE_ARP); | ||
151 | + packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId); | ||
152 | + selectorBuilder = DefaultTrafficSelector.builder(); | ||
153 | + selectorBuilder.matchEthType(TYPE_IPV6); | ||
154 | + selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6); | ||
155 | + selectorBuilder.matchIcmpv6Type(NEIGHBOR_SOLICITATION); | ||
156 | + packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId); | ||
157 | + selectorBuilder = DefaultTrafficSelector.builder(); | ||
158 | + selectorBuilder.matchEthType(TYPE_IPV6); | ||
159 | + selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6); | ||
160 | + selectorBuilder.matchIcmpv6Type(NEIGHBOR_ADVERTISEMENT); | ||
161 | + packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId); | ||
162 | + | ||
130 | } | 163 | } |
131 | 164 | ||
132 | /** | 165 | /** |
... | @@ -187,7 +220,7 @@ public class ProxyArp { | ... | @@ -187,7 +220,7 @@ public class ProxyArp { |
187 | if (ethPkt == null) { | 220 | if (ethPkt == null) { |
188 | return; | 221 | return; |
189 | } | 222 | } |
190 | - if (!ipv6NeighborDiscovery && (ethPkt.getEtherType() == Ethernet.TYPE_IPV6)) { | 223 | + if (!ipv6NeighborDiscovery && (ethPkt.getEtherType() == TYPE_IPV6)) { |
191 | return; | 224 | return; |
192 | } | 225 | } |
193 | //handle the arp packet. | 226 | //handle the arp packet. | ... | ... |
... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | package org.onosproject.reactive.routing; | 16 | package org.onosproject.reactive.routing; |
17 | + | ||
17 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
18 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
19 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -37,7 +38,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket; | ... | @@ -37,7 +38,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket; |
37 | import org.onosproject.net.packet.InboundPacket; | 38 | import org.onosproject.net.packet.InboundPacket; |
38 | import org.onosproject.net.packet.OutboundPacket; | 39 | import org.onosproject.net.packet.OutboundPacket; |
39 | import org.onosproject.net.packet.PacketContext; | 40 | import org.onosproject.net.packet.PacketContext; |
40 | -import org.onosproject.net.packet.PacketPriority; | ||
41 | import org.onosproject.net.packet.PacketProcessor; | 41 | import org.onosproject.net.packet.PacketProcessor; |
42 | import org.onosproject.net.packet.PacketService; | 42 | import org.onosproject.net.packet.PacketService; |
43 | import org.onosproject.routing.RoutingService; | 43 | import org.onosproject.routing.RoutingService; |
... | @@ -46,6 +46,9 @@ import org.slf4j.Logger; | ... | @@ -46,6 +46,9 @@ import org.slf4j.Logger; |
46 | 46 | ||
47 | import java.nio.ByteBuffer; | 47 | import java.nio.ByteBuffer; |
48 | 48 | ||
49 | +import static org.onlab.packet.Ethernet.TYPE_ARP; | ||
50 | +import static org.onlab.packet.Ethernet.TYPE_IPV4; | ||
51 | +import static org.onosproject.net.packet.PacketPriority.REACTIVE; | ||
49 | import static org.slf4j.LoggerFactory.getLogger; | 52 | import static org.slf4j.LoggerFactory.getLogger; |
50 | 53 | ||
51 | /** | 54 | /** |
... | @@ -83,26 +86,46 @@ public class SdnIpReactiveRouting { | ... | @@ -83,26 +86,46 @@ public class SdnIpReactiveRouting { |
83 | appId = coreService.registerApplication(APP_NAME); | 86 | appId = coreService.registerApplication(APP_NAME); |
84 | packetService.addProcessor(processor, | 87 | packetService.addProcessor(processor, |
85 | PacketProcessor.ADVISOR_MAX + 2); | 88 | PacketProcessor.ADVISOR_MAX + 2); |
86 | - | 89 | + requestIntercepts(); |
87 | - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
88 | - // TODO: to support IPv6 later | ||
89 | - selector.matchEthType(Ethernet.TYPE_IPV4); | ||
90 | - packetService.requestPackets(selector.build(), | ||
91 | - PacketPriority.REACTIVE, appId); | ||
92 | - selector.matchEthType(Ethernet.TYPE_ARP); | ||
93 | - packetService.requestPackets(selector.build(), | ||
94 | - PacketPriority.REACTIVE, appId); | ||
95 | - | ||
96 | log.info("SDN-IP Reactive Routing Started"); | 90 | log.info("SDN-IP Reactive Routing Started"); |
97 | } | 91 | } |
98 | 92 | ||
99 | @Deactivate | 93 | @Deactivate |
100 | public void deactivate() { | 94 | public void deactivate() { |
95 | + withdrawIntercepts(); | ||
101 | packetService.removeProcessor(processor); | 96 | packetService.removeProcessor(processor); |
102 | processor = null; | 97 | processor = null; |
103 | log.info("SDN-IP Reactive Routing Stopped"); | 98 | log.info("SDN-IP Reactive Routing Stopped"); |
104 | } | 99 | } |
105 | 100 | ||
101 | + /** | ||
102 | + * Request packet in via the PacketService. | ||
103 | + */ | ||
104 | + private void requestIntercepts() { | ||
105 | + //TODO: to support IPv6 later | ||
106 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
107 | + selector.matchEthType(TYPE_IPV4); | ||
108 | + packetService.requestPackets(selector.build(), | ||
109 | + REACTIVE, appId); | ||
110 | + selector.matchEthType(TYPE_ARP); | ||
111 | + packetService.requestPackets(selector.build(), | ||
112 | + REACTIVE, appId); | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * Cancel request for packet in via PacketService. | ||
117 | + */ | ||
118 | + private void withdrawIntercepts() { | ||
119 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
120 | + selector.matchEthType(TYPE_IPV4); | ||
121 | + packetService.requestPackets(selector.build(), | ||
122 | + REACTIVE, appId); | ||
123 | + selector = DefaultTrafficSelector.builder(); | ||
124 | + selector.matchEthType(TYPE_ARP); | ||
125 | + packetService.requestPackets(selector.build(), | ||
126 | + REACTIVE, appId); | ||
127 | + } | ||
128 | + | ||
106 | private class ReactiveRoutingProcessor implements PacketProcessor { | 129 | private class ReactiveRoutingProcessor implements PacketProcessor { |
107 | @Override | 130 | @Override |
108 | public void process(PacketContext context) { | 131 | public void process(PacketContext context) { | ... | ... |
... | @@ -81,24 +81,41 @@ public class VirtualPublicHosts { | ... | @@ -81,24 +81,41 @@ public class VirtualPublicHosts { |
81 | 81 | ||
82 | packetService.addProcessor(processor, | 82 | packetService.addProcessor(processor, |
83 | PacketProcessor.ADVISOR_MAX + 6); | 83 | PacketProcessor.ADVISOR_MAX + 6); |
84 | - | 84 | + requestIntercepts(); |
85 | - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
86 | - // Only IPv4 is supported in current vBNG. | ||
87 | - selector.matchEthType(Ethernet.TYPE_ARP); | ||
88 | - packetService.requestPackets(selector.build(), | ||
89 | - PacketPriority.REACTIVE, appId); | ||
90 | - | ||
91 | log.info("vBNG virtual public hosts started"); | 85 | log.info("vBNG virtual public hosts started"); |
92 | } | 86 | } |
93 | 87 | ||
94 | @Deactivate | 88 | @Deactivate |
95 | public void deactivate() { | 89 | public void deactivate() { |
90 | + withdrawIntercepts(); | ||
96 | packetService.removeProcessor(processor); | 91 | packetService.removeProcessor(processor); |
97 | processor = null; | 92 | processor = null; |
98 | log.info("vBNG virtual public hosts Stopped"); | 93 | log.info("vBNG virtual public hosts Stopped"); |
99 | } | 94 | } |
100 | 95 | ||
101 | /** | 96 | /** |
97 | + * Request packet in via PacketService. | ||
98 | + */ | ||
99 | + private void requestIntercepts() { | ||
100 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
101 | + // Only IPv4 is supported in current vBNG. | ||
102 | + selector.matchEthType(Ethernet.TYPE_ARP); | ||
103 | + packetService.requestPackets(selector.build(), | ||
104 | + PacketPriority.REACTIVE, appId); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * Cancel request for packet in via PacketService. | ||
109 | + */ | ||
110 | + private void withdrawIntercepts() { | ||
111 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
112 | + // Only IPv4 is supported in current vBNG. | ||
113 | + selector.matchEthType(Ethernet.TYPE_ARP); | ||
114 | + packetService.cancelPackets(selector.build(), | ||
115 | + PacketPriority.REACTIVE, appId); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
102 | * This class filters out the ARP request packets, generates the ARP | 119 | * This class filters out the ARP request packets, generates the ARP |
103 | * reply packets, and emits those packets. | 120 | * reply packets, and emits those packets. |
104 | */ | 121 | */ | ... | ... |
... | @@ -190,7 +190,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid | ... | @@ -190,7 +190,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid |
190 | private void withdrawIntercepts() { | 190 | private void withdrawIntercepts() { |
191 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 191 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
192 | selector.matchEthType(Ethernet.TYPE_ARP); | 192 | selector.matchEthType(Ethernet.TYPE_ARP); |
193 | - packetService.requestPackets(selector.build(), PacketPriority.CONTROL, appId); | 193 | + packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId); |
194 | 194 | ||
195 | // IPv6 Neighbor Solicitation packet. | 195 | // IPv6 Neighbor Solicitation packet. |
196 | selector.matchEthType(Ethernet.TYPE_IPV6); | 196 | selector.matchEthType(Ethernet.TYPE_IPV6); | ... | ... |
... | @@ -145,7 +145,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -145,7 +145,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
145 | // to load configuration at startup | 145 | // to load configuration at startup |
146 | modified(context); | 146 | modified(context); |
147 | if (disableLinkDiscovery) { | 147 | if (disableLinkDiscovery) { |
148 | - log.info("Link Discovery has been permanently disabled by configuration"); | 148 | + log.info("LinkDiscovery has been permanently disabled by configuration"); |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | 151 | ... | ... |
-
Please register or login to post a comment