Skip to content

Commit 322b5b7

Browse files
committed
tests: partial revert of 4627bc1
Python's socketmodule isn't able to construct sockaddr when it doesn't recognize the address family. Until this is solved in python let the tests use the compatibility way to create divert(4) socket.
1 parent 1f7a710 commit 322b5b7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/sys/common/divert.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import argparse
3737

3838

39-
PF_DIVERT = 44
39+
IPPROTO_DIVERT = 258
4040

4141

4242
def parse_args():
@@ -52,22 +52,22 @@ def parse_args():
5252

5353
def ipdivert_ip_output_remote_success(args):
5454
packet = sc.IP(dst=args.dip) / sc.ICMP(type='echo-request')
55-
with socket.socket(PF_DIVERT, socket.SOCK_RAW, 0) as s:
55+
with socket.socket(socket.AF_INET, socket.SOCK_RAW, IPPROTO_DIVERT) as s:
5656
s.bind(('0.0.0.0', args.divert_port))
5757
s.sendto(bytes(packet), ('0.0.0.0', 0))
5858

5959

6060
def ipdivert_ip6_output_remote_success(args):
6161
packet = sc.IPv6(dst=args.dip) / sc.ICMPv6EchoRequest()
62-
with socket.socket(PF_DIVERT, socket.SOCK_RAW, 0) as s:
62+
with socket.socket(socket.AF_INET, socket.SOCK_RAW, IPPROTO_DIVERT) as s:
6363
s.bind(('0.0.0.0', args.divert_port))
6464
s.sendto(bytes(packet), ('0.0.0.0', 0))
6565

6666

6767
def ipdivert_ip_input_local_success(args):
6868
"""Sends IPv4 packet to OS stack as inbound local packet."""
6969
packet = sc.IP(dst=args.dip,src=args.sip) / sc.ICMP(type='echo-request')
70-
with socket.socket(PF_DIVERT, socket.SOCK_RAW, 0) as s:
70+
with socket.socket(socket.AF_INET, socket.SOCK_RAW, IPPROTO_DIVERT) as s:
7171
s.bind(('0.0.0.0', args.divert_port))
7272
s.sendto(bytes(packet), (args.dip, 0))
7373

0 commit comments

Comments
 (0)