From a10090f1257b19f4c4e451dac2483d2d94c1b925 Mon Sep 17 00:00:00 2001 From: gpotter2 <10530980+gpotter2@users.noreply.github.com> Date: Thu, 29 May 2025 16:55:41 +0200 Subject: [PATCH] Fix conf.route.route() on linux --- scapy/route.py | 2 +- test/regression.uts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scapy/route.py b/scapy/route.py index 9e078bfbbc7..3c2227be834 100644 --- a/scapy/route.py +++ b/scapy/route.py @@ -203,7 +203,7 @@ def route(self, dst=None, dev=None, verbose=conf.verb, _internal=False): if dev is not None and i != dev: continue aa = atol(a) - if aa == atol_dst: + if aa == atol_dst and aa != 0: paths.append( (0xffffffff, 1, (conf.loopback_name, a, "0.0.0.0")) # noqa: E501 ) diff --git a/test/regression.uts b/test/regression.uts index 5fe21e23219..a057f80d6ba 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -1840,7 +1840,7 @@ finally: sck.close() = Sending and receiving an ICMPv6EchoRequest -~ netaccess ipv6 +~ netaccess ipv6 needs_root def _test(): with no_debug_dissector(): x = sr1(IPv6(dst="www.google.com")/ICMPv6EchoRequest(),timeout=3) @@ -3414,13 +3414,13 @@ try: (3232235775, 4294967295, '0.0.0.0', 'enp3s0', '2.2.2.2', 281), (3232235639, 4294967295, '0.0.0.0', 'enp3s0', '3.3.3.3', 281), (3232235520, 4294967040, '0.0.0.0', 'enp3s0', '4.4.4.4', 281), - (0, 0, '192.168.0.254', 'enp3s0', '192.168.0.119', 25) + (0, 0, '192.168.0.254', 'enp3s0', '0.0.0.0', 25) ] assert conf.route.route("192.168.0.0-10") == ('enp3s0', '4.4.4.4', '0.0.0.0') assert conf.route.route("192.168.0.119") == ('lo', '192.168.0.119', '0.0.0.0') assert conf.route.route("224.0.0.0") == ('enp3s0', '1.1.1.1', '0.0.0.0') assert conf.route.route("255.255.255.255") == ('enp3s0', '192.168.0.119', '0.0.0.0') - assert conf.route.route("*") == ('enp3s0', '192.168.0.119', '192.168.0.254') + assert conf.route.route("*") == ('enp3s0', '4.4.4.4', '192.168.0.254') finally: conf.loopback_name = old_loopback conf.iface = old_iface