Skip to content

Commit ed91cfc

Browse files
authored
Merge branch 'master' into p4orch_1
2 parents c37d02e + 2c8a65f commit ed91cfc

23 files changed

+1267
-46
lines changed

lib/orch_zmq_config.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <iostream>
2+
#include <fstream>
3+
4+
#include "orch_zmq_config.h"
5+
6+
#define ZMQ_TABLE_CONFIGFILE "/etc/swss/orch_zmq_tables.conf"
7+
8+
std::set<std::string> swss::load_zmq_tables()
9+
{
10+
std::set<std::string> tables;
11+
std::ifstream config_file(ZMQ_TABLE_CONFIGFILE);
12+
if (config_file.is_open())
13+
{
14+
std::string table;
15+
while (std::getline(config_file, table))
16+
{
17+
tables.emplace(table);
18+
}
19+
config_file.close();
20+
}
21+
22+
return tables;
23+
}
24+
25+
26+
std::shared_ptr<swss::ZmqClient> swss::create_zmq_client(std::string zmq_address)
27+
{
28+
// swssconfig running inside swss contianer, so need get ZMQ port according to namespace ID.
29+
auto zmq_port = ORCH_ZMQ_PORT;
30+
if (const char* nsid = std::getenv("NAMESPACE_ID"))
31+
{
32+
// namespace start from 0, using original ZMQ port for global namespace
33+
zmq_port += atoi(nsid) + 1;
34+
}
35+
36+
return std::make_shared<ZmqClient>(zmq_address + ":" + std::to_string(zmq_port));
37+
}

lib/orch_zmq_config.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef SWSS_ORCH_ZMQ_CONFIG_H
2+
#define SWSS_ORCH_ZMQ_CONFIG_H
3+
4+
#include <string.h>
5+
#include <set>
6+
7+
#include "dbconnector.h"
8+
#include "zmqclient.h"
9+
10+
/*
11+
* swssconfig will only connect to local orchagent ZMQ endpoint.
12+
*/
13+
#define ZMQ_LOCAL_ADDRESS "tcp://localhost"
14+
15+
namespace swss {
16+
17+
std::set<std::string> load_zmq_tables();
18+
19+
std::shared_ptr<ZmqClient> create_zmq_client(std::string zmq_address);
20+
21+
}
22+
23+
#endif /* SWSS_ORCH_ZMQ_CONFIG_H */

orchagent/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ orchagent_SOURCES = \
114114
dash/dashvnetorch.cpp \
115115
dash/dashaclorch.cpp \
116116
dash/dashaclgroupmgr.cpp \
117+
dash/dashmeterorch.cpp \
117118
dash/dashtagmgr.cpp \
118119
dash/dashtunnelorch.cpp \
119120
dash/pbutils.cpp \

orchagent/bulker.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,18 @@ struct SaiBulkerTraits<sai_neighbor_api_t>
382382
using bulk_set_entry_attribute_fn = sai_bulk_set_neighbor_entry_attribute_fn;
383383
};
384384

