Aaron Kruglikov
Committed by Gerrit Code Review

Include logic for cancelling requests for packets.

Change-Id: I8244b8e417dd2b4c6feae57b810fe750635e87a7
......@@ -203,7 +203,7 @@ public class ReactiveForwarding {
}
/**
* Request packet in via PacketService.
* Cancel request for packet in via PacketService.
*/
private void withdrawIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
......
......@@ -23,8 +23,6 @@ import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
import org.onlab.packet.ICMP6;
import org.onlab.packet.IPv6;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
......@@ -32,7 +30,6 @@ import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.packet.InboundPacket;
import org.onosproject.net.packet.PacketContext;
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
import org.onosproject.net.proxyarp.ProxyArpService;
......@@ -42,6 +39,12 @@ import org.slf4j.Logger;
import java.util.Dictionary;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.packet.Ethernet.TYPE_ARP;
import static org.onlab.packet.Ethernet.TYPE_IPV6;
import static org.onlab.packet.ICMP6.NEIGHBOR_ADVERTISEMENT;
import static org.onlab.packet.ICMP6.NEIGHBOR_SOLICITATION;
import static org.onlab.packet.IPv6.PROTOCOL_ICMP6;
import static org.onosproject.net.packet.PacketPriority.CONTROL;
import static org.slf4j.LoggerFactory.getLogger;
/**
......@@ -86,8 +89,8 @@ public class ProxyArp {
@Deactivate
public void deactivate() {
// TODO revoke all packet requests when deactivate
cfgService.unregisterProperties(getClass(), false);
withdrawIntercepts();
packetService.removeProcessor(processor);
processor = null;
log.info("Stopped");
......@@ -95,7 +98,6 @@ public class ProxyArp {
@Modified
public void modified(ComponentContext context) {
// TODO revoke unnecessary packet requests when config being modified
readComponentConfiguration(context);
requestPackests();
}
......@@ -106,27 +108,58 @@ public class ProxyArp {
private void requestPackests() {
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_ARP);
selectorBuilder.matchEthType(TYPE_ARP);
packetService.requestPackets(selectorBuilder.build(),
PacketPriority.CONTROL, appId);
CONTROL, appId);
selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(TYPE_IPV6);
selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6);
selectorBuilder.matchIcmpv6Type(NEIGHBOR_SOLICITATION);
if (ipv6NeighborDiscovery) {
// IPv6 Neighbor Solicitation packet.
selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV6);
selectorBuilder.matchIPProtocol(IPv6.PROTOCOL_ICMP6);
selectorBuilder.matchIcmpv6Type(ICMP6.NEIGHBOR_SOLICITATION);
packetService.requestPackets(selectorBuilder.build(),
PacketPriority.CONTROL, appId);
CONTROL, appId);
} else {
packetService.cancelPackets(selectorBuilder.build(),
CONTROL, appId);
}
// IPv6 Neighbor Advertisement packet.
selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV6);
selectorBuilder.matchIPProtocol(IPv6.PROTOCOL_ICMP6);
selectorBuilder.matchIcmpv6Type(ICMP6.NEIGHBOR_ADVERTISEMENT);
// IPv6 Neighbor Advertisement packet.
selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(TYPE_IPV6);
selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6);
selectorBuilder.matchIcmpv6Type(NEIGHBOR_ADVERTISEMENT);
if (ipv6NeighborDiscovery) {
packetService.requestPackets(selectorBuilder.build(),
PacketPriority.CONTROL, appId);
CONTROL, appId);
} else {
packetService.cancelPackets(selectorBuilder.build(),
CONTROL, appId);
}
}
/**
* Cancel requested packet in via packet service.
*/
private void withdrawIntercepts() {
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(TYPE_ARP);
packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId);
selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(TYPE_IPV6);
selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6);
selectorBuilder.matchIcmpv6Type(NEIGHBOR_SOLICITATION);
packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId);
selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(TYPE_IPV6);
selectorBuilder.matchIPProtocol(PROTOCOL_ICMP6);
selectorBuilder.matchIcmpv6Type(NEIGHBOR_ADVERTISEMENT);
packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId);
}
/**
......@@ -187,7 +220,7 @@ public class ProxyArp {
if (ethPkt == null) {
return;
}
if (!ipv6NeighborDiscovery && (ethPkt.getEtherType() == Ethernet.TYPE_IPV6)) {
if (!ipv6NeighborDiscovery && (ethPkt.getEtherType() == TYPE_IPV6)) {
return;
}
//handle the arp packet.
......
......@@ -14,6 +14,7 @@
* limitations under the License.
*/
package org.onosproject.reactive.routing;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -37,7 +38,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.InboundPacket;
import org.onosproject.net.packet.OutboundPacket;
import org.onosproject.net.packet.PacketContext;
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
import org.onosproject.routing.RoutingService;
......@@ -46,6 +46,9 @@ import org.slf4j.Logger;
import java.nio.ByteBuffer;
import static org.onlab.packet.Ethernet.TYPE_ARP;
import static org.onlab.packet.Ethernet.TYPE_IPV4;
import static org.onosproject.net.packet.PacketPriority.REACTIVE;
import static org.slf4j.LoggerFactory.getLogger;
/**
......@@ -83,26 +86,46 @@ public class SdnIpReactiveRouting {
appId = coreService.registerApplication(APP_NAME);
packetService.addProcessor(processor,
PacketProcessor.ADVISOR_MAX + 2);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
// TODO: to support IPv6 later
selector.matchEthType(Ethernet.TYPE_IPV4);
packetService.requestPackets(selector.build(),
PacketPriority.REACTIVE, appId);
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selector.build(),
PacketPriority.REACTIVE, appId);
requestIntercepts();
log.info("SDN-IP Reactive Routing Started");
}
@Deactivate
public void deactivate() {
withdrawIntercepts();
packetService.removeProcessor(processor);
processor = null;
log.info("SDN-IP Reactive Routing Stopped");
}
/**
* Request packet in via the PacketService.
*/
private void requestIntercepts() {
//TODO: to support IPv6 later
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(TYPE_IPV4);
packetService.requestPackets(selector.build(),
REACTIVE, appId);
selector.matchEthType(TYPE_ARP);
packetService.requestPackets(selector.build(),
REACTIVE, appId);
}
/**
* Cancel request for packet in via PacketService.
*/
private void withdrawIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(TYPE_IPV4);
packetService.requestPackets(selector.build(),
REACTIVE, appId);
selector = DefaultTrafficSelector.builder();
selector.matchEthType(TYPE_ARP);
packetService.requestPackets(selector.build(),
REACTIVE, appId);
}
private class ReactiveRoutingProcessor implements PacketProcessor {
@Override
public void process(PacketContext context) {
......@@ -169,9 +192,9 @@ public class SdnIpReactiveRouting {
/**
* Emits the specified packet onto the network.
*
* @param context the packet context
* @param context the packet context
* @param connectPoint the connect point where the packet should be
* sent out
* sent out
*/
private void forwardPacketToDst(PacketContext context,
ConnectPoint connectPoint) {
......
......@@ -81,24 +81,41 @@ public class VirtualPublicHosts {
packetService.addProcessor(processor,
PacketProcessor.ADVISOR_MAX + 6);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
// Only IPv4 is supported in current vBNG.
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selector.build(),
PacketPriority.REACTIVE, appId);
requestIntercepts();
log.info("vBNG virtual public hosts started");
}
@Deactivate
public void deactivate() {
withdrawIntercepts();
packetService.removeProcessor(processor);
processor = null;
log.info("vBNG virtual public hosts Stopped");
}
/**
* Request packet in via PacketService.
*/
private void requestIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
// Only IPv4 is supported in current vBNG.
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selector.build(),
PacketPriority.REACTIVE, appId);
}
/**
* Cancel request for packet in via PacketService.
*/
private void withdrawIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
// Only IPv4 is supported in current vBNG.
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.cancelPackets(selector.build(),
PacketPriority.REACTIVE, appId);
}
/**
* This class filters out the ARP request packets, generates the ARP
* reply packets, and emits those packets.
*/
......
......@@ -190,7 +190,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
private void withdrawIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_ARP);
packetService.requestPackets(selector.build(), PacketPriority.CONTROL, appId);
packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId);
// IPv6 Neighbor Solicitation packet.
selector.matchEthType(Ethernet.TYPE_IPV6);
......
......@@ -145,7 +145,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
// to load configuration at startup
modified(context);
if (disableLinkDiscovery) {
log.info("Link Discovery has been permanently disabled by configuration");
log.info("LinkDiscovery has been permanently disabled by configuration");
return;
}
......