Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <folly/ScopeGuard.h>

#include "fboss/agent/AsicUtils.h"
#include "fboss/agent/FbossError.h"
#include "fboss/agent/SwSwitch.h"
#include "fboss/agent/TxPacket.h"
#include "fboss/agent/packet/PktUtil.h"
#include "fboss/agent/test/TestUtils.h"
Expand Down Expand Up @@ -176,7 +176,20 @@ void AgentMirrorOnDropStatelessTest::validateMirrorOnDropPacket(
EXPECT_EQ(fields.outerDstIp, kCollectorIp_);
EXPECT_EQ(fields.outerSrcPort, static_cast<uint16_t>(kMirrorSrcPort));
EXPECT_EQ(fields.outerDstPort, static_cast<uint16_t>(kMirrorDstPort));
EXPECT_EQ(fields.ingressPort, static_cast<uint16_t>(injectionPortId));
// Some ASICs report the hardware logical port id (not the FBOSS PortID) in
// the MoD packet; translate the injection PortID to match. The mapping comes
// from port stats, which lag a warm boot, so retry until it's populated.
auto expectedIngressPort = static_cast<uint16_t>(injectionPortId);
if (impl()->ingressPortIsHwLogicalPort()) {
std::optional<uint32_t> hwLogicalPortId;
WITH_RETRIES({
hwLogicalPortId = getSw()->getHwLogicalPortId(injectionPortId);
EXPECT_EVENTUALLY_TRUE(hwLogicalPortId.has_value());
});
ASSERT_TRUE(hwLogicalPortId.has_value());
expectedIngressPort = static_cast<uint16_t>(*hwLogicalPortId);
}
EXPECT_EQ(fields.ingressPort, expectedIngressPort);
EXPECT_EQ(fields.dropReasonIngress, expectedReasons.ingressDropReason);
EXPECT_EQ(fields.dropReasonEgress, expectedReasons.egressDropReason);
EXPECT_EQ(fields.innerSrcIp, expectedInnerSrcIp.value_or(kPacketSrcIp_));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>
#include <vector>

#include <folly/IPAddress.h>
#include <folly/IPAddressV6.h>
#include <folly/MacAddress.h>
#include <folly/io/IOBuf.h>

Expand Down Expand Up @@ -80,6 +80,11 @@ class MirrorOnDropImpl {
// (e.g., IPFIX version for XGS).
virtual void verifyInvariants(const folly::IOBuf* buf) const = 0;

// True if the MoD packet's ingress-port field carries the hardware logical
// port id rather than the FBOSS PortID, so the framework translates the
// injection PortID via SwSwitch::getHwLogicalPortId before comparing.
virtual bool ingressPortIsHwLogicalPort() const = 0;

// ASIC-specific raw drop-reason code for each category. The framework
// packs these into the ingress-vs-egress slot expected by the wire format.
virtual uint16_t getDefaultRouteDropReason() const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ void TajoMirrorOnDropImpl::verifyInvariants(const folly::IOBuf* buf) const {
EXPECT_EQ(parsed.puntHeader.reserved2, 0x0000);
}

bool TajoMirrorOnDropImpl::ingressPortIsHwLogicalPort() const {
// The Tajo punt header's ingress-port encoding has not been characterized
// against hardware; keep comparing against the FBOSS PortID as before.
return false;
}

uint16_t TajoMirrorOnDropImpl::getDefaultRouteDropReason() const {
return kTajoDropReasonDefaultRoute;
}
Expand Down
2 changes: 2 additions & 0 deletions fboss/agent/test/agent_hw_tests/AgentMirrorOnDropTajoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class TajoMirrorOnDropImpl : public MirrorOnDropImpl {

void verifyInvariants(const folly::IOBuf* buf) const override;

bool ingressPortIsHwLogicalPort() const override;

uint16_t getDefaultRouteDropReason() const override;
uint16_t getAclDropReason() const override;
uint16_t getMmuDropReason() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ void XgsMirrorOnDropImpl::verifyInvariants(const folly::IOBuf* buf) const {
psamp::XGS_PSAMP_VAR_LEN_INDICATOR);
}

bool XgsMirrorOnDropImpl::ingressPortIsHwLogicalPort() const {
// XGS PSAMP carries the Broadcom hardware logical port id, not the FBOSS
// logical PortID.
return true;
}

uint16_t XgsMirrorOnDropImpl::getDefaultRouteDropReason() const {
return kBcmDropReasonL3DstDiscard;
}
Expand Down
2 changes: 2 additions & 0 deletions fboss/agent/test/agent_hw_tests/AgentMirrorOnDropXgsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class XgsMirrorOnDropImpl : public MirrorOnDropImpl {

void verifyInvariants(const folly::IOBuf* buf) const override;

bool ingressPortIsHwLogicalPort() const override;

uint16_t getDefaultRouteDropReason() const override;
uint16_t getAclDropReason() const override;
uint16_t getMmuDropReason() const override;
Expand Down
Loading