Skip to content

Commit

Permalink
tests: partial revert of 4627bc1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glebius committed Sep 7, 2022
1 parent 1f7a710 commit 322b5b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/sys/common/divert.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import argparse


PF_DIVERT = 44
IPPROTO_DIVERT = 258


def parse_args():
Expand All @@ -52,22 +52,22 @@ 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))


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))

Expand Down

0 comments on commit 322b5b7

Please sign in to comment.