Skip to content

Commit 85000e8

Browse files
mssonicbldlolyu
andauthored
[dualtor][sniffer] Explicitly set listen ports (#18299) (#18362)
What is the motivation for this PR? On scapy with version v2.40 and under, the sniffer will capture packets on every interface if no interface is given. On scapy with version v.2.50 and higher, the sniffer will capture packets on conf.iface if no interface is given; on the ptf, conf.iface is mgmt, so dual_tor_sniffer is not able to capture any meaningful dataplane packets. secdev/scapy#1420 Signed-off-by: Longxiang Lyu lolv@microsoft.com How did you do it? Let dual_tor_sniffer explicitly sniff on dataplane ports (any ptf ports starting with eth) How did you verify/test it? Run dualtor I/O testcase. Signed-off-by: Longxiang Lyu <lolv@microsoft.com> Co-authored-by: Longxiang Lyu <35479537+lolyu@users.noreply.github.com>
1 parent 30b7d73 commit 85000e8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

tests/scripts/dual_tor_sniffer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import argparse
22
import logging
3+
import socket
34

45
import scapy.all as scapyall
56

67

78
class Sniffer(object):
89
def __init__(self, filter=None, timeout=60):
10+
self.ifaces = [iface for _, iface in socket.if_nameindex() if iface.startswith("eth")]
911
self.filter = filter
1012
self.timeout = timeout
1113
self.packets = []
@@ -15,6 +17,7 @@ def sniff(self):
1517
logging.debug("scapy sniffer started: filter={}, timeout={}".format(
1618
self.filter, self.timeout))
1719
scapyall.sniff(
20+
iface=self.ifaces,
1821
filter=self.filter,
1922
prn=self.process_pkt,
2023
timeout=self.timeout)

0 commit comments

Comments
 (0)