Subject: Re: displayed name changed in ip link show for bridge- and other interfaces

From: Nicolas Dichtel <[email-masked]>
Date: Mon, 15 Jun 2015 11:13:12 +0200

Le 15/06/2015 09:23, Nicolas Dichtel a écrit :
> Le 14/06/2015 21:12, Oliver Hartkopp a écrit :
>> @Nicolas: Just saw that you were not responsible for the @NONE m)
>>
>> Sorry.
>>
>> Btw. do you know why this @NONE stuff just emerged in 4.1-rc ?
> Yes, it comes from the iflink cleanup in kernel:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/net/core/dev.c?id=e1622baf54df8cc958bf29d71de5ad545ea7d93c
>
Theoretically, virtual interfaces should advertise an IFLA_LINK to 0.
I don't know what is the best fix:
  - patching iproute2 to avoid this '@NONE'
  - patching the kernel (see below).

As told in the commit log (see e1622baf54df) some other virtual interfaces
are also impacted.

---8<---

 From c9e1d93960365cc5005e1b6c3ad73a8e5687824c Mon Sep 17 00:00:00 2001
From: Nicolas Dichtel <[email-masked]>
Date: Mon, 15 Jun 2015 10:52:16 +0200
Subject: [PATCH] bridge: don't set IFLA_LINK attribute for bridge ifaces

Since commit e1622baf54df ("dev: set iflink to 0 for virtual interfaces"),
this attribute is set for bridge interface. A side effect is that iproute2
now displays '@NONE' after the interface name, which may break existing
scripts:
13: br0@NONE: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT 
group default
     link/ether d2:b3:db:d6:d5:e1 brd ff:ff:ff:ff:ff:ff

To avoid that, let's set iflink to the interface ifindex.

Signed-off-by: Nicolas Dichtel <[email-masked]>
---
  net/bridge/br_device.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 4ff77a16956c..3576a257709c 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -314,6 +314,11 @@ static const struct ethtool_ops br_ethtool_ops = {
  	.get_link	= ethtool_op_get_link,
  };

+int br_get_iflink(const struct net_device *dev)
+{
+	return dev->ifindex;
+}
+
  static const struct net_device_ops br_netdev_ops = {
  	.ndo_open		 = br_dev_open,
  	.ndo_stop		 = br_dev_stop,
@@ -339,6 +344,7 @@ static const struct net_device_ops br_netdev_ops = {
  	.ndo_bridge_getlink	 = br_getlink,
  	.ndo_bridge_setlink	 = br_setlink,
  	.ndo_bridge_dellink	 = br_dellink,
+	.ndo_get_iflink		 = br_get_iflink,
  };

  static void br_dev_free(struct net_device *dev)
-- 
2.4.2