# \[PATCH net-next 3/4\] rtnetlink: fill IFLA\_PARENT\_DEV\_NAME on link dump

- From: Loic Poulain \<hidden\>
- Date: 2021-06-08 13:58:35 
- List: netdev
- Page: https://ratatoskr.run/netdev/2021/06/11204887
- Thread: https://ratatoskr.run/netdev/2021/06/11204886/t.md

```text
From: Sergey Ryazanov <ryazanov.s.a@gmail.com>

Return a parent device using the FLA_PARENT_DEV_NAME attribute during
links dump. This should help a user figure out which links belong to a
particular HW device. E.g. what data channels exists on a specific WWAN
modem.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 net/core/rtnetlink.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 56ac16a..120887c 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1819,6 +1819,11 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 	if (rtnl_fill_prop_list(skb, dev))
 		goto nla_put_failure;
 
+	if (dev->dev.parent &&
+	    nla_put_string(skb, IFLA_PARENT_DEV_NAME,
+			   dev_name(dev->dev.parent)))
+		goto nla_put_failure;
+
 	nlmsg_end(skb, nlh);
 	return 0;
 
-- 
2.7.4

```
