netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Fix the arp error in some cases
@ 2020-06-17  2:07 guodeqing
  2020-06-17  3:10 ` David Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: guodeqing @ 2020-06-17  2:07 UTC (permalink / raw)
  To: davem; +Cc: kuznet, netdev, dsa, kuba, geffrey.guo

ie.,
$ ifconfig eth0 6.6.6.6 netmask 255.255.255.0

$ ip rule add from 6.6.6.6 table 6666

$ ip route add 9.9.9.9 via 6.6.6.6

$ ping -I 6.6.6.6 9.9.9.9
PING 9.9.9.9 (9.9.9.9) from 6.6.6.6 : 56(84) bytes of data.

3 packets transmitted, 0 received, 100% packet loss, time 2079ms

$ arp
Address     HWtype  HWaddress           Flags Mask            Iface
6.6.6.6             (incomplete)                              eth0

The arp request address is error, this is because fib_table_lookup in 
fib_check_nh lookup the destnation 9.9.9.9 nexthop, the scope of 
the fib result is RT_SCOPE_LINK,the correct scope is RT_SCOPE_HOST.  
Here I add a check of whether this is RT_TABLE_MAIN to solve this problem. 

Fixes: 3bfd847203c6("net: Use passed in table for nexthop lookups")
Signed-off-by: guodeqing <geffrey.guo@huawei.com>
---
 net/ipv4/fib_semantics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index e53871e..1f75dc6 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1109,7 +1109,7 @@ static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table,
 		if (fl4.flowi4_scope < RT_SCOPE_LINK)
 			fl4.flowi4_scope = RT_SCOPE_LINK;
 
-		if (table)
+		if (table && table != RT_TABLE_MAIN)
 			tbl = fib_get_table(net, table);
 
 		if (tbl)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: Fix the arp error in some cases
  2020-06-17  2:07 [PATCH] net: Fix the arp error in some cases guodeqing
@ 2020-06-17  3:10 ` David Ahern
  2020-06-17  3:38   ` 答复: " Guodeqing (A)
  0 siblings, 1 reply; 5+ messages in thread
From: David Ahern @ 2020-06-17  3:10 UTC (permalink / raw)
  To: guodeqing, davem; +Cc: kuznet, netdev, dsa, kuba

On 6/16/20 8:07 PM, guodeqing wrote:
> ie.,
> $ ifconfig eth0 6.6.6.6 netmask 255.255.255.0
> 
> $ ip rule add from 6.6.6.6 table 6666
> 
> $ ip route add 9.9.9.9 via 6.6.6.6
> 
> $ ping -I 6.6.6.6 9.9.9.9
> PING 9.9.9.9 (9.9.9.9) from 6.6.6.6 : 56(84) bytes of data.
> 
> 3 packets transmitted, 0 received, 100% packet loss, time 2079ms
> 
> $ arp
> Address     HWtype  HWaddress           Flags Mask            Iface
> 6.6.6.6             (incomplete)                              eth0
> 
> The arp request address is error, this is because fib_table_lookup in 
> fib_check_nh lookup the destnation 9.9.9.9 nexthop, the scope of 
> the fib result is RT_SCOPE_LINK,the correct scope is RT_SCOPE_HOST.  
> Here I add a check of whether this is RT_TABLE_MAIN to solve this problem.

fib_check_nh* is only used when the route is installed into the FIB to
verify the gateway is legit. It is not used when processing arp
requests. Why then, do you believe this fixes something?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 答复: [PATCH] net: Fix the arp error in some cases
  2020-06-17  3:10 ` David Ahern
@ 2020-06-17  3:38   ` Guodeqing (A)
  2020-06-17 12:44     ` David Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: Guodeqing (A) @ 2020-06-17  3:38 UTC (permalink / raw)
  To: David Ahern, davem; +Cc: kuznet, netdev, dsa, kuba

rt_set_nexthop in __mkroute_output will check the nh->nh_scope value to determine whether to use the gw or not.
		if (nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) {
			rt->rt_gateway = nh->nh_gw;
			rt->rt_uses_gateway = 1;
		}

(ip_route_output_key_hash-> ip_route_output_key_hash_rcu-> __mkroute_output-> rt_set_nexthop)

-----邮件原件-----
发件人: David Ahern [mailto:dsahern@gmail.com] 
发送时间: Wednesday, June 17, 2020 11:10
收件人: Guodeqing (A) <geffrey.guo@huawei.com>; davem@davemloft.net
抄送: kuznet@ms2.inr.ac.ru; netdev@vger.kernel.org; dsa@cumulusnetworks.com; kuba@kernel.org
主题: Re: [PATCH] net: Fix the arp error in some cases

On 6/16/20 8:07 PM, guodeqing wrote:
> ie.,
> $ ifconfig eth0 6.6.6.6 netmask 255.255.255.0
> 
> $ ip rule add from 6.6.6.6 table 6666
> 
> $ ip route add 9.9.9.9 via 6.6.6.6
> 
> $ ping -I 6.6.6.6 9.9.9.9
> PING 9.9.9.9 (9.9.9.9) from 6.6.6.6 : 56(84) bytes of data.
> 
> 3 packets transmitted, 0 received, 100% packet loss, time 2079ms
> 
> $ arp
> Address     HWtype  HWaddress           Flags Mask            Iface
> 6.6.6.6             (incomplete)                              eth0
> 
> The arp request address is error, this is because fib_table_lookup in 
> fib_check_nh lookup the destnation 9.9.9.9 nexthop, the scope of the 
> fib result is RT_SCOPE_LINK,the correct scope is RT_SCOPE_HOST.
> Here I add a check of whether this is RT_TABLE_MAIN to solve this problem.

