Skip to contentSkip to conversation

iplink: do not require assigning negative ifindex at link creation

PATCH In review Atzm Watanabe 2 participants 2 messages Oct 1, 2014 – Oct 2, 2014

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

PATCH v2 1/1 iplink: do not require assigning negative ifindex at link creation

Since commit 3c682146aeff, iplink requires assigning negative ifindex (-1) to the kernel when creating interface without specifying index.

v2: checking whether index is -1, suggested by Cong Wang.

---
 ip/iplink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ip/iplink.c +4 -1
index cb9c870..5dd6060 100644
@@ -689,7 +689,10 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 			addattr_l(&req.n, sizeof(req), IFLA_LINK, &ifindex, 4);
 		}
 
-		req.i.ifi_index = index;
+		if (index == -1)
+			req.i.ifi_index = 0;
+		else
+			req.i.ifi_index = index;
 	}
 
 	if (name) {
Signature · 1 line
1.8.1.5