forked from sonic-net/sonic-swss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashorch.h
More file actions
116 lines (103 loc) · 4.63 KB
/
Copy pathdashorch.h
File metadata and controls
116 lines (103 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma once
#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <saitypes.h>
#include "bulker.h"
#include "dbconnector.h"
#include "ipaddress.h"
#include "ipaddresses.h"
#include "ipprefix.h"
#include "macaddress.h"
#include "timer.h"
#include "zmqorch.h"
#include "zmqserver.h"
#include "flex_counter_manager.h"
#include "dash_api/appliance.pb.h"
#include "dash_api/route_type.pb.h"
#include "dash_api/eni.pb.h"
#include "dash_api/qos.pb.h"
#include "dash_api/eni_route.pb.h"
#define ENI_STAT_COUNTER_FLEX_COUNTER_GROUP "ENI_STAT_COUNTER"
#define ENI_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000
#define DASH_RESULT_SUCCESS 0
#define DASH_RESULT_FAILURE 1
struct EniEntry
{
sai_object_id_t eni_id;
dash::eni::Eni metadata;
};
struct ApplianceEntry
{
sai_object_id_t appliance_id;
dash::appliance::Appliance metadata;
};
typedef std::map<std::string, ApplianceEntry> ApplianceTable;
typedef std::map<dash::route_type::RoutingType, dash::route_type::RouteType> RoutingTypeTable;
typedef std::map<std::string, EniEntry> EniTable;
typedef std::map<std::string, dash::qos::Qos> QosTable;
typedef std::map<std::string, dash::eni_route::EniRoute> EniRouteTable;
class DashOrch : public ZmqOrch
{
public:
DashOrch(swss::DBConnector *db, std::vector<std::string> &tables, swss::DBConnector *app_state_db, swss::ZmqServer *zmqServer);
const EniEntry *getEni(const std::string &eni) const;
const EniTable *getEniTable() const { return &eni_entries_; };
bool getRouteTypeActions(dash::route_type::RoutingType routing_type, dash::route_type::RouteType& route_type);
void handleFCStatusUpdate(bool is_enabled);
dash::types::IpAddress getApplianceVip();
bool hasApplianceEntry();
private:
ApplianceTable appliance_entries_;
RoutingTypeTable routing_type_entries_;
EniTable eni_entries_;
QosTable qos_entries_;
EniRouteTable eni_route_entries_;
std::unique_ptr<swss::Table> dash_eni_result_table_;
std::unique_ptr<swss::Table> dash_qos_result_table_;
std::unique_ptr<swss::Table> dash_appliance_result_table_;
std::unique_ptr<swss::Table> dash_eni_route_result_table_;
std::unique_ptr<swss::Table> dash_routing_type_result_table_;
void doTask(ConsumerBase &consumer);
void doTaskApplianceTable(ConsumerBase &consumer);
void doTaskRoutingTypeTable(ConsumerBase &consumer);
void doTaskEniTable(ConsumerBase &consumer);
void doTaskQosTable(ConsumerBase &consumer);
void doTaskEniRouteTable(ConsumerBase &consumer);
void doTaskRouteGroupTable(ConsumerBase &consumer);
bool addApplianceEntry(const std::string& appliance_id, const dash::appliance::Appliance &entry);
void addApplianceTrustedVni(const std::string& appliance_id, const dash::appliance::Appliance& entry);
bool removeApplianceEntry(const std::string& appliance_id);
void removeApplianceTrustedVni(const std::string& appliance_id, const dash::appliance::Appliance& entry);
bool addRoutingTypeEntry(const dash::route_type::RoutingType &routing_type, const dash::route_type::RouteType &entry);
bool removeRoutingTypeEntry(const dash::route_type::RoutingType &routing_type);
bool addEniObject(const std::string& eni, EniEntry& entry);
bool addEniAddrMapEntry(const std::string& eni, const EniEntry& entry);
void addEniTrustedVnis(const std::string& eni, const EniEntry& entry);
bool addEni(const std::string& eni, EniEntry &entry);
bool removeEniObject(const std::string& eni);
bool removeEniAddrMapEntry(const std::string& eni);
void removeEniTrustedVnis(const std::string& eni, const EniEntry& entry);
bool removeEni(const std::string& eni);
bool setEniAdminState(const std::string& eni, const EniEntry& entry);
bool addQosEntry(const std::string& qos_name, const dash::qos::Qos &entry);
bool removeQosEntry(const std::string& qos_name);
bool setEniRoute(const std::string& eni, const dash::eni_route::EniRoute& entry);
bool removeEniRoute(const std::string& eni);
private:
std::map<sai_object_id_t, std::string> m_eni_stat_work_queue;
FlexCounterManager m_eni_stat_manager;
bool m_eni_fc_status = false;
std::unordered_set<std::string> m_counter_stats;
std::unique_ptr<swss::Table> m_eni_name_table;
std::unique_ptr<swss::Table> m_vid_to_rid_table;
std::shared_ptr<swss::DBConnector> m_counter_db;
std::shared_ptr<swss::DBConnector> m_asic_db;
swss::SelectableTimer* m_fc_update_timer = nullptr;
void doTask(swss::SelectableTimer&);
void addEniToFC(sai_object_id_t oid, const std::string& name);
void removeEniFromFC(sai_object_id_t oid, const std::string& name);
void refreshEniFCStats(bool);
};