44# This test sets up 3 netns (src <-> fwd <-> dst). There is no direct veth link
55# between src and dst. The netns fwd has veth links to each src and dst. The
66# client is in src and server in dst. The test installs a TC BPF program to each
7- # host facing veth in fwd which calls into bpf_redirect_peer() to perform the
8- # neigh addr population and redirect; it also installs a dropper prog on the
9- # egress side to drop skbs if neigh addrs were not populated.
7+ # host facing veth in fwd which calls into i) bpf_redirect_neigh() to perform the
8+ # neigh addr population and redirect or ii) bpf_redirect_peer() for namespace
9+ # switch from ingress side; it also installs a checker prog on the egress side
10+ # to drop unexpected traffic.
1011
1112if [[ $EUID -ne 0 ]]; then
1213 echo " This script must be run as root"
@@ -166,15 +167,17 @@ hex_mem_str()
166167 perl -e ' print join(" ", unpack("(H2)8", pack("L", @ARGV)))' $1
167168}
168169
169- netns_setup_neigh ()
170+ netns_setup_bpf ()
170171{
172+ local obj=$1
173+
171174 ip netns exec ${NS_FWD} tc qdisc add dev veth_src_fwd clsact
172- ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd ingress bpf da obj test_tc_neigh.o sec src_ingress
173- ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd egress bpf da obj test_tc_neigh.o sec chk_egress
175+ ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd ingress bpf da obj $obj sec src_ingress
176+ ip netns exec ${NS_FWD} tc filter add dev veth_src_fwd egress bpf da obj $obj sec chk_egress
174177
175178 ip netns exec ${NS_FWD} tc qdisc add dev veth_dst_fwd clsact
176- ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd ingress bpf da obj test_tc_neigh.o sec dst_ingress
177- ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd egress bpf da obj test_tc_neigh.o sec chk_egress
179+ ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd ingress bpf da obj $obj sec dst_ingress
180+ ip netns exec ${NS_FWD} tc filter add dev veth_dst_fwd egress bpf da obj $obj sec chk_egress
178181
179182 veth_src=$( ip netns exec ${NS_FWD} cat /sys/class/net/veth_src_fwd/ifindex)
180183 veth_dst=$( ip netns exec ${NS_FWD} cat /sys/class/net/veth_dst_fwd/ifindex)
@@ -193,5 +196,9 @@ trap netns_cleanup EXIT
193196set -e
194197
195198netns_setup
196- netns_setup_neigh
199+ netns_setup_bpf test_tc_neigh.o
200+ netns_test_connectivity
201+ netns_cleanup
202+ netns_setup
203+ netns_setup_bpf test_tc_peer.o
197204netns_test_connectivity
0 commit comments