From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C5B1236A8B for ; Mon, 5 Jan 2026 21:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767650205; cv=none; b=aKWHNJALtYfTmcdwC1bIE8gugg3M5BGxGzQymxJM5pbyN1OCgxa2+oHXG3B8LqR0Q2vmWCZJWcmnjbAkzaV4Z5KkyjR9cVZWtGMz/8xGKgxvou5cFchiQZTFunmg7fX4dvD9/Tth8hunkN7p7qwoylsJQXQUvWHxPJNlImyrmsI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767650205; c=relaxed/simple; bh=n5AEGPfY/J2s2Xsr++RQ6MPnAJKhMStGlZe2hzKbfw8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WyYKLQzSmnq02ByTUwFtCwMkciiDrJRX4vs1JiwQqazmMQAWcyIR1YzIrOFMlDVUbiS7OpIUiGuEw5k9tgMQxrG/S6BIMV+MfWdEECYUjy876iXyePn1eps77muzHPHZ0YHAdwcIGFETsTtu0l9OeA+KH66OGyBWV8NJizLc0zM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EYjLYk6T; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EYjLYk6T" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4308d81fdf6so150861f8f.2 for ; Mon, 05 Jan 2026 13:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767650201; x=1768255001; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=wJdwe8k5Q1P9Ro2cKEv2Zqzqwu7CMlTZRcFtklLBD2I=; b=EYjLYk6TyprWsplJ6AUUC1Rr/6puYbwU3EJer16kegw5r8UNpjhKQnAdosmUwuGYob Wf46X9nhSXFo2ePZ2q5bKFA3aBkOnYHngF4pz2W2kg+Ivxo/xqK4P47w9nFB1ARWqhUz GFlhs3bWsI86FzSCpYFLF9HwWNjyyt2szsC4/LeBxBTAfFpbiQw9J82y6FQBVwjm1DpX YOkgudxDLnRKdaABAqMlc90RDrCSz7xzTD9SIC4t/IFhLq9fFfoQ1Tw7s6IYmiRbo2yy l4hdAd0U6eLhnjt9zf6JSI79ecY4zjZY/ZQod18AeSaBwwr7drYnhBeJ//SRfDuCbp+P azdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767650201; x=1768255001; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wJdwe8k5Q1P9Ro2cKEv2Zqzqwu7CMlTZRcFtklLBD2I=; b=g9p0CnOq8zcNmTrZbs5wDtaH1oHFjTBt/s9PHyb1PZDOUjsuHcH0INNYscIRVGeFwQ N3EifI/xD/wvqasDD7DG5pK6YSRkW1UsOSUCMslRkMqutMYwU4zYCgZtasvx+WzD+wcz twCX4xzaxW4bcJxZ1NqzSAYCU7HRRdHzUnsiXjimm1kB1RyEVEt58l48BpQV/99bSx1d /3/wZi/r2qZeqBXzva4rcWOuJg8mXafTXQHF6CN5DP3fj5DUqpmp5dnjJNGX/cxcjPvc KWW0Gw6O5eN92PEU3+xQoUcYaXA16RU9NOlLvSLuNr8+/RMjUWmyt+HK6v6A8s2uTDUV DLZw== X-Forwarded-Encrypted: i=1; AJvYcCWd7GnKNkjzItIApv0b9g7dudzANjtZP0AW7gDQz5RIzfZgqPzP4BlnF+kUA3AN/Vv1NxiBXrU9pe5lnjA=@vger.kernel.org X-Gm-Message-State: AOJu0YwCLAVEiSb/nrJitgPVSwNwd/TAJ8T1eMf8RezybEp1J9HribTX GQg07OdQgdg0x692QcqpvCMVl+xfTr2hXN5hbqUVEJVZl5Y99hQzEvTB X-Gm-Gg: AY/fxX5p2ZqzSSy6DYyzzcqYvque4hZAMtQE5ACHrC7FkpcJcU5jcaBdkWs+4cFKYHE RkazzTqFpLuFw0Dy21vi80sugMteDCtiFwY+Kj0WUbb7xKWh8mMV5A/JxIYo0GLw+8AOZAImB46 f5Zm1zxBskbVKdd12AiU/6Per0HE6YlRzTH30icFwwt+Exc9IPfaNsEmR3QF6gG1Gvvo4joI20T nF3SthQHdnPFHEY7UlwAuSTldfc86TAyUk1VxyHt45GvDKkmHjvXVNe6JviAjAUCBVppa8xv65D 9QV727mCfuKAB6s2XuCH0JAka6328oLvfmgVkR/xxJsIWA4EdfMr0j+EeG0FQv63rMxBNsOz8MK bvXlbnMQg8GxIrlX/QeqqwppHofuyj7Q4GAGhvaZd6riYJLa2It8Y4RyHfbq+2iRu34dCfSJ0Rx D9IK/tlXnXDXqzqFOUtf1UUuHtpHXBQsEIDyx/D7vChNGiHs8+lZ1PH74QZ3UYlZf/DuxkdutB5 x2SdeJ/565X5CYuIQ== X-Google-Smtp-Source: AGHT+IHGWTXHufgkP5TAITSLOGuyx2/59UaIQV+tU5VX31oNq624podr7P03+PmlN9fNaGkmmRpKrQ== X-Received: by 2002:a05:6000:288d:b0:431:8ff:206b with SMTP id ffacd0b85a97d-432bca18e08mr1359809f8f.2.1767650201395; Mon, 05 Jan 2026 13:56:41 -0800 (PST) Received: from [172.28.5.111] (static-qvn-qvu-073125.business.bouyguestelecom.com. [89.81.73.125]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ee5eesm675521f8f.34.2026.01.05.13.56.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jan 2026 13:56:41 -0800 (PST) Message-ID: <333ab7ce-55f4-4f19-a1a9-b3c86621e892@gmail.com> Date: Mon, 5 Jan 2026 22:56:40 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2] ipv6: preserve insertion order for same-scope addresses To: Yumei Huang , 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, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org References: <20260104032357.38555-1-yuhuang@redhat.com> Content-Language: en-US From: Justin Iurman In-Reply-To: <20260104032357.38555-1-yuhuang@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/4/26 04:23, 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: 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: 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 > Signed-off-by: Yumei Huang > --- > net/ipv6/addrconf.c | 2 +- > tools/testing/selftests/net/ioam6.sh | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c > index 40e9c336f6c5..ca998bf46863 100644 > --- a/net/ipv6/addrconf.c > +++ b/net/ipv6/addrconf.c > @@ -1013,7 +1013,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp) > list_for_each(p, &idev->addr_list) { > struct inet6_ifaddr *ifa > = list_entry(p, struct inet6_ifaddr, if_list); > - if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr)) > + if (ifp_scope > ipv6_addr_src_scope(&ifa->addr)) > break; > } > > diff --git a/tools/testing/selftests/net/ioam6.sh b/tools/testing/selftests/net/ioam6.sh > index 845c26dd01a9..b2b99889942f 100755 > --- a/tools/testing/selftests/net/ioam6.sh > +++ b/tools/testing/selftests/net/ioam6.sh > @@ -273,8 +273,8 @@ setup() > ip -netns $ioam_node_beta link set ioam-veth-betaR name veth1 &>/dev/null > ip -netns $ioam_node_gamma link set ioam-veth-gamma name veth0 &>/dev/null > > - ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null > ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null > + ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null > ip -netns $ioam_node_alpha link set veth0 up &>/dev/null > ip -netns $ioam_node_alpha link set lo up &>/dev/null > ip -netns $ioam_node_alpha route add 2001:db8:2::/64 \ For tools/testing/selftests/net/ioam6.sh: Acked-by: Justin Iurman