From 243569f67566b4b979e4de9f3485bc5840f80b9a Mon Sep 17 00:00:00 2001 From: Wei Dai Date: Thu, 15 Aug 2024 18:01:31 -0700 Subject: [PATCH] fix AgentCoppTest/0.CpuPortIpv6LinkLocalUcastIp on J3 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 --- .../test/agent_hw_tests/AgentCoppTests.cpp | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/fboss/agent/test/agent_hw_tests/AgentCoppTests.cpp b/fboss/agent/test/agent_hw_tests/AgentCoppTests.cpp index e50b4b29470e9..3694e90b265b3 100644 --- a/fboss/agent/test/agent_hw_tests/AgentCoppTests.cpp +++ b/fboss/agent/test/agent_hw_tests/AgentCoppTests.cpp @@ -205,11 +205,12 @@ class AgentCoppTest : public AgentHwTest { void sendPkt( std::unique_ptr 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) { @@ -236,7 +237,8 @@ class AgentCoppTest : public AgentHwTest { uint8_t trafficClass = 0, std::optional> 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 = @@ -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(), @@ -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 ports; ports.insert(PortDescriptor(AggregatePortID(1))); applyNewState( @@ -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 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);