All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments
@ 2022-01-31 15:41 Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 1/4] selftests: fib rule: Make 'getmatch' and 'match' local variables Guillaume Nault
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Guillaume Nault @ 2022-01-31 15:41 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, Shuah Khan, linux-kselftest, Roopa Prabhu, Hangbin Liu

The first half of these patch set improves the code logic and has no
user visible effect. The second half improves the script output, to
make it clearer and nicer to read.

Guillaume Nault (4):
  selftests: fib rule: Make 'getmatch' and 'match' local variables
  selftests: fib rule: Drop erroneous TABLE variable
  selftests: fib rule: Log test description
  selftests: fib rule: Don't echo modified sysctls

 tools/testing/selftests/net/fib_rule_tests.sh | 26 ++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)

-- 
2.21.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/4] selftests: fib rule: Make 'getmatch' and 'match' local variables
  2022-01-31 15:41 [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments Guillaume Nault
@ 2022-01-31 15:42 ` Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 2/4] selftests: fib rule: Drop erroneous TABLE variable Guillaume Nault
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Guillaume Nault @ 2022-01-31 15:42 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, Shuah Khan, linux-kselftest, Roopa Prabhu

Let's restrict the scope of these variables to avoid possible
interferences.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 tools/testing/selftests/net/fib_rule_tests.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh
index 43ea8407a82e..f04f337dd7c6 100755
--- a/tools/testing/selftests/net/fib_rule_tests.sh
+++ b/tools/testing/selftests/net/fib_rule_tests.sh
@@ -115,6 +115,9 @@ fib_rule6_test_match_n_redirect()
 
 fib_rule6_test()
 {
+	local getmatch
+	local match
+
 	# setup the fib rule redirect route
 	$IP -6 route add table $RTABLE default via $GW_IP6 dev $DEV onlink
 
@@ -184,6 +187,9 @@ fib_rule4_test_match_n_redirect()
 
 fib_rule4_test()
 {
+	local getmatch
+	local match
+
 	# setup the fib rule redirect route
 	$IP route add table $RTABLE default via $GW_IP4 dev $DEV onlink
 
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/4] selftests: fib rule: Drop erroneous TABLE variable
  2022-01-31 15:41 [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 1/4] selftests: fib rule: Make 'getmatch' and 'match' local variables Guillaume Nault
@ 2022-01-31 15:42 ` Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 3/4] selftests: fib rule: Log test description Guillaume Nault
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Guillaume Nault @ 2022-01-31 15:42 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, Shuah Khan, linux-kselftest, Roopa Prabhu

The fib_rule6_del_by_pref() and fib_rule4_del_by_pref() functions use
an uninitialised $TABLE variable. They should use $RTABLE instead.
This doesn't alter the result of the test, as it just makes the grep
command less specific (but since the script always uses the same table
number, that doesn't really matter).

Let's fix it anyway and, while there, specify the filtering parameters
directly in 'ip -X rule show' to avoid the extra grep command entirely.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 tools/testing/selftests/net/fib_rule_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh
index f04f337dd7c6..012f9385d68c 100755
--- a/tools/testing/selftests/net/fib_rule_tests.sh
+++ b/tools/testing/selftests/net/fib_rule_tests.sh
@@ -96,7 +96,7 @@ fib_rule6_del()
 
 fib_rule6_del_by_pref()
 {
-	pref=$($IP -6 rule show | grep "$1 lookup $TABLE" | cut -d ":" -f 1)
+	pref=$($IP -6 rule show $1 table $RTABLE | cut -d ":" -f 1)
 	$IP -6 rule del pref $pref
 }
 
@@ -168,7 +168,7 @@ fib_rule4_del()
 
 fib_rule4_del_by_pref()
 {
-	pref=$($IP rule show | grep "$1 lookup $TABLE" | cut -d ":" -f 1)
+	pref=$($IP rule show $1 table $RTABLE | cut -d ":" -f 1)
 	$IP rule del pref $pref
 }
 
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/4] selftests: fib rule: Log test description
  2022-01-31 15:41 [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 1/4] selftests: fib rule: Make 'getmatch' and 'match' local variables Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 2/4] selftests: fib rule: Drop erroneous TABLE variable Guillaume Nault
