mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-30 10:26:42 +07:00
selftests: forwarding: Add suppport to create veth interfaces
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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
955dc68cb9
commit
190f887c3c
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user