Charles M.C. Chan
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
......@@ -163,26 +163,14 @@ public class ReactiveForwarding {
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2);
readComponentConfiguration(context);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
packetService.requestPackets(selector.build(), PacketPriority.REACTIVE,
appId);
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selector.build(), PacketPriority.REACTIVE,
appId);
if (ipv6Forwarding) {
selector.matchEthType(Ethernet.TYPE_IPV6);
packetService.requestPackets(selector.build(),
PacketPriority.REACTIVE, appId);
}
requestPackests();
log.info("Started with Application ID {}", appId.id());
}
@Deactivate
public void deactivate() {
// TODO revoke all packet requests when deactivate
cfgService.unregisterProperties(getClass(), false);
flowRuleService.removeFlowRulesById(appId);
packetService.removeProcessor(processor);
......@@ -192,7 +180,28 @@ public class ReactiveForwarding {
@Modified
public void modified(ComponentContext context) {
// TODO revoke unnecessary packet requests when config being modified
readComponentConfiguration(context);
requestPackests();
}
/**
* Request packet in via PacketService.
*/
private void requestPackests() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
packetService.requestPackets(selector.build(), PacketPriority.REACTIVE,
appId);
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selector.build(), PacketPriority.REACTIVE,
appId);
if (ipv6Forwarding) {
selector.matchEthType(Ethernet.TYPE_IPV6);
packetService.requestPackets(selector.build(),
PacketPriority.REACTIVE, appId);
}
}
/**
......
......@@ -76,10 +76,34 @@ public class ProxyArp {
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
appId = coreService.registerApplication("org.onosproject.proxyarp");
readComponentConfiguration(context);
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 1);
readComponentConfiguration(context);
requestPackests();
log.info("Started with Application ID {}", appId.id());
}
@Deactivate
public void deactivate() {
// TODO revoke all packet requests when deactivate
cfgService.unregisterProperties(getClass(), false);
packetService.removeProcessor(processor);
processor = null;
log.info("Stopped");
}
@Modified
public void modified(ComponentContext context) {
// TODO revoke unnecessary packet requests when config being modified
readComponentConfiguration(context);
requestPackests();
}
/**
* Request packet in via PacketService.
*/
private void requestPackests() {
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_ARP);
......@@ -103,21 +127,6 @@ public class ProxyArp {
packetService.requestPackets(selectorBuilder.build(),
PacketPriority.CONTROL, appId);
}
log.info("Started with Application ID {}", appId.id());
}
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
packetService.removeProcessor(processor);
processor = null;
log.info("Stopped");
}
@Modified
public void modified(ComponentContext context) {
readComponentConfiguration(context);
}
/**
......
......@@ -128,17 +128,43 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
appId = coreService.registerApplication("org.onosproject.provider.host");
readComponentConfiguration(context);
providerService = providerRegistry.register(this);
packetService.addProcessor(processor, 1);
deviceService.addListener(deviceListener);
readComponentConfiguration(context);
requestPackests();
log.info("Started with Application ID {}", appId.id());
}
@Deactivate
public void deactivate() {
// TODO revoke all packet requests when deactivate
cfgService.unregisterProperties(getClass(), false);
providerRegistry.unregister(this);
packetService.removeProcessor(processor);
deviceService.removeListener(deviceListener);
providerService = null;
log.info("Stopped");
}
@Modified
public void modified(ComponentContext context) {
// TODO revoke unnecessary packet requests when config being modified
readComponentConfiguration(context);
requestPackests();
}
/**
* Request packet in via PacketService.
*/
private void requestPackests() {
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selectorBuilder.build(),
PacketPriority.CONTROL, appId);
PacketPriority.CONTROL, appId);
if (ipv6NeighborDiscovery) {
// IPv6 Neighbor Solicitation packet.
......@@ -157,23 +183,6 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
packetService.requestPackets(selectorBuilder.build(),
PacketPriority.CONTROL, appId);
}
log.info("Started with Application ID {}", appId.id());
}
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
providerRegistry.unregister(this);
packetService.removeProcessor(processor);
deviceService.removeListener(deviceListener);
providerService = null;
log.info("Stopped");
}
@Modified
public void modified(ComponentContext context) {
readComponentConfiguration(context);
}
/**
......
......@@ -183,6 +183,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
@Deactivate
public void deactivate() {
// TODO revoke all packet requests when deactivate
cfgService.unregisterProperties(getClass(), false);
if (disableLinkDiscovery) {
return;
......@@ -202,6 +203,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
@Modified
public void modified(ComponentContext context) {
// TODO revoke unnecessary packet requests when config being modified
if (context == null) {
loadSuppressionRules();
return;
......@@ -241,6 +243,9 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
// should refresh discoverers when we need dynamic reconfiguration
}
/**
* Request packet in via PacketService.
*/
private void requestPackets() {
TrafficSelector.Builder lldpSelector = DefaultTrafficSelector.builder();
lldpSelector.matchEthType(Ethernet.TYPE_LLDP);
......