Skip to content

Commit a81ce54

Browse files
generatedunixname89002005232357meta-codesync[bot]
authored andcommitted
Revert D86903152
Summary: This diff reverts D86903152 currently failing on conveyor Depends on D86903152 Differential Revision: D90355163 fbshipit-source-id: 9d06dec2e415649322cc8f96e64e2f133dc8fd8d
1 parent 3bef2c3 commit a81ce54

File tree

2 files changed

+20
-54
lines changed

2 files changed

+20
-54
lines changed

fboss/agent/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,6 @@ cpp_library(
19311931
exported_deps = [
19321932
":agent_command_executor",
19331933
":agent_dir_util",
1934-
":agent_features",
19351934
":agent_netwhoami",
19361935
":fboss-error",
19371936
":fboss_common_init",

fboss/agent/test/agent_hw_tests/AgentMalformedPacketTests.cpp

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,16 @@
22

33
#include "fboss/agent/test/AgentHwTest.h"
44

5-
#include <folly/IPAddress.h>
6-
#include <folly/io/Cursor.h>
75
#include <folly/io/IOBuf.h>
86
#include <chrono>
97
#include <thread>
108
#include "fboss/agent/TxPacket.h"
11-
#include "fboss/agent/packet/IPv4Hdr.h"
12-
#include "fboss/agent/packet/IPv6Hdr.h"
139
#include "fboss/agent/packet/PktFactory.h"
1410
#include "fboss/agent/test/utils/ConfigUtils.h"
1511
#include "fboss/agent/test/utils/MacTestUtils.h"
1612

17-
namespace {
18-
using TestTypes = ::testing::Types<folly::IPAddressV4, folly::IPAddressV6>;
19-
class IPAddressNameGenerator {
20-
public:
21-
template <typename T>
22-
static std::string GetName(int) {
23-
if constexpr (std::is_same_v<T, folly::IPAddressV4>) {
24-
return "IPv4";
25-
}
26-
if constexpr (std::is_same_v<T, folly::IPAddressV6>) {
27-
return "IPv6";
28-
}
29-
}
30-
};
31-
} // namespace
32-
3313
namespace facebook::fboss {
3414

35-
template <typename AddrT>
3615
class AgentMalformedPacketTest : public AgentHwTest {
3716
public:
3817
std::vector<ProductionFeature> getProductionFeaturesVerified()
@@ -55,16 +34,9 @@ class AgentMalformedPacketTest : public AgentHwTest {
5534
auto intfMac = utility::getInterfaceMac(getProgrammedState(), vlanId);
5635
auto srcMac = utility::MacAddressGenerator().get(intfMac.u64HBO() + 1);
5736

58-
// Create source and destination IPs based on template type
59-
AddrT srcIp, dstIp;
60-
if constexpr (std::is_same_v<AddrT, folly::IPAddressV4>) {
61-
srcIp = folly::IPAddressV4("10.0.0.1");
62-
dstIp = folly::IPAddressV4("10.0.0.2");
63-
} else {
64-
srcIp = folly::IPAddressV6("2001:db8::1");
65-
dstIp = folly::IPAddressV6("2001:db8::2");
66-
}
67-
37+
// Create a normal UDP packet first using the utility function
38+
folly::IPAddressV4 srcIp("10.0.0.1");
39+
folly::IPAddressV4 dstIp("10.0.0.2");
6840
uint16_t srcPort = 1000;
6941
uint16_t dstPort = 2000;
7042

@@ -73,21 +45,17 @@ class AgentMalformedPacketTest : public AgentHwTest {
7345

7446
// Now corrupt the UDP checksum by setting it to 0
7547
// The UDP checksum is located after the IP header and the first 6 bytes of
76-
// UDP header. UDP header format: srcPort(2) + dstPort(2) + length(2) +
48+
// UDP header UDP header format: srcPort(2) + dstPort(2) + length(2) +
7749
// checksum(2)
7850
auto buf = pkt->buf();
7951

8052
// Calculate the offset to UDP checksum
81-
// EthHdr::SIZE + IP header + UDP src port + UDP dst port + UDP length
53+
// EthHdr::SIZE + (VLAN tag if present) + IPv4 header + UDP src port + UDP
54+
// dst port + UDP length
8255
size_t ethSize = EthHdr::SIZE;
83-
size_t ipHeaderSize;
84-
if constexpr (std::is_same_v<AddrT, folly::IPAddressV4>) {
85-
ipHeaderSize = IPv4Hdr::minSize();
86-
} else {
87-
ipHeaderSize = IPv6Hdr::SIZE;
88-
}
56+
size_t ipv4Size = 20; // Standard IPv4 header size
8957
size_t udpChecksumOffset =
90-
ethSize + ipHeaderSize + 2 + 2 + 2; // After src port, dst port, length
58+
ethSize + ipv4Size + 2 + 2 + 2; // After src port, dst port, length
9159

9260
// Set the UDP checksum to 0 (invalid)
9361
folly::io::RWPrivateCursor writer(buf);
@@ -98,31 +66,29 @@ class AgentMalformedPacketTest : public AgentHwTest {
9866
}
9967
};
10068

101-
TYPED_TEST_SUITE(AgentMalformedPacketTest, TestTypes, IPAddressNameGenerator);
102-
103-
TYPED_TEST(
69+
TEST_F(
10470
AgentMalformedPacketTest,
105-
PacketWithNoChecksumDoesNotCreateMacEntry) {
106-
// Get the ingress port to inject the packet on
107-
auto ingressPort = this->masterLogicalInterfacePortIds()[0];
71+
PacketWithNoChecksumDoesNotCreateMacEntry) { // Get the ingress port to
72+
// inject the packet on
73+
auto ingressPort = masterLogicalInterfacePortIds()[0];
10874

10975
// Get initial MAC table entries and drop stats
110-
auto initialL2Entries = utility::getL2Table(this->getSw());
76+
auto initialL2Entries = utility::getL2Table(getSw());
11177
auto initialMacTableSize = initialL2Entries.size();
112-
auto initialDropStats = this->getAggregatedSwitchDropStats();
78+
auto initialDropStats = getAggregatedSwitchDropStats();
11379

11480
// Inject packet with no checksum on ingress port
11581
// This simulates the packet arriving on the switch port
116-
auto pkt = this->createPacketWithNoChecksum();
117-
this->getSw()->sendPacketOutOfPortAsync(std::move(pkt), ingressPort);
82+
auto pkt = createPacketWithNoChecksum();
83+
getSw()->sendPacketOutOfPortAsync(std::move(pkt), ingressPort);
11884

11985
// Wait for potential MAC learning with retry loop
12086
// Check multiple times to ensure MAC table doesn't grow
12187
constexpr int kMaxRetries = 5;
12288
constexpr auto kRetryInterval = std::chrono::milliseconds(500);
12389
for (int i = 0; i < kMaxRetries; ++i) {
12490
std::this_thread::sleep_for(kRetryInterval);
125-
auto currentL2Entries = utility::getL2Table(this->getSw());
91+
auto currentL2Entries = utility::getL2Table(getSw());
12692
// Fail immediately if MAC table grew
12793
ASSERT_EQ(initialMacTableSize, currentL2Entries.size())
12894
<< "MAC table should not learn from malformed packets with no "
@@ -131,7 +97,7 @@ TYPED_TEST(
13197
}
13298

13399
// Final verification that MAC table has not grown
134-
auto finalL2Entries = utility::getL2Table(this->getSw());
100+
auto finalL2Entries = utility::getL2Table(getSw());
135101
auto finalMacTableSize = finalL2Entries.size();
136102
EXPECT_EQ(initialMacTableSize, finalMacTableSize)
137103
<< "MAC table should not learn from malformed packets with no checksum";
@@ -144,7 +110,7 @@ TYPED_TEST(
144110
int64_t finalDropCount = initialDropCount;
145111
for (int i = 0; i < kMaxRetries; ++i) {
146112
std::this_thread::sleep_for(kRetryInterval);
147-
auto finalDropStats = this->getAggregatedSwitchDropStats();
113+
auto finalDropStats = getAggregatedSwitchDropStats();
148114
finalDropCount = finalDropStats.packetIntegrityDrops().has_value()
149115
? *finalDropStats.packetIntegrityDrops()
150116
: 0;
@@ -170,4 +136,5 @@ TYPED_TEST(
170136
<< ", Final drops: " << finalDropCount;
171137
}
172138
}
139+
173140
} // namespace facebook::fboss

0 commit comments

Comments
 (0)