All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] netns: advertise netns via netlink
@ 2015-01-20 14:15 Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 1/6] rtnl: fix error path when adding an iface with a link net Nicolas Dichtel
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem


The first patch of the serie fix a bug of the previous serie (present in
net-next only).
The rest of the serie adds an attribute to advertise the peer netns for
rtnetlink messages where this information is needed by userland to be able to
interpret fully the received message.

 drivers/net/macvlan.c          | 6 ++++++
 drivers/net/veth.c             | 9 +++++++++
 drivers/net/vxlan.c            | 5 +++++
 include/uapi/linux/neighbour.h | 1 +
 net/8021q/vlan_netlink.c       | 8 ++++++++
 net/core/net_namespace.c       | 1 +
 net/core/rtnetlink.c           | 5 ++++-
 net/ipv6/ip6_gre.c             | 1 +
 8 files changed, 35 insertions(+), 1 deletion(-)

Comments are welcome.

Regards,
Nicolas

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

* [PATCH net-next 1/6] rtnl: fix error path when adding an iface with a link net
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
@ 2015-01-20 14:15 ` Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 2/6] ip6gretap: advertise link netns via netlink Nicolas Dichtel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nicolas Dichtel

If an error occurs when the netdevice is moved to the link netns, a full cleanup
must be done.

Fixes: 317f4810e45e ("rtnl: allow to create device with IFLA_LINK_NETNSID set")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/core/rtnetlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a12eecc0f976..07447d1665e6 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2172,8 +2172,11 @@ replay:
 			goto out;
 		}
 
-		if (link_net)
+		if (link_net) {
 			err = dev_change_net_namespace(dev, dest_net, ifname);
+			if (err < 0)
+				unregister_netdevice(dev);
+		}
 out:
 		if (link_net)
 			put_net(link_net);
-- 
2.2.2

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

* [PATCH net-next 2/6] ip6gretap: advertise link netns via netlink
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 1/6] rtnl: fix error path when adding an iface with a link net Nicolas Dichtel
@ 2015-01-20 14:15 ` Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 3/6] vlan: " Nicolas Dichtel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nicolas Dichtel

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

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/ip6_gre.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 9306a5ff9149..6dee2a8ca0a9 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1676,6 +1676,7 @@ static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
 	.changelink	= ip6gre_changelink,
 	.get_size	= ip6gre_get_size,
 	.fill_info	= ip6gre_fill_info,
