netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kui-Feng Lee <sinquersw@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>,
	Kui-Feng Lee <thinker.li@gmail.com>,
	dsahern@kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, netdev@vger.kernel.org, martin.lau@linux.dev,
	kernel-team@meta.com, yhs@meta.com
Cc: Kui-Feng Lee <kuifeng@meta.com>
Subject: Re: [PATCH net-next v2 2/2] selftests: fib_tests: Add a test case for IPv6 garbage collection
Date: Fri, 21 Jul 2023 11:31:21 -0700	[thread overview]
Message-ID: <03ef2491-6087-4fd4-caf7-a589d0dfda13@gmail.com> (raw)
In-Reply-To: <239ca679597a10b6bc00245c66419f4bdedaff83.camel@redhat.com>



On 7/21/23 00:14, Paolo Abeni wrote:
> On Thu, 2023-07-20 at 14:36 -0700, Kui-Feng Lee wrote:
>>
>> On 7/20/23 02:32, Paolo Abeni wrote:
>>> On Tue, 2023-07-18 at 11:03 -0700, Kui-Feng Lee wrote:
>>>> Add 10 IPv6 routes with expiration time.  Wait for a few seconds
>>>> to make sure they are removed correctly.
>>>>
>>>> Signed-off-by: Kui-Feng Lee <kuifeng@meta.com>
>>>
>>> Same thing as the previous patch.
>>>
>>>> ---
>>>>    tools/testing/selftests/net/fib_tests.sh | 49 +++++++++++++++++++++++-
>>>>    1 file changed, 48 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
>>>> index 35d89dfa6f11..55bc6897513a 100755
>>>> --- a/tools/testing/selftests/net/fib_tests.sh
>>>> +++ b/tools/testing/selftests/net/fib_tests.sh
>>>> @@ -9,7 +9,7 @@ ret=0
>>>>    ksft_skip=4
>>>>    
>>>>    # all tests in this script. Can be overridden with -t option
>>>> -TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh"
>>>> +TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test"
>>>
>>> At this point is likely worthy splitting the above line in multiple
>>> ones, something alike:
>>>
>>> TESTS="unregister down carrier nexthop suppress ipv6_notify \
>>> 	ipv4_notify ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric
>>> \
>>> 	ipv6_route_metrics ipv4_route_metrics ipv4_route_v6_gw \
>>> 	rp_filter ipv4_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh \
>>> 	fib6_gc_test"
>>>
>>>>    
>>>>    VERBOSE=0
>>>>    PAUSE_ON_FAIL=no
>>>> @@ -747,6 +747,52 @@ fib_notify_test()
>>>>    	cleanup &> /dev/null
>>>>    }
>>>>    
>>>> +fib6_gc_test()
>>>> +{
>>>> +	setup
>>>> +
>>>> +	echo
>>>> +	echo "Fib6 garbage collection test"
>>>> +	set -e
>>>> +
>>>> +	OLD_INTERVAL=$(sysctl -n net.ipv6.route.gc_interval)
>>>> +	# Check expiration of routes every 3 seconds (GC)
>>>> +	$NS_EXEC sysctl -wq net.ipv6.route.gc_interval=3
>>>> +
>>>> +	$IP link add dummy_10 type dummy
>>>> +	$IP link set dev dummy_10 up
>>>> +	$IP -6 address add 2001:10::1/64 dev dummy_10
>>>> +
>>>> +	for i in 0 1 2 3 4 5 6 7 8 9; do
>>> 		$(seq 0 9)
>>>
>>>> +	    # Expire route after 2 seconds
>>>> +	    $IP -6 route add 2001:20::1$i \
>>>> +		via 2001:10::2 dev dummy_10 expires 2
>>>> +	done
>>>> +	N_EXP=$($IP -6 route list |grep expires|wc -l)
>>>> +	if [ $N_EXP -ne 10 ]; then
>>>> +		echo "FAIL: expected 10 routes with expires, got $N_EXP"
>>>> +		ret=1
>>>> +	else
>>>> +	    sleep 4
>>>> +	    N_EXP_s20=$($IP -6 route list |grep expires|wc -l)
>>>> +
>>>> +	    if [ $N_EXP_s20 -ne 0 ]; then
>>>> +		echo "FAIL: expected 0 routes with expires, got $N_EXP_s20"
>>>> +		ret=1
>>>> +	    else
>>>> +		ret=0
>>>> +	    fi
>>>> +	fi
>>>
>>> Possibly also worth trying with a few K of permanent routes, and dump
>>> the time required in both cases?
>>
>> I just realized that I don't know how to measure the time required to do
>> GC without providing additional APIs or exposing numbers to procfs or
>> sysfs. Do you have any idea about this?
> 
> Something like this should do the trick
> 
> sysctl -wq net.ipv6.route.flush=1
> 
> # add routes
> #...
> 
> # delete expired routes synchronously
> sysctl -wq net.ipv6.route.flush=1
> 
> Note that the net.ipv6.route.flush handler uses the 'old' flush value.

May I use bpftrace to measure time spending on writing to procfs?
It is in the order of microseconds. time command doesn't work.

> 
> Cheers,
> 
> Paolo
> 

  reply	other threads:[~2023-07-21 18:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 18:03 [PATCH net-next v2 0/2] Remove expired routes with a Kui-Feng Lee
2023-07-18 18:03 ` [PATCH net-next v2 1/2] net/ipv6: Remove expired routes with a separated list of routes Kui-Feng Lee
2023-07-20  9:18   ` Paolo Abeni
2023-07-20 16:31     ` Kui-Feng Lee
2023-07-18 18:03 ` [PATCH net-next v2 2/2] selftests: fib_tests: Add a test case for IPv6 garbage collection Kui-Feng Lee
2023-07-20  9:32   ` Paolo Abeni
2023-07-20 16:32     ` Kui-Feng Lee
2023-07-20 21:36     ` Kui-Feng Lee
2023-07-21  7:14       ` Paolo Abeni
2023-07-21 18:31         ` Kui-Feng Lee [this message]
2023-07-21 20:01           ` David Ahern
2023-07-21 20:57             ` Kui-Feng Lee

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=03ef2491-6087-4fd4-caf7-a589d0dfda13@gmail.com \
    --to=sinquersw@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=kuifeng@meta.com \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thinker.li@gmail.com \
    --cc=yhs@meta.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;
as well as URLs for NNTP newsgroup(s).