Skip to content

Fix conf.route.route() on linux #4753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scapy/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
6 changes: 3 additions & 3 deletions test/regression.uts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading