From: Thomas Haller <thaller@redhat.com>
To: Phil Sutter <phil@nwl.cc>,
Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] ip-address: properly display zero IPv4 peer address
Date: Tue, 24 Nov 2015 13:14:40 +0100 [thread overview]
Message-ID: <1448367280.3677.16.camel@redhat.com> (raw)
In-Reply-To: <20151124114417.GA23115@orbit.nwl.cc>
[-- Attachment #1: Type: text/plain, Size: 2547 bytes --]
On Tue, 2015-11-24 at 12:44 +0100, Phil Sutter wrote:
> On Mon, Nov 23, 2015 at 04:04:50PM -0800, Stephen Hemminger wrote:
> > On Thu, 22 Oct 2015 10:34:28 +0200
> > Thomas Haller <thaller@redhat.com> wrote:
> >
> > > Kernel allows for zero IPv4 peer addresses (IFA_ADDRESS):
> > >
> > > ip address add 192.168.5.1 peer 0.0.0.0/24 dev dummy
> > >
> > > which is distinct from a usual address like:
> > >
> > > ip address add 192.168.5.1/24 dev dummy
> > > ip address add 192.168.5.1 peer 192.168.5.1/24 dev dummy
> > >
> > > For IPv4, a missing IFA_ADDRESS attribute means that the peer
> > > is 0.0.0.0. See inet_fill_ifaddr(), which does:
> > >
> > > if ((ifa->ifa_address &&
> > > nla_put_in_addr(skb, IFA_ADDRESS, ifa->ifa_address)) ||
> > >
> > > Signed-off-by: Thomas Haller <thaller@redhat.com>
> >
> > I would prefer that this apply to both IPv4 and IPv6.
>
> The case that patch handles does not happen in IPv6.
>
> > If the kernel sends back an address, then display it.
>
> It's rather "if the kernel *does not* send back an address ...".
>
> When reviewing this patch, I tried to find an easier (and less ugly)
> solution, but failed. Here's the result from testing all variants:
Thank you Phil for evaluating this.
I also tried to change the patch to come up with a cleaner/unified way,
but the result wasn't subjectively better.
Thomas
For reference, the relevant lines of code from kernel:
ipv4: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/devinet.c?id=6a13feb9c82803e2b815eca72fa7a9f5561d7861#n1542
if ((ifa->ifa_address &&
nla_put_in_addr(skb, IFA_ADDRESS, ifa->ifa_address)) ||
(ifa->ifa_local &&
nla_put_in_addr(skb, IFA_LOCAL, ifa->ifa_local)) ||
ipv6: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/ipv6/addrconf.c?id=6a13feb9c82803e2b815eca72fa7a9f5561d7861#n4310
if (!ipv6_addr_any(&ifa->peer_addr)) {
if (nla_put_in6_addr(skb, IFA_LOCAL, &ifa->addr) < 0 ||
nla_put_in6_addr(skb, IFA_ADDRESS, &ifa->peer_addr) < 0)
goto error;
} else
if (nla_put_in6_addr(skb, IFA_ADDRESS, &ifa->addr) < 0)
goto error;
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2015-11-24 12:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 8:34 [PATCH iproute2] ip-address: properly display zero IPv4 peer address Thomas Haller
2015-11-11 11:34 ` Phil Sutter
2015-11-24 0:04 ` Stephen Hemminger
2015-11-24 11:44 ` Phil Sutter
2015-11-24 12:14 ` Thomas Haller [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=1448367280.3677.16.camel@redhat.com \
--to=thaller@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=phil@nwl.cc \
--cc=stephen@networkplumber.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.