fib_check_nh* is only used when the route is installed into the FIB to verify the gateway is legit. It is not used when processing arp requests. Why then, do you believe this fixes something?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 答复: [PATCH] net: Fix the arp error in some cases
  2020-06-17  3:38   ` 答复: " Guodeqing (A)
@ 2020-06-17 12:44     ` David Ahern
  0 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2020-06-17 12:44 UTC (permalink / raw)
  To: Guodeqing (A), davem; +Cc: kuznet, netdev, dsa, kuba

On 6/16/20 9:38 PM, Guodeqing (A) wrote:
> rt_set_nexthop in __mkroute_output will check the nh->nh_scope value to determine whether to use the gw or not.
> 		if (nh->nh_gw && nh->nh_scope == RT_SCOPE_LINK) {
> 			rt->rt_gateway = nh->nh_gw;
> 			rt->rt_uses_gateway = 1;
> 		}
> 
> (ip_route_output_key_hash-> ip_route_output_key_hash_rcu-> __mkroute_output-> rt_set_nexthop)
> 

ok, I see now. Thanks.


Reviewed-by: David Ahern <dsahern@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 答复: [PATCH] net: Fix the arp error in some cases
  2020-06-13 14:31 ` David Ahern
@ 2020-06-15  2:48   ` Guodeqing (A)
  0 siblings, 0 replies; 5+ messages in thread
From: Guodeqing (A) @ 2020-06-15  2:48 UTC (permalink / raw)
  To: David Ahern, davem; +Cc: kuznet, netdev, dsa, kuba



-----邮件原件-----
发件人: David Ahern [mailto:dsahern@gmail.com] 
发送时间: Saturday, June 13, 2020 22:32
收件人: Guodeqing (A) <geffrey.guo@huawei.com>; davem@davemloft.net
抄送: kuznet@ms2.inr.ac.ru; netdev@vger.kernel.org; dsa@cumulusnetworks.com; kuba@kernel.org
主题: Re: [PATCH] net: Fix the arp error in some cases

On 6/13/20 12:49 AM, guodeqing wrote:
> ie.,
> $ ifconfig eth0 6.6.6.6 netmask 255.255.255.0
> 
> $ ip rule add from 6.6.6.6 table 6666

without a default entry in table 6666 the lookup proceeds to the next table - which by default is the main table. 

---yes,if without the rule,this problem will not happen. 
  Follow the steps:
  $ ifconfig eth0 6.6.6.6 netmask 255.255.255.0
  $ ip route add 9.9.9.9 via 6.6.6.6
  $ ping -I 6.6.6.6 9.9.9.9
  And The arp request address is 9.9.9.9 and is right.(" gateway can be actually local interface address,
 *    so that gatewayed route is direct")

> 
> $ ip route add 9.9.9.9 via 6.6.6.6
> 
> $ ping -I 6.6.6.6 9.9.9.9
> PING 9.9.9.9 (9.9.9.9) from 6.6.6.6 : 56(84) bytes of data.
> 
> ^C
> --- 9.9.9.9 ping statistics ---
> 3 packets transmitted, 0 received, 100% packet loss, time 2079ms
> 
> $ arp
> Address     HWtype  HWaddress           Flags Mask            Iface
> 6.6.6.6             (incomplete)                              eth0
> 
> The arp request address is error, this problem can be reproduced easily.
> 
> Fixes: 3bfd847203c6("net: Use passed in table for nexthop lookups")
> Signed-off-by: guodeqing <geffrey.guo@huawei.com>
> ---
>  net/ipv4/fib_semantics.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 
> e53871e..1f75dc6 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -1109,7 +1109,7 @@ static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table,
>  		if (fl4.flowi4_scope < RT_SCOPE_LINK)
>  			fl4.flowi4_scope = RT_SCOPE_LINK;
>  
> -		if (table)
> +		if (table && table != RT_TABLE_MAIN)
>  			tbl = fib_get_table(net, table);
>  
>  		if (tbl)
> 

how does gateway validation when the route is installed affect arp resolution?

you are missing something in explaining the problem you are seeing.

-- This problem can only happen in some cases,this 3bfd847203c6 patch will do the main table lookup error in some cases, and I think it should not do the main table lookup because the next function fib_lookup does the maintable lookup.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-17 12:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17  2:07 [PATCH] net: Fix the arp error in some cases guodeqing
2020-06-17  3:10 ` David Ahern
2020-06-17  3:38   ` 答复: " Guodeqing (A)
2020-06-17 12:44     ` David Ahern
  -- strict thread matches above, loose matches on Subject: below --
2020-06-13  6:49 guodeqing
2020-06-13 14:31 ` David Ahern
2020-06-15  2:48   ` 答复: " Guodeqing (A)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).