[3/3] veth: Set ifindex only if given and not negative

Submitted by Serhey Popovych on June 16, 2017, 2:23 p.m.

Details

Message ID 86924b2059b7460b8998fac46f0d7262d7c358d4.1497621810.git.serhe.popovych@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show

Commit Message

Serhey Popovych June 16, 2017, 2:23 p.m.
There is already check for ifindex being non negative in
register_netdevice(). Do the same here for convenience.

Fixes: e6f8f1a739b6 ("veth: Allow to create peer link with given ifindex")
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 drivers/net/veth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 0156fe8..0689433 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -405,7 +405,7 @@  static int veth_newlink(struct net *src_net, struct net_device *dev,
 	if (tbp[IFLA_ADDRESS] == NULL)
 		eth_hw_addr_random(peer);
 
-	if (ifmp && (dev->ifindex != 0))
+	if (ifmp && dev->ifindex > 0)
 		peer->ifindex = ifmp->ifi_index;
 
 	err = register_netdevice(peer);