netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ipv4:the same route is added repeatedly
@ 2023-03-14 14:41 gaoxingwang
  2023-03-14 17:12 ` Ido Schimmel
  0 siblings, 1 reply; 4+ messages in thread
From: gaoxingwang @ 2023-03-14 14:41 UTC (permalink / raw)
  To: netdev, linux-kernel, davem, yoshfuji, kuba
  Cc: pabeni, shuah, liaichun, yanan

When i add default route in /etc/sysconfig/static-routes, and then restart network service, it appears to add two same default route:
[root@localhost ~]# ip r
default via 9.82.0.1 dev eth0 
default via 9.82.0.1 dev eth0 

The static-routes file contents are as follows:
any net 0.0.0.0 netmask 0.0.0.0 gw 110.1.62.1

This problem seems to be related to patch f96a3d7455(ipv4: Fix incorrect route flushing when source address is deleted). When I revert this patch, the problem gets fixed.
Is that a known issue?

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

* Re: ipv4:the same route is added repeatedly
  2023-03-14 14:41 ipv4:the same route is added repeatedly gaoxingwang
@ 2023-03-14 17:12 ` Ido Schimmel
  2023-03-15  7:43   ` gaoxingwang
  0 siblings, 1 reply; 4+ messages in thread
From: Ido Schimmel @ 2023-03-14 17:12 UTC (permalink / raw)
  To: gaoxingwang
  Cc: netdev, linux-kernel, davem, yoshfuji, kuba, pabeni, shuah,
	liaichun, yanan

On Tue, Mar 14, 2023 at 10:41:59PM +0800, gaoxingwang wrote:
> When i add default route in /etc/sysconfig/static-routes, and then restart network service, it appears to add two same default route:
> [root@localhost ~]# ip r
> default via 9.82.0.1 dev eth0 
> default via 9.82.0.1 dev eth0 
> 
> The static-routes file contents are as follows:
> any net 0.0.0.0 netmask 0.0.0.0 gw 110.1.62.1
> 
> This problem seems to be related to patch f96a3d7455(ipv4: Fix incorrect route flushing when source address is deleted). When I revert this patch, the problem gets fixed.
> Is that a known issue?

'fi->fib_tb_id' is initialized from 'cfg->fc_table' which is not
initialized in the IOCTL path which I guess is what you are using given
the syntax of the file. You can therefore end up having two identical
routes that only differ in their FIB info due to its associated table
ID.

Can you try this fix [1]? Seems to be working for me. Tested using this
reproducer [2].

With f96a3d7455:

 # ./ioctl_repro.sh
 default via 192.0.2.2 dev dummy10
 default via 192.0.2.2 dev dummy10

With f96a3d7455 reverted:

 # ./ioctl_repro.sh
 SIOCADDRT: File exists
 default via 192.0.2.2 dev dummy10

With the fix:

 # ./ioctl_repro.sh
 SIOCADDRT: File exists
 default via 192.0.2.2 dev dummy10

Thanks

[1]
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index b5736ef16ed2..390f4be7f7be 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -576,6 +576,9 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
 			cfg->fc_scope = RT_SCOPE_UNIVERSE;
 	}
 
+	if (!cfg->fc_table)
+		cfg->fc_table = RT_TABLE_MAIN;
+
 	if (cmd == SIOCDELRT)
 		return 0;
 
[2]
#!/bin/bash

ip link del dev dummy10 &> /dev/null
ip link add name dummy10 up type dummy
ip address add 192.0.2.1/24 dev dummy10

ip route add default via 192.0.2.2
route add default gw 192.0.2.2
ip -4 r show default

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

* Re: ipv4:the same route is added repeatedly
  2023-03-14 17:12 ` Ido Schimmel
@ 2023-03-15  7:43   ` gaoxingwang
  2023-03-15  8:54     ` Ido Schimmel
  0 siblings, 1 reply; 4+ messages in thread
From: gaoxingwang @ 2023-03-15  7:43 UTC (permalink / raw)
  To: idosch
  Cc: davem, gaoxingwang1, kuba, liaichun, linux-kernel, netdev, pabeni,
	shuah, yanan, yoshfuji

> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index b5736ef16ed2..390f4be7f7be 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -576,6 +576,9 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
>  			cfg->fc_scope = RT_SCOPE_UNIVERSE;
>  	}
>  
> +	if (!cfg->fc_table)
> +		cfg->fc_table = RT_TABLE_MAIN;
> +
>  	if (cmd == SIOCDELRT)
>  		return 0;
Thanks for you reply.This patch works for me.
Can you submit a patch? Hope the problem will be fixed as soon as possible. 

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

* Re: ipv4:the same route is added repeatedly
  2023-03-15  7:43   ` gaoxingwang
@ 2023-03-15  8:54     ` Ido Schimmel
  0 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2023-03-15  8:54 UTC (permalink / raw)
  To: gaoxingwang
  Cc: davem, kuba, liaichun, linux-kernel, netdev, pabeni, shuah, yanan,
	yoshfuji

On Wed, Mar 15, 2023 at 03:43:10PM +0800, gaoxingwang wrote:
> Thanks for you reply.This patch works for me.

Thanks for testing.

> Can you submit a patch? Hope the problem will be fixed as soon as possible. 

Yes, I will send a patch.

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

end of thread, other threads:[~2023-03-15  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-14 14:41 ipv4:the same route is added repeatedly gaoxingwang
2023-03-14 17:12 ` Ido Schimmel
2023-03-15  7:43   ` gaoxingwang
2023-03-15  8:54     ` Ido Schimmel

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).