Skip to contentSkip to conversation

Virtual ethernet tunnel

PATCH In review Pavel Emelianov 8 participants 26 messages Jun 6, 2007 – Jun 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Virtual ethernet tunnel

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Mainly it allows to communicate between network namespaces but it can be used as is as well.

Eric recently sent a similar driver called etun. This implementation uses another interface - the RTM_NRELINK message introduced by Patric. The patch fits today netdev tree with Patrick's patches.

The newlink callback is organized that way to make it easy to create the peer device in the separate namespace when we have them in kernel.

The patch for an ip utility is also provided.

Eric, since ethtool interface was from your patch, I add your Signed-off-by line.

---

drivers/net/Kconfig +6 -0
index 7d57f4a..7e144be 100644
@@ -119,6 +119,12 @@ config TUN
 
 	  If you don't know what to use this for, you don't need it.
 
+config VETH
+	tristate "Virtual ethernet device"
+	---help---
+	  The device is an ethernet tunnel. Devices are created in pairs. When
+	  one end receives the packet it appears on its pair and vice versa.
+
 config NET_SB1000
 	tristate "General Instruments Surfboard 1000"
 	depends on PNP
drivers/net/Makefile +1 -0
index a77affa..4764119 100644
@@ -185,6 +185,7 @@ obj-$(CONFIG_MACSONIC) += macsonic.o
 obj-$(CONFIG_MACMACE) += macmace.o
 obj-$(CONFIG_MAC89x0) += mac89x0.o
 obj-$(CONFIG_TUN) += tun.o
+obj-$(CONFIG_VETH) += veth.o
 obj-$(CONFIG_NET_NETX) += netx-eth.o
 obj-$(CONFIG_DL2K) += dl2k.o
 obj-$(CONFIG_R8169) += r8169.o
drivers/net/veth.c new file +391 -0

391 lines not on this page · raw message

include/net/veth.h new file +13 -0
new file mode 100644
index 0000000..74c8e1e
@@ -0,0 +1,13 @@
+#ifndef __NET_VETH_H__
+#define __NET_VETH_H__
+
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};
+
+#endif
#1 lore raw

PATCH 1/1 Module for ip utility to support veth device

The usage is

# ip link add [name] type veth [peer <name>] [mac <mac>] [peer_mac <mac>]

The Makefile is maybe not as beautiful as it could be. It is to be discussed.

One thing I noticed during testing is the following. When launching this with link_veth.so module and not specifying any module specific parameters, the kernel refuses to accept the packet when parsing the IFLA_LINKINFO. So the hunk for ip/iplink.c doesn't add an empty extra header if no extra data expected.

---

ip/Makefile +5 -1
index 9a5bfe3..b46bce3 100644
@@ -8,8 +8,9 @@ RTMONOBJ=rtmon.o
 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
 SCRIPTS=ifcfg rtpr routel routef
 TARGETS=ip rtmon
+LIBS=link_veth.so
 
-all: $(TARGETS) $(SCRIPTS)
+all: $(TARGETS) $(SCRIPTS) $(LIBS)
 
 ip: $(IPOBJ) $(LIBNETLINK) $(LIBUTIL)
 
@@ -24,3 +25,6 @@ clean:
 
 LDLIBS	+= -ldl
 LDFLAGS	+= -Wl,-export-dynamic
+
+%.so: %.c
+	$(CC) $(CFLAGS) -shared $< -o $@
ip/iplink.c +1 -1
index 5170419..6975990 100644
@@ -287,7 +287,7 @@ static int iplink_modify(int cmd, unsign
 			 strlen(type));
 
 		lu = get_link_type(type);
