diff --git a/fboss/agent/hw/bcm/BcmMirror.cpp b/fboss/agent/hw/bcm/BcmMirror.cpp index 6921de25f3b0c..ddb6e99216a7f 100644 --- a/fboss/agent/hw/bcm/BcmMirror.cpp +++ b/fboss/agent/hw/bcm/BcmMirror.cpp @@ -27,6 +27,7 @@ int getMirrorFlags(const std::optional& tunnel) { } return BCM_MIRROR_DEST_TUNNEL_IP_GRE; } +const uint16_t kGreProtocol = 0x88be; } // namespace namespace facebook::fboss { @@ -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 diff --git a/fboss/agent/hw/bcm/BcmWarmBootCache.cpp b/fboss/agent/hw/bcm/BcmWarmBootCache.cpp index b53b36a8e4180..07a3426a66657 100644 --- a/fboss/agent/hw/bcm/BcmWarmBootCache.cpp +++ b/fboss/agent/hw/bcm/BcmWarmBootCache.cpp @@ -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() diff --git a/fboss/agent/hw/bcm/tests/HwTestMirrorUtils.cpp b/fboss/agent/hw/bcm/tests/HwTestMirrorUtils.cpp index 9da65f5b8655f..3047611fc358e 100644 --- a/fboss/agent/hw/bcm/tests/HwTestMirrorUtils.cpp +++ b/fboss/agent/hw/bcm/tests/HwTestMirrorUtils.cpp @@ -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()) { diff --git a/fboss/agent/hw/sai/switch/SaiMirrorManager.cpp b/fboss/agent/hw/sai/switch/SaiMirrorManager.cpp index e0d343421886d..ab68b9341d3ed 100644 --- a/fboss/agent/hw/sai/switch/SaiMirrorManager.cpp +++ b/fboss/agent/hw/sai/switch/SaiMirrorManager.cpp @@ -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 tcBufferLimit; #if defined(BRCM_SAI_SDK_DNX_GTE_11_0) @@ -61,7 +62,7 @@ SaiMirrorHandle::SaiMirror SaiMirrorManager::addNodeErSpan( mirrorTunnel.dstIp, mirrorTunnel.srcMac, mirrorTunnel.dstMac, - mirrorTunnel.greProtocol, + greProtocol, headerVersion, mirrorTunnel.ttl, truncateSize, diff --git a/fboss/agent/state/Mirror.h b/fboss/agent/state/Mirror.h index 6eb6fd1b5886b..1860db050a33f 100644 --- a/fboss/agent/state/Mirror.h +++ b/fboss/agent/state/Mirror.h @@ -44,9 +44,7 @@ struct MirrorTunnel { folly::MacAddress srcMac, dstMac; std::optional udpPorts; uint8_t ttl; - uint16_t greProtocol; static constexpr auto kTTL = 127; - static constexpr auto kGreProto = 0x88be; MirrorTunnel( const folly::IPAddress& srcIp, @@ -59,8 +57,7 @@ struct MirrorTunnel { srcMac(srcMac), dstMac(dstMac), udpPorts(std::nullopt), - ttl(ttl), - greProtocol(kGreProto) {} + ttl(ttl) {} MirrorTunnel( const folly::IPAddress& srcIp, @@ -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 {