From 76d8343ad300f6507233abcdf97629290e35848a Mon Sep 17 00:00:00 2001
From: Lei Yang <Lei.Yang@windriver.com>
Date: Wed, 29 Aug 2018 11:51:24 +0800
Subject: [PATCH] netns_helper.sh: use 'ping -6' when ping6 is not avaliable

ping6 has been merged into ping since 2015 by using "ping -6"
in some distributions (e.g. OpenEmbedded) they dropped ping6 completely
this patch will let both "ping -6" and ping6 work.

[pvorel: change was done in s20150815:
ebad35f ("ping: merge `ping6` command into `ping`"),
before that release switch '-6' didn't exist.
Upstream leaves ping6 symlink to distributions.]

Upstream-Status: Backport
[https://github.com/linux-test-project/ltp/commit/76d8343ad300f6507233abcdf97629290e35848a]

Signed-off-by: Lei Yang <Lei.Yang@windriver.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 testcases/kernel/containers/netns/netns_helper.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index 6aea10b..a9d0459 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -168,7 +168,12 @@ netns_setup()
 	ipv6)
 		IFCONF_IN6_ARG="inet6 add"
 		IP0=$6; IP1=$7;
-		tping="ping6"; NETMASK=64
+		if which ping6 >/dev/null 2>&1; then
+		    tping="ping6"
+		else
+		    tping="ping -6"
+		fi
+		NETMASK=64
 		;;
 	*)
 		tst_brkm TBROK "second argument must be an ip version (ipv4|ipv6)"
-- 
2.7.4

