[PATCH 2/2] Virtual ethernet device driver

2007-07-19 Thread Pavel Emelyanov
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. The newlink callback is organized tha

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-16 Thread Patrick McHardy
Pavel Emelianov wrote: > Patrick McHardy wrote: > >> You don't have a struct ifinfomsg for the peer device. At some >> point we might want to add support for specifying initial flags >> for the device (some easily supportable ones are IFF_PROMISC, >> IFF_ALLMULTI, IFF_NOARP) and ideally that shoul

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-16 Thread Pavel Emelianov
Patrick McHardy wrote: Pavel Emelianov wrote: Patrick McHardy wrote: Pavel Emelianov wrote: + if (data != NULL && data[VETH_INFO_PEER] != NULL) { + err = nla_parse_nested(tb, IFLA_INFO_MAX, + data[VETH_INFO_PEER], ifla_policy); +

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-16 Thread Pavel Emelianov
Patrick McHardy wrote: Pavel Emelianov wrote: Patrick McHardy wrote: + + if (tb[IFLA_IFNAME]) + nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); + else + snprintf(ifname, IFNAMSIZ, DRV_NAME "%%d"); Does this work? The other device is not registered at t

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Patrick McHardy
Pavel Emelianov wrote: > Patrick McHardy wrote: > >>Pavel Emelianov wrote: >> >>>+if (data != NULL && data[VETH_INFO_PEER] != NULL) { >>>+err = nla_parse_nested(tb, IFLA_INFO_MAX, >>>+data[VETH_INFO_PEER], ifla_policy); >>>+if (err < 0) >>>+

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Pavel Emelianov
Patrick McHardy wrote: > Pavel Emelianov wrote: >> +if (data != NULL && data[VETH_INFO_PEER] != NULL) { >> +err = nla_parse_nested(tb, IFLA_INFO_MAX, >> +data[VETH_INFO_PEER], ifla_policy); >> +if (err < 0) >> +return err;

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Pavel Emelianov
Patrick McHardy wrote: > Pavel Emelianov wrote: >> Patrick McHardy wrote: >> >>> No, to get unique names the sequence has to be: >>> >>> dev_alloc_name >>> register_netdevice >>> dev_alloc_name >>> register_netdevice >>> >>> But you have: >>> >>> dev_alloc_name >>> dev_alloc_name (<- might allocate

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Patrick McHardy
Pavel Emelianov wrote: > + if (data != NULL && data[VETH_INFO_PEER] != NULL) { > + err = nla_parse_nested(tb, IFLA_INFO_MAX, > + data[VETH_INFO_PEER], ifla_policy); > + if (err < 0) > + return err; > + } One more sugg

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Patrick McHardy
Pavel Emelianov wrote: > Patrick McHardy wrote: > >>No, to get unique names the sequence has to be: >> >>dev_alloc_name >>register_netdevice >>dev_alloc_name >>register_netdevice >> >>But you have: >> >>dev_alloc_name >>dev_alloc_name (<- might allocate same name as first call) >>register_netdevic

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Pavel Emelianov
Patrick McHardy wrote: > Pavel Emelianov wrote: >> Patrick McHardy wrote: >> >>> Pavel Emelianov wrote: >>> +static int veth_newlink(struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[]) +{ + int err; + struct net_device *peer; + st

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Patrick McHardy
Pavel Emelianov wrote: > Patrick McHardy wrote: > >>>+ >>>+if (tb[IFLA_IFNAME]) >>>+nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); >>>+else >>>+snprintf(ifname, IFNAMSIZ, DRV_NAME "%%d"); >> >> >>Does this work? The other device is not registered at this time, so I

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Patrick McHardy
Pavel Emelianov wrote: > Patrick McHardy wrote: > >>Pavel Emelianov wrote: >> >>>+static int veth_newlink(struct net_device *dev, >>>+ struct nlattr *tb[], struct nlattr *data[]) >>>+{ >>>+int err; >>>+struct net_device *peer; >>>+struct veth_priv *priv; >>>+cha

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Pavel Emelianov
Patrick McHardy wrote: > Pavel Emelianov wrote: >> +static int veth_newlink(struct net_device *dev, >> + struct nlattr *tb[], struct nlattr *data[]) >> +{ >> +int err; >> +struct net_device *peer; >> +struct veth_priv *priv; >> +char ifname[IFNAMSIZ]; >> + >> +

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Pavel Emelianov
Patrick McHardy wrote: > Pavel Emelianov wrote: >> +static int veth_newlink(struct net_device *dev, >> + struct nlattr *tb[], struct nlattr *data[]) >> +{ >> +int err; >> +struct net_device *peer; >> +struct veth_priv *priv; >> +char ifname[IFNAMSIZ]; >> + >> +

Re: [PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread Patrick McHardy
Pavel Emelianov wrote: > +static int veth_newlink(struct net_device *dev, > + struct nlattr *tb[], struct nlattr *data[]) > +{ > + int err; > + struct net_device *peer; > + struct veth_priv *priv; > + char ifname[IFNAMSIZ]; > + > + /* > + * prepare the

[PATCH 2/2] Virtual ethernet device driver

2007-07-12 Thread 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. The newlink callback is organized that