From: Atzm Watanabe <atzm@stratosphere.co.jp>
To: Cong Wang <cwang@twopensource.com>
Cc: netdev <netdev@vger.kernel.org>,
Cong Wang <xiyou.wangcong@gmail.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH iproute2] iplink: do not require assigning negative ifindex at link creation
Date: Wed, 01 Oct 2014 13:30:28 +0900 [thread overview]
Message-ID: <87vbo45s4b.wl%atzm@stratosphere.co.jp> (raw)
In-Reply-To: <CAHA+R7NSDU3PeBeJu0jnsZtdmQE=P6zUBH9jram=3gsVZYzcmw@mail.gmail.com>
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.
prev parent reply other threads:[~2014-10-01 4:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbo45s4b.wl%atzm@stratosphere.co.jp \
--to=atzm@stratosphere.co.jp \
--cc=cwang@twopensource.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox