netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	linux-kernel@vger.kernel.org
Subject: Issues during assigning addresses on point to point interfaces
Date: Sun, 6 Jun 2021 17:10:08 +0200	[thread overview]
Message-ID: <20210606151008.7dwx5ukrlvxt4t3k@pali> (raw)

Hello!

Seems that there is a bug during assigning IP addresses on point to
point interfaces.

Assigning just one local address works fine:

    ip address add fe80::6 dev ppp1 --> inet6 fe80::6/128 scope link

Assigning both local and remote peer address also works fine:

    ip address add fe80::7 peer fe80::8 dev ppp1 ---> inet6 fe80::7 peer fe80::8/128 scope link

But trying to assign just remote peer address does not work. Moreover
"ip address" call does not fail, it returns zero but instead of setting
remote peer address, it sets local address:

    ip address add peer fe80::5 dev ppp1 --> inet6 fe80::5/128 scope link

I suspect that this is a bug either in iproute2 "ip" utility or in
kernel how it parse and process netlink messages.

strace for the last command see this netlink packet:

    sendmsg(3, {
        msg_name={
            sa_family=AF_NETLINK,
            nl_pid=0,
            nl_groups=00000000
        },
        msg_namelen=12,
        msg_iov=[{
            iov_base={
                {
                    len=44,
                    type=RTM_NEWADDR,
                    flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL|NLM_F_CREATE,
                    seq=1622990155,
                    pid=0
                },
                {
                    ifa_family=AF_INET6,
                    ifa_prefixlen=128,
                    ifa_flags=0,
                    ifa_scope=RT_SCOPE_UNIVERSE,
                    ifa_index=if_nametoindex("ppp1")
                },
                {
                    {
                        nla_len=20,
                        nla_type=IFA_ADDRESS
                    },
                    inet_pton(AF_INET6, "fe80::5")
                }
            },
            iov_len=44
        }],
        msg_iovlen=1,
        msg_controllen=0,
        msg_flags=0
    }, 0) = 44

On the other hand strace for the first command (which assigns only local
address) see following netlink packet:

    sendmsg(3, {
        msg_name={
            sa_family=AF_NETLINK,
            nl_pid=0,
            nl_groups=00000000
        },
        msg_namelen=12,
        msg_iov=[{
            iov_base={
                {
                    len=64,
                    type=RTM_NEWADDR,
                    flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL|NLM_F_CREATE,
                    seq=1622990488,
                    pid=0
                },
                {
                    ifa_family=AF_INET6,
                    ifa_prefixlen=128,
                    ifa_flags=0,
                    ifa_scope=RT_SCOPE_UNIVERSE,
                    ifa_index=if_nametoindex("ppp1")
                },
                [
                    {
                        {
                            nla_len=20,
                            nla_type=IFA_LOCAL
                        },
                        inet_pton(AF_INET6, "fe80::6")
                    },
                    {
                        {
                            nla_len=20,
                            nla_type=IFA_ADDRESS
                        },
                        inet_pton(AF_INET6, "fe80::6")
                    }
                ]
            },
            iov_len=64
        }],
        msg_iovlen=1,
        msg_controllen=0,
        msg_flags=0
    }, 0) = 64

So it sends two addresses, one IFA_LOCAL, one IFA_ADDRESS, but both are
same.

For completeness here is strace output when assigning both local and
remote peer address:

    sendmsg(3, {
        msg_name={
            sa_family=AF_NETLINK,
            nl_pid=0,
            nl_groups=00000000
        },
        msg_namelen=12,
        msg_iov=[{
            iov_base={
                {
                    len=64,
                    type=RTM_NEWADDR,
                    flags=NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL|NLM_F_CREATE,
                    seq=1622990883,
                    pid=0
                },
                {
                    ifa_family=AF_INET6,
                    ifa_prefixlen=128,
                    ifa_flags=0,
                    ifa_scope=RT_SCOPE_UNIVERSE,
                    ifa_index=if_nametoindex("ppp1")
                },
                [
                    {
                        {
                            nla_len=20,
                            nla_type=IFA_LOCAL
                        },
                        inet_pton(AF_INET6, "fe80::7")
                    },
                    {
                        {
                            nla_len=20,
                            nla_type=IFA_ADDRESS
                        },
                        inet_pton(AF_INET6, "fe80::8")
                    }
                ]
            },
            iov_len=64
        }],
        msg_iovlen=1,
        msg_controllen=0,
        msg_flags=0
    }, 0) = 64

Which means that IFA_LOCAL sets local address and IFA_ADDRESS sets
remote peer address on point point interface.

Therefore there are two suspicious things about address configuration on
point to point interfaces:

1) "ip address add fe80::6 dev ppp1" is trying to set not only local but
   also remote peer address to fe80::6

2) kernel does not configure remote peer address from IFA_ADDRESS when
   local address via IFA_LOCAL is not specified in netlink packet


For tests I used:

    ip -V --> ip utility, iproute2-ss190107
    uname -r -v -m --> 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64

             reply	other threads:[~2021-06-06 15:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06 15:10 Pali Rohár [this message]
2021-06-24 10:45 ` Issues during assigning addresses on point to point interfaces Marek Behún
2021-06-24 12:57   ` Nicolas Dichtel
2021-06-25  8:40     ` Pali Rohár
2021-06-25 15:06       ` Nicolas Dichtel
2021-06-25 15:27         ` Pali Rohár
2021-06-25 15:32           ` Nicolas Dichtel

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=20210606151008.7dwx5ukrlvxt4t3k@pali \
    --to=pali@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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 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).