385+
template<>
386+
struct SaiBulkerTraits<sai_dash_meter_api_t>
387+
{
388+
using entry_t = sai_object_id_t;
389+
using api_t = sai_dash_meter_api_t;
390+
using create_entry_fn = sai_create_meter_rule_fn;
391+
using remove_entry_fn = sai_remove_meter_rule_fn;
392+
using set_entry_attribute_fn = sai_set_meter_rule_attribute_fn;
393+
using bulk_create_entry_fn = sai_bulk_object_create_fn;
394+
using bulk_remove_entry_fn = sai_bulk_object_remove_fn;
395+
};
396+
385397
template<>
386398
struct SaiBulkerTraits<sai_dash_vnet_api_t>
387399
{
@@ -1274,6 +1286,15 @@ inline ObjectBulker<sai_dash_vnet_api_t>::ObjectBulker(SaiBulkerTraits<sai_dash_
12741286
remove_entries = api->remove_vnets;
12751287
}
12761288

1289+
template <>
1290+
inline ObjectBulker<sai_dash_meter_api_t>::ObjectBulker(SaiBulkerTraits<sai_dash_meter_api_t>::api_t *api, sai_object_id_t switch_id, size_t max_bulk_size) :
1291+
switch_id(switch_id),
1292+
max_bulk_size(max_bulk_size)
1293+
{
1294+
create_entries = api->create_meter_rules;
1295+
remove_entries = api->remove_meter_rules;
1296+
}
1297+
12771298
template <>
12781299
inline ObjectBulker<sai_dash_tunnel_api_t>::ObjectBulker(SaiBulkerTraits<sai_dash_tunnel_api_t>::api_t *api, sai_object_id_t switch_id, size_t max_bulk_size, sai_object_type_extensions_t object_type) :
12791300
switch_id(switch_id),

orchagent/crmorch.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ const map<CrmResourceType, string> crmResTypeNameMap =
6464
{ CrmResourceType::CRM_DASH_IPV6_ACL_GROUP, "DASH_IPV6_ACL_GROUP" },
6565
{ CrmResourceType::CRM_DASH_IPV4_ACL_RULE, "DASH_IPV4_ACL_RULE" },
6666
{ CrmResourceType::CRM_DASH_IPV6_ACL_RULE, "DASH_IPV6_ACL_RULE" },
67+
{ CrmResourceType::CRM_DASH_IPV4_METER_POLICY, "DASH_IPV4_METER_POLICY" },
68+
{ CrmResourceType::CRM_DASH_IPV4_METER_RULE, "DASH_IPV4_METER_RULE" },
69+
{ CrmResourceType::CRM_DASH_IPV6_METER_POLICY, "DASH_IPV6_METER_POLICY" },
70+
{ CrmResourceType::CRM_DASH_IPV6_METER_RULE, "DASH_IPV6_METER_RULE" },
6771
{ CrmResourceType::CRM_TWAMP_ENTRY, "TWAMP_ENTRY" }
6872
};
6973

