Skip to contentSkip to conversation

network/ipsec: fix warning when using wrong option for ipv4

PATCH New Alexey Kodanev 2 participants 7 messages Sep 24, 2020 – Sep 30, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 network/ipsec: fix warning when using wrong option for ipv4

This patch is fixing the warning in ipsec vti setup:
Warning: nodad option can be set only for IPv6 addresses

---
 testcases/network/stress/ipsec/ipsec_lib.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/network/stress/ipsec/ipsec_lib.sh +3 -2
index d40941d45..198c9315d 100644
@@ -295,11 +295,12 @@ tst_ipsec_setup_vti()
 	tst_ipsec_vti lhost $ip_loc $ip_rmt $tst_vti
 	tst_ipsec_vti rhost $ip_rmt $ip_loc $tst_vti
 
-	local mask=
+	local mask address_opt
 	if [ "$TST_IPV6" ]; then
 		ip_loc_tun="${IPV6_NET32_UNUSED}::1";
 		ip_rmt_tun="${IPV6_NET32_UNUSED}::2";
 		mask=64
+		address_opt=nodad
 		ROD ip -6 route add ${IPV6_NET32_UNUSED}::/$mask dev $tst_vti
 	else
 		ip_loc_tun="${IPV4_NET16_UNUSED}.1.1";
@@ -311,6 +312,6 @@ tst_ipsec_setup_vti()
 	tst_res TINFO "Add IPs to vti tunnel, " \
 		       "loc: $ip_loc_tun/$mask, rmt: $ip_rmt_tun/$mask"
 
-	ROD ip a add $ip_loc_tun/$mask dev $tst_vti nodad
+	ROD ip a add $ip_loc_tun/$mask dev $tst_vti $address_opt
 	tst_rhost_run -s -c "ip a add $ip_rmt_tun/$mask dev $tst_vti"
 }
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/5 network/virt_lib: use test ip version in virt_compare_netperf()

This will match virtual device underlying ip version.

---
 testcases/network/virt/virt_lib.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
testcases/network/virt/virt_lib.sh +3 -3
index f488932ff..827829633 100644
@@ -292,10 +292,10 @@ virt_compare_netperf()
 	local vt="$(cat res_ipv4)"
 	local vt6="$(cat res_ipv6)"
 
-	tst_netload -H $ip_remote $opts -d res_ipv4
+	tst_netload -H $(tst_ipaddr rhost) $opts -d res_lan
 
-	local lt="$(cat res_ipv4)"
-	tst_res TINFO "time lan($lt) $virt_type IPv4($vt) and IPv6($vt6) ms"
+	local lt="$(cat res_lan)"
+	tst_res TINFO "time lan IPv${TST_IPVER}($lt) $virt_type IPv4($vt) and IPv6($vt6) ms"
 
 	per=$(( $vt * 100 / $lt - 100 ))
 	per6=$(( $vt6 * 100 / $lt - 100 ))
Signature · 1 line
2.20.1
#2 lore raw

PATCH RESEND 3/5 network/nsf_lib.sh: TCONF on mount (udp/udp6) failure for Linux v5.6+

In reply to Alexey Kodanev

Most likely support is disabled with NFS_DISABLE_UDP_SUPPORT config option (default y).
commit b24ee6c64ca7 ("NFS: allow deprecation of NFS UDP protocol")

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +9 -3
index e236cd485..1bd057717 100644
@@ -87,11 +87,17 @@ nfs_mount()
 
 	tst_res TINFO "Mounting NFS: $mnt_cmd"
 	if [ -n "$LTP_NETNS" ] && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then
-		tst_rhost_run -s -c "$mnt_cmd"
-		return
+		tst_rhost_run -c "$mnt_cmd"
+	else
+		$mnt_cmd > /dev/null
 	fi
 
-	ROD $mnt_cmd
+	if [ $? -ne 0 ]; then
+		if [ "$type" = "udp" -o "$type" = "udp6" ] && tst_kvcmp -ge 5.6; then
+			tst_brk TCONF "UDP support disabled with the kernel config NFS_DISABLE_UDP_SUPPORT?"
+		fi
+		tst_brk TBROK "mount command failed"
+	fi
 }
 
 nfs_setup()
Signature · 1 line
2.20.1
#3 lore raw

PATCH 4/5 network/netstress: replace rand with rand_r() in the client thread

In reply to Alexey Kodanev

Store seed per client thread in order to get reproducible results.

---
 configure.ac                            |  1 +
 testcases/network/netstress/netstress.c | 33 ++++++++++++++++---------
 2 files changed, 22 insertions(+), 12 deletions(-)
