netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, willemb@google.com, lorenzo@google.com,
	maze@google.com, dsahern@kernel.org, yoshfuji@linux-ipv6.org,
	shuah@kernel.org, linux-kselftest@vger.kernel.org,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 07/11] selftests: net: cmsg_so_mark: test ICMP and RAW sockets
Date: Wed,  9 Feb 2022 16:36:45 -0800	[thread overview]
Message-ID: <20220210003649.3120861-8-kuba@kernel.org> (raw)
In-Reply-To: <20220210003649.3120861-1-kuba@kernel.org>

Use new capabilities of cmsg_sender to test ICMP and RAW sockets,
previously only UDP was tested.

Before SO_MARK support was added to ICMPv6:

  # ./cmsg_so_mark.sh
   Case ICMP rejection returned 0, expected 1
  FAIL - 1/12 cases failed

After:

  # ./cmsg_so_mark.sh
  OK

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/testing/selftests/net/cmsg_so_mark.sh | 24 ++++++++++++++-------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/net/cmsg_so_mark.sh b/tools/testing/selftests/net/cmsg_so_mark.sh
index 841d706dc91b..925f6b9deee2 100755
--- a/tools/testing/selftests/net/cmsg_so_mark.sh
+++ b/tools/testing/selftests/net/cmsg_so_mark.sh
@@ -18,6 +18,8 @@ trap cleanup EXIT
 # Namespaces
 ip netns add $NS
 
+ip netns exec $NS sysctl -w net.ipv4.ping_group_range='0 2147483647' > /dev/null
+
 # Connectivity
 ip -netns $NS link add type dummy
 ip -netns $NS link set dev dummy0 up
@@ -41,15 +43,21 @@ check_result() {
     fi
 }
 
-ip netns exec $NS ./cmsg_sender -m $((MARK + 1)) $TGT4 1234
-check_result $? 0 "IPv4 pass"
-ip netns exec $NS ./cmsg_sender -m $((MARK + 1)) $TGT6 1234
-check_result $? 0 "IPv6 pass"
+for i in 4 6; do
+    [ $i == 4 ] && TGT=$TGT4 || TGT=$TGT6
+
+    for p in u i r; do
+	[ $p == "u" ] && prot=UDP
+	[ $p == "i" ] && prot=ICMP
+	[ $p == "r" ] && prot=RAW
+
+	ip netns exec $NS ./cmsg_sender -$i -p $p -m $((MARK + 1)) $TGT 1234
+	check_result $? 0 "$prot pass"
 
-ip netns exec $NS ./cmsg_sender -s -m $MARK $TGT4 1234
-check_result $? 1 "IPv4 rejection"
-ip netns exec $NS ./cmsg_sender -s -m $MARK $TGT6 1234
-check_result $? 1 "IPv6 rejection"
+	ip netns exec $NS ./cmsg_sender -$i -p $p -m $MARK -s $TGT 1234
+	check_result $? 1 "$prot rejection"
+    done
+done
 
 # Summary
 if [ $BAD -ne 0 ]; then
-- 
2.34.1


  parent reply	other threads:[~2022-02-10  2:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10  0:36 [PATCH net-next 00/11] net: ping6: support basic socket cmsgs Jakub Kicinski
2022-02-10  0:36 ` [PATCH net-next 01/11] net: ping6: remove a pr_debug() statement Jakub Kicinski
2022-02-10  5:30   ` David Ahern
2022-02-10  0:36 ` [PATCH net-next 02/11] net: ping6: support packet timestamping Jakub Kicinski
2022-02-10  0:44   ` Maciej Żenczykowski
2022-02-10  2:17     ` Jakub Kicinski
2022-02-10  5:30   ` David Ahern
2022-02-10  0:36 ` [PATCH net-next 03/11] net: ping6: support setting socket options via cmsg Jakub Kicinski
2022-02-10  5:30   ` David Ahern
2022-02-10  0:36 ` [PATCH net-next 04/11] selftests: net: rename cmsg_so_mark Jakub Kicinski
2022-02-10  0:36 ` [PATCH net-next 05/11] selftests: net: make cmsg_so_mark ready for more options Jakub Kicinski
2022-02-10  0:36 ` [PATCH net-next 06/11] selftests: net: cmsg_sender: support icmp and raw sockets Jakub Kicinski
2022-02-10  0:36 ` Jakub Kicinski [this message]
2022-02-10  0:36 ` [PATCH net-next 08/11] selftests: net: cmsg_so_mark: test with SO_MARK set by setsockopt Jakub Kicinski
2022-02-10  0:36 ` [PATCH net-next 09/11] selftests: net: cmsg_sender: support setting SO_TXTIME Jakub Kicinski
2022-02-10  0:36 ` [PATCH net-next 10/11] selftests: net: cmsg_sender: support Tx timestamping Jakub Kicinski
2022-02-10  0:36 ` [PATCH net-next 11/11] selftests: net: test standard socket cmsgs across UDP and ICMP sockets Jakub Kicinski
2022-02-10 15:30 ` [PATCH net-next 00/11] net: ping6: support basic socket cmsgs patchwork-bot+netdevbpf
2022-02-10 16:08 ` Willem de Bruijn

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=20220210003649.3120861-8-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lorenzo@google.com \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    --cc=yoshfuji@linux-ipv6.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).