Thread (23 messages) 23 messages, 2 authors, 2025-12-02

Re: [PATCH net-next 07/12] ipvlan: Don't allow children to use IPs of main

From: Dmitry Skorodumov <hidden>
Date: 2025-11-27 11:42:03
Also in: lkml

On 25.11.2025 17:26, Paolo Abeni wrote:
On 11/20/25 6:49 PM, Dmitry Skorodumov wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help