lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190719110029.29466-5-jiri@resnulli.us>
Date:   Fri, 19 Jul 2019 13:00:26 +0200
From:   Jiri Pirko <jiri@...nulli.us>
To:     netdev@...r.kernel.org
Cc:     davem@...emloft.net, jakub.kicinski@...ronome.com,
        sthemmin@...rosoft.com, dsahern@...il.com, dcbw@...hat.com,
        mkubecek@...e.cz, andrew@...n.ch, parav@...lanox.com,
        saeedm@...lanox.com, mlxsw@...lanox.com
Subject: [patch net-next rfc 4/7] net: rtnetlink: put alternative names to getlink message

From: Jiri Pirko <jiri@...lanox.com>

Extend exiting getlink info message with list of alternative names.

Signed-off-by: Jiri Pirko <jiri@...lanox.com>
---
 include/uapi/linux/if_link.h |  2 ++
 net/core/rtnetlink.c         | 41 ++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 92268946e04a..038361f9847b 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -168,6 +168,8 @@ enum {
 	IFLA_MIN_MTU,
 	IFLA_MAX_MTU,
 	IFLA_ALT_IFNAME_MOD, /* Alternative ifname to add/delete */
+	IFLA_ALT_IFNAME_LIST, /* nest */
+	IFLA_ALT_IFNAME, /* Alternative ifname */
 	__IFLA_MAX
 };
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 7a2010b16e10..f11a2367037d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -980,6 +980,18 @@ static size_t rtnl_xdp_size(void)
 	return xdp_size;
 }
 
+static size_t rtnl_alt_ifname_list_size(const struct net_device *dev)
+{
+	struct netdev_name_node *name_node;
+	size_t size = nla_total_size(0);
+
+	if (list_empty(&dev->name_node->list))
+		return 0;
+	list_for_each_entry(name_node, &dev->name_node->list, list)
+		size += nla_total_size(ALTIFNAMSIZ);
+	return size;
+}
+
 static noinline size_t if_nlmsg_size(const struct net_device *dev,
 				     u32 ext_filter_mask)
 {
@@ -1027,6 +1039,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + nla_total_size(4)  /* IFLA_CARRIER_DOWN_COUNT */
 	       + nla_total_size(4)  /* IFLA_MIN_MTU */
 	       + nla_total_size(4)  /* IFLA_MAX_MTU */
+	       + rtnl_alt_ifname_list_size(dev)
 	       + 0;
 }
 
@@ -1584,6 +1597,31 @@ static int rtnl_fill_link_af(struct sk_buff *skb,
 	return 0;
 }
 
+static int rtnl_fill_alt_ifnames(struct sk_buff *skb,
+				 const struct net_device *dev)
+{
+	struct netdev_name_node *name_node;
+	struct nlattr *alt_ifname_list;
+
+	if (list_empty(&dev->name_node->list))
+		return 0;
+
+	alt_ifname_list = nla_nest_start_noflag(skb, IFLA_ALT_IFNAME_LIST);
+	if (!alt_ifname_list)
+		return -EMSGSIZE;
+
+	list_for_each_entry(name_node, &dev->name_node->list, list)
+		if (nla_put_string(skb, IFLA_ALT_IFNAME, name_node->name))
+			goto nla_put_failure;
+
+	nla_nest_end(skb, alt_ifname_list);
+	return 0;
+
+nla_put_failure:
+	nla_nest_cancel(skb, alt_ifname_list);
+	return -EMSGSIZE;
+}
+
 static int rtnl_fill_ifinfo(struct sk_buff *skb,
 			    struct net_device *dev, struct net *src_net,
 			    int type, u32 pid, u32 seq, u32 change,
@@ -1697,6 +1735,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 		goto nla_put_failure_rcu;
 	rcu_read_unlock();
 
+	if (rtnl_fill_alt_ifnames(skb, dev))
+		goto nla_put_failure;
+
 	nlmsg_end(skb, nlh);
 	return 0;
 
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