-		if (lu) {
+		if (lu && argc) {
 			struct rtattr * data = NLMSG_TAIL(&req.n);
 			addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
 
ip/link_veth.c new file +77 -0

77 lines not on this page · raw message

ip/veth.h new file +13 -0
new file mode 100644
index 0000000..74c8e1e
@@ -0,0 +1,13 @@
+#ifndef __NET_VETH_H__
+#define __NET_VETH_H__
+
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};
+
+#endif
#2 lore raw

Re: [PATCH] Module for ip utility to support veth device

ip/iplink.c static int iplink_modify(int cmd, unsign · line 292

Quoted 12 lines · Pavel Emelianov
ip/iplink.c +1 -1
index 5170419..6975990 100644
@@ -287,7 +287,7 @@ static int iplink_modify(int cmd, unsign
 			 strlen(type));
 
 		lu = get_link_type(type);
-		if (lu) {
+		if (lu && argc) {
 			struct rtattr * data = NLMSG_TAIL(&req.n);
 			addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);

I've folded this part into my iproute patch, thanks.

#3 lore raw
In reply to Pavel Emelianov
Quoted 17 lines · Pavel Emelianov

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Mainly it allows to communicate between network namespaces but it can be used as is as well.

Eric recently sent a similar driver called etun. This implementation uses another interface - the RTM_NRELINK message introduced by Patric. The patch fits today netdev tree with Patrick's patches.

The newlink callback is organized that way to make it easy to create the peer device in the separate namespace when we have them in kernel.

drivers/net/veth.c line 24

Quoted 5 lines
drivers/net/veth.c new file +5 -0
+struct veth_priv {
+	struct net_device *peer;
+	struct net_device *dev;
+	struct list_head list;
+	struct net_device_stats stats;

You can use dev->stats instead.

Quoted 6 lines
drivers/net/veth.c new file +6 -0
+static int veth_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct net_device *rcv = NULL;
+	struct veth_priv *priv, *rcv_priv;
+	int length;
+

drivers/net/veth.c line 151

Quoted 10 lines
drivers/net/veth.c new file +10 -0
+	skb_orphan(skb);
+
+	priv = netdev_priv(dev);
+	rcv = priv->peer;
+	rcv_priv = netdev_priv(rcv);
+
+	if (!(rcv->flags & IFF_UP))
+		goto outf;
+
+	skb->dev = rcv;

eth_type_trans already sets skb->dev.

drivers/net/veth.c line 161

Quoted 10 lines
drivers/net/veth.c new file +10 -0
+	skb->pkt_type = PACKET_HOST;
+	skb->protocol = eth_type_trans(skb, rcv);
+	if (dev->features & NETIF_F_NO_CSUM)
+		skb->ip_summed = rcv_priv->ip_summed;
+
+	dst_release(skb->dst);
+	skb->dst = NULL;
+
+	secpath_reset(skb);
+	nf_reset(skb);

Is skb->mark supposed to survive communication between different namespaces?

drivers/net/veth.c line 354

Quoted 5 lines
drivers/net/veth.c new file +5 -0
+static const struct nla_policy veth_policy[VETH_INFO_MAX] = {
+	[VETH_INFO_MAC]		= { .type = NLA_BINARY, .len = ETH_ALEN },
+	[VETH_INFO_PEER]	= { .type = NLA_STRING },
+	[VETH_INFO_PEER_MAC]	= { .type = NLA_BINARY, .len = ETH_ALEN },
+};

The rtnl_link codes looks fine. I don't like the VETH_INFO_MAC attribute very much though, we already have a generic device attribute for MAC addresses. Of course that only allows you to supply one MAC address, so I'm wondering what you think of allocating only a single device per newlink operation and binding them in a seperate enslave operation?

include/net/veth.h line 11

Quoted 8 lines
include/net/veth.h new file +8 -0
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};

Please follow the

#define VETH_INFO_MAX (__VETH_INFO_MAX - 1)

convention here.

#18 lore raw
In reply to Pavel Emelianov

drivers/net/veth.c line 391

Quoted 2 lines · Pavel Emelianov
drivers/net/veth.c new file +2 -0
+MODULE_DESCRIPTION("Virtual Ethernet Tunnel");
+MODULE_LICENSE("GPL v2");

This seems to be missing MODULE_ALIAS_RTNL_LINK("veth");

#19 lore raw
In reply to Pavel Emelianov
Quoted 89 lines · On Wed, 06 Jun 2007 19:11:38 +0400 Pavel Emelianov <[email protected]> wrote:

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Mainly it allows to communicate between network namespaces but it can be used as is as well.

Eric recently sent a similar driver called etun. This implementation uses another interface - the RTM_NRELINK message introduced by Patric. The patch fits today netdev tree with Patrick's patches.

The newlink callback is organized that way to make it easy to create the peer device in the separate namespace when we have them in kernel.

The patch for an ip utility is also provided.

Eric, since ethtool interface was from your patch, I add your Signed-off-by line.

---

drivers/net/Kconfig +6 -0
index 7d57f4a..7e144be 100644
@@ -119,6 +119,12 @@ config TUN
 
 	  If you don't know what to use this for, you don't need it.
 
+config VETH
+	tristate "Virtual ethernet device"
+	---help---
+	  The device is an ethernet tunnel. Devices are created in pairs. When
+	  one end receives the packet it appears on its pair and vice versa.
+
 config NET_SB1000
 	tristate "General Instruments Surfboard 1000"
 	depends on PNP
drivers/net/Makefile +1 -0
index a77affa..4764119 100644
@@ -185,6 +185,7 @@ obj-$(CONFIG_MACSONIC) += macsonic.o
 obj-$(CONFIG_MACMACE) += macmace.o
 obj-$(CONFIG_MAC89x0) += mac89x0.o
 obj-$(CONFIG_TUN) += tun.o
+obj-$(CONFIG_VETH) += veth.o
 obj-$(CONFIG_NET_NETX) += netx-eth.o
 obj-$(CONFIG_DL2K) += dl2k.o
 obj-$(CONFIG_R8169) += r8169.o
drivers/net/veth.c new file +28 -0
new file mode 100644
index 0000000..6746c91
@@ -0,0 +1,391 @@
+/*
+ *  drivers/net/veth.c
+ *
+ *  Copyright (C) 2007 OpenVZ http://openvz.org, SWsoft Inc
+ *
+ */
+
+#include <linux/list.h>
+#include <linux/netdevice.h>
+#include <linux/ethtool.h>
+#include <linux/etherdevice.h>
+
+#include <net/dst.h>
+#include <net/xfrm.h>
+#include <net/veth.h>
+
+#define DRV_NAME	"veth"
+#define DRV_VERSION	"1.0"
+
+struct veth_priv {
+	struct net_device *peer;
+	struct net_device *dev;
+	struct list_head list;
+	struct net_device_stats stats;
+	unsigned ip_summed;
+};
+
+static LIST_HEAD(veth_list);

drivers/net/veth.c line 38

Quoted 10 lines
drivers/net/veth.c new file +10 -0
+
+/*
+ * ethtool interface
+ */
+
+static struct {
+	const char string[ETH_GSTRING_LEN];
+} ethtool_stats_keys[] = {
+	{ "peer_ifindex" },
+};

Seems like a good usage of sysfs attributes, rather than ethtool.

Then you can get rid of all the useless ethtool for what is basically a virtual device.

Quoted 28 lines
drivers/net/veth.c new file +28 -0
+/*
+ * xmit
+ */
+
+static int veth_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct net_device *rcv = NULL;
+	struct veth_priv *priv, *rcv_priv;
+	int length;
+
+	skb_orphan(skb);
+
+	priv = netdev_priv(dev);
+	rcv = priv->peer;
+	rcv_priv = netdev_priv(rcv);
+
+	if (!(rcv->flags & IFF_UP))
+		goto outf;
+
+	skb->dev = rcv;
+	skb->pkt_type = PACKET_HOST;
+	skb->protocol = eth_type_trans(skb, rcv);
+	if (dev->features & NETIF_F_NO_CSUM)
+		skb->ip_summed = rcv_priv->ip_summed;
+
+	dst_release(skb->dst);
+	skb->dst = NULL;
+

drivers/net/veth.c line 169

Quoted 10 lines
drivers/net/veth.c new file +10 -0
+	secpath_reset(skb);
+	nf_reset(skb);
+
+	length = skb->len;
+
+	priv->stats.tx_bytes += length;
+	priv->stats.tx_packets++;
+
+	rcv_priv->stats.rx_bytes += length;
+	rcv_priv->stats.rx_packets++;

Per-cpu stats? This will cacheline thrash.

Quoted 8 lines
drivers/net/veth.c new file +8 -0
+	netif_rx(skb);
+	return 0;
+
+outf:
+	kfree_skb(skb);
+	priv->stats.tx_dropped++;
+	return 0;
+}
Signature · 1 line
Stephen Hemminger <[email protected]>
maintainer
#20 lore raw
In reply to Pavel Emelianov

From: Pavel Emelianov <[email protected]>
Date: Wed, 06 Jun 2007 19:11:38 +0400

Quoted 3 lines

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

I would suggest choosing a different name.

'veth' is also the name of the virtualized ethernet device found on IBM machines, driven by driver/net/ibmveth.[ch]

#21 lore raw
Quoted 9 lines · David Miller

From: Pavel Emelianov <[email protected]>
Date: Wed, 06 Jun 2007 19:11:38 +0400

Quoted 4 lines

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Quoted 5 lines

I would suggest choosing a different name.

'veth' is also the name of the virtualized ethernet device found on IBM machines, driven by driver/net/ibmveth.[ch]

Eric Biederman proposed the name "etun" which stands for "Ethernet TUNnel".

The goal of the pair device is to pass network packets between namespaces. That reminds me the well known "pipe" which pass data between processes.

All network devices have a name describing what they do : "eth" for ethernet, "dummy" for a device doing nothing, loopback, ...

Perhaps, a name like "epipe" or "npipe", which reflects what does the device, is more appropriate ?

-- Daniel

maintainer
#22 lore raw

From: Daniel Lezcano <[email protected]>
Date: Wed, 06 Jun 2007 22:38:11 +0200

Quoted 2 lines

Perhaps, a name like "epipe" or "npipe", which reflects what does the device, is more appropriate ?

'npipe' (Network PIPE) or 'epipe' (Ethernet PIPE) are fine with me.

#4 lore raw
In reply to Patrick McHardy
Quoted 18 lines · Patrick McHardy
Quoted 16 lines · Pavel Emelianov

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Mainly it allows to communicate between network namespaces but it can be used as is as well.

Eric recently sent a similar driver called etun. This implementation uses another interface - the RTM_NRELINK message introduced by Patric. The patch fits today netdev tree with Patrick's patches.

The newlink callback is organized that way to make it easy to create the peer device in the separate namespace when we have them in kernel.

Quoted 8 lines

drivers/net/veth.c line 24

Quoted 5 lines
drivers/net/veth.c new file +5 -0
+struct veth_priv {
+	struct net_device *peer;
+	struct net_device *dev;
+	struct list_head list;
+	struct net_device_stats stats;

You can use dev->stats instead.

OK. Actually I planned to use percpu stats to reduce cacheline trashing (Stephen has noticed it also). The reason I didn't do it here is that the patch would look more complicated, but I wanted to show and approve the netlink interface first.

Quoted 10 lines
Quoted 10 lines
drivers/net/veth.c new file +10 -0
+static int veth_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct net_device *rcv = NULL;
+	struct veth_priv *priv, *rcv_priv;
+	int length;
+
+	skb_orphan(skb);
+
+	priv = netdev_priv(dev);
+	rcv = priv->peer;
Quoted 8 lines

drivers/net/veth.c line 151

Quoted 6 lines
drivers/net/veth.c new file +6 -0
+	rcv_priv = netdev_priv(rcv);
+
+	if (!(rcv->flags & IFF_UP))
+		goto outf;
+
+	skb->dev = rcv;

eth_type_trans already sets skb->dev.

Ok. Thanks.

Quoted 6 lines
Quoted 6 lines
drivers/net/veth.c new file +6 -0
+	skb->pkt_type = PACKET_HOST;
+	skb->protocol = eth_type_trans(skb, rcv);
+	if (dev->features & NETIF_F_NO_CSUM)
+		skb->ip_summed = rcv_priv->ip_summed;
+
+	dst_release(skb->dst);
Quoted 8 lines

drivers/net/veth.c line 161

Quoted 4 lines
drivers/net/veth.c new file +4 -0
+	skb->dst = NULL;
+
+	secpath_reset(skb);
+	nf_reset(skb);

Is skb->mark supposed to survive communication between different namespaces?

I guess it must not. Thanks.

Quoted 4 lines
Quoted 4 lines
drivers/net/veth.c new file +4 -0
+static const struct nla_policy veth_policy[VETH_INFO_MAX] = {
+	[VETH_INFO_MAC]		= { .type = NLA_BINARY, .len = ETH_ALEN },
+	[VETH_INFO_PEER]	= { .type = NLA_STRING },
+	[VETH_INFO_PEER_MAC]	= { .type = NLA_BINARY, .len = ETH_ALEN },
Quoted 8 lines
Quoted 1 line

+};

The rtnl_link codes looks fine. I don't like the VETH_INFO_MAC attribute very much though, we already have a generic device attribute for MAC addresses. Of course that only allows you to supply one MAC address, so I'm wondering what you think of allocating only a single device per newlink operation and binding them in a seperate enslave operation?

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

But with such approach the creation looks really logical. We send a packet to the kernel and have a single response about the new device appearance. At the same time we have a RTNL_NEWLINK message arrived at the destination namespace informing that a new device has appeared there as well.

Quoted 11 lines

include/net/veth.h line 11

Quoted 8 lines
include/net/veth.h new file +8 -0
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};

Please follow the

Quoted 3 lines

#define VETH_INFO_MAX (__VETH_INFO_MAX - 1)

convention here.

Could you please clarify this point. I saw the lines

enum {
	...
	RTNL_NEWLINK
#define RTNL_NEWLINK RTNL_NEWLINK
	...
}

and had my brains exploded imagining what this would mean :(

Quoted 5 lines

-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw
In reply to David Miller
Quoted 9 lines · David Miller

From: Pavel Emelianov <[email protected]>
Date: Wed, 06 Jun 2007 19:11:38 +0400

Quoted 3 lines

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Quoted 4 lines

I would suggest choosing a different name.

'veth' is also the name of the virtualized ethernet device found on IBM machines, driven by driver/net/ibmveth.[ch]

AFAICS, ibmveth.c registers ethX devices, while this driver registers vethX by default, so there is no much conflict IMHO.

But if you still don't like it, I would suggest 'ethtun' and later we will come with iptun for IP tunneling. Is it ok for you?

Thanks,
Kirill

maintainer
#24 lore raw

From: Kirill Korotaev <[email protected]>
Date: Thu, 07 Jun 2007 12:14:29 +0400

Quoted 10 lines
Quoted 9 lines · David Miller

From: Pavel Emelianov <[email protected]>
Date: Wed, 06 Jun 2007 19:11:38 +0400

Quoted 3 lines

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Quoted 7 lines
Quoted 4 lines

I would suggest choosing a different name.

'veth' is also the name of the virtualized ethernet device found on IBM machines, driven by driver/net/ibmveth.[ch]

AFAICS, ibmveth.c registers ethX devices, while this driver registers vethX by default, so there is no much conflict IMHO.

If that's the case, veth is fine with me.

#5 lore raw
In reply to Pavel Emelianov
Quoted 90 lines · Pavel Emelianov
Quoted 19 lines · Patrick McHardy
Quoted 17 lines · Pavel Emelianov

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Mainly it allows to communicate between network namespaces but it can be used as is as well.

Eric recently sent a similar driver called etun. This implementation uses another interface - the RTM_NRELINK message introduced by Patric. The patch fits today netdev tree with Patrick's patches.

The newlink callback is organized that way to make it easy to create the peer device in the separate namespace when we have them in kernel.

Quoted 8 lines

drivers/net/veth.c line 24

Quoted 6 lines
drivers/net/veth.c new file +5 -0
+struct veth_priv {
+	struct net_device *peer;
+	struct net_device *dev;
+	struct list_head list;
+	struct net_device_stats stats;

You can use dev->stats instead.

OK. Actually I planned to use percpu stats to reduce cacheline trashing (Stephen has noticed it also). The reason I didn't do it here is that the patch would look more complicated, but I wanted to show and approve the netlink interface first.

Quoted 10 lines
Quoted 10 lines
drivers/net/veth.c new file +10 -0
+static int veth_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct net_device *rcv = NULL;
+	struct veth_priv *priv, *rcv_priv;
+	int length;
+
+	skb_orphan(skb);
+
+	priv = netdev_priv(dev);
+	rcv = priv->peer;
Quoted 9 lines

drivers/net/veth.c line 151

Quoted 7 lines
drivers/net/veth.c new file +6 -0
+	rcv_priv = netdev_priv(rcv);
+
+	if (!(rcv->flags & IFF_UP))
+		goto outf;
+
+	skb->dev = rcv;

eth_type_trans already sets skb->dev.

Ok. Thanks.

Quoted 5 lines
Quoted 5 lines
drivers/net/veth.c new file +5 -0
+	skb->pkt_type = PACKET_HOST;
+	skb->protocol = eth_type_trans(skb, rcv);
+	if (dev->features & NETIF_F_NO_CSUM)
+		skb->ip_summed = rcv_priv->ip_summed;
+
Quoted 9 lines

drivers/net/veth.c line 161

Quoted 6 lines
drivers/net/veth.c new file +5 -0
+	dst_release(skb->dst);
+	skb->dst = NULL;
+
+	secpath_reset(skb);
+	nf_reset(skb);

Is skb->mark supposed to survive communication between different namespaces?

I guess it must not. Thanks.

Quoted 12 lines

drivers/net/veth.c line 354

Quoted 6 lines
drivers/net/veth.c new file +5 -0
+static const struct nla_policy veth_policy[VETH_INFO_MAX] = {
+	[VETH_INFO_MAC]		= { .type = NLA_BINARY, .len = ETH_ALEN },
+	[VETH_INFO_PEER]	= { .type = NLA_STRING },
+	[VETH_INFO_PEER_MAC]	= { .type = NLA_BINARY, .len = ETH_ALEN },
+};

The rtnl_link codes looks fine. I don't like the VETH_INFO_MAC attribute very much though, we already have a generic device attribute for MAC addresses. Of course that only allows you to supply one MAC address, so I'm wondering what you think of allocating only a single device per newlink operation and binding them in a seperate enslave operation?

Quoted 7 lines

I did this at the very first version, but Alexey showed me that this
would be wrong. Look. When we create the second device it must be in
the other namespace as it is useless to have them in one namespace.
But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and
moving it into the new one is rather a complex task.

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity. When the network namespace dies, the netdev is moved back to the init namespace. That facilitate network device management.

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Quoted 42 lines

But with such approach the creation looks really logical. We send a packet to the kernel and have a single response about the new device appearance. At the same time we have a RTNL_NEWLINK message arrived at the destination namespace informing that a new device has appeared there as well.

Quoted 11 lines

include/net/veth.h line 11

Quoted 9 lines
include/net/veth.h new file +8 -0
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};

Please follow the

Quoted 4 lines

#define VETH_INFO_MAX (__VETH_INFO_MAX - 1)

convention here.

Could you please clarify this point. I saw the lines

enum {
	...
	RTNL_NEWLINK
#define RTNL_NEWLINK RTNL_NEWLINK
	...
}

and had my brains exploded imagining what this would mean :(

Quoted 6 lines

-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

#25 lore raw
In reply to David Miller
Quoted 12 lines · David Miller

From: Kirill Korotaev <[email protected]>
Date: Thu, 07 Jun 2007 12:14:29 +0400

Quoted 9 lines
Quoted 8 lines · David Miller

From: Pavel Emelianov <[email protected]>
Date: Wed, 06 Jun 2007 19:11:38 +0400

Quoted 3 lines

Veth stands for Virtual ETHernet. It is a simple tunnel driver that works at the link layer and looks like a pair of ethernet devices interconnected with each other.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I would suggest choosing a different name.

'veth' is also the name of the virtualized ethernet device found on IBM machines, driven by driver/net/ibmveth.[ch]

AFAICS, ibmveth.c registers ethX devices, while this driver registers vethX by default, so there is no much conflict IMHO.

If that's the case, veth is fine with me.

I like Daniel's proposals with the tunnel or pipe thing in the name. I think it is more explicit about what the device really is.

I'm currently using etun, Eric Biederman's implementation. It will be nice to have this kind of device merged.

-- Benjamin

Signature · 3 lines
B e n j a m i n   T h e r y  - BULL/DT/Open Software R&D

   http://www.bull.com
#6 lore raw
In reply to Daniel Lezcano
Quoted 8 lines
Quoted 8 lines

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 4 lines

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

By saying complex I didn't mean that this is difficult to implement, but that it consists (must consist) of many stages. I.e. composite. Making the device right in the namespace is liter.

Quoted 2 lines

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity.

I do not mind that.

Quoted 10 lines

When the network namespace dies, the netdev is moved back to the init namespace.
That facilitate network device management.

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Agree. Moving the devices is a must-have functionality.

I do not mind making the pair in the init namespace and move the second one into the desired namespace. But if we *always* will have two ends in different namespaces what to complicate things for?

Thanks,
Pavel

#7 lore raw
Quoted 38 lines · Pavel Emelianov
Quoted 9 lines
Quoted 9 lines

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 5 lines

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

By saying complex I didn't mean that this is difficult to implement, but that it consists (must consist) of many stages. I.e. composite. Making the device right in the namespace is liter.

Quoted 3 lines

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity.

I do not mind that.

Quoted 11 lines

When the network namespace dies, the netdev is moved back to the init namespace.
That facilitate network device management.

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Quoted 6 lines

Agree. Moving the devices is a must-have functionality.

I do not mind making the pair in the init namespace and move the second one into the desired namespace. But if we *always* will have two ends in different namespaces what to complicate things for?

Just to provide a netdev sufficiently generic to be used by people who don't want namespaces but just want to do some network testing, like Ben Greear does. He mentioned in a previous email, he will be happy to stop redirecting people to out of tree patch.

https://lists.linux-foundation.org/pipermail/containers/2007-April/004420.html

Quoted 4 lines

Thanks,
Pavel

#8 lore raw

Deniel,

Quoted 50 lines · Daniel Lezcano
Quoted 41 lines · Pavel Emelianov
Quoted 10 lines
Quoted 9 lines

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 5 lines

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

By saying complex I didn't mean that this is difficult to implement, but that it consists (must consist) of many stages. I.e. composite. Making the device right in the namespace is liter.

Quoted 3 lines

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity.

I do not mind that.

Quoted 11 lines

When the network namespace dies, the netdev is moved back to the init namespace.
That facilitate network device management.

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Quoted 6 lines

Agree. Moving the devices is a must-have functionality.

I do not mind making the pair in the init namespace and move the second one into the desired namespace. But if we *always* will have two ends in different namespaces what to complicate things for?

Quoted 6 lines

Just to provide a netdev sufficiently generic to be used by people who don't want namespaces but just want to do some network testing, like Ben Greear does. He mentioned in a previous email, he will be happy to stop redirecting people to out of tree patch.

https://lists.linux-foundation.org/pipermail/containers/2007-April/004420.html

no one is against generic code and ability to create 2 interfaces in *one* namespace. (Like we currently allow to do so in OpenVZ)

However, believe me, moving an interface is a *hard* operation. Much harder then netdev register from the scratch.

Because it requires to take into account many things like:
- packets in flight which requires synchronize and is slow on big machines
- asynchronous sysfs entries registration/deregistration from rtln_unlock -> netdev_run_todo
- name/ifindex collisions
- shutdown/cleanup of addresses/routes/qdisc and other similar stuff

Thanks,
Kirill

#9 lore raw
Quoted 68 lines · Kirill Korotaev

Deniel,

Quoted 48 lines · Daniel Lezcano
Quoted 45 lines · Pavel Emelianov
Quoted 10 lines
Quoted 10 lines

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 6 lines

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

By saying complex I didn't mean that this is difficult to implement, but that it consists (must consist) of many stages. I.e. composite. Making the device right in the namespace is liter.

Quoted 4 lines

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity.

I do not mind that.

Quoted 4 lines

When the network namespace dies, the netdev is moved back to the init namespace.
That facilitate network device management.

Quoted 8 lines

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Agree. Moving the devices is a must-have functionality.

Quoted 9 lines
Quoted 5 lines

I do not mind making the pair in the init namespace and move the second one into the desired namespace. But if we *always* will have two ends in different namespaces what to complicate things for?

Just to provide a netdev sufficiently generic to be used by people who don't want namespaces but just want to do some network testing, like Ben Greear does. He mentioned in a previous email, he will be happy to stop redirecting people to out of tree patch.

https://lists.linux-foundation.org/pipermail/containers/2007-April/004420.html

no one is against generic code and ability to create 2 interfaces in *one* namespace. (Like we currently allow to do so in OpenVZ)

However, believe me, moving an interface is a *hard* operation. Much harder then netdev register from the scratch.

Quoted 8 lines

Because it requires to take into account many things like:
- packets in flight which requires synchronize and is slow on big machines
- asynchronous sysfs entries registration/deregistration from rtln_unlock -> netdev_run_todo
- name/ifindex collisions
- shutdown/cleanup of addresses/routes/qdisc and other similar stuff

All of what you are describing is already implemented in the Eric's patchset.

You can have a look at :

http://lxc.sourceforge.net/patches/2.6.20/2.6.20-netns1/broken_out/

And more precisly:

for sysfs issues:
http://lxc.sourceforge.net/patches/2.6.20/2.6.20-netns1/broken_out/0065-sysfs-Shadow-directory-support.patch

for network device movement:
http://lxc.sourceforge.net/patches/2.6.20/2.6.20-netns1/broken_out/0096-net-Implment-network-device-movement-between-namesp.patch

Thanks,
Daniel

#11 lore raw
In reply to Daniel Lezcano
Quoted 41 lines · Daniel Lezcano
Quoted 40 lines · Pavel Emelianov
Quoted 8 lines
Quoted 8 lines

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 5 lines

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

By saying complex I didn't mean that this is difficult to implement, but that it consists (must consist) of many stages. I.e. composite. Making the device right in the namespace is liter.

Quoted 3 lines

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity.

I do not mind that.

Quoted 4 lines

When the network namespace dies, the netdev is moved back to the init namespace.
That facilitate network device management.

Quoted 8 lines

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Agree. Moving the devices is a must-have functionality.

Quoted 8 lines
Quoted 4 lines

I do not mind making the pair in the init namespace and move the second one into the desired namespace. But if we *always* will have two ends in different namespaces what to complicate things for?

Just to provide a netdev sufficiently generic to be used by people who don't want namespaces but just want to do some network testing, like Ben Greear does. He mentioned in a previous email, he will be happy to stop redirecting people to out of tree patch.

This patch creates booth devices in the init namespace. That's what you want, isn't it? When we have the namespaces we will be able to create the pair with booth ends in the init namespace - just do not specify the namespace id to create the 2nd end in and the driver will leave it int the init one.

Quoted 13 lines

https://lists.linux-foundation.org/pipermail/containers/2007-April/004420.html

Quoted 4 lines

Thanks,
Pavel

-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw
In reply to Daniel Lezcano
Quoted 18 lines
Quoted 9 lines

no one is against generic code and ability to create 2 interfaces in *one* namespace.
(Like we currently allow to do so in OpenVZ)

However, believe me, moving an interface is a *hard* operation. Much harder then netdev
register from the scratch.

Quoted 9 lines

Because it requires to take into account many things like:
- packets in flight which requires synchronize and is slow on big machines
- asynchronous sysfs entries registration/deregistration from rtln_unlock -> netdev_run_todo
- name/ifindex collisions
- shutdown/cleanup of addresses/routes/qdisc and other similar stuff

Quoted 2 lines

All of what you are describing is already implemented in the Eric's patchset.

Daniel. We *agree* that this task *is implementable*. We just want to say that creating the device in the namespace is less comp... (oh, well, forget this word) faster than creating and then moving.

Quoted 4 lines

You can have a look at :

http://lxc.sourceforge.net/patches/2.6.20/2.6.20-netns1/broken_out/

Quoted 8 lines

And more precisly:

for sysfs issues:
http://lxc.sourceforge.net/patches/2.6.20/2.6.20-netns1/broken_out/0065-sysfs-Shadow-directory-support.patch

for network device movement:
http://lxc.sourceforge.net/patches/2.6.20/2.6.20-netns1/broken_out/0096-net-Implment-network-device-movement-between-namesp.patch

Good job. Can you prove that this code is less buggy than the existing register_netdevice() one? This requires testing, doesn't it? But on the other hand we have the ability to create the device right in the namespace using well known (and thus well debugged) code with minimal actions from the kernel.

Quoted 8 lines

Thanks,
Daniel
-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
In reply to Pavel Emelianov
Quoted 48 lines · Pavel Emelianov
Quoted 38 lines · Daniel Lezcano
Quoted 37 lines · Pavel Emelianov
Quoted 8 lines
Quoted 8 lines

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 5 lines

Pavel,

moving the netdevice to another namespace is not a complex task. Eric Biederman did it in its patchset ( cf. http://lxc.sf.net/network )

By saying complex I didn't mean that this is difficult to implement, but that it consists (must consist) of many stages. I.e. composite. Making the device right in the namespace is liter.

Quoted 3 lines

When the pair device is created, both extremeties are into the init namespace and you can choose to which namespace to move one extremity.

I do not mind that.

Quoted 4 lines

When the network namespace dies, the netdev is moved back to the init namespace.
That facilitate network device management.

Quoted 8 lines

Concerning netlink events, this is automatically generated when the network device is moved through namespaces.

IMHO, we should have the network device movement between namespaces in order to be able to move a physical network device too (eg. you have 4 NIC and you want to create 3 containers and assign 3 NIC to each of them)

Agree. Moving the devices is a must-have functionality.

Quoted 8 lines
Quoted 4 lines

I do not mind making the pair in the init namespace and move the second one into the desired namespace. But if we *always* will have two ends in different namespaces what to complicate things for?

Just to provide a netdev sufficiently generic to be used by people who don't want namespaces but just want to do some network testing, like Ben Greear does. He mentioned in a previous email, he will be happy to stop redirecting people to out of tree patch.

Quoted 5 lines

This patch creates booth devices in the init namespace. That's what you want, isn't it? When we have the namespaces we will be able to create the pair with booth ends in the init namespace - just do not specify the namespace id to create the 2nd end in and the driver will leave it int the init one.

Ok, fine.

#13 lore raw
In reply to Pavel Emelianov
Quoted 19 lines · Pavel Emelianov
Quoted 6 lines · Patrick McHardy
Quoted 6 lines
drivers/net/veth.c new file +6 -0
+	skb->pkt_type = PACKET_HOST;
+	skb->protocol = eth_type_trans(skb, rcv);
+	if (dev->features & NETIF_F_NO_CSUM)
+		skb->ip_summed = rcv_priv->ip_summed;
+
+	dst_release(skb->dst);
Quoted 8 lines

drivers/net/veth.c line 161

Quoted 4 lines
drivers/net/veth.c new file +4 -0
+	skb->dst = NULL;
+
+	secpath_reset(skb);
+	nf_reset(skb);

Is skb->mark supposed to survive communication between different namespaces?

Quoted 1 line

I guess it must not. Thanks.

I guess there are a few others that should be cleared as well, like the tc related members, secmark, ipvs_property, ...

Quoted 15 lines
Quoted 5 lines

The rtnl_link codes looks fine. I don't like the VETH_INFO_MAC attribute very much though, we already have a generic device attribute for MAC addresses. Of course that only allows you to supply one MAC address, so I'm wondering what you think of allocating only a single device per newlink operation and binding them in a seperate enslave operation?

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 5 lines

But with such approach the creation looks really logical. We send a packet to the kernel and have a single response about the new device appearance. At the same time we have a RTNL_NEWLINK message arrived at the destination namespace informing that a new device has appeared there as well.

The question is how to proceed. I haven't read all mails yet, but it seems there is some disagreement about whether to create all devices in the same namespace and move them later or create them directly in their target namespace. For now I guess it doesn't matter much, so can everyone agree to adding a IFLA_PARTNER attribute that includes a complete ifinfomsg and the attributes and you later decide how to handle namespaces?

Quoted 16 lines
Quoted 11 lines

include/net/veth.h line 11

Quoted 8 lines
include/net/veth.h new file +8 -0
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};

Please follow the

Quoted 3 lines

#define VETH_INFO_MAX (__VETH_INFO_MAX - 1)

convention here.

Quoted 8 lines

Could you please clarify this point. I saw the lines

enum {
	...
	RTNL_NEWLINK
#define RTNL_NEWLINK RTNL_NEWLINK
	...
}

and had my brains exploded imagining what this would mean :(

Thats just to make the new attributes visible as preprocessor symbols so userspace can use them for #ifdefs. We usually use it when adding new attributes/message types, but its not necessary for the initial set of attributes if you already have some other preprocessor-visisble symbol (like VETH_INFO_MAX) userspace can use.

What I was refering to is this convention:

enum {
...

        __IFLA_MAX
};

#define IFLA_MAX (__IFLA_MAX - 1)

Which is used to make sure that IFLA_MAX is really the max and not max + 1 and additionally people won't forget to update it.

#14 lore raw
Quoted 18 lines · Patrick McHardy
Quoted 17 lines · Pavel Emelianov
Quoted 13 lines · Patrick McHardy

drivers/net/veth.c line 161

Quoted 10 lines
drivers/net/veth.c new file +10 -0
+	skb->pkt_type = PACKET_HOST;
+	skb->protocol = eth_type_trans(skb, rcv);
+	if (dev->features & NETIF_F_NO_CSUM)
+		skb->ip_summed = rcv_priv->ip_summed;
+
+	dst_release(skb->dst);
+	skb->dst = NULL;
+
+	secpath_reset(skb);
+	nf_reset(skb);

Is skb->mark supposed to survive communication between different namespaces?

Quoted 5 lines
Quoted 1 line

I guess it must not. Thanks.

I guess there are a few others that should be cleared as well, like the tc related members, secmark, ipvs_property, ...

It seems like we are about to have some skb_reset_all() routine to make the skb look like newborn.

Quoted 21 lines
Quoted 14 lines
Quoted 5 lines

The rtnl_link codes looks fine. I don't like the VETH_INFO_MAC attribute very much though, we already have a generic device attribute for MAC addresses. Of course that only allows you to supply one MAC address, so I'm wondering what you think of allocating only a single device per newlink operation and binding them in a seperate enslave operation?

I did this at the very first version, but Alexey showed me that this would be wrong. Look. When we create the second device it must be in the other namespace as it is useless to have them in one namespace. But if we have the device in the other namespace the RTNL_NEWLINK message from kernel would come into this namespace thus confusing ip utility in the init namespace. Creating the device in the init ns and moving it into the new one is rather a complex task.

Quoted 5 lines

But with such approach the creation looks really logical. We send a packet to the kernel and have a single response about the new device appearance. At the same time we have a RTNL_NEWLINK message arrived at the destination namespace informing that a new device has appeared there as well.

Quoted 3 lines

The question is how to proceed. I haven't read all mails yet, but it seems there is some disagreement about whether to create all devices in the same namespace and move them later or create them directly in

The agreement was that we can make any of the above. We can create booth devices in the init namespace and then move one of them into the desired namespace, or we can explicitly specify which namespace to create the pair in.

Quoted 40 lines

their target namespace. For now I guess it doesn't matter much, so can everyone agree to adding a IFLA_PARTNER attribute that includes a complete ifinfomsg and the attributes and you later decide how to handle namespaces?

Quoted 14 lines
Quoted 10 lines

include/net/veth.h line 11

Quoted 8 lines
include/net/veth.h new file +8 -0
+enum {
+	VETH_INFO_UNSPEC,
+	VETH_INFO_MAC,
+	VETH_INFO_PEER,
+	VETH_INFO_PEER_MAC,
+
+	VETH_INFO_MAX
+};

Please follow the

Quoted 3 lines

#define VETH_INFO_MAX (__VETH_INFO_MAX - 1)

convention here.

Quoted 8 lines

Could you please clarify this point. I saw the lines

enum {
	...
	RTNL_NEWLINK
#define RTNL_NEWLINK RTNL_NEWLINK
	...
}

and had my brains exploded imagining what this would mean :(

Thats just to make the new attributes visible as preprocessor symbols so userspace can use them for #ifdefs. We usually use it when adding new attributes/message types, but its not necessary for the initial set of attributes if you already have some other preprocessor-visisble symbol (like VETH_INFO_MAX) userspace can use.

What I was refering to is this convention:

enum {
...

Quoted 7 lines
        __IFLA_MAX
};

#define IFLA_MAX (__IFLA_MAX - 1)

Which is used to make sure that IFLA_MAX is really the max and not max + 1 and additionally people won't forget to update it.

OK thanks. This is already done in the v2.

Thanks,
Pavel

#15 lore raw
Quoted 11 lines · Pavel Emelianov
Quoted 3 lines · Patrick McHardy

The question is how to proceed. I haven't read all mails yet, but it seems there is some disagreement about whether to create all devices in the same namespace and move them later or create them directly in

The agreement was that we can make any of the above. We can create booth devices in the init namespace and then move one of them into the desired namespace, or we can explicitly specify which namespace to create the pair in.

I'm going to push my latest patches to Dave today, the easiest way is probably is you just add whatever you need to the API afterwards.

#16 lore raw
Quoted 7 lines · Patrick McHardy
Quoted 6 lines · Pavel Emelianov
Quoted 3 lines · Patrick McHardy

The question is how to proceed. I haven't read all mails yet, but it seems there is some disagreement about whether to create all devices in the same namespace and move them later or create them directly in

Quoted 10 lines
Quoted 4 lines

The agreement was that we can make any of the above. We can create booth devices in the init namespace and then move one of them into the desired namespace, or we can explicitly specify which namespace to create the pair in.

I'm going to push my latest patches to Dave today, the easiest way is probably is you just add whatever you need to the API afterwards.

OK. Dave didn't object against the driver. Hope he will accept it as well.

I have also found a BUG in your API. Look, when you declare the alias with the MODULE_ALIAS_RTNL_LINK in drivers you use strings as an argument. But this macro stringifyes the argument itself which results in bad aliases.

---

include/net/rtnetlink.h +1 -1
index d744198..f627e1f 100644
@@ -77,6 +77,6 @@ extern void	__rtnl_link_unregister(struc
 extern int	rtnl_link_register(struct rtnl_link_ops *ops);
 extern void	rtnl_link_unregister(struct rtnl_link_ops *ops);
 
-#define MODULE_ALIAS_RTNL_LINK(name) MODULE_ALIAS("rtnl-link-" #name)
+#define MODULE_ALIAS_RTNL_LINK(name) MODULE_ALIAS("rtnl-link-" name)
 
 #endif
#17 lore raw
Quoted 22 lines · Pavel Emelianov
Quoted 3 lines · Patrick McHardy

I'm going to push my latest patches to Dave today, the easiest way is probably is you just add whatever you need to the API afterwards.

OK. Dave didn't object against the driver. Hope he will accept it as well.

I have also found a BUG in your API. Look, when you declare the alias with the MODULE_ALIAS_RTNL_LINK in drivers you use strings as an argument. But this macro stringifyes the argument itself which results in bad aliases.

---

include/net/rtnetlink.h +0 -0
index d744198..f627e1f 100644

include/net/rtnetlink.h extern void __rtnl_link_unregister(struc · line 80

Quoted 5 lines
include/net/rtnetlink.h +1 -1
@@ -77,6 +77,6 @@ extern void	__rtnl_link_unregister(struc
 extern int	rtnl_link_register(struct rtnl_link_ops *ops);
 extern void	rtnl_link_unregister(struct rtnl_link_ops *ops);
 
-#define MODULE_ALIAS_RTNL_LINK(name) MODULE_ALIAS("rtnl-link-" #name)
+#define MODULE_ALIAS_RTNL_LINK(name) MODULE_ALIAS("rtnl-link-" name)

Thanks, I already fixed this during final round of testing :)