git: d9d6e77965b3 - main - tests/pf/igmp: fix attribute error with newer versions of scapy
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 27 Oct 2026 16:55:33 UTC
The branch main has been updated by siva:
URL: https://cgit.FreeBSD.org/src/commit/?id=d9d6e77965b32a8d2f9eeffd34e519a087e603e2
commit d9d6e77965b32a8d2f9eeffd34e519a087e603e2
Author: Siva Mahadevan <siva@FreeBSD.org>
AuthorDate: 2026-10-27 14:23:11 +0000
Commit: Siva Mahadevan <siva@FreeBSD.org>
CommitDate: 2026-10-27 16:54:20 +0000
tests/pf/igmp: fix attribute error with newer versions of scapy
This fixes the flaky testcase in CI[0].
While here:
* fix a typo in a comment
* remove an unnecessary import
* fix this deprecation warning:
/usr/local/lib/python3.12/site-packages/scapy/contrib/igmp.py:12:
DeprecationWarning: scapy.contrib.igmp is deprecated. Please use
scapy.layers.igmp instead !
[0] https://ci.freebsd.org/job/FreeBSD-main-amd64-test/29813/testReport/junit/sys.netpfil.pf.igmp/py/TestIGMP__test_ip_opts/
Reviewed by: kp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
---
tests/sys/netpfil/pf/igmp.py | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/tests/sys/netpfil/pf/igmp.py b/tests/sys/netpfil/pf/igmp.py
index 5d72a1c093a7..6f2a5066155d 100644
--- a/tests/sys/netpfil/pf/igmp.py
+++ b/tests/sys/netpfil/pf/igmp.py
@@ -54,11 +54,11 @@ class TestIGMP(VnetTestTemplate):
packets = self.sp.sniff(iface=ifname, timeout=5)
for r in packets:
r.show()
- igmp = r.getlayer(self.sc.igmp.IGMP)
+ igmp = r.getlayer(self.sl.igmp.IGMP)
if not igmp:
continue
igmp.show()
- if not igmp.gaddr == "230.0.0.1":
+ if getattr(igmp, 'gaddr', '0.0.0.0') != "230.0.0.1":
continue
found = True
return found
@@ -69,33 +69,32 @@ class TestIGMP(VnetTestTemplate):
"""Verify that we allow IGMP packets with IP options"""
ifname = self.vnet.iface_alias_map["if1"].name
- # Import in the correct vnet, so at to not confuse Scapy
+ # Import in the correct vnet, so as to not confuse Scapy
import scapy.all as sp
- import scapy.contrib as sc
- import scapy.contrib.igmp
+ import scapy.layers as sl
self.sp = sp
- self.sc = sc
+ self.sl = sl
# We allow IGMP packets with the router alert option
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=1,
options=[sp.IPOption_Router_Alert()]) \
- / sc.igmp.IGMP(type=0x11, mrcode=1)
+ / sl.igmp.IGMP(type=0x11, mrcode=1)
assert self.find_igmp_reply(pkt, ifname)
# But not with other options
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=1,
options=[sp.IPOption_NOP()]) \
- / sc.igmp.IGMP(type=0x11, mrcode=1)
+ / sl.igmp.IGMP(type=0x11, mrcode=1)
assert not self.find_igmp_reply(pkt, ifname)
# Or with the wrong TTL
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=2,
options=[sp.IPOption_Router_Alert()]) \
- / sc.igmp.IGMP(type=0x11, mrcode=1)
+ / sl.igmp.IGMP(type=0x11, mrcode=1)
assert not self.find_igmp_reply(pkt, ifname)
# Or with the wrong destination address
pkt = sp.IP(dst="224.0.0.2%%%s" % ifname, ttl=2,
options=[sp.IPOption_Router_Alert()]) \
- / sc.igmp.IGMP(type=0x11, mrcode=1)
+ / sl.igmp.IGMP(type=0x11, mrcode=1)
assert not self.find_igmp_reply(pkt, ifname)