public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
f954646f2034c1e5b8def16b7acbd6e9044e74d4 blob 4904 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 
# SPDX-License-Identifier: GPL-2.0-or-later
#
# PASST - Plug A Simple Socket Transport
#  for qemu/UNIX domain socket mode
#
# PASTA - Pack A Subtle Tap Abstraction
#  for network namespace/tap device mode
#
# test/pasta_options/multipath_gateway - Check gateway selection

htools	ip unshare sed grep

set	OUT __STATEDIR__/multipath-gateway.out
set	ERR __STATEDIR__/multipath-gateway.err

def	ipv4
set	FAMILY 4
set	PREFIX 192.0.2.
set	ADDRESS 192.0.2.10/24
set	LINKLOCAL true
set	ADDRESS_SETUP ip -__FAMILY__ address add __ADDRESS__ dev dummy0; __LINKLOCAL__
set	OTHER_INTERFACE_SETUP true
endef

def	ipv6
set	FAMILY 6
set	PREFIX 2001:db8:1::
set	ADDRESS 2001:db8:1::10/64
set	LINKLOCAL ip -6 addr add fe80::10/64 dev dummy0 nodad
set	ADDRESS_SETUP ip -__FAMILY__ address add __ADDRESS__ dev dummy0 nodad; __LINKLOCAL__
set	OTHER_INTERFACE_SETUP true
endef

def	ipv4_other_interface
ipv4
set	OTHER_PREFIX 192.51.100.
set	OTHER_INTERFACE_SETUP ip link add dummy1 type dummy; ip link set dummy1 up; ip -4 address add __OTHER_PREFIX__10/24 dev dummy1
endef

def	ipv6_other_interface
ipv6
set	OTHER_PREFIX 2001:db8:2::
set	OTHER_INTERFACE_SETUP ip link add dummy1 type dummy; ip link set dummy1 up; ip -6 address add __OTHER_PREFIX__10/64 dev dummy1 nodad
endef

# Keep each invocation in its own user/network namespace
# Reuse unshare's user namespace instead of creating another with pasta
def	check_gateway
set	LOG __STATEDIR__/ipv__FAMILY__-__CASE__.log
set	LINK_SETUP ip link set lo up; ip link add dummy0 type dummy; ip link set dummy0 up
set	ROUTE_SETUP ip -__FAMILY__ route add default __NEXTHOPS__
set	ROUTE_SHOW ip -__FAMILY__ route show default
set	NETWORK_SHOW ip -__FAMILY__ address show dev dummy0; ip -__FAMILY__ route show table all
set	SETUP __LINK_SETUP__; __ADDRESS_SETUP__; __OTHER_INTERFACE_SETUP__; __NETWORK_SHOW__; __ROUTE_SETUP__
set	PASTA ./pasta --netns-only --ipv__FAMILY__-only --debug --interface dummy0
hout	STATUS unshare --map-root-user --net -- sh -ec '__SETUP__; __ROUTE_SHOW__; exec __PASTA__ -- true' >'__LOG__' 2>&1; echo \$?
host	cat '__LOG__'
check	[ '__STATUS__' = '0' ]
hout	ACTUAL sed --quiet 's/.*router: *//p' '__LOG__'
info	Gateway: expected __EXPECTED__, actual __ACTUAL__
check	[ '__ACTUAL__' = '__EXPECTED__' ]
endef

test	IPv4: first gateway wins an equal-weight tie
set	CASE equal
ipv4
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 1 nexthop via __PREFIX__2 dev dummy0 weight 1
set	EXPECTED __PREFIX__1
check_gateway

test	IPv6: first gateway wins an equal-weight tie
set	CASE equal
ipv6
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 1 nexthop via __PREFIX__2 dev dummy0 weight 1
set	EXPECTED __PREFIX__1
check_gateway

test	IPv4: first gateway with the highest weight wins
set	CASE highest
ipv4
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 1 nexthop via __PREFIX__2 dev dummy0 weight 3 nexthop via __PREFIX__3 dev dummy0 weight 3
set	EXPECTED __PREFIX__2
check_gateway

test	IPv6: first gateway with the highest weight wins
set	CASE highest
ipv6
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 1 nexthop via __PREFIX__2 dev dummy0 weight 3 nexthop via __PREFIX__3 dev dummy0 weight 3
set	EXPECTED __PREFIX__2
check_gateway

test	IPv4: lower-weight gateway does not replace the selected gateway
set	CASE lower
ipv4
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 3 nexthop via __PREFIX__2 dev dummy0 weight 1
set	EXPECTED __PREFIX__1
check_gateway

test	IPv6: lower-weight gateway does not replace the selected gateway
set	CASE lower
ipv6
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 3 nexthop via __PREFIX__2 dev dummy0 weight 1
set	EXPECTED __PREFIX__1
check_gateway

test	IPv4: gateway-less nexthop does not mask an equal-weight gateway
set	CASE direct
ipv4
set	NEXTHOPS nexthop dev dummy0 weight 1 nexthop via __PREFIX__2 dev dummy0 weight 1
set	EXPECTED __PREFIX__2
check_gateway

test	IPv4: higher-weight gateway on another interface is ignored
set	CASE other-after
ipv4_other_interface
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 1 nexthop via __OTHER_PREFIX__1 dev dummy1 weight 3
set	EXPECTED __PREFIX__1
check_gateway

test	IPv6: higher-weight gateway on another interface is ignored
set	CASE other-after
ipv6_other_interface
set	NEXTHOPS nexthop via __PREFIX__1 dev dummy0 weight 1 nexthop via __OTHER_PREFIX__1 dev dummy1 weight 3
set	EXPECTED __PREFIX__1
check_gateway

test	IPv4: selected interface can be the second multipath nexthop
set	CASE other-before
ipv4_other_interface
set	NEXTHOPS nexthop via __OTHER_PREFIX__1 dev dummy1 weight 3 nexthop via __PREFIX__1 dev dummy0 weight 1
set	EXPECTED __PREFIX__1
check_gateway

test	IPv6: selected interface can be the second multipath nexthop
set	CASE other-before
ipv6_other_interface
set	NEXTHOPS nexthop via __OTHER_PREFIX__1 dev dummy1 weight 3 nexthop via __PREFIX__1 dev dummy0 weight 1
set	EXPECTED __PREFIX__1
check_gateway
debug log:

solving f954646 ...
found f954646 in https://archives.passt.top/passt-dev/2UuogkMNAhFH_0bGAADpm7VgzMi123uydmdNZpZZ6tWdhkxB8y5S4Z4h4Ela1Vyb0QymFQg2Pe03CsvEWjLtdvbeFhbCuBJthILFuMs-JYo=@benschubert.me/
found f7bd45d in https://passt.top/passt
preparing index
index prepared:
100644 f7bd45d89350dcd79e162d7bfbf244a163390c6c	test/pasta_options/multipath_gateway

applying [1/1] https://archives.passt.top/passt-dev/2UuogkMNAhFH_0bGAADpm7VgzMi123uydmdNZpZZ6tWdhkxB8y5S4Z4h4Ela1Vyb0QymFQg2Pe03CsvEWjLtdvbeFhbCuBJthILFuMs-JYo=@benschubert.me/
diff --git a/test/pasta_options/multipath_gateway b/test/pasta_options/multipath_gateway
index f7bd45d..f954646 100644

Checking patch test/pasta_options/multipath_gateway...
Applied patch test/pasta_options/multipath_gateway cleanly.

index at:
100644 f954646f2034c1e5b8def16b7acbd6e9044e74d4	test/pasta_options/multipath_gateway

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).