public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Yumei Huang <yuhuang@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Cc: sbrivio@redhat.com, david@gibson.dropbear.id.au,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, justin.iurman@uliege.be,
	shuah@kernel.org
Subject: Re: [PATCH net-next v2] ipv6: preserve insertion order for same-scope addresses
Date: Tue, 6 Jan 2026 10:37:25 -0700	[thread overview]
Message-ID: <08eb450b-e644-4968-b83e-54364c449a5b@kernel.org> (raw)
In-Reply-To: <20260104032357.38555-1-yuhuang@redhat.com>

On 1/3/26 8:23 PM, Yumei Huang wrote:
> IPv6 addresses with the same scope are returned in reverse insertion
> order, unlike IPv4. For example, when adding a -> b -> c, the list is
> reported as c -> b -> a, while IPv4 preserves the original order.
> 
> This behavior causes:
> 
> a. When using `ip -6 a save` and `ip -6 a restore`, addresses are restored
>    in the opposite order from which they were saved. See example below
>    showing addresses added as 1::1, 1::2, 1::3 but displayed and saved
>    in reverse order.
> 
>    # ip -6 a a 1::1 dev x
>    # ip -6 a a 1::2 dev x
>    # ip -6 a a 1::3 dev x
>    # ip -6 a s dev x
>    2: x: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
>        inet6 1::3/128 scope global tentative
>        valid_lft forever preferred_lft forever
>        inet6 1::2/128 scope global tentative
>        valid_lft forever preferred_lft forever
>        inet6 1::1/128 scope global tentative
>        valid_lft forever preferred_lft forever
>    # ip -6 a save > dump
>    # ip -6 a d 1::1 dev x
>    # ip -6 a d 1::2 dev x
>    # ip -6 a d 1::3 dev x
>    # ip a d ::1 dev lo
>    # ip a restore < dump
>    # ip -6 a s dev x
>    2: x: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
>        inet6 1::1/128 scope global tentative
>        valid_lft forever preferred_lft forever
>        inet6 1::2/128 scope global tentative
>        valid_lft forever preferred_lft forever
>        inet6 1::3/128 scope global tentative
>        valid_lft forever preferred_lft forever
>    # ip a showdump < dump
>     if1:
>         inet6 ::1/128 scope host proto kernel_lo
>         valid_lft forever preferred_lft forever
>     if2:
>         inet6 1::3/128 scope global tentative
>         valid_lft forever preferred_lft forever
>     if2:
>         inet6 1::2/128 scope global tentative
>         valid_lft forever preferred_lft forever
>     if2:
>         inet6 1::1/128 scope global tentative
>         valid_lft forever preferred_lft forever
> 
> b. Addresses in pasta to appear in reversed order compared to host
>    addresses.
> 
> The ipv6 addresses were added in reverse order by commit e55ffac60117
> ("[IPV6]: order addresses by scope"), then it was changed by commit
> 502a2ffd7376 ("ipv6: convert idev_list to list macros"), and restored by
> commit b54c9b98bbfb ("ipv6: Preserve pervious behavior in
> ipv6_link_dev_addr()."). However, this reverse ordering within the same
> scope causes inconsistency with IPv4 and the issues described above.
> 
> This patch aligns IPv6 address ordering with IPv4 for consistency
> by changing the comparison from >= to > when inserting addresses
> into the address list. Also updates the ioam6 selftest to reflect
> the new address ordering behavior. Combine these two changes into
> one patch for bisectability.
> 
> Fixes: e55ffac60117 ("[IPV6]: order addresses by scope")
> Link: https://bugs.passt.top/show_bug.cgi?id=175
> Suggested-by: Stefano Brivio <sbrivio@redhat.com>
> Signed-off-by: Yumei Huang <yuhuang@redhat.com>
> ---
>  net/ipv6/addrconf.c                  | 2 +-
>  tools/testing/selftests/net/ioam6.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
>

I am ok with the change, but I will not be surprised if someone
complains about a change in behavior.

Reviewed-by: David Ahern <dsahern@kernel.org>


  parent reply	other threads:[~2026-01-06 17:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-04  3:23 [PATCH net-next v2] ipv6: preserve insertion order for same-scope addresses Yumei Huang
2026-01-05 21:56 ` Justin Iurman
2026-01-06 17:37 ` David Ahern [this message]
2026-01-07  1:00 ` patchwork-bot+netdevbpf

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=08eb450b-e644-4968-b83e-54364c449a5b@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david@gibson.dropbear.id.au \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=justin.iurman@uliege.be \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbrivio@redhat.com \
    --cc=shuah@kernel.org \
    --cc=yuhuang@redhat.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