Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jan 2021 22:18:48 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 63fb868d2913 - stable/12 - Follow r354121 to fix some python3 errors in sys.netpfil.*
Message-ID:  <202101032218.103MImm2020371@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=63fb868d2913d5cb4efcc123eb57fe0287837758

commit 63fb868d2913d5cb4efcc123eb57fe0287837758
Author:     Li-Wen Hsu <lwhsu@FreeBSD.org>
AuthorDate: 2019-10-27 21:07:50 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-01-03 20:26:50 +0000

    Follow r354121 to fix some python3 errors in sys.netpfil.*
    
    stderr:
    
    Traceback (most recent call last):
      File "/usr/tests/sys/netpfil/common/pft_ping.py", line 135, in <module>
        main()
      File "/usr/tests/sys/netpfil/common/pft_ping.py", line 124, in main
        ping(args.sendif[0], args.to[0], args)
      File "/usr/tests/sys/netpfil/common/pft_ping.py", line 74, in ping
        raw = sp.raw(str(PAYLOAD_MAGIC))
      File "/usr/local/lib/python3.6/site-packages/scapy/compat.py", line 52, in raw
        return bytes(x)
    TypeError: string argument without an encoding
    
    MFC with:       r354121
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit cfa8b6482740b2be1719d51e927f76b4adec3b92)
---
 tests/sys/netpfil/common/pft_ping.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/sys/netpfil/common/pft_ping.py b/tests/sys/netpfil/common/pft_ping.py
index da8edd9f7b63..89cb3e1a5d01 100644
--- a/tests/sys/netpfil/common/pft_ping.py
+++ b/tests/sys/netpfil/common/pft_ping.py
@@ -5,7 +5,7 @@ import scapy.all as sp
 import sys
 from sniffer import Sniffer
 
-PAYLOAD_MAGIC = 0x42c0ffee
+PAYLOAD_MAGIC = bytes.fromhex('42c0ffee')
 
 def check_ping_request(args, packet):
 	if args.ip6:
@@ -34,7 +34,7 @@ def check_ping4_request(args, packet):
 	raw = packet.getlayer(sp.Raw)
 	if not raw:
 		return False
-	if int(raw.load) != PAYLOAD_MAGIC:
+	if raw.load != PAYLOAD_MAGIC:
 		return False
 
 	# Wait to check expectations until we've established this is the packet we
@@ -62,7 +62,7 @@ def check_ping6_request(args, packet):
 	icmp = packet.getlayer(sp.ICMPv6EchoRequest)
 	if not icmp:
 		return False
-	if int(icmp.data) != PAYLOAD_MAGIC:
+	if icmp.data != PAYLOAD_MAGIC:
 		return False
 
 	return True
@@ -71,7 +71,7 @@ def ping(send_if, dst_ip, args):
 	ether = sp.Ether()
 	ip = sp.IP(dst=dst_ip)
 	icmp = sp.ICMP(type='echo-request')
-	raw = sp.raw(str(PAYLOAD_MAGIC))
+	raw = sp.raw(PAYLOAD_MAGIC)
 
 	if args.send_tos:
 		ip.tos = int(args.send_tos[0])
@@ -82,7 +82,7 @@ def ping(send_if, dst_ip, args):
 def ping6(send_if, dst_ip, args):
 	ether = sp.Ether()
 	ip6 = sp.IPv6(dst=dst_ip)
-	icmp = sp.ICMPv6EchoRequest(data=sp.raw(str(PAYLOAD_MAGIC)))
+	icmp = sp.ICMPv6EchoRequest(data=sp.raw(PAYLOAD_MAGIC))
 
 	req = ether / ip6 / icmp
 	sp.sendp(req, iface=send_if, verbose=False)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101032218.103MImm2020371>