#!/bin/bash## This test is for checking rtnetlink callpaths, and get as much coverage as possible.## set -edevdummy="test-dummy0"# Kselftest framework requirement - SKIP code is 4.ksft_skip=4# set global exit status, but never reset nonzero one.
check_err(){if[$ret-eq0];thenret=$1fi}# same but inverted -- used when command must fail for test to pass
check_fail(){if[$1-eq0];thenret=1fi}
kci_add_dummy(){iplinkaddname"$devdummy"typedummy
check_err$?iplinkset"$devdummy"up
check_err$?}
kci_del_dummy(){iplinkdeldev"$devdummy"check_err$?}
kci_test_netconf(){dev="$1"r=$retipnetconfshowdev"$dev">/dev/null
check_err$?forfin46;doip-$fnetconfshowdev"$dev">/dev/null
check_err$?doneif[$ret-ne0];thenecho"FAIL: ip netconf show $dev"test$r-eq0&&ret=0return1fi}# add a bridge with vlans on top
kci_test_bridge(){devbr="test-br0"vlandev="testbr-vlan1"localret=0iplinkaddname"$devbr"typebridge
check_err$?iplinksetdev"$devdummy"master"$devbr"check_err$?iplinkset"$devbr"up
check_err$?iplinkaddlink"$devbr"name"$vlandev"typevlanid1check_err$?ipaddradddev"$vlandev"10.200.7.23/30
check_err$?ip-6addradddev"$vlandev"dead:42::1234/64
check_err$?ip-dlink>/dev/null
check_err$?iprstall>/dev/null
check_err$?fornamein"$devbr""$vlandev""$devdummy";dokci_test_netconf"$name"doneip-6addrdeldev"$vlandev"dead:42::1234/64
check_err$?iplinkdeldev"$vlandev"check_err$?iplinkdeldev"$devbr"check_err$?if[$ret-ne0];thenecho"FAIL: bridge setup"return1fiecho"PASS: bridge setup"}
kci_test_gre(){gredev=neta
rem=10.42.42.1
loc=10.0.0.1
localret=0iptunneladd$gredevmodegreremote$remlocal$locttl1check_err$?iplinkset$gredevup
check_err$?ipaddradd10.23.7.10dev$gredevcheck_err$?iprouteadd10.23.8.0/30dev$gredevcheck_err <