Skip to content

Commit

Permalink
selftests: rtnetlink: add gretap test cases
Browse files Browse the repository at this point in the history
Add test cases for gretap and ip6gretap, native mode
and external (collect metadata) mode.

Signed-off-by: William Tu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
williamtu authored and davem330 committed Dec 20, 2017
1 parent 143337c commit 5d0c138
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions tools/testing/selftests/net/rtnetlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,102 @@ kci_test_macsec()
echo "PASS: macsec"
}

kci_test_gretap()
{
testns="testns"
DEV_NS=gretap00
ret=0

ip netns add "$testns"
if [ $? -ne 0 ]; then
echo "SKIP gretap tests: cannot add net namespace $testns"
return 1
fi

ip link help gretap 2>&1 | grep -q "^Usage:"
if [ $? -ne 0 ];then
echo "SKIP: gretap: iproute2 too old"
return 1
fi

# test native tunnel
ip netns exec "$testns" ip link add dev "$DEV_NS" type gretap seq \
key 102 local 172.16.1.100 remote 172.16.1.200
check_err $?

ip netns exec "$testns" ip addr add dev "$DEV_NS" 10.1.1.100/24
check_err $?

ip netns exec "$testns" ip link set dev $DEV_NS up
check_err $?

ip netns exec "$testns" ip link del "$DEV_NS"
check_err $?

# test external mode
ip netns exec "$testns" ip link add dev "$DEV_NS" type gretap external
check_err $?

ip netns exec "$testns" ip link del "$DEV_NS"
check_err $?

if [ $ret -ne 0 ]; then
echo "FAIL: gretap"
return 1
fi
echo "PASS: gretap"

ip netns del "$testns"
}

kci_test_ip6gretap()
{
testns="testns"
DEV_NS=ip6gretap00
ret=0

ip netns add "$testns"
if [ $? -ne 0 ]; then
echo "SKIP ip6gretap tests: cannot add net namespace $testns"
return 1
fi

ip link help ip6gretap 2>&1 | grep -q "^Usage:"
if [ $? -ne 0 ];then
echo "SKIP: ip6gretap: iproute2 too old"
return 1
fi

# test native tunnel
ip netns exec "$testns" ip link add dev "$DEV_NS" type ip6gretap seq \
key 102 local fc00:100::1 remote fc00:100::2
check_err $?

ip netns exec "$testns" ip addr add dev "$DEV_NS" fc00:200::1/96
check_err $?

ip netns exec "$testns" ip link set dev $DEV_NS up
check_err $?

ip netns exec "$testns" ip link del "$DEV_NS"
check_err $?

# test external mode
ip netns exec "$testns" ip link add dev "$DEV_NS" type ip6gretap external
check_err $?

ip netns exec "$testns" ip link del "$DEV_NS"
check_err $?

if [ $ret -ne 0 ]; then
echo "FAIL: ip6gretap"
return 1
fi
echo "PASS: ip6gretap"

ip netns del "$testns"
}

kci_test_rtnl()
{
kci_add_dummy
Expand All @@ -514,6 +610,8 @@ kci_test_rtnl()
kci_test_route_get
kci_test_tc
kci_test_gre
kci_test_gretap
kci_test_ip6gretap
kci_test_bridge
kci_test_addrlabel
kci_test_ifalias
Expand Down

0 comments on commit 5d0c138

Please sign in to comment.