dataplane: extract VLAN from AF_PACKET auxiliary data
The original reason we switched to libpcap was that it handled VLAN offload for
us. Now that libpcap isn't reliable on Linux (TPACKET_V3 is broken) we have to
reconstruct the VLAN tag ourselves.
diff --git a/src/python/oftest/dataplane.py b/src/python/oftest/dataplane.py
index 8cda932..1cb04b8 100644
--- a/src/python/oftest/dataplane.py
+++ b/src/python/oftest/dataplane.py
@@ -27,6 +27,9 @@
import netutils
from pcap_writer import PcapWriter
+if "linux" in sys.platform:
+ import afpacket
+
have_pypcap = False
try:
import pcap
@@ -66,6 +69,7 @@
self.interface_name = interface_name
self.socket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW,
socket.htons(self.ETH_P_ALL))
+ afpacket.enable_auxdata(self.socket)
self.socket.bind((interface_name, 0))
netutils.set_promisc(self.socket, interface_name)
self.socket.settimeout(self.RCV_TIMEOUT)
@@ -85,7 +89,7 @@
Receive a packet from this port.
@retval (packet data, timestamp)
"""
- pkt = self.socket.recv(self.RCV_SIZE_DEFAULT)
+ pkt = afpacket.recv(self.socket, self.RCV_SIZE_DEFAULT)
return (pkt, time.time())
def send(self, packet):
@@ -191,7 +195,6 @@
elif have_pypcap:
self.dppclass = DataPlanePortPcap
else:
- self.logger.warning("Missing pypcap, VLAN tests may fail. See README for installation instructions.")
self.dppclass = DataPlanePort
self.start()