mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
selftests: net: use setup_ns for SRv6 tests and remove rp_filter configuration
Some SRv6 tests manually set up network namespaces and disable rp_filter. Since the setup_ns library function already handles rp_filter configuration, convert these SRv6 tests to use setup_ns and remove the redundant rp_filter settings. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Acked-by: Andrea Mayer <andrea.mayer@uniroma2.it> Link: https://patch.msgid.link/20250508081910.84216-5-liuhangbin@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
69ea46e7d0
commit
3f68f59e95
@@ -285,11 +285,6 @@ setup_hs()
|
||||
ip netns exec ${hsname} sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec ${hsname} sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
|
||||
# disable the rp_filter otherwise the kernel gets confused about how
|
||||
# to route decap ipv4 packets.
|
||||
ip netns exec ${rtname} sysctl -wq net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec ${rtname} sysctl -wq net.ipv4.conf.default.rp_filter=0
|
||||
|
||||
ip -netns ${hsname} link add veth0 type veth peer name ${rtveth}
|
||||
ip -netns ${hsname} link set ${rtveth} netns ${rtname}
|
||||
ip -netns ${hsname} addr add ${IPv6_HS_NETWORK}::${hid}/64 dev veth0 nodad
|
||||
|
||||
@@ -250,11 +250,6 @@ setup_hs()
|
||||
eval local rtname=\${rt_${rid}}
|
||||
local rtveth=veth-t${tid}
|
||||
|
||||
# disable the rp_filter otherwise the kernel gets confused about how
|
||||
# to route decap ipv4 packets.
|
||||
ip netns exec ${rtname} sysctl -wq net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec ${rtname} sysctl -wq net.ipv4.conf.default.rp_filter=0
|
||||
|
||||
ip -netns ${hsname} link add veth0 type veth peer name ${rtveth}
|
||||
ip -netns ${hsname} link set ${rtveth} netns ${rtname}
|
||||
ip -netns ${hsname} addr add ${IPv4_HS_NETWORK}.${hid}/24 dev veth0
|
||||
|
||||
@@ -245,10 +245,8 @@
|
||||
# that adopted in the use cases already examined (of course, it is necessary to
|
||||
# consider the different SIDs/C-SIDs).
|
||||
|
||||
# Kselftest framework requirement - SKIP code is 4.
|
||||
readonly ksft_skip=4
|
||||
source lib.sh
|
||||
|
||||
readonly RDMSUFF="$(mktemp -u XXXXXXXX)"
|
||||
readonly DUMMY_DEVNAME="dum0"
|
||||
readonly VRF_TID=100
|
||||
readonly VRF_DEVNAME="vrf-${VRF_TID}"
|
||||
@@ -376,32 +374,18 @@ test_command_or_ksft_skip()
|
||||
fi
|
||||
}
|
||||
|
||||
get_nodename()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
echo "${name}-${RDMSUFF}"
|
||||
}
|
||||
|
||||
get_rtname()
|
||||
{
|
||||
local rtid="$1"
|
||||
|
||||
get_nodename "rt-${rtid}"
|
||||
echo "rt_${rtid}"
|
||||
}
|
||||
|
||||
get_hsname()
|
||||
{
|
||||
local hsid="$1"
|
||||
|
||||
get_nodename "hs-${hsid}"
|
||||
}
|
||||
|
||||
__create_namespace()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
ip netns add "${name}"
|
||||
echo "hs_${hsid}"
|
||||
}
|
||||
|
||||
create_router()
|
||||
@@ -410,8 +394,7 @@ create_router()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_rtname "${rtid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
create_host()
|
||||
@@ -420,28 +403,12 @@ create_host()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_hsname "${hsid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
local nsname
|
||||
local i
|
||||
|
||||
# destroy routers
|
||||
for i in ${ROUTERS}; do
|
||||
nsname="$(get_rtname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
|
||||
# destroy hosts
|
||||
for i in ${HOSTS}; do
|
||||
nsname="$(get_hsname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
cleanup_all_ns
|
||||
|
||||
# check whether the setup phase was completed successfully or not. In
|
||||
# case of an error during the setup phase of the testing environment,
|
||||
@@ -462,10 +429,10 @@ add_link_rt_pairs()
|
||||
local nsname
|
||||
local neigh_nsname
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
neigh_nsname="$(get_rtname "${neigh}")"
|
||||
eval neigh_nsname=\${$(get_rtname "${neigh}")}
|
||||
|
||||
ip link add "veth-rt-${rt}-${neigh}" netns "${nsname}" \
|
||||
type veth peer name "veth-rt-${neigh}-${rt}" \
|
||||
@@ -497,7 +464,7 @@ setup_rt_networking()
|
||||
local devname
|
||||
local neigh
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -518,9 +485,6 @@ setup_rt_networking()
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.forwarding=1
|
||||
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.default.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.ip_forward=1
|
||||
}
|
||||
|
||||
@@ -596,7 +560,7 @@ setup_rt_local_sids()
|
||||
local lcnode_func_prefix
|
||||
local lcblock_prefix
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -668,8 +632,8 @@ __setup_l3vpn()
|
||||
local rtsrc_nsname
|
||||
local rtdst_nsname
|
||||
|
||||
rtsrc_nsname="$(get_rtname "${src}")"
|
||||
rtdst_nsname="$(get_rtname "${dst}")"
|
||||
eval rtsrc_nsname=\${$(get_rtname "${src}")}
|
||||
eval rtdst_nsname=\${$(get_rtname "${dst}")}
|
||||
|
||||
container="${LCBLOCK_ADDR}"
|
||||
|
||||
@@ -744,8 +708,8 @@ setup_hs()
|
||||
local hsname
|
||||
local rtname
|
||||
|
||||
hsname="$(get_hsname "${hs}")"
|
||||
rtname="$(get_rtname "${rt}")"
|
||||
eval hsname=\${$(get_hsname "${hs}")}
|
||||
eval rtname=\${$(get_rtname "${rt}")}
|
||||
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
@@ -791,11 +755,6 @@ setup_hs()
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".proxy_arp=1
|
||||
|
||||
# disable the rp_filter otherwise the kernel gets confused about how
|
||||
# to route decap ipv4 packets.
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".rp_filter=0
|
||||
|
||||
ip netns exec "${rtname}" sh -c "echo 1 > /proc/sys/net/vrf/strict_mode"
|
||||
}
|
||||
|
||||
@@ -880,7 +839,7 @@ check_rt_connectivity()
|
||||
local prefix
|
||||
local rtsrc_nsname
|
||||
|
||||
rtsrc_nsname="$(get_rtname "${rtsrc}")"
|
||||
eval rtsrc_nsname=\${$(get_rtname "${rtsrc}")}
|
||||
|
||||
prefix="$(get_network_prefix "${rtsrc}" "${rtdst}")"
|
||||
|
||||
@@ -903,7 +862,7 @@ check_hs_ipv6_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv6_HS_NETWORK}::${hsdst}" >/dev/null 2>&1
|
||||
@@ -915,7 +874,7 @@ check_hs_ipv4_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv4_HS_NETWORK}.${hsdst}" >/dev/null 2>&1
|
||||
@@ -1025,7 +984,7 @@ rt_x_nextcsid_end_behavior_test()
|
||||
local nsname
|
||||
local ret
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
__nextcsid_end_behavior_test "${nsname}" "add" "${blen}" "${flen}"
|
||||
ret="$?"
|
||||
|
||||
@@ -287,10 +287,8 @@
|
||||
# packet using the SRv6 End.DT46 behavior (associated with the SID fcff:1::d46)
|
||||
# and sends it to the host hs-1.
|
||||
|
||||
# Kselftest framework requirement - SKIP code is 4.
|
||||
readonly ksft_skip=4
|
||||
source lib.sh
|
||||
|
||||
readonly RDMSUFF="$(mktemp -u XXXXXXXX)"
|
||||
readonly DUMMY_DEVNAME="dum0"
|
||||
readonly VRF_TID=100
|
||||
readonly VRF_DEVNAME="vrf-${VRF_TID}"
|
||||
@@ -418,32 +416,18 @@ test_command_or_ksft_skip()
|
||||
fi
|
||||
}
|
||||
|
||||
get_nodename()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
echo "${name}-${RDMSUFF}"
|
||||
}
|
||||
|
||||
get_rtname()
|
||||
{
|
||||
local rtid="$1"
|
||||
|
||||
get_nodename "rt-${rtid}"
|
||||
echo "rt_${rtid}"
|
||||
}
|
||||
|
||||
get_hsname()
|
||||
{
|
||||
local hsid="$1"
|
||||
|
||||
get_nodename "hs-${hsid}"
|
||||
}
|
||||
|
||||
__create_namespace()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
ip netns add "${name}"
|
||||
echo "hs_${hsid}"
|
||||
}
|
||||
|
||||
create_router()
|
||||
@@ -452,15 +436,12 @@ create_router()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_rtname "${rtid}")"
|
||||
setup_ns "${nsname}"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
|
||||
eval nsname=\${$(get_rtname "${rtid}")}
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.forwarding=1
|
||||
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.default.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.ip_forward=1
|
||||
}
|
||||
|
||||
@@ -470,29 +451,12 @@ create_host()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_hsname "${hsid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
local nsname
|
||||
local i
|
||||
|
||||
# destroy routers
|
||||
for i in ${ROUTERS}; do
|
||||
nsname="$(get_rtname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
|
||||
# destroy hosts
|
||||
for i in ${HOSTS}; do
|
||||
nsname="$(get_hsname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
|
||||
cleanup_all_ns
|
||||
# check whether the setup phase was completed successfully or not. In
|
||||
# case of an error during the setup phase of the testing environment,
|
||||
# the selftest is considered as "skipped".
|
||||
@@ -512,10 +476,10 @@ add_link_rt_pairs()
|
||||
local nsname
|
||||
local neigh_nsname
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
neigh_nsname="$(get_rtname "${neigh}")"
|
||||
eval neigh_nsname=\${$(get_rtname "${neigh}")}
|
||||
|
||||
ip link add "veth-rt-${rt}-${neigh}" netns "${nsname}" \
|
||||
type veth peer name "veth-rt-${neigh}-${rt}" \
|
||||
@@ -547,7 +511,7 @@ setup_rt_networking()
|
||||
local devname
|
||||
local neigh
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -631,7 +595,7 @@ set_end_x_nextcsid()
|
||||
local rt="$1"
|
||||
local adj="$2"
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
net_prefix="$(get_network_prefix "${rt}" "${adj}")"
|
||||
lcnode_func_prefix="$(build_lcnode_func_prefix "${rt}")"
|
||||
|
||||
@@ -650,7 +614,7 @@ set_underlay_sids_reachability()
|
||||
local rt="$1"
|
||||
local rt_neighs="$2"
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -685,7 +649,7 @@ setup_rt_local_sids()
|
||||
local lcnode_func_prefix
|
||||
local lcblock_prefix
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
set_underlay_sids_reachability "${rt}" "${rt_neighs}"
|
||||
|
||||
@@ -728,8 +692,8 @@ __setup_l3vpn()
|
||||
local rtsrc_nsname
|
||||
local rtdst_nsname
|
||||
|
||||
rtsrc_nsname="$(get_rtname "${src}")"
|
||||
rtdst_nsname="$(get_rtname "${dst}")"
|
||||
eval rtsrc_nsname=\${$(get_rtname "${src}")}
|
||||
eval rtdst_nsname=\${$(get_rtname "${dst}")}
|
||||
|
||||
container="${LCBLOCK_ADDR}"
|
||||
|
||||
@@ -804,8 +768,8 @@ setup_hs()
|
||||
local hsname
|
||||
local rtname
|
||||
|
||||
hsname="$(get_hsname "${hs}")"
|
||||
rtname="$(get_rtname "${rt}")"
|
||||
eval hsname=\${$(get_hsname "${hs}")}
|
||||
eval rtname=\${$(get_rtname "${rt}")}
|
||||
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
@@ -851,11 +815,6 @@ setup_hs()
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".proxy_arp=1
|
||||
|
||||
# disable the rp_filter otherwise the kernel gets confused about how
|
||||
# to route decap ipv4 packets.
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".rp_filter=0
|
||||
|
||||
ip netns exec "${rtname}" sh -c "echo 1 > /proc/sys/net/vrf/strict_mode"
|
||||
}
|
||||
|
||||
@@ -947,7 +906,7 @@ check_rt_connectivity()
|
||||
local prefix
|
||||
local rtsrc_nsname
|
||||
|
||||
rtsrc_nsname="$(get_rtname "${rtsrc}")"
|
||||
eval rtsrc_nsname=\${$(get_rtname "${rtsrc}")}
|
||||
|
||||
prefix="$(get_network_prefix "${rtsrc}" "${rtdst}")"
|
||||
|
||||
@@ -970,7 +929,7 @@ check_hs_ipv6_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv6_HS_NETWORK}::${hsdst}" >/dev/null 2>&1
|
||||
@@ -982,7 +941,7 @@ check_hs_ipv4_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv4_HS_NETWORK}.${hsdst}" >/dev/null 2>&1
|
||||
@@ -1093,7 +1052,7 @@ rt_x_nextcsid_end_x_behavior_test()
|
||||
local nsname
|
||||
local ret
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
__nextcsid_end_x_behavior_test "${nsname}" "add" "${blen}" "${flen}"
|
||||
ret="$?"
|
||||
|
||||
@@ -166,10 +166,8 @@
|
||||
# hs-4->hs-3 |IPv6 DA=fcff:1::e|SRH SIDs=fcff:3::d46|IPv6|...| (i.d)
|
||||
#
|
||||
|
||||
# Kselftest framework requirement - SKIP code is 4.
|
||||
readonly ksft_skip=4
|
||||
source lib.sh
|
||||
|
||||
readonly RDMSUFF="$(mktemp -u XXXXXXXX)"
|
||||
readonly VRF_TID=100
|
||||
readonly VRF_DEVNAME="vrf-${VRF_TID}"
|
||||
readonly RT2HS_DEVNAME="veth-t${VRF_TID}"
|
||||
@@ -248,32 +246,18 @@ test_command_or_ksft_skip()
|
||||
fi
|
||||
}
|
||||
|
||||
get_nodename()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
echo "${name}-${RDMSUFF}"
|
||||
}
|
||||
|
||||
get_rtname()
|
||||
{
|
||||
local rtid="$1"
|
||||
|
||||
get_nodename "rt-${rtid}"
|
||||
echo "rt_${rtid}"
|
||||
}
|
||||
|
||||
get_hsname()
|
||||
{
|
||||
local hsid="$1"
|
||||
|
||||
get_nodename "hs-${hsid}"
|
||||
}
|
||||
|
||||
__create_namespace()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
ip netns add "${name}"
|
||||
echo "hs_${hsid}"
|
||||
}
|
||||
|
||||
create_router()
|
||||
@@ -282,8 +266,7 @@ create_router()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_rtname "${rtid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
create_host()
|
||||
@@ -292,29 +275,12 @@ create_host()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_hsname "${hsid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
local nsname
|
||||
local i
|
||||
|
||||
# destroy routers
|
||||
for i in ${ROUTERS}; do
|
||||
nsname="$(get_rtname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
|
||||
# destroy hosts
|
||||
for i in ${HOSTS}; do
|
||||
nsname="$(get_hsname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
|
||||
cleanup_all_ns
|
||||
# check whether the setup phase was completed successfully or not. In
|
||||
# case of an error during the setup phase of the testing environment,
|
||||
# the selftest is considered as "skipped".
|
||||
@@ -334,10 +300,10 @@ add_link_rt_pairs()
|
||||
local nsname
|
||||
local neigh_nsname
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
neigh_nsname="$(get_rtname "${neigh}")"
|
||||
eval neigh_nsname=\${$(get_rtname "${neigh}")}
|
||||
|
||||
ip link add "veth-rt-${rt}-${neigh}" netns "${nsname}" \
|
||||
type veth peer name "veth-rt-${neigh}-${rt}" \
|
||||
@@ -369,7 +335,7 @@ setup_rt_networking()
|
||||
local devname
|
||||
local neigh
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -387,9 +353,6 @@ setup_rt_networking()
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.forwarding=1
|
||||
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.default.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.ip_forward=1
|
||||
}
|
||||
|
||||
@@ -403,7 +366,7 @@ setup_rt_local_sids()
|
||||
local nsname
|
||||
local neigh
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -469,7 +432,7 @@ __setup_rt_policy()
|
||||
local policy=''
|
||||
local n
|
||||
|
||||
nsname="$(get_rtname "${encap_rt}")"
|
||||
eval nsname=\${$(get_rtname "${encap_rt}")}
|
||||
|
||||
for n in ${end_rts}; do
|
||||
policy="${policy}${VPN_LOCATOR_SERVICE}:${n}::${END_FUNC},"
|
||||
@@ -516,8 +479,8 @@ setup_hs()
|
||||
local hsname
|
||||
local rtname
|
||||
|
||||
hsname="$(get_hsname "${hs}")"
|
||||
rtname="$(get_rtname "${rt}")"
|
||||
eval hsname=\${$(get_hsname "${hs}")}
|
||||
eval rtname=\${$(get_rtname "${rt}")}
|
||||
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
@@ -555,11 +518,6 @@ setup_hs()
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".proxy_arp=1
|
||||
|
||||
# disable the rp_filter otherwise the kernel gets confused about how
|
||||
# to route decap ipv4 packets.
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".rp_filter=0
|
||||
|
||||
ip netns exec "${rtname}" sh -c "echo 1 > /proc/sys/net/vrf/strict_mode"
|
||||
}
|
||||
|
||||
@@ -656,7 +614,7 @@ check_rt_connectivity()
|
||||
local prefix
|
||||
local rtsrc_nsname
|
||||
|
||||
rtsrc_nsname="$(get_rtname "${rtsrc}")"
|
||||
eval rtsrc_nsname=\${$(get_rtname "${rtsrc}")}
|
||||
|
||||
prefix="$(get_network_prefix "${rtsrc}" "${rtdst}")"
|
||||
|
||||
@@ -679,7 +637,7 @@ check_hs_ipv6_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv6_HS_NETWORK}::${hsdst}" >/dev/null 2>&1
|
||||
@@ -691,7 +649,7 @@ check_hs_ipv4_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv4_HS_NETWORK}.${hsdst}" >/dev/null 2>&1
|
||||
|
||||
@@ -116,10 +116,8 @@
|
||||
# hs-2->hs-1 |IPv6 DA=fcff:4::e|SRH SIDs=fcff:3::e,fcff:1::d2|eth|...| (i.b)
|
||||
#
|
||||
|
||||
# Kselftest framework requirement - SKIP code is 4.
|
||||
readonly ksft_skip=4
|
||||
source lib.sh
|
||||
|
||||
readonly RDMSUFF="$(mktemp -u XXXXXXXX)"
|
||||
readonly DUMMY_DEVNAME="dum0"
|
||||
readonly RT2HS_DEVNAME="veth-hs"
|
||||
readonly HS_VETH_NAME="veth0"
|
||||
@@ -199,32 +197,18 @@ test_command_or_ksft_skip()
|
||||
fi
|
||||
}
|
||||
|
||||
get_nodename()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
echo "${name}-${RDMSUFF}"
|
||||
}
|
||||
|
||||
get_rtname()
|
||||
{
|
||||
local rtid="$1"
|
||||
|
||||
get_nodename "rt-${rtid}"
|
||||
echo "rt_${rtid}"
|
||||
}
|
||||
|
||||
get_hsname()
|
||||
{
|
||||
local hsid="$1"
|
||||
|
||||
get_nodename "hs-${hsid}"
|
||||
}
|
||||
|
||||
__create_namespace()
|
||||
{
|
||||
local name="$1"
|
||||
|
||||
ip netns add "${name}"
|
||||
echo "hs_${hsid}"
|
||||
}
|
||||
|
||||
create_router()
|
||||
@@ -233,8 +217,7 @@ create_router()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_rtname "${rtid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
create_host()
|
||||
@@ -243,28 +226,12 @@ create_host()
|
||||
local nsname
|
||||
|
||||
nsname="$(get_hsname "${hsid}")"
|
||||
|
||||
__create_namespace "${nsname}"
|
||||
setup_ns "${nsname}"
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
local nsname
|
||||
local i
|
||||
|
||||
# destroy routers
|
||||
for i in ${ROUTERS}; do
|
||||
nsname="$(get_rtname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
|
||||
# destroy hosts
|
||||
for i in ${HOSTS}; do
|
||||
nsname="$(get_hsname "${i}")"
|
||||
|
||||
ip netns del "${nsname}" &>/dev/null || true
|
||||
done
|
||||
cleanup_all_ns
|
||||
|
||||
# check whether the setup phase was completed successfully or not. In
|
||||
# case of an error during the setup phase of the testing environment,
|
||||
@@ -285,10 +252,10 @@ add_link_rt_pairs()
|
||||
local nsname
|
||||
local neigh_nsname
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
neigh_nsname="$(get_rtname "${neigh}")"
|
||||
eval neigh_nsname=\${$(get_rtname "${neigh}")}
|
||||
|
||||
ip link add "veth-rt-${rt}-${neigh}" netns "${nsname}" \
|
||||
type veth peer name "veth-rt-${neigh}-${rt}" \
|
||||
@@ -320,7 +287,7 @@ setup_rt_networking()
|
||||
local devname
|
||||
local neigh
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -341,9 +308,6 @@ setup_rt_networking()
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv6.conf.all.forwarding=1
|
||||
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.conf.default.rp_filter=0
|
||||
ip netns exec "${nsname}" sysctl -wq net.ipv4.ip_forward=1
|
||||
}
|
||||
|
||||
@@ -357,7 +321,7 @@ setup_rt_local_sids()
|
||||
local nsname
|
||||
local neigh
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
for neigh in ${rt_neighs}; do
|
||||
devname="veth-rt-${rt}-${neigh}"
|
||||
@@ -407,7 +371,7 @@ __setup_rt_policy()
|
||||
local policy=''
|
||||
local n
|
||||
|
||||
nsname="$(get_rtname "${encap_rt}")"
|
||||
eval nsname=\${$(get_rtname "${encap_rt}")}
|
||||
|
||||
for n in ${end_rts}; do
|
||||
policy="${policy}${VPN_LOCATOR_SERVICE}:${n}::${END_FUNC},"
|
||||
@@ -446,7 +410,7 @@ setup_decap()
|
||||
local rt="$1"
|
||||
local nsname
|
||||
|
||||
nsname="$(get_rtname "${rt}")"
|
||||
eval nsname=\${$(get_rtname "${rt}")}
|
||||
|
||||
# Local End.DX2 behavior
|
||||
ip -netns "${nsname}" -6 route \
|
||||
@@ -463,8 +427,8 @@ setup_hs()
|
||||
local hsname
|
||||
local rtname
|
||||
|
||||
hsname="$(get_hsname "${hs}")"
|
||||
rtname="$(get_rtname "${rt}")"
|
||||
eval hsname=\${$(get_hsname "${hs}")}
|
||||
eval rtname=\${$(get_rtname "${rt}")}
|
||||
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.all.accept_dad=0
|
||||
ip netns exec "${hsname}" sysctl -wq net.ipv6.conf.default.accept_dad=0
|
||||
@@ -486,11 +450,6 @@ setup_hs()
|
||||
add "${IPv4_HS_NETWORK}.254/24" dev "${RT2HS_DEVNAME}"
|
||||
|
||||
ip -netns "${rtname}" link set "${RT2HS_DEVNAME}" up
|
||||
|
||||
# disable the rp_filter otherwise the kernel gets confused about how
|
||||
# to route decap ipv4 packets.
|
||||
ip netns exec "${rtname}" \
|
||||
sysctl -wq net.ipv4.conf."${RT2HS_DEVNAME}".rp_filter=0
|
||||
}
|
||||
|
||||
# set an auto-generated mac address
|
||||
@@ -508,7 +467,7 @@ set_mac_address()
|
||||
local ifname="$4"
|
||||
local nsname
|
||||
|
||||
nsname=$(get_nodename "${nodename}")
|
||||
eval nsname=\${${nodename}}
|
||||
|
||||
ip -netns "${nsname}" link set dev "${ifname}" down
|
||||
|
||||
@@ -532,7 +491,7 @@ set_host_l2peer()
|
||||
local hssrc_name
|
||||
local ipaddr
|
||||
|
||||
hssrc_name="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_name=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
if [ "${proto}" -eq 6 ]; then
|
||||
ipaddr="${ipprefix}::${hsdst}"
|
||||
@@ -562,7 +521,7 @@ setup_l2vpn()
|
||||
local rtdst="${hsdst}"
|
||||
|
||||
# set fixed mac for source node and the neigh MAC address
|
||||
set_mac_address "hs-${hssrc}" "${hssrc}" "${hssrc}" "${HS_VETH_NAME}"
|
||||
set_mac_address "hs_${hssrc}" "${hssrc}" "${hssrc}" "${HS_VETH_NAME}"
|
||||
set_host_l2peer "${hssrc}" "${hsdst}" "${IPv6_HS_NETWORK}" 6
|
||||
set_host_l2peer "${hssrc}" "${hsdst}" "${IPv4_HS_NETWORK}" 4
|
||||
|
||||
@@ -570,7 +529,7 @@ setup_l2vpn()
|
||||
# to the mac address of the remote peer (L2 VPN destination host).
|
||||
# Otherwise, traffic coming from the source host is dropped at the
|
||||
# ingress router.
|
||||
set_mac_address "rt-${rtsrc}" "${hsdst}" 254 "${RT2HS_DEVNAME}"
|
||||
set_mac_address "rt_${rtsrc}" "${hsdst}" 254 "${RT2HS_DEVNAME}"
|
||||
|
||||
# set the SRv6 Policies at the ingress router
|
||||
setup_rt_policy_ipv6 "${hsdst}" "${rtsrc}" "${end_rts}" "${rtdst}" \
|
||||
@@ -647,7 +606,7 @@ check_rt_connectivity()
|
||||
local prefix
|
||||
local rtsrc_nsname
|
||||
|
||||
rtsrc_nsname="$(get_rtname "${rtsrc}")"
|
||||
eval rtsrc_nsname=\${$(get_rtname "${rtsrc}")}
|
||||
|
||||
prefix="$(get_network_prefix "${rtsrc}" "${rtdst}")"
|
||||
|
||||
@@ -670,7 +629,7 @@ check_hs_ipv6_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv6_HS_NETWORK}::${hsdst}" >/dev/null 2>&1
|
||||
@@ -682,7 +641,7 @@ check_hs_ipv4_connectivity()
|
||||
local hsdst="$2"
|
||||
local hssrc_nsname
|
||||
|
||||
hssrc_nsname="$(get_hsname "${hssrc}")"
|
||||
eval hssrc_nsname=\${$(get_hsname "${hssrc}")}
|
||||
|
||||
ip netns exec "${hssrc_nsname}" ping -c 1 -W "${PING_TIMEOUT_SEC}" \
|
||||
"${IPv4_HS_NETWORK}.${hsdst}" >/dev/null 2>&1
|
||||
|
||||
Reference in New Issue
Block a user