Skip to content

Commit 114ad9a

Browse files
authored
Fix conf.route.route() on linux (#4753)
1 parent 15c632d commit 114ad9a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

scapy/route.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def route(self, dst=None, dev=None, verbose=conf.verb, _internal=False):
203203
if dev is not None and i != dev:
204204
continue
205205
aa = atol(a)
206-
if aa == atol_dst:
206+
if aa == atol_dst and aa != 0:
207207
paths.append(
208208
(0xffffffff, 1, (conf.loopback_name, a, "0.0.0.0")) # noqa: E501
209209
)

test/regression.uts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ finally:
18401840
sck.close()
18411841

18421842
= Sending and receiving an ICMPv6EchoRequest
1843-
~ netaccess ipv6
1843+
~ netaccess ipv6 needs_root
18441844
def _test():
18451845
with no_debug_dissector():
18461846
x = sr1(IPv6(dst="www.google.com")/ICMPv6EchoRequest(),timeout=3)
@@ -3414,13 +3414,13 @@ try:
34143414
(3232235775, 4294967295, '0.0.0.0', 'enp3s0', '2.2.2.2', 281),
34153415
(3232235639, 4294967295, '0.0.0.0', 'enp3s0', '3.3.3.3', 281),
34163416
(3232235520, 4294967040, '0.0.0.0', 'enp3s0', '4.4.4.4', 281),
3417-
(0, 0, '192.168.0.254', 'enp3s0', '192.168.0.119', 25)
3417+
(0, 0, '192.168.0.254', 'enp3s0', '0.0.0.0', 25)
34183418
]
34193419
assert conf.route.route("192.168.0.0-10") == ('enp3s0', '4.4.4.4', '0.0.0.0')
34203420
assert conf.route.route("192.168.0.119") == ('lo', '192.168.0.119', '0.0.0.0')
34213421
assert conf.route.route("224.0.0.0") == ('enp3s0', '1.1.1.1', '0.0.0.0')
34223422
assert conf.route.route("255.255.255.255") == ('enp3s0', '192.168.0.119', '0.0.0.0')
3423-
assert conf.route.route("*") == ('enp3s0', '192.168.0.119', '192.168.0.254')
3423+
assert conf.route.route("*") == ('enp3s0', '4.4.4.4', '192.168.0.254')
34243424
finally:
34253425
conf.loopback_name = old_loopback
34263426
conf.iface = old_iface

0 commit comments

Comments
 (0)