@@ -127,6 +131,10 @@ const map<CrmResourceType, sai_object_type_t> crmResSaiObjAttrMap =
127131
{ CrmResourceType::CRM_DASH_IPV6_ACL_GROUP, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_GROUP },
128132
{ CrmResourceType::CRM_DASH_IPV4_ACL_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE },
129133
{ CrmResourceType::CRM_DASH_IPV6_ACL_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE },
134+
{ CrmResourceType::CRM_DASH_IPV4_METER_POLICY, (sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY },
135+
{ CrmResourceType::CRM_DASH_IPV6_METER_POLICY, (sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY },
136+
{ CrmResourceType::CRM_DASH_IPV4_METER_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_METER_RULE },
137+
{ CrmResourceType::CRM_DASH_IPV6_METER_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_METER_RULE },
130138
{ CrmResourceType::CRM_TWAMP_ENTRY, SAI_OBJECT_TYPE_NULL }
131139
};
132140

@@ -189,6 +197,10 @@ const map<string, CrmResourceType> crmThreshTypeResMap =
189197
{ "dash_ipv6_acl_group_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
190198
{ "dash_ipv4_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
191199
{ "dash_ipv6_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
200+
{ "dash_ipv4_meter_policy_threshold_type", CrmResourceType::CRM_DASH_IPV4_METER_POLICY },
201+
{ "dash_ipv6_meter_policy_threshold_type", CrmResourceType::CRM_DASH_IPV6_METER_POLICY },
202+
{ "dash_ipv4_meter_rule_threshold_type", CrmResourceType::CRM_DASH_IPV4_METER_RULE },
203+
{ "dash_ipv6_meter_rule_threshold_type", CrmResourceType::CRM_DASH_IPV6_METER_RULE },
192204
{ "twamp_entry_threshold_type", CrmResourceType::CRM_TWAMP_ENTRY }
193205
};
194206

@@ -231,6 +243,10 @@ const map<string, CrmResourceType> crmThreshLowResMap =
231243
{ "dash_ipv6_acl_group_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
232244
{ "dash_ipv4_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
233245
{ "dash_ipv6_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
246+
{ "dash_ipv4_meter_policy_low_threshold", CrmResourceType::CRM_DASH_IPV4_METER_POLICY },
247+
{ "dash_ipv6_meter_policy_low_threshold", CrmResourceType::CRM_DASH_IPV6_METER_POLICY },
248+
{ "dash_ipv4_meter_rule_low_threshold", CrmResourceType::CRM_DASH_IPV4_METER_RULE },
249+
{ "dash_ipv6_meter_rule_low_threshold", CrmResourceType::CRM_DASH_IPV6_METER_RULE },
234250
{ "twamp_entry_low_threshold", CrmResourceType::CRM_TWAMP_ENTRY }
235251
};
236252

@@ -273,6 +289,10 @@ const map<string, CrmResourceType> crmThreshHighResMap =
273289
{ "dash_ipv6_acl_group_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
274290
{ "dash_ipv4_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
275291
{ "dash_ipv6_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
292+
{ "dash_ipv4_meter_policy_high_threshold", CrmResourceType::CRM_DASH_IPV4_METER_POLICY },
293+
{ "dash_ipv6_meter_policy_high_threshold", CrmResourceType::CRM_DASH_IPV6_METER_POLICY },
294+
{ "dash_ipv4_meter_rule_high_threshold", CrmResourceType::CRM_DASH_IPV4_METER_RULE },
295+
{ "dash_ipv6_meter_rule_high_threshold", CrmResourceType::CRM_DASH_IPV6_METER_RULE },
276296
{ "twamp_entry_high_threshold", CrmResourceType::CRM_TWAMP_ENTRY }
277297
};
278298

@@ -322,6 +342,10 @@ const map<string, CrmResourceType> crmAvailCntsTableMap =
322342
{ "crm_stats_dash_ipv6_acl_group_available", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
323343
{ "crm_stats_dash_ipv4_acl_rule_available", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
324344
{ "crm_stats_dash_ipv6_acl_rule_available", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
345+
{ "crm_stats_dash_ipv4_meter_policy_available", CrmResourceType::CRM_DASH_IPV4_METER_POLICY },
346+
{ "crm_stats_dash_ipv6_meter_policy_available", CrmResourceType::CRM_DASH_IPV6_METER_POLICY },
347+
{ "crm_stats_dash_ipv4_meter_rule_available", CrmResourceType::CRM_DASH_IPV4_METER_RULE },
348+
{ "crm_stats_dash_ipv6_meter_rule_available", CrmResourceType::CRM_DASH_IPV6_METER_RULE },
325349
{ "crm_stats_twamp_entry_available", CrmResourceType::CRM_TWAMP_ENTRY }
326350
};
327351

@@ -364,6 +388,10 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
364388
{ "crm_stats_dash_ipv6_acl_group_used", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
365389
{ "crm_stats_dash_ipv4_acl_rule_used", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
366390
{ "crm_stats_dash_ipv6_acl_rule_used", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
391+
{ "crm_stats_dash_ipv4_meter_policy_used", CrmResourceType::CRM_DASH_IPV4_METER_POLICY },
392+
{ "crm_stats_dash_ipv6_meter_policy_used", CrmResourceType::CRM_DASH_IPV6_METER_POLICY },
393+
{ "crm_stats_dash_ipv4_meter_rule_used", CrmResourceType::CRM_DASH_IPV4_METER_RULE },
394+
{ "crm_stats_dash_ipv6_meter_rule_used", CrmResourceType::CRM_DASH_IPV6_METER_RULE },
367395
{ "crm_stats_twamp_entry_used", CrmResourceType::CRM_TWAMP_ENTRY },
368396
};
369397

@@ -891,6 +919,10 @@ void CrmOrch::getResAvailableCounters()
891919
case CrmResourceType::CRM_DASH_IPV6_INBOUND_ROUTING:
892920
case CrmResourceType::CRM_DASH_IPV4_OUTBOUND_ROUTING:
893921
case CrmResourceType::CRM_DASH_IPV6_OUTBOUND_ROUTING:
922+
case CrmResourceType::CRM_DASH_IPV4_METER_POLICY:
923+
case CrmResourceType::CRM_DASH_IPV6_METER_POLICY:
924+
case CrmResourceType::CRM_DASH_IPV4_METER_RULE:
925+
case CrmResourceType::CRM_DASH_IPV6_METER_RULE:
894926
case CrmResourceType::CRM_DASH_IPV4_PA_VALIDATION:
895927
case CrmResourceType::CRM_DASH_IPV6_PA_VALIDATION:
896928
case CrmResourceType::CRM_DASH_IPV4_OUTBOUND_CA_TO_PA:

orchagent/crmorch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ enum class CrmResourceType
5050
CRM_DASH_IPV6_ACL_GROUP,
5151
CRM_DASH_IPV4_ACL_RULE,
5252
CRM_DASH_IPV6_ACL_RULE,
53+
CRM_DASH_IPV4_METER_POLICY,
54+
CRM_DASH_IPV6_METER_POLICY,
55+
CRM_DASH_IPV4_METER_RULE,
56+
CRM_DASH_IPV6_METER_RULE,
5357
CRM_TWAMP_ENTRY
5458
};
5559

0 commit comments

Comments
 (0)