Skip to content

Commit

Permalink
Add addTrapPacketAcl utility for mac address
Browse files Browse the repository at this point in the history
Summary: Add addTrapPacketAcl utility targeting a mac address.

Reviewed By: nivinl

Differential Revision: D66568766

fbshipit-source-id: e610ce105d6382e3c33fa136661f899002a46ccb
  • Loading branch information
maxwindiff authored and facebook-github-bot committed Dec 3, 2024
1 parent 397481b commit 80b893d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fboss/agent/test/utils/TrapPacketUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,26 @@ void addTrapPacketAcl(
config->cpuTrafficPolicy() = cpuTrafficPolicy;
}

void addTrapPacketAcl(cfg::SwitchConfig* config, folly::MacAddress mac) {
cfg::AclEntry entry;
entry.name() = folly::to<std::string>("trap-packet-", mac.toString());
entry.dstMac() = mac.toString();
entry.actionType() = cfg::AclActionType::PERMIT;
utility::addAclEntry(config, entry, utility::kDefaultAclTable());

cfg::MatchToAction matchToAction;
matchToAction.matcher() = *entry.name();
cfg::MatchAction& action = matchToAction.action().ensure();
action.toCpuAction() = cfg::ToCpuAction::TRAP;
action.sendToQueue().ensure().queueId() = 0;
action.setTc().ensure().tcValue() = 0;
config->cpuTrafficPolicy()
.ensure()
.trafficPolicy()
.ensure()
.matchToAction()
.ensure()
.push_back(matchToAction);
}

} // namespace facebook::fboss::utility
2 changes: 2 additions & 0 deletions fboss/agent/test/utils/TrapPacketUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "fboss/agent/types.h"

#include <folly/IPAddress.h>
#include <folly/MacAddress.h>

#include <set>

Expand All @@ -32,5 +33,6 @@ void addTrapPacketAcl(
const HwAsic* asic,
cfg::SwitchConfig* config,
uint16_t l4DstPort);
void addTrapPacketAcl(cfg::SwitchConfig* config, folly::MacAddress mac);

} // namespace facebook::fboss::utility

0 comments on commit 80b893d

Please sign in to comment.