Committed by
Gerrit Code Review
Request packet in when config being modified during runtime.
We can now enable features such as IPv6 via cfg command dynamically. NOTE: We should remove unnecessary packet requests when app being deactivated or modified once PacketService support the request revocation. Change-Id: I7f239ce9db74456097675d03de99468db70a919f
Showing
4 changed files
with
80 additions
and
48 deletions
| ... | @@ -163,26 +163,14 @@ public class ReactiveForwarding { | ... | @@ -163,26 +163,14 @@ public class ReactiveForwarding { |
| 163 | 163 | ||
| 164 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); | 164 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); |
| 165 | readComponentConfiguration(context); | 165 | readComponentConfiguration(context); |
| 166 | - | 166 | + requestPackests(); |
| 167 | - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
| 168 | - selector.matchEthType(Ethernet.TYPE_IPV4); | ||
| 169 | - packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, | ||
| 170 | - appId); | ||
| 171 | - selector.matchEthType(Ethernet.TYPE_ARP); | ||
| 172 | - packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, | ||
| 173 | - appId); | ||
| 174 | - | ||
| 175 | - if (ipv6Forwarding) { | ||
| 176 | - selector.matchEthType(Ethernet.TYPE_IPV6); | ||
| 177 | - packetService.requestPackets(selector.build(), | ||
| 178 | - PacketPriority.REACTIVE, appId); | ||
| 179 | - } | ||
| 180 | 167 | ||
| 181 | log.info("Started with Application ID {}", appId.id()); | 168 | log.info("Started with Application ID {}", appId.id()); |
| 182 | } | 169 | } |
| 183 | 170 | ||
| 184 | @Deactivate | 171 | @Deactivate |
| 185 | public void deactivate() { | 172 | public void deactivate() { |
| 173 | + // TODO revoke all packet requests when deactivate | ||
| 186 | cfgService.unregisterProperties(getClass(), false); | 174 | cfgService.unregisterProperties(getClass(), false); |
| 187 | flowRuleService.removeFlowRulesById(appId); | 175 | flowRuleService.removeFlowRulesById(appId); |
| 188 | packetService.removeProcessor(processor); | 176 | packetService.removeProcessor(processor); |
| ... | @@ -192,7 +180,28 @@ public class ReactiveForwarding { | ... | @@ -192,7 +180,28 @@ public class ReactiveForwarding { |
| 192 | 180 | ||
| 193 | @Modified | 181 | @Modified |
| 194 | public void modified(ComponentContext context) { | 182 | public void modified(ComponentContext context) { |
| 183 | + // TODO revoke unnecessary packet requests when config being modified | ||
| 195 | readComponentConfiguration(context); | 184 | readComponentConfiguration(context); |
| 185 | + requestPackests(); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * Request packet in via PacketService. | ||
| 190 | + */ | ||
| 191 | + private void requestPackests() { | ||
| 192 | + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
| 193 | + selector.matchEthType(Ethernet.TYPE_IPV4); | ||
| 194 | + packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, | ||
| 195 | + appId); | ||
| 196 | + selector.matchEthType(Ethernet.TYPE_ARP); | ||
| 197 | + packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, | ||
| 198 | + appId); | ||
| 199 | + | ||
| 200 | + if (ipv6Forwarding) { | ||
| 201 | + selector.matchEthType(Ethernet.TYPE_IPV6); | ||
| 202 | + packetService.requestPackets(selector.build(), | ||
| 203 | + PacketPriority.REACTIVE, appId); | ||
| 204 | + } | ||
| 196 | } | 205 | } |
| 197 | 206 | ||
| 198 | /** | 207 | /** | ... | ... |
| ... | @@ -76,10 +76,34 @@ public class ProxyArp { | ... | @@ -76,10 +76,34 @@ public class ProxyArp { |
| 76 | public void activate(ComponentContext context) { | 76 | public void activate(ComponentContext context) { |
| 77 | cfgService.registerProperties(getClass()); | 77 | cfgService.registerProperties(getClass()); |
| 78 | appId = coreService.registerApplication("org.onosproject.proxyarp"); | 78 | appId = coreService.registerApplication("org.onosproject.proxyarp"); |
| 79 | - readComponentConfiguration(context); | ||
| 80 | 79 | ||
| 81 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 1); | 80 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 1); |
| 81 | + readComponentConfiguration(context); | ||
| 82 | + requestPackests(); | ||
| 83 | + | ||
| 84 | + log.info("Started with Application ID {}", appId.id()); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Deactivate | ||
| 88 | + public void deactivate() { | ||
| 89 | + // TODO revoke all packet requests when deactivate | ||
| 90 | + cfgService.unregisterProperties(getClass(), false); | ||
| 91 | + packetService.removeProcessor(processor); | ||
| 92 | + processor = null; | ||
| 93 | + log.info("Stopped"); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + @Modified | ||
| 97 | + public void modified(ComponentContext context) { | ||
| 98 | + // TODO revoke unnecessary packet requests when config being modified | ||
| 99 | + readComponentConfiguration(context); | ||
| 100 | + requestPackests(); | ||
| 101 | + } | ||
| 82 | 102 | ||
| 103 | + /** | ||
| 104 | + * Request packet in via PacketService. | ||
| 105 | + */ | ||
| 106 | + private void requestPackests() { | ||
| 83 | TrafficSelector.Builder selectorBuilder = | 107 | TrafficSelector.Builder selectorBuilder = |
| 84 | DefaultTrafficSelector.builder(); | 108 | DefaultTrafficSelector.builder(); |
| 85 | selectorBuilder.matchEthType(Ethernet.TYPE_ARP); | 109 | selectorBuilder.matchEthType(Ethernet.TYPE_ARP); |
| ... | @@ -103,21 +127,6 @@ public class ProxyArp { | ... | @@ -103,21 +127,6 @@ public class ProxyArp { |
| 103 | packetService.requestPackets(selectorBuilder.build(), | 127 | packetService.requestPackets(selectorBuilder.build(), |
| 104 | PacketPriority.CONTROL, appId); | 128 | PacketPriority.CONTROL, appId); |
| 105 | } | 129 | } |
| 106 | - | ||
| 107 | - log.info("Started with Application ID {}", appId.id()); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - @Deactivate | ||
| 111 | - public void deactivate() { | ||
| 112 | - cfgService.unregisterProperties(getClass(), false); | ||
| 113 | - packetService.removeProcessor(processor); | ||
| 114 | - processor = null; | ||
| 115 | - log.info("Stopped"); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - @Modified | ||
| 119 | - public void modified(ComponentContext context) { | ||
| 120 | - readComponentConfiguration(context); | ||
| 121 | } | 130 | } |
| 122 | 131 | ||
| 123 | /** | 132 | /** | ... | ... |
| ... | @@ -128,12 +128,38 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid | ... | @@ -128,12 +128,38 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid |
| 128 | public void activate(ComponentContext context) { | 128 | public void activate(ComponentContext context) { |
| 129 | cfgService.registerProperties(getClass()); | 129 | cfgService.registerProperties(getClass()); |
| 130 | appId = coreService.registerApplication("org.onosproject.provider.host"); | 130 | appId = coreService.registerApplication("org.onosproject.provider.host"); |
| 131 | - readComponentConfiguration(context); | ||
| 132 | 131 | ||
| 133 | providerService = providerRegistry.register(this); | 132 | providerService = providerRegistry.register(this); |
| 134 | packetService.addProcessor(processor, 1); | 133 | packetService.addProcessor(processor, 1); |
| 135 | deviceService.addListener(deviceListener); | 134 | deviceService.addListener(deviceListener); |
| 135 | + readComponentConfiguration(context); | ||
| 136 | + requestPackests(); | ||
| 137 | + | ||
| 138 | + log.info("Started with Application ID {}", appId.id()); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + @Deactivate | ||
| 142 | + public void deactivate() { | ||
| 143 | + // TODO revoke all packet requests when deactivate | ||
| 144 | + cfgService.unregisterProperties(getClass(), false); | ||
| 145 | + providerRegistry.unregister(this); | ||
| 146 | + packetService.removeProcessor(processor); | ||
| 147 | + deviceService.removeListener(deviceListener); | ||
| 148 | + providerService = null; | ||
| 149 | + log.info("Stopped"); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + @Modified | ||
| 153 | + public void modified(ComponentContext context) { | ||
| 154 | + // TODO revoke unnecessary packet requests when config being modified | ||
| 155 | + readComponentConfiguration(context); | ||
| 156 | + requestPackests(); | ||
| 157 | + } | ||
| 136 | 158 | ||
| 159 | + /** | ||
| 160 | + * Request packet in via PacketService. | ||
| 161 | + */ | ||
| 162 | + private void requestPackests() { | ||
| 137 | TrafficSelector.Builder selectorBuilder = | 163 | TrafficSelector.Builder selectorBuilder = |
| 138 | DefaultTrafficSelector.builder(); | 164 | DefaultTrafficSelector.builder(); |
| 139 | selectorBuilder.matchEthType(Ethernet.TYPE_ARP); | 165 | selectorBuilder.matchEthType(Ethernet.TYPE_ARP); |
| ... | @@ -157,23 +183,6 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid | ... | @@ -157,23 +183,6 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid |
| 157 | packetService.requestPackets(selectorBuilder.build(), | 183 | packetService.requestPackets(selectorBuilder.build(), |
| 158 | PacketPriority.CONTROL, appId); | 184 | PacketPriority.CONTROL, appId); |
| 159 | } | 185 | } |
| 160 | - | ||
| 161 | - log.info("Started with Application ID {}", appId.id()); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - @Deactivate | ||
| 165 | - public void deactivate() { | ||
| 166 | - cfgService.unregisterProperties(getClass(), false); | ||
| 167 | - providerRegistry.unregister(this); | ||
| 168 | - packetService.removeProcessor(processor); | ||
| 169 | - deviceService.removeListener(deviceListener); | ||
| 170 | - providerService = null; | ||
| 171 | - log.info("Stopped"); | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - @Modified | ||
| 175 | - public void modified(ComponentContext context) { | ||
| 176 | - readComponentConfiguration(context); | ||
| 177 | } | 186 | } |
| 178 | 187 | ||
| 179 | /** | 188 | /** | ... | ... |
| ... | @@ -183,6 +183,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -183,6 +183,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 183 | 183 | ||
| 184 | @Deactivate | 184 | @Deactivate |
| 185 | public void deactivate() { | 185 | public void deactivate() { |
| 186 | + // TODO revoke all packet requests when deactivate | ||
| 186 | cfgService.unregisterProperties(getClass(), false); | 187 | cfgService.unregisterProperties(getClass(), false); |
| 187 | if (disableLinkDiscovery) { | 188 | if (disableLinkDiscovery) { |
| 188 | return; | 189 | return; |
| ... | @@ -202,6 +203,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -202,6 +203,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 202 | 203 | ||
| 203 | @Modified | 204 | @Modified |
| 204 | public void modified(ComponentContext context) { | 205 | public void modified(ComponentContext context) { |
| 206 | + // TODO revoke unnecessary packet requests when config being modified | ||
| 205 | if (context == null) { | 207 | if (context == null) { |
| 206 | loadSuppressionRules(); | 208 | loadSuppressionRules(); |
| 207 | return; | 209 | return; |
| ... | @@ -241,6 +243,9 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -241,6 +243,9 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 241 | // should refresh discoverers when we need dynamic reconfiguration | 243 | // should refresh discoverers when we need dynamic reconfiguration |
| 242 | } | 244 | } |
| 243 | 245 | ||
| 246 | + /** | ||
| 247 | + * Request packet in via PacketService. | ||
| 248 | + */ | ||
| 244 | private void requestPackets() { | 249 | private void requestPackets() { |
| 245 | TrafficSelector.Builder lldpSelector = DefaultTrafficSelector.builder(); | 250 | TrafficSelector.Builder lldpSelector = DefaultTrafficSelector.builder(); |
| 246 | lldpSelector.matchEthType(Ethernet.TYPE_LLDP); | 251 | lldpSelector.matchEthType(Ethernet.TYPE_LLDP); | ... | ... |
-
Please register or login to post a comment