mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-18 10:51:04 +02:00
Handle packets that can't be deserialized properly.
Catch BufferUnderflowExceptions that occur while trying to deserialzed Ethernet packet, and account for the fact that packets may not have been deserialized correctly when using InboundPackets. Addresses ONOS-605. Change-Id: Ia7191e62a339125c9c4d3fe0cf63f9c33eb74cb5
This commit is contained in:
parent
70fc7fb791
commit
e8600eb0c4
@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Modified;
|
|||||||
import org.apache.felix.scr.annotations.Property;
|
import org.apache.felix.scr.annotations.Property;
|
||||||
import org.apache.felix.scr.annotations.Reference;
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.core.CoreService;
|
import org.onosproject.core.CoreService;
|
||||||
import org.onosproject.net.Host;
|
import org.onosproject.net.Host;
|
||||||
@ -46,7 +47,6 @@ import org.onosproject.net.packet.PacketContext;
|
|||||||
import org.onosproject.net.packet.PacketProcessor;
|
import org.onosproject.net.packet.PacketProcessor;
|
||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onosproject.net.topology.TopologyService;
|
import org.onosproject.net.topology.TopologyService;
|
||||||
import org.onlab.packet.Ethernet;
|
|
||||||
import org.osgi.service.component.ComponentContext;
|
import org.osgi.service.component.ComponentContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -167,6 +167,10 @@ public class ReactiveForwarding {
|
|||||||
InboundPacket pkt = context.inPacket();
|
InboundPacket pkt = context.inPacket();
|
||||||
Ethernet ethPkt = pkt.parsed();
|
Ethernet ethPkt = pkt.parsed();
|
||||||
|
|
||||||
|
if (ethPkt == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Bail if this is deemed to be a control packet.
|
// Bail if this is deemed to be a control packet.
|
||||||
if (isControlPacket(ethPkt)) {
|
if (isControlPacket(ethPkt)) {
|
||||||
return;
|
return;
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.ifwd;
|
package org.onosproject.ifwd;
|
||||||
|
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
import org.apache.felix.scr.annotations.Activate;
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
import org.apache.felix.scr.annotations.Component;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
import org.apache.felix.scr.annotations.Deactivate;
|
import org.apache.felix.scr.annotations.Deactivate;
|
||||||
import org.apache.felix.scr.annotations.Reference;
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.core.CoreService;
|
import org.onosproject.core.CoreService;
|
||||||
import org.onosproject.net.Host;
|
import org.onosproject.net.Host;
|
||||||
@ -39,11 +42,8 @@ import org.onosproject.net.packet.PacketContext;
|
|||||||
import org.onosproject.net.packet.PacketProcessor;
|
import org.onosproject.net.packet.PacketProcessor;
|
||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onosproject.net.topology.TopologyService;
|
import org.onosproject.net.topology.TopologyService;
|
||||||
import org.onlab.packet.Ethernet;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
|
* WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
|
||||||
*/
|
*/
|
||||||
@ -100,6 +100,10 @@ public class IntentReactiveForwarding {
|
|||||||
InboundPacket pkt = context.inPacket();
|
InboundPacket pkt = context.inPacket();
|
||||||
Ethernet ethPkt = pkt.parsed();
|
Ethernet ethPkt = pkt.parsed();
|
||||||
|
|
||||||
|
if (ethPkt == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HostId srcId = HostId.hostId(ethPkt.getSourceMAC());
|
HostId srcId = HostId.hostId(ethPkt.getSourceMAC());
|
||||||
HostId dstId = HostId.hostId(ethPkt.getDestinationMAC());
|
HostId dstId = HostId.hostId(ethPkt.getDestinationMAC());
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ import org.apache.felix.scr.annotations.Deactivate;
|
|||||||
import org.apache.felix.scr.annotations.Reference;
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||||
import org.apache.felix.scr.annotations.Service;
|
import org.apache.felix.scr.annotations.Service;
|
||||||
|
import org.onlab.packet.ARP;
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
|
import org.onlab.packet.Ip4Address;
|
||||||
|
import org.onlab.packet.IpAddress;
|
||||||
|
import org.onlab.packet.MacAddress;
|
||||||
|
import org.onlab.packet.VlanId;
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.core.CoreService;
|
import org.onosproject.core.CoreService;
|
||||||
import org.onosproject.net.ConnectPoint;
|
import org.onosproject.net.ConnectPoint;
|
||||||
@ -61,12 +67,6 @@ import org.onosproject.net.packet.InboundPacket;
|
|||||||
import org.onosproject.net.packet.PacketContext;
|
import org.onosproject.net.packet.PacketContext;
|
||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onosproject.net.proxyarp.ProxyArpService;
|
import org.onosproject.net.proxyarp.ProxyArpService;
|
||||||
import org.onlab.packet.ARP;
|
|
||||||
import org.onlab.packet.Ethernet;
|
|
||||||
import org.onlab.packet.Ip4Address;
|
|
||||||
import org.onlab.packet.IpAddress;
|
|
||||||
import org.onlab.packet.MacAddress;
|
|
||||||
import org.onlab.packet.VlanId;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
@ -309,7 +309,7 @@ public class ProxyArpManager implements ProxyArpService {
|
|||||||
public boolean handleArp(PacketContext context) {
|
public boolean handleArp(PacketContext context) {
|
||||||
InboundPacket pkt = context.inPacket();
|
InboundPacket pkt = context.inPacket();
|
||||||
Ethernet ethPkt = pkt.parsed();
|
Ethernet ethPkt = pkt.parsed();
|
||||||
if (ethPkt.getEtherType() == Ethernet.TYPE_ARP) {
|
if (ethPkt != null && ethPkt.getEtherType() == Ethernet.TYPE_ARP) {
|
||||||
ARP arp = (ARP) ethPkt.getPayload();
|
ARP arp = (ARP) ethPkt.getPayload();
|
||||||
if (arp.getOpCode() == ARP.OP_REPLY) {
|
if (arp.getOpCode() == ARP.OP_REPLY) {
|
||||||
forward(ethPkt);
|
forward(ethPkt);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package org.onosproject.openflow.controller;
|
package org.onosproject.openflow.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import java.nio.BufferUnderflowException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ -85,8 +86,12 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
|
|||||||
@Override
|
@Override
|
||||||
public Ethernet parsed() {
|
public Ethernet parsed() {
|
||||||
Ethernet eth = new Ethernet();
|
Ethernet eth = new Ethernet();
|
||||||
eth.deserialize(pktin.getData(), 0, pktin.getTotalLen());
|
try {
|
||||||
return eth;
|
eth.deserialize(pktin.getData(), 0, pktin.getData().length);
|
||||||
|
return eth;
|
||||||
|
} catch (BufferUnderflowException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.provider.host.impl;
|
package org.onosproject.provider.host.impl;
|
||||||
|
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.felix.scr.annotations.Activate;
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
import org.apache.felix.scr.annotations.Component;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
import org.apache.felix.scr.annotations.Deactivate;
|
import org.apache.felix.scr.annotations.Deactivate;
|
||||||
@ -22,6 +27,14 @@ import org.apache.felix.scr.annotations.Modified;
|
|||||||
import org.apache.felix.scr.annotations.Property;
|
import org.apache.felix.scr.annotations.Property;
|
||||||
import org.apache.felix.scr.annotations.Reference;
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||||
|
import org.onlab.packet.ARP;
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
|
import org.onlab.packet.IPacket;
|
||||||
|
import org.onlab.packet.IPv6;
|
||||||
|
import org.onlab.packet.IpAddress;
|
||||||
|
import org.onlab.packet.VlanId;
|
||||||
|
import org.onlab.packet.ndp.NeighborAdvertisement;
|
||||||
|
import org.onlab.packet.ndp.NeighborSolicitation;
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.core.CoreService;
|
import org.onosproject.core.CoreService;
|
||||||
import org.onosproject.net.ConnectPoint;
|
import org.onosproject.net.ConnectPoint;
|
||||||
@ -52,22 +65,9 @@ import org.onosproject.net.provider.AbstractProvider;
|
|||||||
import org.onosproject.net.provider.ProviderId;
|
import org.onosproject.net.provider.ProviderId;
|
||||||
import org.onosproject.net.topology.Topology;
|
import org.onosproject.net.topology.Topology;
|
||||||
import org.onosproject.net.topology.TopologyService;
|
import org.onosproject.net.topology.TopologyService;
|
||||||
import org.onlab.packet.ARP;
|
|
||||||
import org.onlab.packet.Ethernet;
|
|
||||||
import org.onlab.packet.IpAddress;
|
|
||||||
import org.onlab.packet.IPacket;
|
|
||||||
import org.onlab.packet.IPv6;
|
|
||||||
import org.onlab.packet.ndp.NeighborAdvertisement;
|
|
||||||
import org.onlab.packet.ndp.NeighborSolicitation;
|
|
||||||
import org.onlab.packet.VlanId;
|
|
||||||
import org.osgi.service.component.ComponentContext;
|
import org.osgi.service.component.ComponentContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.Dictionary;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider which uses an OpenFlow controller to detect network
|
* Provider which uses an OpenFlow controller to detect network
|
||||||
* end-station hosts.
|
* end-station hosts.
|
||||||
@ -200,6 +200,10 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
|
|||||||
}
|
}
|
||||||
Ethernet eth = context.inPacket().parsed();
|
Ethernet eth = context.inPacket().parsed();
|
||||||
|
|
||||||
|
if (eth == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VlanId vlan = VlanId.vlanId(eth.getVlanID());
|
VlanId vlan = VlanId.vlanId(eth.getVlanID());
|
||||||
ConnectPoint heardOn = context.inPacket().receivedFrom();
|
ConnectPoint heardOn = context.inPacket().receivedFrom();
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
import org.jboss.netty.util.Timeout;
|
import org.jboss.netty.util.Timeout;
|
||||||
import org.jboss.netty.util.TimerTask;
|
import org.jboss.netty.util.TimerTask;
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
|
import org.onlab.packet.ONOSLLDP;
|
||||||
|
import org.onlab.util.Timer;
|
||||||
import org.onosproject.mastership.MastershipService;
|
import org.onosproject.mastership.MastershipService;
|
||||||
import org.onosproject.net.ConnectPoint;
|
import org.onosproject.net.ConnectPoint;
|
||||||
import org.onosproject.net.Device;
|
import org.onosproject.net.Device;
|
||||||
@ -47,9 +50,6 @@ import org.onosproject.net.packet.DefaultOutboundPacket;
|
|||||||
import org.onosproject.net.packet.OutboundPacket;
|
import org.onosproject.net.packet.OutboundPacket;
|
||||||
import org.onosproject.net.packet.PacketContext;
|
import org.onosproject.net.packet.PacketContext;
|
||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onlab.packet.Ethernet;
|
|
||||||
import org.onlab.packet.ONOSLLDP;
|
|
||||||
import org.onlab.util.Timer;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
// TODO: add 'fast discovery' mode: drop LLDPs in destination switch but listen for flow_removed messages
|
// TODO: add 'fast discovery' mode: drop LLDPs in destination switch but listen for flow_removed messages
|
||||||
@ -208,6 +208,10 @@ public class LinkDiscovery implements TimerTask {
|
|||||||
*/
|
*/
|
||||||
public boolean handleLLDP(PacketContext context) {
|
public boolean handleLLDP(PacketContext context) {
|
||||||
Ethernet eth = context.inPacket().parsed();
|
Ethernet eth = context.inPacket().parsed();
|
||||||
|
if (eth == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ONOSLLDP onoslldp = ONOSLLDP.parseONOSLLDP(eth);
|
ONOSLLDP onoslldp = ONOSLLDP.parseONOSLLDP(eth);
|
||||||
if (onoslldp != null) {
|
if (onoslldp != null) {
|
||||||
final PortNumber dstPort =
|
final PortNumber dstPort =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user