@ 2022-01-31 15:42 ` Guillaume Nault
  2022-01-31 15:42 ` [PATCH net-next 4/4] selftests: fib rule: Don't echo modified sysctls Guillaume Nault
  2022-02-01 14:20 ` [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Guillaume Nault @ 2022-01-31 15:42 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, Shuah Khan, linux-kselftest, Roopa Prabhu

All callers of fib_rule6_test_match_n_redirect() and
fib_rule4_test_match_n_redirect() pass a third argument containing a
description of the test being run. Instead of ignoring this argument,
let's use it for logging instead of printing a truncated version of the
command.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 tools/testing/selftests/net/fib_rule_tests.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh
index 012f9385d68c..6a05e81fc81d 100755
--- a/tools/testing/selftests/net/fib_rule_tests.sh
+++ b/tools/testing/selftests/net/fib_rule_tests.sh
@@ -104,13 +104,14 @@ fib_rule6_test_match_n_redirect()
 {
 	local match="$1"
 	local getmatch="$2"
+	local description="$3"
 
 	$IP -6 rule add $match table $RTABLE
 	$IP -6 route get $GW_IP6 $getmatch | grep -q "table $RTABLE"
-	log_test $? 0 "rule6 check: $1"
+	log_test $? 0 "rule6 check: $description"
 
 	fib_rule6_del_by_pref "$match"
-	log_test $? 0 "rule6 del by pref: $match"
+	log_test $? 0 "rule6 del by pref: $description"
 }
 
 fib_rule6_test()
@@ -176,13 +177,14 @@ fib_rule4_test_match_n_redirect()
 {
 	local match="$1"
 	local getmatch="$2"
+	local description="$3"
 
 	$IP rule add $match table $RTABLE
 	$IP route get $GW_IP4 $getmatch | grep -q "table $RTABLE"
-	log_test $? 0 "rule4 check: $1"
+	log_test $? 0 "rule4 check: $description"
 
 	fib_rule4_del_by_pref "$match"
-	log_test $? 0 "rule4 del by pref: $match"
+	log_test $? 0 "rule4 del by pref: $description"
 }
 
 fib_rule4_test()
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 4/4] selftests: fib rule: Don't echo modified sysctls
  2022-01-31 15:41 [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments Guillaume Nault
                   ` (2 preceding siblings ...)
  2022-01-31 15:42 ` [PATCH net-next 3/4] selftests: fib rule: Log test description Guillaume Nault
@ 2022-01-31 15:42 ` Guillaume Nault
  2022-02-01 14:20 ` [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Guillaume Nault @ 2022-01-31 15:42 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski
  Cc: netdev, Shuah Khan, linux-kselftest, Roopa Prabhu, Hangbin Liu

Run sysctl in quiet mode. Echoing the modified sysctl doesn't bring any
useful information.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 tools/testing/selftests/net/fib_rule_tests.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh
index 6a05e81fc81d..3b0489910422 100755
--- a/tools/testing/selftests/net/fib_rule_tests.sh
+++ b/tools/testing/selftests/net/fib_rule_tests.sh
@@ -200,11 +200,11 @@ fib_rule4_test()
 
 	# need enable forwarding and disable rp_filter temporarily as all the
 	# addresses are in the same subnet and egress device == ingress device.
-	ip netns exec testns sysctl -w net.ipv4.ip_forward=1
-	ip netns exec testns sysctl -w net.ipv4.conf.$DEV.rp_filter=0
+	ip netns exec testns sysctl -qw net.ipv4.ip_forward=1
+	ip netns exec testns sysctl -qw net.ipv4.conf.$DEV.rp_filter=0
 	match="from $SRC_IP iif $DEV"
 	fib_rule4_test_match_n_redirect "$match" "$match" "iif redirect to table"
-	ip netns exec testns sysctl -w net.ipv4.ip_forward=0
+	ip netns exec testns sysctl -qw net.ipv4.ip_forward=0
 
 	match="tos 0x10"
 	fib_rule4_test_match_n_redirect "$match" "$match" "tos redirect to table"
-- 
2.21.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments
  2022-01-31 15:41 [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments Guillaume Nault
                   ` (3 preceding siblings ...)
  2022-01-31 15:42 ` [PATCH net-next 4/4] selftests: fib rule: Don't echo modified sysctls Guillaume Nault
@ 2022-02-01 14:20 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-01 14:20 UTC (permalink / raw)
  To: Guillaume Nault
  Cc: davem, kuba, netdev, shuah, linux-kselftest, roopa, liuhangbin

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 31 Jan 2022 16:41:54 +0100 you wrote:
> The first half of these patch set improves the code logic and has no
> user visible effect. The second half improves the script output, to
> make it clearer and nicer to read.
> 
> Guillaume Nault (4):
>   selftests: fib rule: Make 'getmatch' and 'match' local variables
>   selftests: fib rule: Drop erroneous TABLE variable
>   selftests: fib rule: Log test description
>   selftests: fib rule: Don't echo modified sysctls
> 
> [...]

Here is the summary with links:
  - [net-next,1/4] selftests: fib rule: Make 'getmatch' and 'match' local variables
    https://git.kernel.org/netdev/net-next/c/8af2ba9a7811
  - [net-next,2/4] selftests: fib rule: Drop erroneous TABLE variable
    https://git.kernel.org/netdev/net-next/c/2e2521136327
  - [net-next,3/4] selftests: fib rule: Log test description
    https://git.kernel.org/netdev/net-next/c/21f25cd43672
  - [net-next,4/4] selftests: fib rule: Don't echo modified sysctls
    https://git.kernel.org/netdev/net-next/c/9f397dd5f155

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-01 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31 15:41 [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments Guillaume Nault
2022-01-31 15:42 ` [PATCH net-next 1/4] selftests: fib rule: Make 'getmatch' and 'match' local variables Guillaume Nault
2022-01-31 15:42 ` [PATCH net-next 2/4] selftests: fib rule: Drop erroneous TABLE variable Guillaume Nault
2022-01-31 15:42 ` [PATCH net-next 3/4] selftests: fib rule: Log test description Guillaume Nault
2022-01-31 15:42 ` [PATCH net-next 4/4] selftests: fib rule: Don't echo modified sysctls Guillaume Nault
2022-02-01 14:20 ` [PATCH net-next 0/4] selftests: fib rule: Small internal and test output improvments patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.