configure.ac +1 -0
index 142bfe26e..03e4e09c9 100644
@@ -108,6 +108,7 @@ AC_CHECK_FUNCS_ONCE([ \
     profil \
     pwritev \
     pwritev2 \
+    rand_r \
     readlinkat \
     recvmmsg \
     renameat \
testcases/network/netstress/netstress.c +21 -12
index c5da4d464..e79e64220 100644
@@ -31,6 +31,13 @@
 #include "tst_test.h"
 #include "tst_safe_net.h"
 
+#if !defined(HAVE_RAND_R)
+static int rand_r(LTP_ATTRIBUTE_UNUSED unsigned int *seed)
+{
+    return rand();
+}
+#endif
+
 static const int max_msg_len = (1 << 16) - 1;
 static const int min_msg_len = 5;
 
@@ -62,6 +69,7 @@ static const int end_byte	= 0x0a;
 static int init_cln_msg_len	= 32;
 static int init_srv_msg_len	= 128;
 static int max_rand_msg_len;
+static int init_seed;
 
 /*
  * The number of requests from client after
@@ -344,10 +352,11 @@ union net_size_field {
 	uint16_t value;
 };
 
-static void make_client_request(char client_msg[], int *cln_len, int *srv_len)
+static void make_client_request(char client_msg[], int *cln_len, int *srv_len,
+				unsigned int *seed)
 {
 	if (max_rand_msg_len)
-		*cln_len = *srv_len = min_msg_len + rand() % max_rand_msg_len;
+		*cln_len = *srv_len = min_msg_len + rand_r(seed) % max_rand_msg_len;
 
 	memset(client_msg, client_byte, *cln_len);
 	client_msg[0] = start_byte;
@@ -362,7 +371,7 @@ static void make_client_request(char client_msg[], int *cln_len, int *srv_len)
 	client_msg[*cln_len - 1] = end_byte;
 }
 
-void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
+void *client_fn(void *id)
 {
 	int cln_len = init_cln_msg_len,
 	    srv_len = init_srv_msg_len;
@@ -371,13 +380,14 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
 	char client_msg[max_msg_len];
 	int i = 0;
 	intptr_t err = 0;
+	unsigned int seed = init_seed ^ (intptr_t)id;
 
 	inf.raddr_len = sizeof(inf.raddr);
 	inf.etime_cnt = 0;
 	inf.timeout = wait_timeout;
 	inf.pmtu_err_cnt = 0;
 
-	make_client_request(client_msg, &cln_len, &srv_len);
+	make_client_request(client_msg, &cln_len, &srv_len, &seed);
 
 	/* connect & send requests */
 	inf.fd = client_connect_send(client_msg, cln_len);
@@ -407,7 +417,7 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
 		}
 
 		if (max_rand_msg_len)
-			make_client_request(client_msg, &cln_len, &srv_len);
+			make_client_request(client_msg, &cln_len, &srv_len, &seed);
 
 		SAFE_SEND(1, inf.fd, client_msg, cln_len, send_flags);
 
@@ -468,9 +478,9 @@ static void client_init(void)
 	family = remote_addrinfo->ai_family;
 
 	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_start);
-	int i;
+	intptr_t i;
 	for (i = 0; i < clients_num; ++i)
-		SAFE_PTHREAD_CREATE(&thread_ids[i], 0, client_fn, NULL);
+		SAFE_PTHREAD_CREATE(&thread_ids[i], 0, client_fn, (void *)i);
 }
 
 static void client_run(void)
@@ -496,7 +506,7 @@ static void client_run(void)
 	int msg_len = min_msg_len;
 
 	max_rand_msg_len = 0;
-	make_client_request(client_msg, &msg_len, &msg_len);
+	make_client_request(client_msg, &msg_len, &msg_len, NULL);
 	/* ask server to terminate */
 	client_msg[0] = start_fin_byte;
 	int cfd = client_connect_send(client_msg, msg_len);
@@ -861,10 +871,9 @@ static void setup(void)
 
 	if (max_rand_msg_len) {
 		max_rand_msg_len -= min_msg_len;
-		unsigned int seed = max_rand_msg_len ^ client_max_requests;
-
-		srand(seed);
-		tst_res(TINFO, "srand() seed 0x%x", seed);
+		init_seed = max_rand_msg_len ^ client_max_requests;
+		srand(init_seed); /* in case rand_r() is missing */
+		tst_res(TINFO, "rand start seed 0x%x", init_seed);
 	}
 
 	/* if client_num is not set, use num of processors */
Signature · 1 line
2.20.1
#4 lore raw

PATCH 5/5 network/ipneigh01: use ROD when deleting the entries

In reply to Alexey Kodanev
---
 testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +3 -3
index e15dd708c..6ad987c49 100755
@@ -20,14 +20,14 @@ do_setup()
 	case $CMD in
 	ip)
 		SHOW_CMD="ip neigh show"
-		DEL_CMD="ip neigh del $(tst_ipaddr rhost) dev $(tst_iface)"
+		DEL_CMD="ROD ip neigh del $(tst_ipaddr rhost) dev $(tst_iface)"
 		;;
 	arp)
 		if [ -n "$TST_IPV6" ]; then
 			tst_brk TCONF "'arp' doesn't support IPv6"
 		fi
 		SHOW_CMD="arp -a"
-		DEL_CMD="arp -d $(tst_ipaddr rhost) -i $(tst_iface)"
+		DEL_CMD="ROD arp -d $(tst_ipaddr rhost) -i $(tst_iface)"
 		;;
 	*)
 		tst_brk TBROK "unknown or missing command, use -c [ arp | ip ]"
@@ -75,7 +75,7 @@ do_test()
 		[ "$ret" -ne 0 ] && \
 			tst_brk TFAIL "$entry_name entry '$(tst_ipaddr rhost)' not listed"
 
-		$DEL_CMD || tst_brk TFAIL "fail to delete entry"
+		$DEL_CMD
 
 		$SHOW_CMD | grep -q "$(tst_ipaddr rhost).*$(tst_hwaddr rhost)" && \
 			tst_brk TFAIL "'$DEL_CMD' failed, entry has " \
Signature · 1 line
2.20.1
#5 lore raw

PATCH 5/5 network/ipneigh01: use ROD when deleting the entries

Hi Alexey,

sorry for late review.

For whole patchset.

I'm going to merge it so it gets into the release (should be done today).

Kind regards,
Petr

#6 lore raw

PATCH 5/5 network/ipneigh01: use ROD when deleting the entries

Quoted 8 lines · Petr Vorel

Hi Alexey,

sorry for late review.

For whole patchset.

I'm going to merge it so it gets into the release (should be done today).

Thank you Petr!

Quoted 4 lines

Kind regards,
Petr