[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d67662fc-cdd1-4f48-87b6-40da838fea32@huawei.com>
Date: Thu, 27 Nov 2025 14:42:00 +0300
From: Dmitry Skorodumov <skorodumov.dmitry@...wei.com>
To: Paolo Abeni <pabeni@...hat.com>, <netdev@...r.kernel.org>, Kuniyuki
Iwashima <kuniyu@...gle.com>, Xiao Liang <shaw.leon@...il.com>, Jakub
Kicinski <kuba@...nel.org>, Julian Vetter <julian@...er-limits.org>, Ido
Schimmel <idosch@...dia.com>, Guillaume Nault <gnault@...hat.com>, Eric
Dumazet <edumazet@...gle.com>, Stanislav Fomichev <sdf@...ichev.me>, Etienne
Champetier <champetier.etienne@...il.com>, <linux-kernel@...r.kernel.org>
CC: <andrey.bokhanko@...wei.com>, Andrew Lunn <andrew+netdev@...n.ch>, "David
S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH net-next 07/12] ipvlan: Don't allow children to use IPs of
main
On 25.11.2025 17:26, Paolo Abeni wrote:
> On 11/20/25 6:49 PM, Dmitry Skorodumov wrote:
>> Remember all ip-addresses on main iface and check
>> in ipvlan_addr_busy() that addr is not used on main.
> Why?
>
> Why using in_dev_for_each_ifa_rcu()/in6_dev->addr_list is not good enough?
>
> Note that IP addtion on the main interface can race with
> ipvlan_addr_busy() even with the code you are proposing.
>
Hm.. I don't see lt:
the ipvlan_port_add_addr_event(addr) does { ipvlan_port_add_addr(addr); ipvlan_port_del_addr_ipvlans(addr); }
ipvlan_port_add_addr(addr) { lock(addrs_lock); list_add(addr); unlock(addrs_lock);}
ipvlan_port_del_addr_ipvlans(addr) { lock(addrs_lock); for_each_ipvlan ipvlan_del_addr(ipvlan, addr); unlock(addrs_lock);}
ipvlan_macnat_addr_learn(addr); { lock(addrs_lock); if !ipvlan_addr_busy(): ipvlan_remember(addr); unlock(addrs_lock); }
There is a small window when addr can be remembered on ipvlan. But with the next step in ipvlan_port_add_addr_event(), it will be cleaned up with ipvlan_port_del_addr_ipvlans()
The idea is "it is ok to allow few packets to pass the protection, but don't allow this address be white-listed for forever"
===
I tried first in_dev_for_each_ifa_rcu(), instead of remembering on main iface, but it's not easy to invent synchronization mechanic for this..
if in ipvlan_macnat_addr_learn() we Start -> (1) iterated through in_dev_for_each_ifa_rcu(); found that address is not used and (2) remembered it on ipvlan -> (3) End
there is no way how ipvlan_port_add_addr() can ensure without locks: we can be in the [1-2] stage in addr_learn. And if we try to call ipvlan_del_addr() - again, we can be in the [1-2] stage in addr_learn
may be we could
in ipvlan_macnat_addr_learn()
Start -> (1) iterated through in_dev_for_each_ifa_rcu(); found that address is not used and (2) remembered it on ipvlan -> (3) reiterate again through in_dev_for_each_ifa_rcu() -> End
but I think the code becomes overcomplicated with this
Dmitry
Powered by blists - more mailing lists