From: Hangbin Liu <liuhangbin@gmail.com>
To: Sam Edwards <cfsworks@gmail.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net 2/2] selftests/rtnetlink.sh: add mngtempaddr test
Date: Tue, 19 Nov 2024 08:23:10 +0000 [thread overview]
Message-ID: <ZzxK7hZSF7nPfuOj@fedora> (raw)
In-Reply-To: <CAH5Ym4jGZou27-bwGqxHAf2AHWXpT0=wOa0XNNuqtG9OOhi8EQ@mail.gmail.com>
On Fri, Nov 15, 2024 at 12:59:27PM -0800, Sam Edwards wrote:
> Hi Hangbin,
>
> My apologies, I should have shared my version of the check function
> before. Here it is:
>
> ```bash
> # Called to validate the addresses on $IFNAME:
> #
> # 1. Every `temporary` address must have a matching `mngtmpaddr`
> # 2. Every `mngtmpaddr` address must have some un`deprecated` `temporary`
Thanks, this is much clear.
> #
> # Fails the whole test script if a problem is detected, else returns silently.
> validate()
> {
> mng_prefixes=()
> undep_prefixes=()
> temp_addrs=()
>
> while read -r line; do
> line_array=($line)
> address="${line_array[1]}"
> prefix="$(echo "$address" | cut -d: -f1-4)::/64"
> if echo "$line" | grep -q mngtmpaddr; then
> mng_prefixes+=("$prefix")
> elif echo "$line" | grep -q temporary; then
> temp_addrs+=("$address")
> if echo "$line" | grep -qv deprecated; then
> undep_prefixes+=("$prefix")
> fi
> fi
> done < <(ip -6 addr show dev $IFNAME | grep '^\s*inet6')
>
> # 1. All temporary addresses (temp and dep) must have a matching mngtmpaddr
> for address in ${temp_addrs[@]}; do
> prefix="$(echo "$address" | cut -d: -f1-4)::/64"
> if [[ ! " ${mng_prefixes[*]} " =~ " $prefix " ]]; then
> echo "FAIL: Temporary $address with no matching mngtmpaddr!";
> exit 1
> fi
> done
>
> # 2. All mngtmpaddr addresses must have a temporary address (not dep)
> for prefix in ${mng_prefixes[@]}; do
> if [[ ! " ${undep_prefixes[*]} " =~ " $prefix " ]]; then
> echo "FAIL: No undeprecated temporary in $prefix!";
> exit 1
> fi
> done
> }
> ```
>
> Of course this is using awful text parsing and not JSON output. But
> the idea is that it groups addresses by their /64 prefix, to confirm
> that every /64 containing a mngtmpaddrs address also contains an
> undeprecated temporary, and that every /64 containing a temporary
> (deprecated or not) contains a mngtmpaddrs.
And I will modify and use your checking version.
>
> This can be extended for the lifetime checking: when we build the set
> of mngtmpaddrs /64s, we also note the valid/preferred_life_time values
> for each mngtmpaddr. Then later when we confirm rule 1 (all temporary
> addresses must have a matching mngtmpaddr) we also confirm that each
> temporary does not outlive the mngtmpaddr in the same /64.
Since we add all mngtmpaddrs manually, which valid/preferred_life_time
will be forever. So we only need to check the temporary addresses'
valid/preferred_life_time, right? And on the other hand, the preferred_lft
maybe 0 in my example.
inet6 2001::743:ec1e:5c19:404f/64 scope global temporary dynamic
valid_lft 25sec preferred_lft 5sec
inet6 2001::938f:432:f32d:602f/64 scope global temporary dynamic
valid_lft 19sec preferred_lft 0sec
It looks we only need to check the valid_lft. Am I miss anything?
Thanks
Hangbin
prev parent reply other threads:[~2024-11-19 8:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 12:51 [PATCH net 0/2] ipv6: fix temporary address not removed correctly Hangbin Liu
2024-11-13 12:51 ` [PATCH net 1/2] net/ipv6: delete temporary address if mngtmpaddr is removed or un-mngtmpaddr Hangbin Liu
2024-11-13 21:03 ` Sam Edwards
2024-11-14 7:38 ` Hangbin Liu
2024-11-15 20:46 ` Sam Edwards
2024-11-15 22:51 ` David Ahern
2024-11-19 7:52 ` Hangbin Liu
2024-11-13 12:51 ` [PATCH net 2/2] selftests/rtnetlink.sh: add mngtempaddr test Hangbin Liu
2024-11-13 19:56 ` Jakub Kicinski
2024-11-14 2:00 ` Hangbin Liu
2024-11-14 2:43 ` Jakub Kicinski
2024-11-14 8:19 ` Hangbin Liu
2024-11-14 15:13 ` Jakub Kicinski
2024-11-18 1:19 ` Hangbin Liu
2024-11-13 20:43 ` Sam Edwards
2024-11-14 8:46 ` Hangbin Liu
2024-11-15 20:59 ` Sam Edwards
2024-11-19 8:23 ` Hangbin Liu [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=ZzxK7hZSF7nPfuOj@fedora \
--to=liuhangbin@gmail.com \
--cc=cfsworks@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--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=shuah@kernel.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).