+	.get_link_net	= ip6_tnl_get_link_net,
 };
 
 /*
-- 
2.2.2

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

* [PATCH net-next 3/6] vlan: advertise link netns via netlink
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 1/6] rtnl: fix error path when adding an iface with a link net Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 2/6] ip6gretap: advertise link netns via netlink Nicolas Dichtel
@ 2015-01-20 14:15 ` Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 4/6] macvlan: " Nicolas Dichtel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nicolas Dichtel

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

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/8021q/vlan_netlink.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index 8ac8a5cc2143..c92b52f37d38 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -238,6 +238,13 @@ nla_put_failure:
 	return -EMSGSIZE;
 }
 
+static struct net *vlan_get_link_net(const struct net_device *dev)
+{
+	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
+
+	return dev_net(real_dev);
+}
+
 struct rtnl_link_ops vlan_link_ops __read_mostly = {
 	.kind		= "vlan",
 	.maxtype	= IFLA_VLAN_MAX,
@@ -250,6 +257,7 @@ struct rtnl_link_ops vlan_link_ops __read_mostly = {
 	.dellink	= unregister_vlan_dev,
 	.get_size	= vlan_get_size,
 	.fill_info	= vlan_fill_info,
+	.get_link_net	= vlan_get_link_net,
 };
 
 int __init vlan_netlink_init(void)
-- 
2.2.2

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

* [PATCH net-next 4/6] macvlan: advertise link netns via netlink
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
                   ` (2 preceding siblings ...)
  2015-01-20 14:15 ` [PATCH net-next 3/6] vlan: " Nicolas Dichtel
@ 2015-01-20 14:15 ` Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 5/6] veth: " Nicolas Dichtel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nicolas Dichtel

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

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 drivers/net/macvlan.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 612e0731142d..1df38bdae2ee 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1471,11 +1471,17 @@ int macvlan_link_register(struct rtnl_link_ops *ops)
 };
 EXPORT_SYMBOL_GPL(macvlan_link_register);
 
+static struct net *macvlan_get_link_net(const struct net_device *dev)
+{
+	return dev_net(macvlan_dev_real_dev(dev));
+}
+
 static struct rtnl_link_ops macvlan_link_ops = {
 	.kind		= "macvlan",
 	.setup		= macvlan_setup,
 	.newlink	= macvlan_newlink,
 	.dellink	= macvlan_dellink,
+	.get_link_net	= macvlan_get_link_net,
 };
 
 static int macvlan_device_event(struct notifier_block *unused,
-- 
2.2.2

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

* [PATCH net-next 5/6] veth: advertise link netns via netlink
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
                   ` (3 preceding siblings ...)
  2015-01-20 14:15 ` [PATCH net-next 4/6] macvlan: " Nicolas Dichtel
@ 2015-01-20 14:15 ` Nicolas Dichtel
  2015-01-20 14:15 ` [PATCH net-next 6/6] vxlan: advertise netns of vxlan dev in fdb msg Nicolas Dichtel
  2015-01-24  1:51 ` [PATCH net-next 0/6] netns: advertise netns via netlink David Miller
  6 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nicolas Dichtel

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

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 drivers/net/veth.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8ad596573d17..4cca36ebc4fb 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -469,6 +469,14 @@ static const struct nla_policy veth_policy[VETH_INFO_MAX + 1] = {
 	[VETH_INFO_PEER]	= { .len = sizeof(struct ifinfomsg) },
 };
 
+static struct net *veth_get_link_net(const struct net_device *dev)
+{
+	struct veth_priv *priv = netdev_priv(dev);
+	struct net_device *peer = rtnl_dereference(priv->peer);
+
+	return peer ? dev_net(peer) : dev_net(dev);
+}
+
 static struct rtnl_link_ops veth_link_ops = {
 	.kind		= DRV_NAME,
 	.priv_size	= sizeof(struct veth_priv),
@@ -478,6 +486,7 @@ static struct rtnl_link_ops veth_link_ops = {
 	.dellink	= veth_dellink,
 	.policy		= veth_policy,
 	.maxtype	= VETH_INFO_MAX,
+	.get_link_net	= veth_get_link_net,
 };
 
 /*
-- 
2.2.2

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

* [PATCH net-next 6/6] vxlan: advertise netns of vxlan dev in fdb msg
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
                   ` (4 preceding siblings ...)
  2015-01-20 14:15 ` [PATCH net-next 5/6] veth: " Nicolas Dichtel
@ 2015-01-20 14:15 ` Nicolas Dichtel
  2015-01-24  1:51 ` [PATCH net-next 0/6] netns: advertise netns via netlink David Miller
  6 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-20 14:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nicolas Dichtel

Netlink FDB messages are sent in the link netns. The header of these messages
contains the ifindex (ndm_ifindex) of the netdevice, but this ifindex is
unusable in case of x-netns vxlan.
I named the new attribute NDA_NDM_IFINDEX_NETNSID, to avoid confusion with
NDA_IFINDEX.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 drivers/net/vxlan.c            | 5 +++++
 include/uapi/linux/neighbour.h | 1 +
 net/core/net_namespace.c       | 1 +
 3 files changed, 7 insertions(+)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 0346eaa6d236..19d3664ab9dd 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -339,6 +339,11 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
 	ndm->ndm_flags = fdb->flags;
 	ndm->ndm_type = RTN_UNICAST;
 
+	if (!net_eq(dev_net(vxlan->dev), vxlan->net) &&
+	    nla_put_s32(skb, NDA_NDM_IFINDEX_NETNSID,
+			peernet2id(vxlan->net, dev_net(vxlan->dev))))
+		goto nla_put_failure;
+
 	if (send_eth && nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->eth_addr))
 		goto nla_put_failure;
 
diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbour.h
index f3d77f9f1e0b..38f236853cc0 100644
--- a/include/uapi/linux/neighbour.h
+++ b/include/uapi/linux/neighbour.h
@@ -25,6 +25,7 @@ enum {
 	NDA_VNI,
 	NDA_IFINDEX,
 	NDA_MASTER,
+	NDA_NDM_IFINDEX_NETNSID,
 	__NDA_MAX
 };
 
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 9d1a4cac83b6..b7bde551ef76 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -202,6 +202,7 @@ int peernet2id(struct net *net, struct net *peer)
 
 	return id >= 0 ? id : NETNSA_NSID_NOT_ASSIGNED;
 }
+EXPORT_SYMBOL(peernet2id);
 
 struct net *get_net_ns_by_id(struct net *net, int id)
 {
-- 
2.2.2

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

* Re: [PATCH net-next 0/6] netns: advertise netns via netlink
  2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
                   ` (5 preceding siblings ...)
  2015-01-20 14:15 ` [PATCH net-next 6/6] vxlan: advertise netns of vxlan dev in fdb msg Nicolas Dichtel
@ 2015-01-24  1:51 ` David Miller
  2015-01-26  9:20   ` Nicolas Dichtel
  6 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2015-01-24  1:51 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Tue, 20 Jan 2015 15:15:41 +0100

> 
> The first patch of the serie fix a bug of the previous serie (present in
> net-next only).
> The rest of the serie adds an attribute to advertise the peer netns for
> rtnetlink messages where this information is needed by userland to be able to
> interpret fully the received message.

"series" has a final 's'.  Well, as least you consistently misspell it
3 times :-)

"Series" applied, thanks!

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

* Re: [PATCH net-next 0/6] netns: advertise netns via netlink
  2015-01-24  1:51 ` [PATCH net-next 0/6] netns: advertise netns via netlink David Miller
@ 2015-01-26  9:20   ` Nicolas Dichtel
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dichtel @ 2015-01-26  9:20 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Le 24/01/2015 02:51, David Miller a écrit :
> From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> Date: Tue, 20 Jan 2015 15:15:41 +0100
>
>>
>> The first patch of the serie fix a bug of the previous serie (present in
>> net-next only).
>> The rest of the serie adds an attribute to advertise the peer netns for
>> rtnetlink messages where this information is needed by userland to be able to
>> interpret fully the received message.
>
> "series" has a final 's'.  Well, as least you consistently misspell it
> 3 times :-)
Thanks for noticing it.
For the story, it comes from the french word 'serie' which don't end with a 's'
;-)

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

end of thread, other threads:[~2015-01-26  9:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-20 14:15 [PATCH net-next 0/6] netns: advertise netns via netlink Nicolas Dichtel
2015-01-20 14:15 ` [PATCH net-next 1/6] rtnl: fix error path when adding an iface with a link net Nicolas Dichtel
2015-01-20 14:15 ` [PATCH net-next 2/6] ip6gretap: advertise link netns via netlink Nicolas Dichtel
2015-01-20 14:15 ` [PATCH net-next 3/6] vlan: " Nicolas Dichtel
2015-01-20 14:15 ` [PATCH net-next 4/6] macvlan: " Nicolas Dichtel
2015-01-20 14:15 ` [PATCH net-next 5/6] veth: " Nicolas Dichtel
2015-01-20 14:15 ` [PATCH net-next 6/6] vxlan: advertise netns of vxlan dev in fdb msg Nicolas Dichtel
2015-01-24  1:51 ` [PATCH net-next 0/6] netns: advertise netns via netlink David Miller
2015-01-26  9:20   ` Nicolas Dichtel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.