2019-09-04 07:41:18

by Su, Yanjun

[permalink] [raw]
Subject: [PATCH net] ipv4: fix ifa_flags reuse problem in using ifconfig tool

When NetworkManager has already set ipv4 address then uses
ifconfig set another ipv4 address. It will use previous ifa_flags
that will cause device route not be inserted.

As NetworkManager has already support IFA_F_NOPREFIXROUTE flag [1],
but ifconfig will reuse the ifa_flags. It's weird especially
some old scripts or program [2] still use ifconfig.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/
commit/fec80e7473ad16979af75ed299d68103e7aa3fe9

[2] LTP or TAHI

Signed-off-by: Su Yanjun <[email protected]>
---
net/ipv4/devinet.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index a4b5bd4..56ca339 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1159,6 +1159,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
inet_del_ifa(in_dev, ifap, 0);
ifa->ifa_broadcast = 0;
ifa->ifa_scope = 0;
+ ifa->ifa_flags = 0;
}

ifa->ifa_address = ifa->ifa_local = sin->sin_addr.s_addr;
--
2.7.4




2019-09-05 12:15:48

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net] ipv4: fix ifa_flags reuse problem in using ifconfig tool

From: Su Yanjun <[email protected]>
Date: Wed, 4 Sep 2019 15:37:47 +0800

> When NetworkManager has already set ipv4 address then uses
> ifconfig set another ipv4 address. It will use previous ifa_flags
> that will cause device route not be inserted.
>
> As NetworkManager has already support IFA_F_NOPREFIXROUTE flag [1],
> but ifconfig will reuse the ifa_flags. It's weird especially
> some old scripts or program [2] still use ifconfig.
>
> [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/
> commit/fec80e7473ad16979af75ed299d68103e7aa3fe9
>
> [2] LTP or TAHI
>
> Signed-off-by: Su Yanjun <[email protected]>

I don't know about this.

This will lose things like IFA_F_SECONDARY as well.

Sorry, I am not convinced that this change is correct nor safe.