Skip to content

Commit

Permalink
fix AgentCoppTest/0.CpuPortIpv6LinkLocalUcastIp on J3
Browse files Browse the repository at this point in the history
Summary: DNX does not support L2 features. So, need to create L3 ecmp loop in test CpuPortIpv6LinkLocalUcastIp and verified packets sent without pipeline lookup would goes through all step 1-4 explained in the comments.

Differential Revision: D61310596

fbshipit-source-id: 4b1a35f84f14cd5214d3f9ce28b69bd360803228
  • Loading branch information
daiwei1983 authored and facebook-github-bot committed Aug 16, 2024
1 parent 5f28378 commit 243569f
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions fboss/agent/test/agent_hw_tests/AgentCoppTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ class AgentCoppTest : public AgentHwTest {
void sendPkt(
std::unique_ptr<TxPacket> pkt,
bool outOfPort,
bool snoopAndVerify = false) {
bool snoopAndVerify = false,
bool skipTtlDecrement = true) {
XLOG(DBG2) << "Packet Dump::"
<< folly::hexDump(pkt->buf()->data(), pkt->buf()->length());

auto ethFrame = utility::makeEthFrame(*pkt, true /*skipTtlDecrement*/);
auto ethFrame = utility::makeEthFrame(*pkt, skipTtlDecrement);
utility::SwSwitchPacketSnooper snooper(
getSw(), "snoop", std::nullopt, ethFrame);
if (outOfPort) {
Expand All @@ -236,7 +237,8 @@ class AgentCoppTest : public AgentHwTest {
uint8_t trafficClass = 0,
std::optional<std::vector<uint8_t>> payload = std::nullopt,
bool expectQueueHit = true,
bool outOfPort = true) {
bool outOfPort = true,
bool skipTtlDecrement = true) {
const auto kNumPktsToSend = 1;
auto vlanId = utility::firstVlanID(getProgrammedState());
auto destinationMac =
Expand All @@ -251,7 +253,11 @@ class AgentCoppTest : public AgentHwTest {
l4DstPort,
trafficClass,
payload);
sendPkt(std::move(pkt), outOfPort, expectQueueHit /*snoopAndVerify*/);
sendPkt(
std::move(pkt),
outOfPort,
expectQueueHit /*snoopAndVerify*/,
skipTtlDecrement);
};
utility::sendPktAndVerifyCpuQueue(
getSw(),
Expand Down Expand Up @@ -381,13 +387,18 @@ class AgentCoppTest : public AgentHwTest {
EXPECT_EQ(1, afterOutPkts - beforeOutPkts);
}

void setupEcmp() {
void setupEcmp(bool useInterfaceMac = false) {
if constexpr (!isTrunk) {
utility::EcmpSetupAnyNPorts6 ecmpHelper(
getProgrammedState(), getLocalMacAddress());
getProgrammedState(),
useInterfaceMac ? utility::getFirstInterfaceMac(getProgrammedState())
: getLocalMacAddress());
resolveNeigborAndProgramRoutes(ecmpHelper, 1);
} else {
utility::EcmpSetupTargetedPorts6 ecmpHelper(getProgrammedState());
utility::EcmpSetupTargetedPorts6 ecmpHelper(
getProgrammedState(),
useInterfaceMac ? utility::getFirstInterfaceMac(getProgrammedState())
: getLocalMacAddress());
flat_set<PortDescriptor> ports;
ports.insert(PortDescriptor(AggregatePortID(1)));
applyNewState(
Expand Down Expand Up @@ -959,22 +970,39 @@ TYPED_TEST(AgentCoppTest, Ipv6LinkLocalUcastIpNetworkControlDscpToHighPriQ) {
* packets. This gets forwarded to cpu queue 9
*/
TYPED_TEST(AgentCoppTest, CpuPortIpv6LinkLocalUcastIp) {
auto setup = [=, this]() { this->setup(); };
auto setup = [=, this]() {
this->setup();
if (!this->isSupportedOnAllAsics(HwAsic::Feature::BRIDGE_PORT_8021Q)) {
// no l2 bridging, need to create L3 loop on DNX
this->setupEcmp(true);
}
};

auto verify = [=, this]() {
std::optional<folly::MacAddress> dstMac;
bool skipTtlDecrement;
if (this->isSupportedOnAllAsics(HwAsic::Feature::BRIDGE_PORT_8021Q)) {
// use random mac, packets would be flooded and loopback
dstMac = folly::MacAddress("00:00:00:00:00:01");
skipTtlDecrement = true;
} else {
// use interface mac, otherwise would be dropped on dnx
dstMac = utility::getFirstInterfaceMac(this->getProgrammedState());
skipTtlDecrement = false;
}
auto nbrLinkLocalAddr = folly::IPAddressV6("fe80:face:b11c::1");
auto randomMac = folly::MacAddress("00:00:00:00:00:01");
this->sendTcpPktAndVerifyCpuQueue(
utility::getCoppHighPriQueueId(utility::checkSameAndGetAsic(
this->getAgentEnsemble()->getL3Asics())),
nbrLinkLocalAddr,
utility::kNonSpecialPort1,
utility::kNonSpecialPort2,
randomMac,
dstMac,
kNetworkControlDscp,
std::nullopt,
true,
false /*outOfPort*/);
false /*outOfPort*/,
skipTtlDecrement);
};

this->verifyAcrossWarmBoots(setup, verify);
Expand Down

0 comments on commit 243569f

Please sign in to comment.