* [PATCH v2 net-next] selftests: forwarding: Add suppport to create veth interfaces
@ 2018-03-05 1:37 David Ahern
2018-03-05 7:43 ` Ido Schimmel
2018-03-05 15:44 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: David Ahern @ 2018-03-05 1:37 UTC (permalink / raw)
To: netdev; +Cc: idosch, David Ahern
For tests using veth interfaces, the test infrastructure can create
the netdevs if they do not exist. Arguably this is a preferred approach
since the tests require p$N and p$(N+1) to be pairs.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
v2
- local on j declaration and line wrap
.../net/forwarding/forwarding.config.sample | 5 ++++
tools/testing/selftests/net/forwarding/lib.sh | 35 ++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/forwarding.config.sample b/tools/testing/selftests/net/forwarding/forwarding.config.sample
index ab235c124f20..df54c9eb5100 100644
--- a/tools/testing/selftests/net/forwarding/forwarding.config.sample
+++ b/tools/testing/selftests/net/forwarding/forwarding.config.sample
@@ -14,6 +14,11 @@ NETIFS[p6]=veth5
NETIFS[p7]=veth6
NETIFS[p8]=veth7
+NETIF_TYPE=veth
+
+# only virtual interfaces (veth) can be created by test infra
+#NETIF_CREATE=yes
+
##############################################################################
# Defines
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index d0af52109360..273511ef2b43 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -76,6 +76,41 @@ done
##############################################################################
# Network interfaces configuration
+create_netif_veth()
+{
+ local i
+
+ for i in $(eval echo {1..$NUM_NETIFS}); do
+ local j=$((i+1))
+
+ ip link show dev ${NETIFS[p$i]} &> /dev/null
+ if [[ $? -ne 0 ]]; then
+ ip link add ${NETIFS[p$i]} type veth \
+ peer name ${NETIFS[p$j]}
+ if [[ $? -ne 0 ]]; then
+ echo "Failed to create netif"
+ exit 1
+ fi
+ fi
+ i=$j
+ done
+}
+
+create_netif()
+{
+ case "$NETIF_TYPE" in
+ veth) create_netif_veth
+ ;;
+ *) echo "Can not create interfaces of type \'$NETIF_TYPE\'"
+ exit 1
+ ;;
+ esac
+}
+
+if [[ "$NETIF_CREATE" = "yes" ]]; then
+ create_netif
+fi
+
for i in $(eval echo {1..$NUM_NETIFS}); do
ip link show dev ${NETIFS[p$i]} &> /dev/null
if [[ $? -ne 0 ]]; then
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] selftests: forwarding: Add suppport to create veth interfaces
2018-03-05 1:37 [PATCH v2 net-next] selftests: forwarding: Add suppport to create veth interfaces David Ahern
@ 2018-03-05 7:43 ` Ido Schimmel
2018-03-05 15:44 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2018-03-05 7:43 UTC (permalink / raw)
To: David Ahern; +Cc: netdev
On Sun, Mar 04, 2018 at 05:37:47PM -0800, David Ahern wrote:
> For tests using veth interfaces, the test infrastructure can create
> the netdevs if they do not exist. Arguably this is a preferred approach
> since the tests require p$N and p$(N+1) to be pairs.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] selftests: forwarding: Add suppport to create veth interfaces
2018-03-05 1:37 [PATCH v2 net-next] selftests: forwarding: Add suppport to create veth interfaces David Ahern
2018-03-05 7:43 ` Ido Schimmel
@ 2018-03-05 15:44 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-03-05 15:44 UTC (permalink / raw)
To: dsahern; +Cc: netdev, idosch
From: David Ahern <dsahern@gmail.com>
Date: Sun, 4 Mar 2018 17:37:47 -0800
> For tests using veth interfaces, the test infrastructure can create
> the netdevs if they do not exist. Arguably this is a preferred approach
> since the tests require p$N and p$(N+1) to be pairs.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
> ---
> v2
> - local on j declaration and line wrap
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-05 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-05 1:37 [PATCH v2 net-next] selftests: forwarding: Add suppport to create veth interfaces David Ahern
2018-03-05 7:43 ` Ido Schimmel
2018-03-05 15:44 ` David Miller
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).