mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00
test/system: Add support for multipath routes in pasta networking tests
In some environments, such as the one described in https://github.com/containers/podman/issues/20927, the default route is given as nexthop gateways. That is, it's a multipath routes with multiple gateways. That means that pasta(1), after commit 6c7623d07bbd ("netlink: Add support to fetch default gateway from multipath routes"), can start and use a default gateway from that route. Just like in pasta(1), in these tests, the default route indicates which upstream interface we should pick. If we ignore multipath routes, IPv6 addresses and gateway addresses themselves won't be available, so, while pasta is now able to configure the container, IPv6 tests will expect to find no address and no gateway, hence fail due to the mismatch. Try to get routes, including gateway addresses and interface names, from nexthop objects, in case the selection of a regular default route yields no results. Link: https://github.com/containers/podman/issues/20927 Closes: #20927 Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
@ -208,15 +208,31 @@ EOF
|
||||
# ipv4_get_route_default() - Print first default IPv4 route reported by netlink
|
||||
# $1: Optional output of 'ip -j -4 route show' from a different context
|
||||
function ipv4_get_route_default() {
|
||||
local jq_expr='[.[] | select(.dst == "default").gateway] | .[0]'
|
||||
echo "${1:-$(ip -j -4 route show)}" | jq -rM "${jq_expr}"
|
||||
local jq_gw='[.[] | select(.dst == "default").gateway] | .[0]'
|
||||
local jq_nh='[.[] | select(.dst == "default").nexthops[0].gateway] | .[0]'
|
||||
local out
|
||||
|
||||
out="$(echo "${1:-$(ip -j -4 route show)}" | jq -rM "${jq_gw}")"
|
||||
if [ "${out}" = "null" ]; then
|
||||
out="$(echo "${1:-$(ip -j -4 route show)}" | jq -rM "${jq_nh}")"
|
||||
fi
|
||||
|
||||
echo "${out}"
|
||||
}
|
||||
|
||||
# ipv6_get_route_default() - Print first default IPv6 route reported by netlink
|
||||
# $1: Optional output of 'ip -j -6 route show' from a different context
|
||||
function ipv6_get_route_default() {
|
||||
local jq_expr='[.[] | select(.dst == "default").gateway] | .[0]'
|
||||
echo "${1:-$(ip -j -6 route show)}" | jq -rM "${jq_expr}"
|
||||
local jq_gw='[.[] | select(.dst == "default").gateway] | .[0]'
|
||||
local jq_nh='[.[] | select(.dst == "default").nexthops[0].gateway] | .[0]'
|
||||
local out
|
||||
|
||||
out="$(echo "${1:-$(ip -j -6 route show)}" | jq -rM "${jq_gw}")"
|
||||
if [ "${out}" = "null" ]; then
|
||||
out="$(echo "${1:-$(ip -j -6 route show)}" | jq -rM "${jq_nh}")"
|
||||
fi
|
||||
|
||||
echo "${out}"
|
||||
}
|
||||
|
||||
# ether_get_mtu() - Get MTU of first Ethernet-like link
|
||||
@ -373,10 +389,17 @@ function tcp_port_probe() {
|
||||
### Pasta Helpers ##############################################################
|
||||
|
||||
function default_ifname() {
|
||||
local jq_expr='[.[] | select(.dst == "default").dev] | .[0]'
|
||||
local jq_expr_nh='[.[] | select(.dst == "default").nexthops[0].dev] | .[0]'
|
||||
local ip_ver="${1}"
|
||||
local out
|
||||
|
||||
local expr='[.[] | select(.dst == "default").dev] | .[0]'
|
||||
ip -j -"${ip_ver}" route show | jq -rM "${expr}"
|
||||
out="$(ip -j -"${ip_ver}" route show | jq -rM "${jq_expr}")"
|
||||
if [ "${out}" = "null" ]; then
|
||||
out="$(ip -j -"${ip_ver}" route show | jq -rM "${jq_expr_nh}")"
|
||||
fi
|
||||
|
||||
echo "${out}"
|
||||
}
|
||||
|
||||
function default_addr() {
|
||||
|
Reference in New Issue
Block a user