This reverts commit feadc4b6cf42a53a8a93c918a569a0b7e62bd350.

It fixed the particular issue that was seen in the OpenShift setup,
but ignored the case of tunnels like VXLAN, which export a
IFLA_LINK_NETNSID attribute but don't have an IFLA_LINK.

In case a vxlan device is created in one netns, then moved to another,
we end up seeing:

  # ip -net foo link
  15: vxlan1@if15: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode 
DEFAULT group default qlen 1000
             ^

The next patch will fix the original problem properly.

Fixes: feadc4b6cf42 ("rtnetlink: always put IFLA_LINK for links with a 
link-netnsid")
Signed-off-by: Sabrina Dubroca <s...@queasysnail.net>
---
 net/core/rtnetlink.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 68e0682450c6..c35b3f02b4f9 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1547,15 +1547,14 @@ static int put_master_ifindex(struct sk_buff *skb, 
struct net_device *dev)
        return ret;
 }
 
-static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev,
-                         bool force)
+static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev)
 {
        int ifindex = dev_get_iflink(dev);
 
-       if (force || dev->ifindex != ifindex)
-               return nla_put_u32(skb, IFLA_LINK, ifindex);
+       if (dev->ifindex == ifindex)
+               return 0;
 
-       return 0;
+       return nla_put_u32(skb, IFLA_LINK, ifindex);
 }
 
 static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb,
@@ -1572,8 +1571,6 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
                                  const struct net_device *dev,
                                  struct net *src_net, gfp_t gfp)
 {
-       bool put_iflink = false;
-
        if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) {
                struct net *link_net = dev->rtnl_link_ops->get_link_net(dev);
 
@@ -1582,12 +1579,10 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
 
                        if (nla_put_s32(skb, IFLA_LINK_NETNSID, id))
                                return -EMSGSIZE;
-
-                       put_iflink = true;
                }
        }
 
-       return nla_put_iflink(skb, dev, put_iflink);
+       return 0;
 }
 
 static int rtnl_fill_link_af(struct sk_buff *skb,
@@ -1738,6 +1733,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 #ifdef CONFIG_RPS
            nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
 #endif
+           nla_put_iflink(skb, dev) ||
            put_master_ifindex(skb, dev) ||
            nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
            (dev->qdisc &&
-- 
2.28.0

Reply via email to