From: Stephen Hemminger <stephen@networkplumber.org>
To: Hangbin Liu <liuhangbin@gmail.com>
Cc: netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>,
Phil Sutter <phil@nwl.cc>, David Ahern <dsahern@gmail.com>,
Andrea Claudi <aclaudi@redhat.com>
Subject: Re: [PATCH iproute2] ip/iptoken: fix dump error when ipv6 disabled
Date: Tue, 25 Jun 2019 13:11:26 -0700 [thread overview]
Message-ID: <20190625131126.6a7121b4@hermes.lan> (raw)
In-Reply-To: <20190625093550.7804-1-liuhangbin@gmail.com>
On Tue, 25 Jun 2019 17:35:50 +0800
Hangbin Liu <liuhangbin@gmail.com> wrote:
> When we disable IPv6 from the start up (ipv6.disable=1), there will be
> no IPv6 route info in the dump message. If we return -1 when
> ifi->ifi_family != AF_INET6, we will get error like
>
> $ ip token list
> Dump terminated
>
> which will make user feel confused. There is no need to return -1 if the
> dump message not match. Return 0 is enough.
>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
> ip/iptoken.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/ip/iptoken.c b/ip/iptoken.c
> index f1194c3e..dfd22734 100644
> --- a/ip/iptoken.c
> +++ b/ip/iptoken.c
> @@ -59,13 +59,9 @@ static int print_token(struct nlmsghdr *n, void *arg)
> if (len < 0)
> return -1;
>
> - if (ifi->ifi_family != AF_INET6)
> - return -1;
> - if (ifi->ifi_index == 0)
> - return -1;
> - if (ifindex > 0 && ifi->ifi_index != ifindex)
> - return 0;
> - if (ifi->ifi_flags & (IFF_LOOPBACK | IFF_NOARP))
> + if (ifi->ifi_family != AF_INET6 || ifi->ifi_index == 0 ||
> + (ifindex > 0 && ifi->ifi_index != ifindex) ||
> + (ifi->ifi_flags & (IFF_LOOPBACK | IFF_NOARP)))
> return 0;
Please don't combine all the conditions, it is simpler as:
if (ifi->ifi_family != AF_INET6)
return 0;
next prev parent reply other threads:[~2019-06-25 20:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 9:35 [PATCH iproute2] ip/iptoken: fix dump error when ipv6 disabled Hangbin Liu
2019-06-25 20:11 ` Stephen Hemminger [this message]
2019-06-26 1:44 ` [PATCHv2 " Hangbin Liu
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=20190625131126.6a7121b4@hermes.lan \
--to=stephen@networkplumber.org \
--cc=aclaudi@redhat.com \
--cc=daniel@iogearbox.net \
--cc=dsahern@gmail.com \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=phil@nwl.cc \
/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;
as well as URLs for NNTP newsgroup(s).