* [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation
@ 2014-09-30 11:10 Atzm Watanabe
2014-09-30 18:26 ` Cong Wang
0 siblings, 1 reply; 3+ messages in thread
From: Atzm Watanabe @ 2014-09-30 11:10 UTC (permalink / raw)
To: netdev; +Cc: Cong Wang, Stephen Hemminger
Since commit 3c682146aeff, iplink requires assigning negative
ifindex (-1) to the kernel when creating interface without
specifying index.
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
---
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;
}
if (name) {
--
1.8.1.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation
2014-09-30 11:10 [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation Atzm Watanabe
@ 2014-09-30 18:26 ` Cong Wang
2014-10-01 4:30 ` Atzm Watanabe
0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2014-09-30 18:26 UTC (permalink / raw)
To: Atzm Watanabe; +Cc: netdev, Cong Wang, Stephen Hemminger
On Tue, Sep 30, 2014 at 4:10 AM, Atzm Watanabe <atzm@stratosphere.co.jp> wrote:
> Since commit 3c682146aeff, iplink requires assigning negative
> ifindex (-1) to the kernel when creating interface without
> specifying index.
>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
> ---
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation
2014-09-30 18:26 ` Cong Wang
@ 2014-10-01 4:30 ` Atzm Watanabe
0 siblings, 0 replies; 3+ messages in thread
From: Atzm Watanabe @ 2014-10-01 4:30 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Cong Wang, Stephen Hemminger
At Tue, 30 Sep 2014 11:26:04 -0700,
Cong Wang wrote:
>
> On Tue, Sep 30, 2014 at 4:10 AM, Atzm Watanabe <atzm@stratosphere.co.jp> wrote:
> > Since commit 3c682146aeff, iplink requires assigning negative
> > ifindex (-1) to the kernel when creating interface without
> > specifying index.
> >
> > Cc: Cong Wang <xiyou.wangcong@gmail.com>
> > Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
> > ---
> > 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;
Agreed, will fix.
Because iplink_parse() forbids specifying negative index, it will be
actually same. But your suggestion seems more nicer than my patch.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-01 4:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-30 11:10 [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation Atzm Watanabe
2014-09-30 18:26 ` Cong Wang
2014-10-01 4:30 ` Atzm Watanabe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox