netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 00/12] net: iflink and link-netnsid fixes
@ 2020-10-01  7:59 Sabrina Dubroca
  2020-10-01  7:59 ` [PATCH net 01/12] ipvlan: add get_link_net Sabrina Dubroca
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Sabrina Dubroca @ 2020-10-01  7:59 UTC (permalink / raw)
  To: netdev
  Cc: Sabrina Dubroca, Nicolas Dichtel, Marek Lindner, Simon Wunderlich,
	Antonio Quartulli, Sven Eckelmann, b.a.t.m.a.n, Roopa Prabhu,
	Nikolay Aleksandrov

In a lot of places, we use this kind of comparison to detect if a
device has a lower link:

  dev->ifindex != dev_get_iflink(dev)

This seems to be a leftover of the pre-netns days, when the ifindex
was unique over the whole system. Nowadays, with network namespaces,
it's very easy to create a device with the same ifindex as its lower
link:

    ip netns add main
    ip netns add peer
    ip -net main link add dummy0 type dummy
    ip -net main link add link dummy0 macvlan0 netns peer type macvlan
    ip -net main link show type dummy
        9: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop ...
    ip -net peer link show type macvlan
        9: macvlan0@if9: <BROADCAST,MULTICAST> mtu 1500 qdisc noop ...

To detect if a device has a lower link, we can simply check the
existence of the dev->netdev_ops->ndo_get_iflink operation, instead of
checking its return value. In particular, I attempted to fix one of
these checks in commit feadc4b6cf42 ("rtnetlink: always put IFLA_LINK
for links with a link-netnsid"), but this patch isn't correct, since
tunnel devices can export IFLA_LINK_NETNSID without IFLA_LINK. That
patch needs to be reverted.

This series will fix all those bogus comparisons, and export missing
IFLA_LINK_NETNSID attributes in bridge and ipv6 dumps.

ipvlan and geneve are also missing the get_link_net operation, so
userspace can't know when those device are cross-netns. There are a
couple of other device types that have an ndo_get_iflink op but no
get_link_net (virt_wifi, ipoib), and should probably also have a
get_link_net.

Sabrina Dubroca (12):
  ipvlan: add get_link_net
  geneve: add get_link_net
  Revert "rtnetlink: always put IFLA_LINK for links with a link-netnsid"
  rtnetlink: always put IFLA_LINK for links with ndo_get_iflink
  bridge: always put IFLA_LINK for ports with ndo_get_iflink
  bridge: advertise IFLA_LINK_NETNSID when dumping bridge ports
  ipv6: always put IFLA_LINK for devices with ndo_get_iflink
  ipv6: advertise IFLA_LINK_NETNSID when dumping ipv6 addresses
  net: link_watch: fix operstate when the link has the same index as the
    device
  net: link_watch: fix detection of urgent events
  batman-adv: fix iflink detection in batadv_is_on_batman_iface
  batman-adv: fix detection of lower link in batadv_get_real_netdevice

 drivers/net/can/vxcan.c          |  2 +-
 drivers/net/geneve.c             |  8 ++++++++
 drivers/net/ipvlan/ipvlan_main.c |  9 +++++++++
 drivers/net/veth.c               |  2 +-
 include/net/rtnetlink.h          |  4 ++++
 net/batman-adv/hard-interface.c  |  4 ++--
 net/bridge/br_netlink.c          |  4 +++-
 net/core/link_watch.c            |  4 ++--
 net/core/rtnetlink.c             | 25 ++++++++++++-------------
 net/ipv6/addrconf.c              | 11 ++++++++++-
 10 files changed, 52 insertions(+), 21 deletions(-)

-- 
2.28.0


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

end of thread, other threads:[~2022-05-14 10:21 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-01  7:59 [PATCH net 00/12] net: iflink and link-netnsid fixes Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 01/12] ipvlan: add get_link_net Sabrina Dubroca
2020-10-01  8:19   ` Eric Dumazet
2020-10-01  7:59 ` [PATCH net 02/12] geneve: " Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 03/12] Revert "rtnetlink: always put IFLA_LINK for links with a link-netnsid" Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 04/12] rtnetlink: always put IFLA_LINK for links with ndo_get_iflink Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 05/12] bridge: always put IFLA_LINK for ports " Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 06/12] bridge: advertise IFLA_LINK_NETNSID when dumping bridge ports Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 07/12] ipv6: always put IFLA_LINK for devices with ndo_get_iflink Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 08/12] ipv6: advertise IFLA_LINK_NETNSID when dumping ipv6 addresses Sabrina Dubroca
2020-10-01 15:58   ` Nicolas Dichtel
2020-10-02  9:03     ` Sabrina Dubroca
2020-10-05 15:16       ` Nicolas Dichtel
2020-10-01  7:59 ` [PATCH net 09/12] net: link_watch: fix operstate when the link has the same index as the device Sabrina Dubroca
2020-10-01 11:00   ` Taehee Yoo
2020-10-01  7:59 ` [PATCH net 10/12] net: link_watch: fix detection of urgent events Sabrina Dubroca
2020-10-01  7:59 ` [PATCH net 11/12] batman-adv: fix iflink detection in batadv_is_on_batman_iface Sabrina Dubroca
2022-05-14 10:21   ` Sven Eckelmann
2020-10-01  7:59 ` [PATCH net 12/12] batman-adv: fix detection of lower link in batadv_get_real_netdevice Sabrina Dubroca
2020-10-01 21:25 ` [PATCH net 00/12] net: iflink and link-netnsid fixes Stephen Hemminger
2020-10-02  9:07   ` Sabrina Dubroca

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