Thread (3 messages) 3 messages, 2 authors, 2014-10-01

Re: [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation

From: Cong Wang <hidden>
Date: 2014-09-30 18:26:06

On Tue, Sep 30, 2014 at 4:10 AM, Atzm Watanabe [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Since commit 3c682146aeff, iplink requires assigning negative
ifindex (-1) to the kernel when creating interface without
specifying index.

Cc: Cong Wang <redacted>
Signed-off-by: Atzm Watanabe <redacted>
---
 ip/iplink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index cb9c870..de6b2a9 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -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 <= 0)
+                       req.i.ifi_index = 0;
+               else
+                       req.i.ifi_index = index;
How about checking if it is -1?

if (index == -1)
   req.i.ifi_index = 0;
else
   req.i.ifi_index = index;


Thanks for fixing it.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help