2 # SPDX-License-Identifier: GPL-2.0
8 # veth0 <---|---> veth1
9 # Validate source address selection for route without gateway
15 ################################################################################
24 if [ ${rc} -eq ${expected} ]; then
25 printf "TEST: %-60s [ OK ]\n" "${msg}"
26 nsuccess=$((nsuccess+1))
30 printf "TEST: %-60s [FAIL]\n" "${msg}"
31 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
33 echo "hit enter to continue, 'q' to quit"
35 [ "$a" = "q" ] && exit 1
39 [ "$VERBOSE" = "1" ] && echo
48 if [ "$VERBOSE" = "1" ]; then
54 if [ "$VERBOSE" = "1" -a -n "$out" ]; then
58 [ "$VERBOSE" = "1" ] && echo
63 ################################################################################
68 ip -n h1 link set lo up
70 ip -n h2 link set lo up
72 # Add a fake eth0 to support an ip address
73 ip -n h1 link add name eth0 type dummy
74 ip -n h1 link set eth0 up
75 ip -n h1 address add 192.168.0.1/24 dev eth0
77 # Configure veths (same @mac, arp off)
78 ip -n h1 link add name veth0 type veth peer name veth1 netns h2
79 ip -n h1 link set veth0 up
81 ip -n h2 link set veth1 up
83 # Configure @IP in the peer netns
84 ip -n h2 address add 192.168.1.1/32 dev veth1
85 ip -n h2 route add default dev veth1
87 # Add a nexthop without @gw and use it in a route
88 ip -n h1 nexthop add id 1 dev veth0
89 ip -n h1 route add 192.168.1.1 nhid 1
94 ip netns del h1 2>/dev/null
95 ip netns del h2 2>/dev/null
100 ################################################################################
106 p) PAUSE_ON_FAIL=yes;;
114 run_cmd ip -netns h1 route get 192.168.1.1
115 log_test $? 0 "nexthop: get route with nexthop without gw"
116 run_cmd ip netns exec h1 ping -c1 192.168.1.1
117 log_test $? 0 "nexthop: ping through nexthop without gw"