Skip to content

Commit eb55dc0

Browse files
NicolasDichtelkuba-moo
authored andcommitted
ip: fix triggering of 'icmp redirect'
__mkroute_input() uses fib_validate_source() to trigger an icmp redirect. My understanding is that fib_validate_source() is used to know if the src address and the gateway address are on the same link. For that, fib_validate_source() returns 1 (same link) or 0 (not the same network). __mkroute_input() is the only user of these positive values, all other callers only look if the returned value is negative. Since the below patch, fib_validate_source() didn't return anymore 1 when both addresses are on the same network, because the route lookup returns RT_SCOPE_LINK instead of RT_SCOPE_HOST. But this is, in fact, right. Let's adapat the test to return 1 again when both addresses are on the same link. CC: [email protected] Fixes: 747c143 ("ip: fix dflt addr selection for connected nexthop") Reported-by: kernel test robot <[email protected]> Reported-by: Heng Qi <[email protected]> Signed-off-by: Nicolas Dichtel <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 90fabae commit eb55dc0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/fib_frontend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
389389
dev_match = dev_match || (res.type == RTN_LOCAL &&
390390
dev == net->loopback_dev);
391391
if (dev_match) {
392-
ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST;
392+
ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_LINK;
393393
return ret;
394394
}
395395
if (no_addr)
@@ -401,7 +401,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
401401
ret = 0;
402402
if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) {
403403
if (res.type == RTN_UNICAST)
404-
ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_HOST;
404+
ret = FIB_RES_NHC(res)->nhc_scope >= RT_SCOPE_LINK;
405405
}
406406
return ret;
407407

0 commit comments

Comments
 (0)