Skip to content

Commit

Permalink
tests: flood test now tests aggregation as well
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Sep 5, 2024
1 parent 4321860 commit ffcfaeb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
15 changes: 15 additions & 0 deletions tests/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,19 @@ async def setup_routed_tun(

mtustr = f"mtu {tun_route_mtu}" if tun_route_mtu else ""

# r1tunip = "10.0.1.2"
# r1tunip6 = "fc00:0:0:1::2"
# XXX should this be 10.0.0.2??
r1srcip = f"src 10.0.1.2 {mtustr}"
r1srcip6 = f"src fc00:0:0:0::2 {mtustr}"
if network3:
# r2tunip = "10.0.2.4"
# r2tunip6 = "fc00:0:0:2::4"
r2srcip = f"src 10.0.3.4 {mtustr}"
r2srcip6 = f"src fc00:0:0:3::4 {mtustr}"
else:
# r2tunip = "10.0.1.3"
# r2tunip6 = "fc00:0:0:1::3"
r2srcip = f"src 10.0.2.3 {mtustr}"
r2srcip6 = f"src fc00:0:0:2::3 {mtustr}"

Expand All @@ -933,10 +940,14 @@ async def setup_routed_tun(
r1con.cmd_raises(f"ip route add 10.0.2.0/24 dev ipsec0 {r1srcip}")
if network3:
r1con.cmd_raises(f"ip route add 10.0.3.0/24 dev ipsec0 {r1srcip}")
# This causes a routing loop, not sure how to do routed local originated
# r1con.cmd_raises(f"ip route add {r2tunip}/32 dev ipsec0")
if r2con:
r2con.cmd_raises(f"ip route add 10.0.0.0/24 dev ipsec0 {r2srcip}")
if network3:
r2con.cmd_raises(f"ip route add 10.0.1.0/24 dev ipsec0 {r2srcip}")
# This causes a routing loop, not sure how to do routed local originated
# r2con.cmd_raises(f"ip route add {r1tunip}/32 dev ipsec0")

else:
if r1con:
Expand All @@ -955,12 +966,16 @@ async def setup_routed_tun(
r1con.cmd_raises(
f"ip route add fc00:0:0:3::/64 dev ipsec0 {r1srcip6}"
)
# This causes a routing loop, not sure how to do routed local originated
# r1con.cmd_raises(f"ip route add {r2tunip6}/128 dev ipsec0")
if r2con:
r2con.cmd_raises(f"ip route add fc00:0:0:0::/64 dev ipsec0 {r2srcip6}")
if network3:
r2con.cmd_raises(
f"ip route add fc00:0:0:1::/64 dev ipsec0 {r2srcip6}"
)
# This causes a routing loop, not sure how to do routed local originated
# r2con.cmd_raises(f"ip route add {r1tunip6}/128 dev ipsec0")
else:
if r1con:
r1con.cmd_raises(f"ip route add 2012::/64 dev ipsec0 {r1srcip6}")
Expand Down
27 changes: 13 additions & 14 deletions tests/flood/test_flood.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ async def do_ping(host, dest4, dest6, astepf):
logging.debug(host.cmd_raises(f"ping -q -n -s 8 -f -c{count} {dest6}"))


def check_rx_tx_count(host, v6, nrx, ntx):
# Now validate that we have sent and received the exact number of ESP packets
base = "fc00:0:0:1::" if v6 else "10.0.1."
o = host.cmd_raises(f"ip x s l src {base}2")
assert f" oseq 0x{ntx:x}," in o or f" oseq 0x{ntx:x}\n" in o
o = host.cmd_raises(f"ip x s l src {base}3")
assert f" seq 0x{nrx:x}," in o or f" seq 0x{nrx:x}\n" in o


@pytest.mark.parametrize("tun_ipv6", [False, True])
async def test_policy_tun_agg(unet, astepf, tun_ipv6):
await setup_policy_tun(
Expand All @@ -75,14 +84,10 @@ async def test_policy_tun_agg(unet, astepf, tun_ipv6):
)

await do_ping(unet.hosts["r1"], "10.0.1.3", "fc00:0:0:1::3", astepf)
await do_ping(unet.hosts["h1"], "10.0.2.4", "fc00:0:0:2::4", astepf)
check_rx_tx_count(unet.hosts["r1"], tun_ipv6, 2, 2)

# Now validate that we have sent and received exactly 8 ESP packets
base = "fc00:0:0:1::" if tun_ipv6 else "10.0.1."
o = unet.hosts["r1"].cmd_raises(f"ip x s l src {base}2")
assert " oseq 0x4" in o
o = unet.hosts["r1"].cmd_raises(f"ip x s l src {base}3")
assert " seq 0x4" in o
await do_ping(unet.hosts["h1"], "10.0.2.4", "fc00:0:0:2::4", astepf)
check_rx_tx_count(unet.hosts["r1"], tun_ipv6, 4, 4)


@pytest.mark.parametrize("tun_ipv6", [False, True])
Expand All @@ -98,10 +103,4 @@ async def test_routed_tun_agg(unet, astepf, tun_ipv6):

# We don't have routes setup for local originated pings
await do_ping(unet.hosts["h1"], "10.0.2.4", "fc00:0:0:2::4", astepf)

# Now validate that we have sent and received exactly 8 ESP packets
base = "fc00:0:0:1::" if tun_ipv6 else "10.0.1."
o = unet.hosts["r1"].cmd_raises(f"ip x s l src {base}2")
assert " oseq 0x2" in o
o = unet.hosts["r1"].cmd_raises(f"ip x s l src {base}3")
assert " seq 0x2" in o
check_rx_tx_count(unet.hosts["r1"], tun_ipv6, 2, 2)

0 comments on commit ffcfaeb

Please sign in to comment.