From ffcfaebc6ead2d29f59ac1c72f9f85756a80f7df Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Thu, 5 Sep 2024 12:47:16 -0400 Subject: [PATCH] tests: flood test now tests aggregation as well Signed-off-by: Christian Hopps --- tests/common/config.py | 15 +++++++++++++++ tests/flood/test_flood.py | 27 +++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/common/config.py b/tests/common/config.py index 45cdfc7..2735627 100644 --- a/tests/common/config.py +++ b/tests/common/config.py @@ -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}" @@ -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: @@ -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}") diff --git a/tests/flood/test_flood.py b/tests/flood/test_flood.py index 56608f9..738312b 100644 --- a/tests/flood/test_flood.py +++ b/tests/flood/test_flood.py @@ -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( @@ -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]) @@ -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)