Skip to content

Commit

Permalink
remove greProtocol from MirrorTunnel
Browse files Browse the repository at this point in the history
Summary:
as titled

this attribute is not required and can be determined based on ASIC in HwSwitch

Reviewed By: srikrishnagopu

Differential Revision:
D67212949

Privacy Context Container: L1125642

fbshipit-source-id: 32c81c11c56a5dc8a2f22034c5ad3fcd80475471
  • Loading branch information
Parvez Shaikh authored and facebook-github-bot committed Dec 16, 2024
1 parent ed3124b commit 3066d96
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
3 changes: 2 additions & 1 deletion fboss/agent/hw/bcm/BcmMirror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ int getMirrorFlags(const std::optional<facebook::fboss::MirrorTunnel>& tunnel) {
}
return BCM_MIRROR_DEST_TUNNEL_IP_GRE;
}
const uint16_t kGreProtocol = 0x88be;
} // namespace
namespace facebook::fboss {

Expand Down Expand Up @@ -70,7 +71,7 @@ BcmMirrorDestination::BcmMirrorDestination(
<< "/" << mirrorTunnel.dstMac << ")";

} else {
mirror_destination.gre_protocol = mirrorTunnel.greProtocol;
mirror_destination.gre_protocol = kGreProtocol;
mirror_destination.flags = BCM_MIRROR_DEST_TUNNEL_IP_GRE;
XLOG(DBG2) << "ERSPAN(I) tunnel: source(" << mirrorTunnel.srcIp << "/"
<< mirrorTunnel.srcMac << "), destination(" << mirrorTunnel.dstIp
Expand Down
3 changes: 1 addition & 2 deletions fboss/agent/hw/bcm/BcmWarmBootCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,8 +1427,7 @@ void BcmWarmBootCache::programmedMirror(MirrorEgressPath2HandleCitr itr) {
const auto& tunnel = key.second;
if (tunnel) {
XLOG(DBG1) << "Programmed ERSPAN mirror egressing through: " << port
<< " with " << "proto=" << tunnel->greProtocol
<< "source ip=" << tunnel->srcIp.str()
<< " with " << "source ip=" << tunnel->srcIp.str()
<< "source mac=" << tunnel->srcMac.toString()
<< "destination ip=" << tunnel->dstIp.str()
<< "destination mac=" << tunnel->dstMac.toString()
Expand Down
4 changes: 3 additions & 1 deletion fboss/agent/hw/bcm/tests/HwTestMirrorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ void verifyResolvedMirror(
EXPECT_EQ(udpPorts.value().udpDstPort, mirror_dest.udp_dst_port);
EXPECT_NE(0, mirror_dest.flags & BCM_MIRROR_DEST_TUNNEL_SFLOW);
} else {
EXPECT_EQ(tunnel->greProtocol, mirror_dest.gre_protocol);
EXPECT_EQ(
hwSwitch->getPlatform()->getAsic()->getGreProtocol(),
mirror_dest.gre_protocol);
EXPECT_NE(0, mirror_dest.flags & BCM_MIRROR_DEST_TUNNEL_IP_GRE);
}
if (mirror->getDestinationIp()->isV4()) {
Expand Down
3 changes: 2 additions & 1 deletion fboss/agent/hw/sai/switch/SaiMirrorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SaiMirrorHandle::SaiMirror SaiMirrorManager::addNodeErSpan(
auto headerVersion = mirrorTunnel.srcIp.isV4() ? 4 : 6;
auto truncateSize =
mirror->getTruncate() ? platform_->getAsic()->getMirrorTruncateSize() : 0;
auto greProtocol = platform_->getAsic()->getGreProtocol();
std::optional<SaiEnhancedRemoteMirrorTraits::Attributes::TcBufferLimit>
tcBufferLimit;
#if defined(BRCM_SAI_SDK_DNX_GTE_11_0)
Expand All @@ -61,7 +62,7 @@ SaiMirrorHandle::SaiMirror SaiMirrorManager::addNodeErSpan(
mirrorTunnel.dstIp,
mirrorTunnel.srcMac,
mirrorTunnel.dstMac,
mirrorTunnel.greProtocol,
greProtocol,
headerVersion,
mirrorTunnel.ttl,
truncateSize,
Expand Down
16 changes: 5 additions & 11 deletions fboss/agent/state/Mirror.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ struct MirrorTunnel {
folly::MacAddress srcMac, dstMac;
std::optional<TunnelUdpPorts> udpPorts;
uint8_t ttl;
uint16_t greProtocol;
static constexpr auto kTTL = 127;
static constexpr auto kGreProto = 0x88be;

MirrorTunnel(
const folly::IPAddress& srcIp,
Expand All @@ -59,8 +57,7 @@ struct MirrorTunnel {
srcMac(srcMac),
dstMac(dstMac),
udpPorts(std::nullopt),
ttl(ttl),
greProtocol(kGreProto) {}
ttl(ttl) {}

MirrorTunnel(
const folly::IPAddress& srcIp,
Expand All @@ -74,25 +71,22 @@ struct MirrorTunnel {
srcMac(srcMac),
dstMac(dstMac),
udpPorts(sflowPorts),
ttl(ttl),
greProtocol(0) {}
ttl(ttl) {}

bool operator==(const MirrorTunnel& rhs) const {
return srcIp == rhs.srcIp && dstIp == rhs.dstIp && srcMac == rhs.srcMac &&
dstMac == rhs.dstMac && udpPorts == rhs.udpPorts && ttl == rhs.ttl &&
greProtocol == rhs.greProtocol;
dstMac == rhs.dstMac && udpPorts == rhs.udpPorts && ttl == rhs.ttl;
}

bool operator<(const MirrorTunnel& rhs) const {
return std::tie(srcIp, dstIp, srcMac, dstMac, udpPorts, ttl, greProtocol) <
return std::tie(srcIp, dstIp, srcMac, dstMac, udpPorts, ttl) <
std::tie(
rhs.srcIp,
rhs.dstIp,
rhs.srcMac,
rhs.dstMac,
rhs.udpPorts,
rhs.ttl,
rhs.greProtocol);
rhs.ttl);
}

state::MirrorTunnel toThrift() const {
Expand Down

0 comments on commit 3066d96

Please sign in to comment.