All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] veth: Be more robust on network device creation when no attributes
@ 2017-06-16 15:05 Serhey Popovych
  2017-06-20 16:40 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Serhey Popovych @ 2017-06-16 15:05 UTC (permalink / raw)
  To: netdev

There are number of problems with configuration peer
network device in absence of IFLA_VETH_PEER attributes
where attributes for main network device shared with
peer.

First it is not feasible to configure both network
devices with same MAC address since this makes
communication in such configuration problematic.

This case can be reproduced with following sequence:

  # ip link add address 02:11:22:33:44:55 type veth
  # ip li sh
  ...
  26: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
  noop state DOWN mode DEFAULT qlen 1000
      link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
  27: veth1@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
  noop state DOWN mode DEFAULT qlen 1000
      link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

Second it is not possible to register main network device
with given name and automatically create peer network
device name. That happens because IFLA_IFNAME used when
creating main and reused when creating peer.

This case can be reproduced with following sequence:

  # ip link add dev veth1a type veth
  RTNETLINK answers: File exists

To fix both of the cases check if corresponding netlink
attributes are taken from peer_tb when valid or
name based on rtnl ops kind and random address is used.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 drivers/net/veth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 0689433..17714db 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -383,7 +383,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 		tbp = tb;
 	}
 
-	if (tbp[IFLA_IFNAME]) {
+	if (ifmp && tbp[IFLA_IFNAME]) {
 		nla_strlcpy(ifname, tbp[IFLA_IFNAME], IFNAMSIZ);
 		name_assign_type = NET_NAME_USER;
 	} else {
@@ -402,7 +402,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 		return PTR_ERR(peer);
 	}
 
-	if (tbp[IFLA_ADDRESS] == NULL)
+	if (!ifmp || !tbp[IFLA_ADDRESS])
 		eth_hw_addr_random(peer);
 
 	if (ifmp && dev->ifindex > 0)
-- 
1.8.3.1

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

* Re: [PATCH] veth: Be more robust on network device creation when no attributes
  2017-06-16 15:05 [PATCH] veth: Be more robust on network device creation when no attributes Serhey Popovych
@ 2017-06-20 16:40 ` David Miller
  2017-06-21  9:02   ` Serhey Popovych
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2017-06-20 16:40 UTC (permalink / raw)
  To: serhe.popovych; +Cc: netdev

From: Serhey Popovych <serhe.popovych@gmail.com>
Date: Fri, 16 Jun 2017 18:05:00 +0300

> There are number of problems with configuration peer
> network device in absence of IFLA_VETH_PEER attributes
> where attributes for main network device shared with
> peer.
> 
> First it is not feasible to configure both network
> devices with same MAC address since this makes
> communication in such configuration problematic.
> 
> This case can be reproduced with following sequence:
> 
>   # ip link add address 02:11:22:33:44:55 type veth
>   # ip li sh
>   ...
>   26: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
>   noop state DOWN mode DEFAULT qlen 1000
>       link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
>   27: veth1@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
>   noop state DOWN mode DEFAULT qlen 1000
>       link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
> 
> Second it is not possible to register main network device
> with given name and automatically create peer network
> device name. That happens because IFLA_IFNAME used when
> creating main and reused when creating peer.
> 
> This case can be reproduced with following sequence:
> 
>   # ip link add dev veth1a type veth
>   RTNETLINK answers: File exists
> 
> To fix both of the cases check if corresponding netlink
> attributes are taken from peer_tb when valid or
> name based on rtnl ops kind and random address is used.
> 
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>

This does not apply cleanly to the 'net' tree, please respin.

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

* veth: Be more robust on network device creation when no attributes
  2017-06-20 16:40 ` David Miller
@ 2017-06-21  9:02   ` Serhey Popovych
  2017-06-21  9:12     ` Serhey Popovych
  0 siblings, 1 reply; 5+ messages in thread
From: Serhey Popovych @ 2017-06-21  9:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

There are number of problems with configuration peer
network device in absence of IFLA_VETH_PEER attributes
where attributes for main network device shared with
peer.

First it is not feasible to configure both network
devices with same MAC address since this makes
communication in such configuration problematic.

This case can be reproduced with following sequence:

  # ip link add address 02:11:22:33:44:55 type veth
  # ip li sh
  ...
  26: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
  noop state DOWN mode DEFAULT qlen 1000
      link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
  27: veth1@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
  noop state DOWN mode DEFAULT qlen 1000
      link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

Second it is not possible to register both main and
peer network devices with same name, that happens
when name for main interface is given with IFLA_IFNAME
and same attribute reused for peer.

This case can be reproduced with following sequence:

  # ip link add dev veth1a type veth
  RTNETLINK answers: File exists

To fix both of the cases check if corresponding netlink
attributes are taken from peer_tb when valid or
name based on rtnl ops kind and random address is used.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 v2: Rebase to kernel/davem/net.git
 
 drivers/net/veth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 0689433..17714db 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -383,7 +383,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 		tbp = tb;
 	}
 
-	if (tbp[IFLA_IFNAME]) {
+	if (ifmp && tbp[IFLA_IFNAME]) {
 		nla_strlcpy(ifname, tbp[IFLA_IFNAME], IFNAMSIZ);
 		name_assign_type = NET_NAME_USER;
 	} else {
@@ -402,7 +402,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 		return PTR_ERR(peer);
 	}
 
-	if (tbp[IFLA_ADDRESS] == NULL)
+	if (!ifmp || !tbp[IFLA_ADDRESS])
 		eth_hw_addr_random(peer);
 
 	if (ifmp && dev->ifindex > 0)
-- 
1.8.3.1

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

* veth: Be more robust on network device creation when no attributes
  2017-06-21  9:02   ` Serhey Popovych
@ 2017-06-21  9:12     ` Serhey Popovych
  2017-06-22 15:16       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Serhey Popovych @ 2017-06-21  9:12 UTC (permalink / raw)
  To: davem; +Cc: netdev

There are number of problems with configuration peer
network device in absence of IFLA_VETH_PEER attributes
where attributes for main network device shared with
peer.

First it is not feasible to configure both network
devices with same MAC address since this makes
communication in such configuration problematic.

This case can be reproduced with following sequence:

  # ip link add address 02:11:22:33:44:55 type veth
  # ip li sh
  ...
  26: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
  noop state DOWN mode DEFAULT qlen 1000
      link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
  27: veth1@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
  noop state DOWN mode DEFAULT qlen 1000
      link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

Second it is not possible to register both main and
peer network devices with same name, that happens
when name for main interface is given with IFLA_IFNAME
and same attribute reused for peer.

This case can be reproduced with following sequence:

  # ip link add dev veth1a type veth
  RTNETLINK answers: File exists

To fix both of the cases check if corresponding netlink
attributes are taken from peer_tb when valid or
name based on rtnl ops kind and random address is used.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 v3: Really rebase to kernel/davem/net.git
 v2: Rebase to kernel/davem/net.git
 
 drivers/net/veth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 0156fe8..364fa9d 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -383,7 +383,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 		tbp = tb;
 	}
 
-	if (tbp[IFLA_IFNAME]) {
+	if (ifmp && tbp[IFLA_IFNAME]) {
 		nla_strlcpy(ifname, tbp[IFLA_IFNAME], IFNAMSIZ);
 		name_assign_type = NET_NAME_USER;
 	} else {
@@ -402,7 +402,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 		return PTR_ERR(peer);
 	}
 
-	if (tbp[IFLA_ADDRESS] == NULL)
+	if (!ifmp || !tbp[IFLA_ADDRESS])
 		eth_hw_addr_random(peer);
 
 	if (ifmp && (dev->ifindex != 0))
-- 
1.8.3.1

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

* Re: veth: Be more robust on network device creation when no attributes
  2017-06-21  9:12     ` Serhey Popovych
@ 2017-06-22 15:16       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-06-22 15:16 UTC (permalink / raw)
  To: serhe.popovych; +Cc: netdev

From: Serhey Popovych <serhe.popovych@gmail.com>
Date: Wed, 21 Jun 2017 12:12:24 +0300

> There are number of problems with configuration peer
> network device in absence of IFLA_VETH_PEER attributes
> where attributes for main network device shared with
> peer.
> 
> First it is not feasible to configure both network
> devices with same MAC address since this makes
> communication in such configuration problematic.
> 
> This case can be reproduced with following sequence:
> 
>   # ip link add address 02:11:22:33:44:55 type veth
>   # ip li sh
>   ...
>   26: veth0@veth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
>   noop state DOWN mode DEFAULT qlen 1000
>       link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
>   27: veth1@veth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc \
>   noop state DOWN mode DEFAULT qlen 1000
>       link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
> 
> Second it is not possible to register both main and
> peer network devices with same name, that happens
> when name for main interface is given with IFLA_IFNAME
> and same attribute reused for peer.
> 
> This case can be reproduced with following sequence:
> 
>   # ip link add dev veth1a type veth
>   RTNETLINK answers: File exists
> 
> To fix both of the cases check if corresponding netlink
> attributes are taken from peer_tb when valid or
> name based on rtnl ops kind and random address is used.
> 
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>

Applied.

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

end of thread, other threads:[~2017-06-22 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-16 15:05 [PATCH] veth: Be more robust on network device creation when no attributes Serhey Popovych
2017-06-20 16:40 ` David Miller
2017-06-21  9:02   ` Serhey Popovych
2017-06-21  9:12     ` Serhey Popovych
2017-06-22 15:16       ` David Miller

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.