git: 322b5b7c1666 - main - tests: partial revert of 4627bc1e90fd17c8d4f44de6b932d456b67661fc

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 07 Sep 2022 03:55:34 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=322b5b7c16666c40d2763f18c1a51e6f0580d4e9

commit 322b5b7c16666c40d2763f18c1a51e6f0580d4e9
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-09-07 03:54:49 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-09-07 03:54:49 +0000

    tests: partial revert of 4627bc1e90fd17c8d4f44de6b932d456b67661fc
    
    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.
---
 tests/sys/common/divert.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/sys/common/divert.py b/tests/sys/common/divert.py
index 44b1f49ae13f..94e20a03571f 100755
--- a/tests/sys/common/divert.py
+++ b/tests/sys/common/divert.py
@@ -36,7 +36,7 @@ import scapy.all as sc
 import argparse
 
 
-PF_DIVERT = 44
+IPPROTO_DIVERT = 258
 
 
 def parse_args():
@@ -52,14 +52,14 @@ def parse_args():
 
 def ipdivert_ip_output_remote_success(args):
     packet = sc.IP(dst=args.dip) / sc.ICMP(type='echo-request')
-    with socket.socket(PF_DIVERT, socket.SOCK_RAW, 0) as s:
+    with socket.socket(socket.AF_INET, socket.SOCK_RAW, IPPROTO_DIVERT) as s:
         s.bind(('0.0.0.0', args.divert_port))
         s.sendto(bytes(packet), ('0.0.0.0', 0))
 
 
 def ipdivert_ip6_output_remote_success(args):
     packet = sc.IPv6(dst=args.dip) / sc.ICMPv6EchoRequest()
-    with socket.socket(PF_DIVERT, socket.SOCK_RAW, 0) as s:
+    with socket.socket(socket.AF_INET, socket.SOCK_RAW, IPPROTO_DIVERT) as s:
         s.bind(('0.0.0.0', args.divert_port))
         s.sendto(bytes(packet), ('0.0.0.0', 0))
 
@@ -67,7 +67,7 @@ def ipdivert_ip6_output_remote_success(args):
 def ipdivert_ip_input_local_success(args):
     """Sends IPv4 packet to OS stack as inbound local packet."""
     packet = sc.IP(dst=args.dip,src=args.sip) / sc.ICMP(type='echo-request')
-    with socket.socket(PF_DIVERT, socket.SOCK_RAW, 0) as s:
+    with socket.socket(socket.AF_INET, socket.SOCK_RAW, IPPROTO_DIVERT) as s:
         s.bind(('0.0.0.0', args.divert_port))
         s.sendto(bytes(packet), (args.dip, 0))