Skip to content

Commit

Permalink
Fix macro conflict with glibc-2.40+ headers
Browse files Browse the repository at this point in the history
Summary:
Newer versions of glibc define a `IP_PROTOCOL` macro in the inet headers
which leads to conflicts with this enum.  As there's not really a great way to
prevent this conflict from the glibc side, this just renames the variants in our
thrift struct.

```
buck-out/v2/gen/fbcode/2539d56e20c7e2e1/fboss/agent/__switch_config-cpp2-types__/buck-headers/fboss/agent/gen-cpp2/switch_config_types.h:2673:3: error: expected identifier
 2673 |   IP_PROTOCOL = 6,
      |   ^
fbcode/third-party-buck/platform010-aarch64/build/glibc/include/bits/in.h:132:23: note: expanded from macro 'IP_PROTOCOL'
  132 | #define IP_PROTOCOL                     52
      |                                         ^
1 error generated.
```

Reviewed By: jasmeetbagga

Differential Revision: D67050587

fbshipit-source-id: a4bdf7369d173f0a4c5f7d3e0c55bc15faeaec9c
  • Loading branch information
andrewjcg authored and facebook-github-bot committed Dec 11, 2024
1 parent e59b7bf commit 5fa5e43
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion fboss/agent/hw/sai/hw_test/SaiAclTableGroupTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class SaiAclTableGroupTest : public HwTest {
std::vector<cfg::AclTableQualifier> qualifiers = {
cfg::AclTableQualifier::L4_SRC_PORT,
cfg::AclTableQualifier::L4_DST_PORT,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::ICMPV4_TYPE,
cfg::AclTableQualifier::ICMPV4_CODE,
cfg::AclTableQualifier::ICMPV6_TYPE,
Expand Down
14 changes: 7 additions & 7 deletions fboss/agent/hw/sai/switch/SaiAclTableManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ AclEntrySaiId SaiAclTableManager::addAclEntry(
auto stage = static_cast<sai_acl_stage_t>(
GET_ATTR(AclTable, Stage, aclTableHandle->aclTable->attributes()));
auto qualifierSet = getSupportedQualifierSet(stage);
if (qualifierSet.find(cfg::AclTableQualifier::IP_PROTOCOL) !=
if (qualifierSet.find(cfg::AclTableQualifier::IP_PROTOCOL_NUMBER) !=
qualifierSet.end() &&
matchV4 && addedAclEntry->getProto()) {
fieldIpProtocol = SaiAclEntryTraits::Attributes::FieldIpProtocol{
Expand Down Expand Up @@ -1585,7 +1585,7 @@ std::set<cfg::AclTableQualifier> SaiAclTableManager::getSupportedQualifierSet(
cfg::AclTableQualifier::DST_IPV6,
cfg::AclTableQualifier::SRC_IPV4,
cfg::AclTableQualifier::DST_IPV4,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::DSCP,
cfg::AclTableQualifier::IP_TYPE,
cfg::AclTableQualifier::TTL,
Expand Down Expand Up @@ -1621,7 +1621,7 @@ std::set<cfg::AclTableQualifier> SaiAclTableManager::getSupportedQualifierSet(
cfg::AclTableQualifier::DST_IPV6,
cfg::AclTableQualifier::SRC_PORT,
cfg::AclTableQualifier::DSCP,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::IP_TYPE,
cfg::AclTableQualifier::TTL,
};
Expand All @@ -1636,7 +1636,7 @@ std::set<cfg::AclTableQualifier> SaiAclTableManager::getSupportedQualifierSet(
cfg::AclTableQualifier::SRC_PORT,
cfg::AclTableQualifier::DSCP,
cfg::AclTableQualifier::TTL,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::IPV6_NEXT_HEADER,
cfg::AclTableQualifier::IP_TYPE,
cfg::AclTableQualifier::LOOKUP_CLASS_NEIGHBOR,
Expand All @@ -1660,7 +1660,7 @@ std::set<cfg::AclTableQualifier> SaiAclTableManager::getSupportedQualifierSet(
cfg::AclTableQualifier::DST_IPV4,
cfg::AclTableQualifier::L4_SRC_PORT,
cfg::AclTableQualifier::L4_DST_PORT,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::SRC_PORT,
cfg::AclTableQualifier::DSCP,
cfg::AclTableQualifier::TTL,
Expand All @@ -1682,7 +1682,7 @@ std::set<cfg::AclTableQualifier> SaiAclTableManager::getSupportedQualifierSet(
cfg::AclTableQualifier::DST_IPV4,
cfg::AclTableQualifier::L4_SRC_PORT,
cfg::AclTableQualifier::L4_DST_PORT,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::TCP_FLAGS,
cfg::AclTableQualifier::SRC_PORT,
cfg::AclTableQualifier::OUT_PORT,
Expand Down Expand Up @@ -1794,7 +1794,7 @@ bool SaiAclTableManager::isQualifierSupported(
std::get<
std::optional<SaiAclTableTraits::Attributes::FieldL4DstPort>>(
attributes));
case cfg::AclTableQualifier::IP_PROTOCOL:
case cfg::AclTableQualifier::IP_PROTOCOL_NUMBER:
return hasField(
std::get<
std::optional<SaiAclTableTraits::Attributes::FieldIpProtocol>>(
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/hw/sai/switch/npu/SaiAclTableManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ std::
qualifierExistsFn(cfg::AclTableQualifier::DST_IPV4),
qualifierExistsFn(cfg::AclTableQualifier::L4_SRC_PORT),
qualifierExistsFn(cfg::AclTableQualifier::L4_DST_PORT),
qualifierExistsFn(cfg::AclTableQualifier::IP_PROTOCOL),
qualifierExistsFn(cfg::AclTableQualifier::IP_PROTOCOL_NUMBER),
qualifierExistsFn(cfg::AclTableQualifier::TCP_FLAGS),
qualifierExistsFn(cfg::AclTableQualifier::SRC_PORT),
qualifierExistsFn(cfg::AclTableQualifier::OUT_PORT),
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/state/AclEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::set<cfg::AclTableQualifier> AclEntry::getRequiredAclTableQualifiers()
cfg::AclTableQualifier::DST_IPV6);

if (getProto()) {
qualifiers.insert(cfg::AclTableQualifier::IP_PROTOCOL);
qualifiers.insert(cfg::AclTableQualifier::IP_PROTOCOL_NUMBER);
}
if (getTcpFlagsBitMap()) {
qualifiers.insert(cfg::AclTableQualifier::TCP_FLAGS);
Expand Down
4 changes: 2 additions & 2 deletions fboss/agent/state/tests/AclTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ TEST(Acl, GetRequiredAclTableQualifiers) {
std::set<cfg::AclTableQualifier> qualifiers0{
cfg::AclTableQualifier::SRC_IPV4,
cfg::AclTableQualifier::DST_IPV4,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::TCP_FLAGS,
cfg::AclTableQualifier::IP_FRAG,
cfg::AclTableQualifier::DSCP,
Expand All @@ -1280,7 +1280,7 @@ TEST(Acl, GetRequiredAclTableQualifiers) {
std::set<cfg::AclTableQualifier> qualifiers1{
cfg::AclTableQualifier::SRC_IPV6,
cfg::AclTableQualifier::DST_IPV6,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::TCP_FLAGS,
cfg::AclTableQualifier::IP_FRAG,
cfg::AclTableQualifier::DSCP,
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/switch_config.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ enum AclTableQualifier {
DST_IPV4 = 3,
L4_SRC_PORT = 4,
L4_DST_PORT = 5,
IP_PROTOCOL = 6,
IP_PROTOCOL_NUMBER = 6,
TCP_FLAGS = 7,
SRC_PORT = 8,
OUT_PORT = 9,
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/test/utils/AclTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::vector<cfg::AclTableQualifier> genAclQualifiersConfig(
cfg::AclTableQualifier::DST_IPV4,
cfg::AclTableQualifier::L4_SRC_PORT,
cfg::AclTableQualifier::L4_DST_PORT,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::DSCP,
cfg::AclTableQualifier::TTL,
cfg::AclTableQualifier::ICMPV4_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/test/utils/DscpMarkingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void addDscpAclTable(
std::vector<cfg::AclTableQualifier> qualifiers = {
cfg::AclTableQualifier::L4_SRC_PORT,
cfg::AclTableQualifier::L4_DST_PORT,
cfg::AclTableQualifier::IP_PROTOCOL,
cfg::AclTableQualifier::IP_PROTOCOL_NUMBER,
cfg::AclTableQualifier::ICMPV4_TYPE,
cfg::AclTableQualifier::ICMPV4_CODE,
cfg::AclTableQualifier::ICMPV6_TYPE,
Expand Down

0 comments on commit 5fa5e43

Please sign in to comment.