Committed by
Gerrit Code Review
Include logic for cancelling requests for packets.
Change-Id: I8244b8e417dd2b4c6feae57b810fe750635e87a7
Showing
7 changed files
with
115 additions
and
42 deletions
This diff is collapsed. Click to expand it.
... | @@ -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); | ||
129 | } | 139 | } |
140 | + | ||
141 | + | ||
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) { |
... | @@ -169,9 +192,9 @@ public class SdnIpReactiveRouting { | ... | @@ -169,9 +192,9 @@ public class SdnIpReactiveRouting { |
169 | /** | 192 | /** |
170 | * Emits the specified packet onto the network. | 193 | * Emits the specified packet onto the network. |
171 | * | 194 | * |
172 | - * @param context the packet context | 195 | + * @param context the packet context |
173 | * @param connectPoint the connect point where the packet should be | 196 | * @param connectPoint the connect point where the packet should be |
174 | - * sent out | 197 | + * sent out |
175 | */ | 198 | */ |
176 | private void forwardPacketToDst(PacketContext context, | 199 | private void forwardPacketToDst(PacketContext context, |
177 | ConnectPoint connectPoint) { | 200 | ConnectPoint connectPoint) { | ... | ... |
... | @@ -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