mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
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
This commit is contained in:
1 parent
eca7cba74c
commit
d9d6e77965
1 file changed
+9
-10
@@ -54,11 +54,11 @@ class TestIGMP(VnetTestTemplate):
|
|||||||
packets = self.sp.sniff(iface=ifname, timeout=5)
|
packets = self.sp.sniff(iface=ifname, timeout=5)
|
||||||
for r in packets:
|
for r in packets:
|
||||||
r.show()
|
r.show()
|
||||||
igmp = r.getlayer(self.sc.igmp.IGMP)
|
igmp = r.getlayer(self.sl.igmp.IGMP)
|
||||||
if not igmp:
|
if not igmp:
|
||||||
continue
|
continue
|
||||||
igmp.show()
|
igmp.show()
|
||||||
if not igmp.gaddr == "230.0.0.1":
|
if getattr(igmp, 'gaddr', '0.0.0.0') != "230.0.0.1":
|
||||||
continue
|
continue
|
||||||
found = True
|
found = True
|
||||||
return found
|
return found
|
||||||
@@ -69,33 +69,32 @@ class TestIGMP(VnetTestTemplate):
|
|||||||
"""Verify that we allow IGMP packets with IP options"""
|
"""Verify that we allow IGMP packets with IP options"""
|
||||||
ifname = self.vnet.iface_alias_map["if1"].name
|
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.all as sp
|
||||||
import scapy.contrib as sc
|
import scapy.layers as sl
|
||||||
import scapy.contrib.igmp
|
|
||||||
self.sp = sp
|
self.sp = sp
|
||||||
self.sc = sc
|
self.sl = sl
|
||||||
|
|
||||||
# We allow IGMP packets with the router alert option
|
# We allow IGMP packets with the router alert option
|
||||||
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=1,
|
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=1,
|
||||||
options=[sp.IPOption_Router_Alert()]) \
|
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)
|
assert self.find_igmp_reply(pkt, ifname)
|
||||||
|
|
||||||
# But not with other options
|
# But not with other options
|
||||||
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=1,
|
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=1,
|
||||||
options=[sp.IPOption_NOP()]) \
|
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)
|
assert not self.find_igmp_reply(pkt, ifname)
|
||||||
|
|
||||||
# Or with the wrong TTL
|
# Or with the wrong TTL
|
||||||
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=2,
|
pkt = sp.IP(dst="224.0.0.1%%%s" % ifname, ttl=2,
|
||||||
options=[sp.IPOption_Router_Alert()]) \
|
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)
|
assert not self.find_igmp_reply(pkt, ifname)
|
||||||
|
|
||||||
# Or with the wrong destination address
|
# Or with the wrong destination address
|
||||||
pkt = sp.IP(dst="224.0.0.2%%%s" % ifname, ttl=2,
|
pkt = sp.IP(dst="224.0.0.2%%%s" % ifname, ttl=2,
|
||||||
options=[sp.IPOption_Router_Alert()]) \
|
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)
|
assert not self.find_igmp_reply(pkt, ifname)
|
||||||
Reference in new issue
Block a user