|
| 1 | +// clang-format off |
| 2 | + |
| 3 | +/* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved |
| 4 | + * |
| 5 | + * This program is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation; version 2 of the License. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | + */ |
| 18 | + |
| 19 | +#pragma once |
| 20 | +#include <vector> |
| 21 | +#include "katran/lib/testing/tools/PacketAttributes.h" |
| 22 | +#include "katran/lib/testing/tools/PacketBuilder.h" |
| 23 | + |
| 24 | +/** |
| 25 | + * Test fixtures for egress decapsulation (XDP_TX after GUE decap). |
| 26 | + * |
| 27 | + * Unlike xpop decap which recirculates the inner packet through Katran, |
| 28 | + * egress decap strips the GUE header, swaps MACs, and returns XDP_TX |
| 29 | + * directly. Used for DSR egress from cloud backends (EoPC). |
| 30 | + * |
| 31 | + * Input packets: GUE-encapsulated to the egress decap VIP (fc00:1405::1). |
| 32 | + * Expected output: inner packet with MACs swapped (dst=src, src=dst of input). |
| 33 | + */ |
| 34 | + |
| 35 | +namespace katran { |
| 36 | +namespace testing { |
| 37 | + |
| 38 | +const std::vector<::katran::PacketAttributes> egressDecapTestFixtures = { |
| 39 | + //1: Egress decap IPv4 inner packet — XDP_TX with MAC swap |
| 40 | + { |
| 41 | + .description = "Egress decap: GUE IPv6->IPv4 inner, XDP_TX with MAC swap.", |
| 42 | + .expectedReturnValue = "XDP_TX", |
| 43 | + .inputPacketBuilder = katran::testing::PacketBuilder::newPacket() |
| 44 | + .Eth("0x1", "0x2") |
| 45 | + .IPv6("100::64", "fc00:1405::1", 64) |
| 46 | + .UDP(31337, 9886) |
| 47 | + .IPv4("10.200.1.1", "192.168.1.3", 64) |
| 48 | + .UDP(80, 31337) |
| 49 | + .payload("egress decap test"), |
| 50 | + // After decap: inner packet with MACs swapped (0x2 -> dst, 0x1 -> src) |
| 51 | + .expectedOutputPacketBuilder = katran::testing::PacketBuilder::newPacket() |
| 52 | + .Eth("02:00:00:00:00:00", "01:00:00:00:00:00") |
| 53 | + .IPv4("10.200.1.1", "192.168.1.3", 63, 0, 1) |
| 54 | + .UDP(80, 31337) |
| 55 | + .payload("egress decap test") |
| 56 | + }, |
| 57 | + //2: Egress decap IPv6 inner packet — XDP_TX with MAC swap |
| 58 | + { |
| 59 | + .description = "Egress decap: GUE IPv6->IPv6 inner, XDP_TX with MAC swap.", |
| 60 | + .expectedReturnValue = "XDP_TX", |
| 61 | + .inputPacketBuilder = katran::testing::PacketBuilder::newPacket() |
| 62 | + .Eth("0x1", "0x2") |
| 63 | + .IPv6("100::64", "fc00:1405::1", 64) |
| 64 | + .UDP(31337, 9886) |
| 65 | + .IPv6("fc00:1::1", "fc00:2307:1::2", 64) |
| 66 | + .TCP(80, 31337, 0, 0, 8192, 0x10) |
| 67 | + .payload("egress decap test"), |
| 68 | + .expectedOutputPacketBuilder = katran::testing::PacketBuilder::newPacket() |
| 69 | + .Eth("02:00:00:00:00:00", "01:00:00:00:00:00") |
| 70 | + .IPv6("fc00:1::1", "fc00:2307:1::2", 63) |
| 71 | + .TCP(80, 31337, 0, 0, 8192, 0x10) |
| 72 | + .payload("egress decap test") |
| 73 | + }, |
| 74 | + //3: Egress decap with TTL expired — XDP_DROP |
| 75 | + { |
| 76 | + .description = "Egress decap: GUE IPv6->IPv4 inner with TTL expired, XDP_DROP.", |
| 77 | + .expectedReturnValue = "XDP_DROP", |
| 78 | + .inputPacketBuilder = katran::testing::PacketBuilder::newPacket() |
| 79 | + .Eth("0x1", "0x2") |
| 80 | + .IPv6("100::64", "fc00:1405::1", 64) |
| 81 | + .UDP(31337, 9886) |
| 82 | + .IPv4("10.200.1.1", "192.168.1.3", 1) |
| 83 | + .UDP(80, 31337) |
| 84 | + .payload("egress decap test"), |
| 85 | + .expectedOutputPacketBuilder = katran::testing::PacketBuilder::newPacket() |
| 86 | + .Eth("01:00:00:00:00:00", "02:00:00:00:00:00") |
| 87 | + .IPv4("10.200.1.1", "192.168.1.3", 0, 0, 1) |
| 88 | + .UDP(80, 31337) |
| 89 | + .payload("egress decap test") |
| 90 | + }, |
| 91 | +}; |
| 92 | + |
| 93 | +} // namespace testing |
| 94 | +} // namespace katran |
0 commit comments