Skip to content

Commit d26368a

Browse files
committed
Fix style
1 parent dbd533c commit d26368a

File tree

3 files changed

+32
-47
lines changed

3 files changed

+32
-47
lines changed

orchagent/acltable.h

+6-8
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ extern "C" {
1515
#define ACL_TABLE_PORTS "PORTS"
1616
#define ACL_TABLE_SERVICES "SERVICES"
1717

18-
#define STAGE_INGRESS "INGRESS"
19-
#define STAGE_EGRESS "EGRESS"
20-
#define STAGE_PRE_INGRESS "PRE_INGRESS"
18+
#define STAGE_INGRESS "INGRESS"
19+
#define STAGE_EGRESS "EGRESS"
20+
#define STAGE_PRE_INGRESS "PRE_INGRESS"
2121

2222
#define TABLE_TYPE_L3 "L3"
2323
#define TABLE_TYPE_L3V6 "L3V6"
@@ -64,14 +64,12 @@ typedef std::unordered_map<std::string, acl_table_type_t> acl_table_type_lookup_
6464
typedef std::map<std::string, sai_acl_stage_t> acl_stage_lookup_t;
6565
typedef std::map<sai_acl_stage_t, sai_switch_attr_t> acl_stage_to_switch_attr_lookup_t;
6666

67-
struct AclTableGroupMember {
67+
struct AclTableGroupMember
68+
{
6869
sai_object_id_t m_group_oid;
6970
sai_object_id_t m_group_member_oid;
7071
uint32_t m_priority;
71-
AclTableGroupMember()
72-
: m_group_oid(SAI_NULL_OBJECT_ID)
73-
, m_group_member_oid(SAI_NULL_OBJECT_ID)
74-
, m_priority(0)
72+
AclTableGroupMember() : m_group_oid(SAI_NULL_OBJECT_ID), m_group_member_oid(SAI_NULL_OBJECT_ID), m_priority(0)
7573
{}
7674
};
7775

orchagent/switchorch.cpp

+21-33
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace swss;
1414

1515
extern sai_object_id_t gSwitchId;
1616
extern sai_switch_api_t *sai_switch_api;
17-
extern sai_acl_api_t* sai_acl_api;
17+
extern sai_acl_api_t *sai_acl_api;
1818
extern MacAddress gVxlanMacAddress;
1919
extern CrmOrch *gCrmOrch;
2020

@@ -64,36 +64,32 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector<TableConnector>& connectors, Tabl
6464
void SwitchOrch::initAclGroupsBindToSwitch()
6565
{
6666
// Create an ACL group per stage, INGRESS, EGRESS and PRE_INGRESS
67-
for (auto stage_it : aclStageLookup) {
67+
for (auto stage_it : aclStageLookup)
68+
{
6869
sai_object_id_t group_oid;
6970
auto status = createAclGroup(fvValue(stage_it), &group_oid);
7071
if (!status.ok())
7172
{
72-
status.prepend("Failed to create ACL group for stage " +
73-
fvField(stage_it) + ": ");
73+
status.prepend("Failed to create ACL group for stage " + fvField(stage_it) + ": ");
7474
SWSS_LOG_THROW("%s", status.message().c_str());
7575
}
76-
SWSS_LOG_NOTICE("Created ACL group for stage %s",
77-
fvField(stage_it).c_str());
76+
SWSS_LOG_NOTICE("Created ACL group for stage %s", fvField(stage_it).c_str());
7877
m_aclGroups[fvValue(stage_it)] = group_oid;
7978
status = bindAclGroupToSwitch(fvValue(stage_it), group_oid);
8079
if (!status.ok())
8180
{
82-
status.prepend("Failed to bind ACL group to stage " +
83-
fvField(stage_it) + ": ");
81+
status.prepend("Failed to bind ACL group to stage " + fvField(stage_it) + ": ");
8482
SWSS_LOG_THROW("%s", status.message().c_str());
8583
}
8684
}
8785
}
8886

89-
const std::map<sai_acl_stage_t, sai_object_id_t>&
90-
SwitchOrch::getAclGroupOidsBindingToSwitch()
87+
const std::map<sai_acl_stage_t, sai_object_id_t> &SwitchOrch::getAclGroupOidsBindingToSwitch()
9188
{
9289
return m_aclGroups;
9390
}
9491

95-
ReturnCode SwitchOrch::createAclGroup(const sai_acl_stage_t& group_stage,
96-
sai_object_id_t* acl_grp_oid)
92+
ReturnCode SwitchOrch::createAclGroup(const sai_acl_stage_t &group_stage, sai_object_id_t *acl_grp_oid)
9793
{
9894
SWSS_LOG_ENTER();
9995

@@ -114,47 +110,39 @@ ReturnCode SwitchOrch::createAclGroup(const sai_acl_stage_t& group_stage,
114110
acl_grp_attr.value.s32list.list = bpoint_list.data();
115111
acl_grp_attrs.push_back(acl_grp_attr);
116112

117-
CHECK_ERROR_AND_LOG_AND_RETURN(
118-
sai_acl_api->create_acl_table_group(acl_grp_oid, gSwitchId,
119-
(uint32_t)acl_grp_attrs.size(),
120-
acl_grp_attrs.data()),
121-
"Failed to create ACL group for stage " << group_stage);
122-
if (group_stage == SAI_ACL_STAGE_INGRESS ||
123-
group_stage == SAI_ACL_STAGE_PRE_INGRESS ||
113+
CHECK_ERROR_AND_LOG_AND_RETURN(sai_acl_api->create_acl_table_group(
114+
acl_grp_oid, gSwitchId, (uint32_t)acl_grp_attrs.size(), acl_grp_attrs.data()),
115+
"Failed to create ACL group for stage " << group_stage);
116+
if (group_stage == SAI_ACL_STAGE_INGRESS || group_stage == SAI_ACL_STAGE_PRE_INGRESS ||
124117
group_stage == SAI_ACL_STAGE_EGRESS)
125118
{
126-
gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP,
127-
(sai_acl_stage_t)group_stage,
128-
SAI_ACL_BIND_POINT_TYPE_SWITCH);
119+
gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, (sai_acl_stage_t)group_stage,
120+
SAI_ACL_BIND_POINT_TYPE_SWITCH);
129121
}
130-
SWSS_LOG_INFO("Suceeded to create ACL group %s in stage %d ",
131-
sai_serialize_object_id(*acl_grp_oid).c_str(), group_stage);
122+
SWSS_LOG_INFO("Suceeded to create ACL group %s in stage %d ", sai_serialize_object_id(*acl_grp_oid).c_str(),
123+
group_stage);
132124
return ReturnCode();
133125
}
134126

135-
ReturnCode SwitchOrch::bindAclGroupToSwitch(
136-
const sai_acl_stage_t& group_stage, const sai_object_id_t& acl_grp_oid)
127+
ReturnCode SwitchOrch::bindAclGroupToSwitch(const sai_acl_stage_t &group_stage, const sai_object_id_t &acl_grp_oid)
137128
{
138129
SWSS_LOG_ENTER();
139130

140131
auto switch_attr_it = aclStageToSwitchAttrLookup.find(group_stage);
141132
if (switch_attr_it == aclStageToSwitchAttrLookup.end())
142133
{
143134
LOG_ERROR_AND_RETURN(ReturnCode(StatusCode::SWSS_RC_INVALID_PARAM)
144-
<< "Failed to set ACL group(" << acl_grp_oid
145-
<< ") to the SWITCH bind point at stage "
146-
<< group_stage);
135+
<< "Failed to set ACL group(" << acl_grp_oid << ") to the SWITCH bind point at stage "
136+
<< group_stage);
147137
}
148138
sai_attribute_t attr;
149139
attr.id = switch_attr_it->second;
150140
attr.value.oid = acl_grp_oid;
151141
auto sai_status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
152142
if (sai_status != SAI_STATUS_SUCCESS)
153143
{
154-
LOG_ERROR_AND_RETURN(
155-
ReturnCode(sai_status)
156-
<< "[SAI] Failed to set_switch_attribute with attribute.id=" << attr.id
157-
<< " and acl group oid=" << acl_grp_oid);
144+
LOG_ERROR_AND_RETURN(ReturnCode(sai_status) << "[SAI] Failed to set_switch_attribute with attribute.id="
145+
<< attr.id << " and acl group oid=" << acl_grp_oid);
158146
}
159147
return ReturnCode();
160148
}

orchagent/switchorch.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

3+
#include "acltable.h"
34
#include "orch.h"
45
#include "timer.h"
5-
#include "acltable.h"
66

77
#define DEFAULT_ASIC_SENSORS_POLLER_INTERVAL 60
88
#define ASIC_SENSORS_POLLER_STATUS "ASIC_SENSORS_POLLER_STATUS"
@@ -32,9 +32,10 @@ class SwitchOrch : public Orch
3232

3333
// Return reference to ACL group created for each stage and the bind point is
3434
// the switch
35-
const std::map<sai_acl_stage_t, sai_object_id_t>& getAclGroupOidsBindingToSwitch();
35+
const std::map<sai_acl_stage_t, sai_object_id_t> &getAclGroupOidsBindingToSwitch();
3636
// Initialize the ACL groups bind to Switch
3737
void initAclGroupsBindToSwitch();
38+
3839
private:
3940
void doTask(Consumer &consumer);
4041
void doTask(swss::SelectableTimer &timer);
@@ -47,13 +48,11 @@ class SwitchOrch : public Orch
4748
// Create the default ACL group for the given stage, bind point is
4849
// SAI_ACL_BIND_POINT_TYPE_SWITCH and group type is
4950
// SAI_ACL_TABLE_GROUP_TYPE_PARALLEL.
50-
ReturnCode createAclGroup(const sai_acl_stage_t& group_stage,
51-
sai_object_id_t* acl_grp_oid);
51+
ReturnCode createAclGroup(const sai_acl_stage_t &group_stage, sai_object_id_t *acl_grp_oid);
5252

5353
// Bind the ACL group to switch for the given stage.
5454
// Set the SAI_SWITCH_ATTR_{STAGE}_ACL with the group oid.
55-
ReturnCode bindAclGroupToSwitch(const sai_acl_stage_t& group_stage,
56-
const sai_object_id_t& acl_grp_oid);
55+
ReturnCode bindAclGroupToSwitch(const sai_acl_stage_t &group_stage, const sai_object_id_t &acl_grp_oid);
5756

5857
swss::NotificationConsumer* m_restartCheckNotificationConsumer;
5958
void doTask(swss::NotificationConsumer& consumer);

0 commit comments

Comments
 (0)