Skip to content

Commit

Permalink
[ptf_nn_agent] enable capturing vlan tag by using afpacket
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Faryma <[email protected]>
  • Loading branch information
Mykola Faryma authored and antoninbas committed Mar 11, 2020
1 parent 361e659 commit 1935ea2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ptf_nn/ptf_nn_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import os
import logging
from fcntl import ioctl
from ptf import afpacket
from socket import AF_NETLINK, SOCK_DGRAM

# copied from ptf.netutils
Expand Down Expand Up @@ -251,6 +252,7 @@ def run(self):
try:
self.socket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW,
socket.htons(0x03))
afpacket.enable_auxdata(self.socket)
if self.iface_rcv_buf != 0:
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, self.iface_rcv_buf)

Expand All @@ -261,7 +263,7 @@ def run(self):
logger.debug("IfaceMgr {}-{} ({}) AF_PACKET socket is open".format(
self.dev, self.port, self.iface_name))
while True:
msg = self.socket.recv(4096)
msg = afpacket.recv(self.socket, 4096)
self.received(msg)
except socket.error as err:
logger.debug("IfaceMgr {}-{} ({}) Error reading from the socket.".format(
Expand Down

0 comments on commit 1935ea2

Please sign in to comment.