All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: netdev@vger.kernel.org
Cc: Sabrina Dubroca <sd@queasysnail.net>,
	Roopa Prabhu <roopa@nvidia.com>,
	Nikolay Aleksandrov <nikolay@nvidia.com>
Subject: [PATCH net 05/12] bridge: always put IFLA_LINK for ports with ndo_get_iflink
Date: Thu,  1 Oct 2020 09:59:29 +0200	[thread overview]
Message-ID: <a343c9b6b1b2194df3f9e205b9067c945f240fda.1600770261.git.sd@queasysnail.net> (raw)
In-Reply-To: <cover.1600770261.git.sd@queasysnail.net>

Bridge devices try to detect if devices have a lower link when dumping
information about their ports, but that detection doesn't work when
the device and its link have the same ifindex:

For a bridge with the following ports:

    20: veth1@if20: <BROADCAST,MULTICAST> mtu 1500 qdisc noop master bridge0 ...
    22: veth2@if21: <BROADCAST,MULTICAST> mtu 1500 qdisc noop master bridge0 ...

We get this output with the "bridge link" command:

    20: veth1: <BROADCAST,MULTICAST> mtu 1500 master bridge0 ...
    22: veth2@if21: <BROADCAST,MULTICAST> mtu 1500 master bridge0 ...

veth1 should also have "@if20" in bridge link.

Instead of calling dev_get_iflink(), we can use the existence of the
ndo_get_iflink operation (which dev_get_iflink would call) to check if
a device has a lower link.

Fixes: d8a5ec672768 ("[NET]: netlink support for moving devices between network namespaces.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/bridge/br_netlink.c | 2 +-
 net/core/rtnetlink.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 147d52596e17..6af5d62ddf7b 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -410,7 +410,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
 	    nla_put_u8(skb, IFLA_OPERSTATE, operstate) ||
 	    (dev->addr_len &&
 	     nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
-	    (dev->ifindex != dev_get_iflink(dev) &&
+	    (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink &&
 	     nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))))
 		goto nla_put_failure;
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a8459fb59ccd..3d8051158890 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4625,7 +4625,7 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 	     nla_put_u32(skb, IFLA_MASTER, br_dev->ifindex)) ||
 	    (dev->addr_len &&
 	     nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
-	    (dev->ifindex != dev_get_iflink(dev) &&
+	    (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink &&
 	     nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))))
 		goto nla_put_failure;
 
-- 
2.28.0


  parent reply	other threads:[~2020-10-01  8:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Sabrina Dubroca [this message]
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
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a343c9b6b1b2194df3f9e205b9067c945f240fda.1600770261.git.sd@queasysnail.net \
    --to=sd@queasysnail.net \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.