Aaron Kruglikov
Committed by Gerrit Code Review

Include logic for cancelling requests for packets.

Change-Id: I8244b8e417dd2b4c6feae57b810fe750635e87a7
......@@ -54,7 +54,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.xosintegration.VoltTenantService;
......@@ -71,6 +70,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import static org.onosproject.net.packet.PacketPriority.CONTROL;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -130,7 +130,7 @@ public class AAA {
private String radiusIpAddress = DEFAULT_RADIUS_IP;
@Property(name = "nasIpAddress", value = DEFAULT_NAS_IP,
label = "NAP IP Address")
label = "NAS IP Address")
private String nasIpAddress = DEFAULT_NAS_IP;
@Property(name = "radiusMacAddress", value = RADIUS_MAC_ADDRESS,
......@@ -138,7 +138,7 @@ public class AAA {
private String radiusMacAddress = RADIUS_MAC_ADDRESS;
@Property(name = "nasMacAddress", value = NAS_MAC_ADDRESS,
label = "NAP MAC Address")
label = "NAS MAC Address")
private String nasMacAddress = NAS_MAC_ADDRESS;
@Property(name = "radiusSecret", value = DEFAULT_RADIUS_SECRET,
......@@ -205,12 +205,7 @@ public class AAA {
appId = coreService.registerApplication("org.onosproject.aaa");
// register our event handler
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort());
packetService.requestPackets(selector.build(),
PacketPriority.CONTROL, appId);
requestIntercepts();
// Instantiate the map of the state machines
stateMachineMap = Collections.synchronizedMap(Maps.newHashMap());
......@@ -221,16 +216,39 @@ public class AAA {
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
appId = coreService.registerApplication("org.onosproject.aaa");
withdrawIntercepts();
// de-register and null our handler
packetService.removeProcessor(processor);
processor = null;
}
/**
* Request packet in via PacketService.
*/
private void requestIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort());
packetService.requestPackets(selector.build(),
CONTROL, appId);
}
/**
* Cancel request for packet in via PacketService.
*/
private void withdrawIntercepts() {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort());
packetService.cancelPackets(selector.build(), CONTROL, appId);
}
/**
* Builds an EAPOL packet based on the given parameters.
*
* @param dstMac destination MAC address
* @param srcMac source MAC address
* @param vlan vlan identifier
* @param eapolType EAPOL type
* @param eap EAP payload
* @return Ethernet frame
......@@ -447,7 +465,8 @@ public class AAA {
eapPayload = radiusPacket.decapsulateMessage();
stateMachine.setChallengeInfo(eapPayload.getIdentifier(), challengeState);
eth = buildEapolResponse(stateMachine.supplicantAddress,
MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET, eapPayload);
MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET,
eapPayload);
this.sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint);
break;
case RADIUS.RADIUS_CODE_ACCESS_ACCEPT:
......@@ -458,7 +477,8 @@ public class AAA {
eapPayload = new EAP();
eapPayload = (EAP) eapPayload.deserialize(eapMessage, 0, eapMessage.length);
eth = buildEapolResponse(stateMachine.supplicantAddress,
MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET, eapPayload);
MacAddress.valueOf(1L), stateMachine.vlanId, EAPOL.EAPOL_PACKET,
eapPayload);
this.sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint);
stateMachine.authorizeAccess();
......
......@@ -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);
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) {
......
......@@ -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;
}
......