Skip to contentSkip to conversation

netns_helper.sh: Fix parsing recent iproute2 versions

PATCH New Petr Vorel 2 participants 4 messages May 12, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 netns_helper.sh: Fix parsing recent iproute2 versions

iproute2 prior v5.8.0 contained snapshot date:

$ ip -V
ip utility, iproute2-ss190107

But since version v5.7.0-77-gb687d1067169 (released in v5.8.0) there is new scheme. For releases it contains kernel version:

$ip -V
ip utility, iproute2-5.8.0

and for snapshots build from git it contains version generated with git describe:

$ip -V
ip utility, iproute2-v5.10.0-74-g2953235e

Thus the original parsing in tst_check_iproute() leads to error:
[: too many arguments

Because function was used only on single place, move expected version into the function and consider new format as always valid.

---
Hi,

there are more tests which need ip version check: mc_cmds.sh, netns_netlink.c, netns_helper.sh.

netns_netlink.c can be checked for tuntap support with simple running 'ip tuntap' [1], mc_cmds.sh correctly detect new version with new scheme, thus only netns_helper.sh needs to be fixed, although it's just a warning.

Proper way would be to have C implementation to check version, which would be reusable in both C and shell. I plan to add it after the release but because there is git freeze due new release sending just this quick fix.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

 testcases/kernel/containers/netns/netns_helper.sh | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
testcases/kernel/containers/netns/netns_helper.sh +10 -5
index a5b77a0aa..4dac0e306 100755
@@ -47,16 +47,21 @@ IFCONF_IN6_ARG=
 
 tst_check_iproute()
 {
-	local cur_ipver="$(ip -V)"
-	local spe_ipver="$1"
+	local current_ver="$(ip -V)"
+	local expected_ver="111010"
 
-	cur_ipver=${cur_ipver##*s}
+	current_ver=${current_ver##*s}
 
-	if [ -z "$cur_ipver" -o -z "$spe_ipver" ]; then
+	if [ -z "$current_ver" ]; then
 		tst_brk TBROK "failed to obtain valid iproute version"
 	fi
 
-	if [ $cur_ipver -lt $spe_ipver ]; then
+	# new version scheme since v5.7.0-77-gb687d1067169
+	if echo "$current_ver" | grep -q 'iproute2-v\?[0-9]\+\.'; then
+		return
+	fi
+
+	if [ $current_ver -lt $expected_ver ]; then
 		tst_brk TCONF "too old iproute version"
 	fi
 }
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 netns_helper.sh: Fix parsing recent iproute2 versions

Hi!

testcases/kernel/containers/netns/netns_helper.sh IFCONF_IN6_ARG= · line 51

Quoted 12 lines
testcases/kernel/containers/netns/netns_helper.sh +2 -2
index a5b77a0aa..4dac0e306 100755
@@ -47,16 +47,21 @@ IFCONF_IN6_ARG=
 
 tst_check_iproute()
 {
-	local cur_ipver="$(ip -V)"
-	local spe_ipver="$1"
+	local current_ver="$(ip -V)"
+	local expected_ver="111010"

So if I'm reading this right, this is 2010 again. I wonder if we can just remove this check as well.

I guess that the most safe variant at the moment would be pushing this patch, then dropping the check completely after the release.

Quoted 21 lines
testcases/kernel/containers/netns/netns_helper.sh +8 -3
-	cur_ipver=${cur_ipver##*s}
+	current_ver=${current_ver##*s}
 
-	if [ -z "$cur_ipver" -o -z "$spe_ipver" ]; then
+	if [ -z "$current_ver" ]; then
 		tst_brk TBROK "failed to obtain valid iproute version"
 	fi
 
-	if [ $cur_ipver -lt $spe_ipver ]; then
+	# new version scheme since v5.7.0-77-gb687d1067169
+	if echo "$current_ver" | grep -q 'iproute2-v\?[0-9]\+\.'; then
+		return
+	fi
+
+	if [ $current_ver -lt $expected_ver ]; then
 		tst_brk TCONF "too old iproute version"
 	fi
 }
Signature · 1 line
2.31.1
Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH 1/1 netns_helper.sh: Fix parsing recent iproute2 versions

Hi Cyril,

Quoted 7 lines

Hi!

Quoted 5 lines
testcases/kernel/containers/netns/netns_helper.sh +0 -0
index a5b77a0aa..4dac0e306 100755
@@ -47,16 +47,21 @@ IFCONF_IN6_ARG=
Quoted 9 lines

testcases/kernel/containers/netns/netns_helper.sh IFCONF_IN6_ARG= · line 51

Quoted 6 lines
testcases/kernel/containers/netns/netns_helper.sh +2 -2
 tst_check_iproute()
 {
-	local cur_ipver="$(ip -V)"
-	local spe_ipver="$1"
+	local current_ver="$(ip -V)"
+	local expected_ver="111010"

So if I'm reading this right, this is 2010 again. I wonder if we can just remove this check as well.

Thanks for your input. FYI it's about iproute2 v3.0.0 (2011).

Quoted 2 lines

I guess that the most safe variant at the moment would be pushing this patch, then dropping the check completely after the release.

I'm ok if we don't want to bother with this (and with patch for netns_netlink.c [1]). But if you're ok to fix it for the release, I'd send new patch which fixes it similar way as the fix for netns_netlink.c:
here just run "ip netns" to detect required support instead of checking version info.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

#3 lore raw

PATCH 1/1 netns_helper.sh: Fix parsing recent iproute2 versions

Hi!

Quoted 7 lines
Quoted 2 lines

I guess that the most safe variant at the moment would be pushing this patch, then dropping the check completely after the release.

I'm ok if we don't want to bother with this (and with patch for netns_netlink.c [1]). But if you're ok to fix it for the release, I'd send new patch which fixes it similar way as the fix for netns_netlink.c:
here just run "ip netns" to detect required support instead of checking version info.

I do not have a strong opinion here. If you want to spend time fix these tests for this release I'm fine with that as long as the fix is minimal and works fine.

Signature · 2 lines
Cyril Hrubis
[email protected]