Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net-next] ipvlan: advertise link netns via netlink
@ 2020-08-21 17:47 Taehee Yoo
  2020-08-24 22:53 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Taehee Yoo @ 2020-08-21 17:47 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: ap420073

Assign rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is
added to rtnetlink messages.

Test commands:
    ip netns add nst
    ip link add dummy0 type dummy
    ip link add ipvlan0 link dummy0 type ipvlan
    ip link set ipvlan0 netns nst
    ip netns exec nst ip link show ipvlan0

Result:
    ---Before---
    6: ipvlan0@if5: <BROADCAST,MULTICAST> ...
        link/ether 82:3a:78:ab:60:50 brd ff:ff:ff:ff:ff:ff

    ---After---
    12: ipvlan0@if11: <BROADCAST,MULTICAST> ...
        link/ether 42:b1:ad:57:4e:27 brd ff:ff:ff:ff:ff:ff link-netnsid 0
                                                           ~~~~~~~~~~~~~~

Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
 drivers/net/ipvlan/ipvlan_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 5bca94c99006..60b7d93bb834 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -684,6 +684,13 @@ static const struct nla_policy ipvlan_nl_policy[IFLA_IPVLAN_MAX + 1] =
 	[IFLA_IPVLAN_FLAGS] = { .type = NLA_U16 },
 };
 
+static struct net *ipvlan_get_link_net(const struct net_device *dev)
+{
+	struct ipvl_dev *ipvlan = netdev_priv(dev);
+
+	return dev_net(ipvlan->phy_dev);
+}
+
 static struct rtnl_link_ops ipvlan_link_ops = {
 	.kind		= "ipvlan",
 	.priv_size	= sizeof(struct ipvl_dev),
@@ -691,6 +698,7 @@ static struct rtnl_link_ops ipvlan_link_ops = {
 	.setup		= ipvlan_link_setup,
 	.newlink	= ipvlan_link_new,
 	.dellink	= ipvlan_link_delete,
+	.get_link_net   = ipvlan_get_link_net,
 };
 
 int ipvlan_link_register(struct rtnl_link_ops *ops)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] ipvlan: advertise link netns via netlink
  2020-08-21 17:47 [PATCH net-next] ipvlan: advertise link netns via netlink Taehee Yoo
@ 2020-08-24 22:53 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-24 22:53 UTC (permalink / raw)
  To: ap420073; +Cc: kuba, netdev

From: Taehee Yoo <ap420073@gmail.com>
Date: Fri, 21 Aug 2020 17:47:32 +0000

> Assign rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is
> added to rtnetlink messages.
> 
> Test commands:
>     ip netns add nst
>     ip link add dummy0 type dummy
>     ip link add ipvlan0 link dummy0 type ipvlan
>     ip link set ipvlan0 netns nst
>     ip netns exec nst ip link show ipvlan0
> 
> Result:
>     ---Before---
>     6: ipvlan0@if5: <BROADCAST,MULTICAST> ...
>         link/ether 82:3a:78:ab:60:50 brd ff:ff:ff:ff:ff:ff
> 
>     ---After---
>     12: ipvlan0@if11: <BROADCAST,MULTICAST> ...
>         link/ether 42:b1:ad:57:4e:27 brd ff:ff:ff:ff:ff:ff link-netnsid 0
>                                                            ~~~~~~~~~~~~~~
> 
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-24 22:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 17:47 [PATCH net-next] ipvlan: advertise link netns via netlink Taehee Yoo
2020-08-24 22:53 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).