net: Improve netns handling in rtnetlink
Status from this message: This series was applied to netdev/net-next.git (main)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v10 Latest13 patches 10 repliesApplied 13/13
- v911 patches 14 repliesSuperseded
- v811 patches 3 repliesSuperseded
Earlier versions · 7
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v7 | 11 patches | 7 replies | Superseded | |
| v6 | 11 patches | 2 replies | Superseded | |
| v5 | 5 patches | 4 replies | Superseded | |
| v4 | 5 patches | 1 reply | Superseded | |
| v3 | 6 patches | 1 reply | Superseded | |
| v2 | 8 patches | 17 replies | Superseded | |
| v1 | 5 patches | 8 replies | Superseded |
Changes in v10 from the cover letter
- Move link/peer net helper functions to from patch 02 to 03.
- Remove redundant tunnel->net assignment for IPv4 tunnels (patch 05).
- Initialize tunnel->net before calling register_netdevice() for IPv6 tunnels (patch 07).
- Coding style fixes.
Patches in v10 All 13 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/13 | rtnetlink: Lookup device in target netns when creating linknet/ | +8 | 0 replies | Applied |
| 2/13 | rtnetlink: Pack newlink() params into structdrivers/ drivers/ drivers/ +39 more | +223 | 1 reply | Applied |
| 3/13 | net: Use link/peer netns in newlink() of rtnl_link_opsdrivers/ drivers/ drivers/ +18 more | +58 | 0 replies | Applied |
| 4/13 | ieee802154: 6lowpan: Validate link netns in newlink() of rtnl_link_opsnet/ | +2 | 0 replies | Applied |
| 5/13 | net: ip_tunnel: Don't set tunnel->net in ip_tunnel_init()net/ | +0 | 1 reply | Applied |
| 6/13 | net: ip_tunnel: Use link netns in newlink() of rtnl_link_opsinclude/ net/ net/ +2 more | +15 | 1 reply | Applied |
| 7/13 | net: ipv6: Init tunnel link-netns before registering devnet/ net/ net/ +1 more | +9 | 2 replies | Applied |
| 8/13 | net: ipv6: Use link netns in newlink() of rtnl_link_opsnet/ net/ net/ +1 more | +17 | 1 reply | Applied |
| 9/13 | net: xfrm: Use link netns in newlink() of rtnl_link_opsnet/ | +4 | 1 reply | Applied |
| 10/13 | rtnetlink: Remove "net" from newlink paramsinclude/ net/ | +0 | 1 reply | Applied |
| 11/13 | rtnetlink: Create link directly in target net namespacenet/ | +2 | 1 reply | Applied |
| 12/13 | selftests: net: Add python context manager for netns enteringtools/ tools/ | +19 | 0 replies | Applied |
| 13/13 | selftests: net: Add test cases for link and peer netnstools/ tools/ tools/ +1 more | +157 | 0 replies | Applied |
Reviews trailers per patch
11 of 13 patches have a Reviewed-by or Acked-by.
| Patch | Kuniyuki Iwashima |
|---|---|
| 1/13 | R-b |
| 2/13 | R-b |
| 3/13 | R-b |
| 4/13 | R-b |
| 5/13 | R-b |
| 6/13 | R-b |
| 7/13 | R-b |
| 8/13 | R-b |
| 9/13 | R-b |
| 10/13 | R-b |
| 11/13 | R-b |
| 12/13 | |
| 13/13 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net-next v10 00/13] net: Improve netns handling in rtnetlink
This patch series includes some netns-related improvements and fixes for rtnetlink, to make link creation more intuitive:
1) Creating link in another net namespace doesn't conflict with link names in current one.
2) Refector rtnetlink link creation. Create link in target namespace directly.
So that
# ip link add netns ns1 link-netns ns2 tun0 type gre ...
will create tun0 in ns1, rather than create it in ns2 and move to ns1. And don't conflict with another interface named "tun0" in current netns.
Patch 01 avoids link name conflict in different netns.
To achieve 2), there're mainly 3 steps:
- Patch 02 packs newlink() parameters into a struct, including the original "src_net" along with more netns context. No semantic changes are introduced.
- Patch 03 ~ 09 converts device drivers to use the explicit netns extracted from params.
- Patch 10 ~ 11 removes the old netns parameter, and converts rtnetlink to create device in target netns directly.
Patch 12 ~ 13 adds some tests for link name and link netns.
---
BTW please note there're some issues found in current code:
- In amt_newlink() drivers/net/amt.c:
amt->net = net;
...
amt->stream_dev = dev_get_by_index(net, ... Uses net, but amt_lookup_upper_dev() only searches in dev_net. So the AMT device may not be properly deleted if it's in a different netns from lower dev.
- In lowpan_newlink() in net/ieee802154/6lowpan/core.c:
wdev = dev_get_by_index(dev_net(ldev), nla_get_u32(tb[IFLA_LINK]));
Looks for IFLA_LINK in dev_net, but in theory the ifindex is defined in link netns.
And thanks to Kuniyuki for fixing related issues in gtp and pfcp:
https://lore.kernel.org/netdev/[email protected]/
---
v10:
- Move link/peer net helper functions to from patch 02 to 03.
- Remove redundant tunnel->net assignment for IPv4 tunnels (patch 05).
- Initialize tunnel->net before calling register_netdevice() for IPv6 tunnels (patch 07).
- Coding style fixes.
v9:
- Change the prototype of macvlan_common_newlink().
- Minor fixes of coding style and local variables.
v8:
- Move dev and ext_ack out from param struct.
- Validate link_net and dev_net are identical for 6lowpan.
v7:
- Add selftest kconfig.
- Remove a duplicated test of ip6gre.
v6:
- Split prototype, driver and rtnetlink changes.
- Add more tests for link netns.
- Fix IPv6 tunnel net overwriten in ndo_init().
- Reorder variable declarations.
- Exclude a ip_tunnel-specific patch.
v5:
- Fix function doc in batman-adv.
- Include peer_net in rtnl newlink parameters.
v4:
- Pack newlink() parameters to a single struct.
- Use ynl async_msg_queue.empty() in selftest.
v3:
- Drop "netns_atomic" flag and module parameter. Add netns parameter to newlink() instead, and convert drivers accordingly.
- Move python NetNSEnter helper to net selftest lib.
v2:
- Check NLM_F_EXCL to ensure only link creation is affected.
- Add self tests for link name/ifindex conflict and notifications in different netns.
- Changes in dummy driver and ynl in order to add the test case.
v1:
Xiao Liang (13):
rtnetlink: Lookup device in target netns when creating link
rtnetlink: Pack newlink() params into struct
net: Use link/peer netns in newlink() of rtnl_link_ops
ieee802154: 6lowpan: Validate link netns in newlink() of rtnl_link_ops
net: ip_tunnel: Don't set tunnel->net in ip_tunnel_init()
net: ip_tunnel: Use link netns in newlink() of rtnl_link_ops
net: ipv6: Init tunnel link-netns before registering dev
net: ipv6: Use link netns in newlink() of rtnl_link_ops
net: xfrm: Use link netns in newlink() of rtnl_link_ops
rtnetlink: Remove "net" from newlink params
rtnetlink: Create link directly in target net namespace
selftests: net: Add python context manager for netns entering
selftests: net: Add test cases for link and peer netns
drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 9 +- drivers/net/amt.c | 11 +- drivers/net/bareudp.c | 9 +- drivers/net/bonding/bond_netlink.c | 6 +- drivers/net/can/dev/netlink.c | 4 +- drivers/net/can/vxcan.c | 7 +- .../ethernet/qualcomm/rmnet/rmnet_config.c | 9 +- drivers/net/geneve.c | 9 +- drivers/net/gtp.c | 10 +- drivers/net/ipvlan/ipvlan.h | 3 +- drivers/net/ipvlan/ipvlan_main.c | 8 +- drivers/net/ipvlan/ipvtap.c | 6 +- drivers/net/macsec.c | 9 +- drivers/net/macvlan.c | 21 +-- drivers/net/macvtap.c | 6 +- drivers/net/netkit.c | 14 +- drivers/net/pfcp.c | 9 +- drivers/net/ppp/ppp_generic.c | 9 +- drivers/net/team/team_core.c | 6 +- drivers/net/veth.c | 7 +- drivers/net/vrf.c | 5 +- drivers/net/vxlan/vxlan_core.c | 9 +- drivers/net/wireguard/device.c | 7 +- drivers/net/wireless/virtual/virt_wifi.c | 8 +- drivers/net/wwan/wwan_core.c | 16 +- include/linux/if_macvlan.h | 6 +- include/net/ip_tunnels.h | 5 +- include/net/rtnetlink.h | 40 ++++- net/8021q/vlan_netlink.c | 9 +- net/batman-adv/soft-interface.c | 9 +- net/bridge/br_netlink.c | 6 +- net/caif/chnl_net.c | 5 +- net/core/rtnetlink.c | 34 +++-- net/hsr/hsr_netlink.c | 12 +- net/ieee802154/6lowpan/core.c | 7 +- net/ipv4/ip_gre.c | 22 ++- net/ipv4/ip_tunnel.c | 7 +- net/ipv4/ip_vti.c | 9 +- net/ipv4/ipip.c | 9 +- net/ipv6/ip6_gre.c | 26 ++-- net/ipv6/ip6_tunnel.c | 18 ++- net/ipv6/ip6_vti.c | 14 +- net/ipv6/sit.c | 20 ++- net/xfrm/xfrm_interface_core.c | 15 +- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/config | 5 + .../testing/selftests/net/lib/py/__init__.py | 2 +- tools/testing/selftests/net/lib/py/netns.py | 18 +++ tools/testing/selftests/net/link_netns.py | 141 ++++++++++++++++++ tools/testing/selftests/net/netns-name.sh | 10 ++ 50 files changed, 486 insertions(+), 181 deletions(-) create mode 100755 tools/testing/selftests/net/link_netns.py
Signature · 1 line
2.48.1