Skip to content

Commit

Permalink
Merge pull request #22058 from sbrivio-rh/main
Browse files Browse the repository at this point in the history
test/system: Add support for multipath routes in pasta networking tests
  • Loading branch information
openshift-merge-bot[bot] authored Mar 18, 2024
2 parents affdf66 + 23433ec commit 15c33c0
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions test/system/helpers.network.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

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

local expr='[.[] | select(.dst == "default").dev] | .[0]'
ip -j -"${ip_ver}" route show | jq -rM "${expr}"
echo "${out}"
}

function default_addr() {
Expand Down

0 comments on commit 15c33c0

Please sign in to comment.