|
1 |
| -#ifndef __FDBSYNC__ |
2 |
| -#define __FDBSYNC__ |
3 |
| - |
4 |
| -#include <string> |
5 |
| -#include <arpa/inet.h> |
6 |
| -#include "dbconnector.h" |
7 |
| -#include "producerstatetable.h" |
8 |
| -#include "subscriberstatetable.h" |
9 |
| -#include "netmsg.h" |
10 |
| -#include "warmRestartAssist.h" |
11 |
| - |
12 |
| -/* |
13 |
| - * Default timer interval for fdbsyncd reconcillation |
14 |
| - */ |
15 |
| -#define DEFAULT_FDBSYNC_WARMSTART_TIMER 120 |
16 |
| - |
17 |
| -/* |
18 |
| - * This is the MAX time in seconds, fdbsyncd will wait after warm-reboot |
19 |
| - * for the interface entries to be recreated in kernel before attempting to |
20 |
| - * write the FDB data to kernel |
21 |
| - */ |
22 |
| -#define INTF_RESTORE_MAX_WAIT_TIME 180 |
23 |
| - |
24 |
| -namespace swss { |
25 |
| - |
26 |
| -enum FDB_OP_TYPE { |
27 |
| - FDB_OPER_ADD =1, |
28 |
| - FDB_OPER_DEL = 2, |
29 |
| -}; |
30 |
| - |
31 |
| -enum FDB_TYPE { |
32 |
| - FDB_TYPE_STATIC = 1, |
33 |
| - FDB_TYPE_DYNAMIC = 2, |
34 |
| -}; |
35 |
| - |
36 |
| -struct m_fdb_info |
37 |
| -{ |
38 |
| - std::string mac; |
39 |
| - std::string vid; /*Store as Vlan<ID> */ |
40 |
| - std::string port_name; |
41 |
| - short type; /*dynamic or static*/ |
42 |
| - short op_type; /*add or del*/ |
43 |
| -}; |
44 |
| - |
45 |
| -class FdbSync : public NetMsg |
46 |
| -{ |
47 |
| -public: |
48 |
| - enum { MAX_ADDR_SIZE = 64 }; |
49 |
| - |
50 |
| - FdbSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb, DBConnector *config_db); |
51 |
| - ~FdbSync(); |
52 |
| - |
53 |
| - virtual void onMsg(int nlmsg_type, struct nl_object *obj); |
54 |
| - |
55 |
| - bool isIntfRestoreDone(); |
56 |
| - |
57 |
| - AppRestartAssist *getRestartAssist() |
58 |
| - { |
59 |
| - return m_AppRestartAssist; |
60 |
| - } |
61 |
| - |
62 |
| - SubscriberStateTable *getFdbStateTable() |
63 |
| - { |
64 |
| - return &m_fdbStateTable; |
65 |
| - } |
66 |
| - |
67 |
| - SubscriberStateTable *getCfgEvpnNvoTable() |
68 |
| - { |
69 |
| - return &m_cfgEvpnNvoTable; |
70 |
| - } |
71 |
| - |
72 |
| - void processStateFdb(); |
73 |
| - |
74 |
| - void processCfgEvpnNvo(); |
75 |
| - |
76 |
| - bool m_reconcileDone = false; |
77 |
| - |
78 |
| - bool m_isEvpnNvoExist = false; |
79 |
| - |
80 |
| -private: |
81 |
| - ProducerStateTable m_fdbTable; |
82 |
| - ProducerStateTable m_imetTable; |
83 |
| - SubscriberStateTable m_fdbStateTable; |
84 |
| - AppRestartAssist *m_AppRestartAssist; |
85 |
| - SubscriberStateTable m_cfgEvpnNvoTable; |
86 |
| - |
87 |
| - struct m_local_fdb_info |
88 |
| - { |
89 |
| - std::string port_name; |
90 |
| - short type;/*dynamic or static*/ |
91 |
| - }; |
92 |
| - std::unordered_map<std::string, m_local_fdb_info> m_fdb_mac; |
93 |
| - |
94 |
| - void macDelVxlanEntry(std::string auxkey, struct m_fdb_info *info); |
95 |
| - |
96 |
| - void macUpdateCache(struct m_fdb_info *info); |
97 |
| - |
98 |
| - bool macCheckSrcDB(struct m_fdb_info *info); |
99 |
| - |
100 |
| - void updateLocalMac(struct m_fdb_info *info); |
101 |
| - |
102 |
| - void updateAllLocalMac(); |
103 |
| - |
104 |
| - void macRefreshStateDB(int vlan, std::string kmac); |
105 |
| - |
106 |
| - bool checkImetExist(std::string key, uint32_t vni); |
107 |
| - |
108 |
| - bool checkDelImet(std::string key, uint32_t vni); |
109 |
| - |
110 |
| - struct m_mac_info |
111 |
| - { |
112 |
| - std::string vtep; |
113 |
| - std::string type; |
114 |
| - unsigned int vni; |
115 |
| - std::string ifname; |
116 |
| - }; |
117 |
| - std::unordered_map<std::string, m_mac_info> m_mac; |
118 |
| - |
119 |
| - struct m_imet_info |
120 |
| - { |
121 |
| - unsigned int vni; |
122 |
| - }; |
123 |
| - std::unordered_map<std::string, m_imet_info> m_imet_route; |
124 |
| - |
125 |
| - struct intf |
126 |
| - { |
127 |
| - std::string ifname; |
128 |
| - unsigned int vni; |
129 |
| - }; |
130 |
| - std::unordered_map<int, intf> m_intf_info; |
131 |
| - |
132 |
| - void addLocalMac(std::string key, std::string op); |
133 |
| - void macAddVxlan(std::string key, struct in_addr vtep, std::string type, uint32_t vni, std::string intf_name); |
134 |
| - void macDelVxlan(std::string auxkey); |
135 |
| - void macDelVxlanDB(std::string key); |
136 |
| - void imetAddRoute(struct in_addr vtep, std::string ifname, uint32_t vni); |
137 |
| - void imetDelRoute(struct in_addr vtep, std::string ifname, uint32_t vni); |
138 |
| - void onMsgNbr(int nlmsg_type, struct nl_object *obj); |
139 |
| - void onMsgLink(int nlmsg_type, struct nl_object *obj); |
140 |
| -}; |
141 |
| - |
142 |
| -} |
143 |
| - |
144 |
| -#endif |
145 |
| - |
| 1 | +#ifndef __FDBSYNC__ |
| 2 | +#define __FDBSYNC__ |
| 3 | + |
| 4 | +#include <string> |
| 5 | +#include <arpa/inet.h> |
| 6 | +#include "dbconnector.h" |
| 7 | +#include "producerstatetable.h" |
| 8 | +#include "subscriberstatetable.h" |
| 9 | +#include "netmsg.h" |
| 10 | +#include "warmRestartAssist.h" |
| 11 | + |
| 12 | +/* |
| 13 | + * Default timer interval for fdbsyncd reconcillation |
| 14 | + */ |
| 15 | +#define DEFAULT_FDBSYNC_WARMSTART_TIMER 120 |
| 16 | + |
| 17 | +/* |
| 18 | + * This is the MAX time in seconds, fdbsyncd will wait after warm-reboot |
| 19 | + * for the interface entries to be recreated in kernel before attempting to |
| 20 | + * write the FDB data to kernel |
| 21 | + */ |
| 22 | +#define INTF_RESTORE_MAX_WAIT_TIME 180 |
| 23 | + |
| 24 | +namespace swss { |
| 25 | + |
| 26 | +enum FDB_OP_TYPE { |
| 27 | + FDB_OPER_ADD =1, |
| 28 | + FDB_OPER_DEL = 2, |
| 29 | +}; |
| 30 | + |
| 31 | +enum FDB_TYPE { |
| 32 | + FDB_TYPE_STATIC = 1, |
| 33 | + FDB_TYPE_DYNAMIC = 2, |
| 34 | +}; |
| 35 | + |
| 36 | +struct m_fdb_info |
| 37 | +{ |
| 38 | + std::string mac; |
| 39 | + std::string vid; /*Store as Vlan<ID> */ |
| 40 | + std::string port_name; |
| 41 | + short type; /*dynamic or static*/ |
| 42 | + short op_type; /*add or del*/ |
| 43 | +}; |
| 44 | + |
| 45 | +class FdbSync : public NetMsg |
| 46 | +{ |
| 47 | +public: |
| 48 | + enum { MAX_ADDR_SIZE = 64 }; |
| 49 | + |
| 50 | + FdbSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb, DBConnector *config_db); |
| 51 | + ~FdbSync(); |
| 52 | + |
| 53 | + virtual void onMsg(int nlmsg_type, struct nl_object *obj); |
| 54 | + |
| 55 | + bool isIntfRestoreDone(); |
| 56 | + |
| 57 | + AppRestartAssist *getRestartAssist() |
| 58 | + { |
| 59 | + return m_AppRestartAssist; |
| 60 | + } |
| 61 | + |
| 62 | + SubscriberStateTable *getFdbStateTable() |
| 63 | + { |
| 64 | + return &m_fdbStateTable; |
| 65 | + } |
| 66 | + |
| 67 | + SubscriberStateTable *getMclagRemoteFdbStateTable() |
| 68 | + { |
| 69 | + return &m_mclagRemoteFdbStateTable; |
| 70 | + } |
| 71 | + |
| 72 | + SubscriberStateTable *getCfgEvpnNvoTable() |
| 73 | + { |
| 74 | + return &m_cfgEvpnNvoTable; |
| 75 | + } |
| 76 | + |
| 77 | + void processStateFdb(); |
| 78 | + |
| 79 | + void processStateMclagRemoteFdb(); |
| 80 | + |
| 81 | + void processCfgEvpnNvo(); |
| 82 | + |
| 83 | + bool m_reconcileDone = false; |
| 84 | + |
| 85 | + bool m_isEvpnNvoExist = false; |
| 86 | + |
| 87 | +private: |
| 88 | + ProducerStateTable m_fdbTable; |
| 89 | + ProducerStateTable m_imetTable; |
| 90 | + SubscriberStateTable m_fdbStateTable; |
| 91 | + SubscriberStateTable m_mclagRemoteFdbStateTable; |
| 92 | + AppRestartAssist *m_AppRestartAssist; |
| 93 | + SubscriberStateTable m_cfgEvpnNvoTable; |
| 94 | + |
| 95 | + struct m_local_fdb_info |
| 96 | + { |
| 97 | + std::string port_name; |
| 98 | + short type;/*dynamic or static*/ |
| 99 | + }; |
| 100 | + std::unordered_map<std::string, m_local_fdb_info> m_fdb_mac; |
| 101 | + |
| 102 | + std::unordered_map<std::string, m_local_fdb_info> m_mclag_remote_fdb_mac; |
| 103 | + |
| 104 | + void macDelVxlanEntry(std::string auxkey, struct m_fdb_info *info); |
| 105 | + |
| 106 | + void macUpdateCache(struct m_fdb_info *info); |
| 107 | + |
| 108 | + bool macCheckSrcDB(struct m_fdb_info *info); |
| 109 | + |
| 110 | + void updateLocalMac(struct m_fdb_info *info); |
| 111 | + |
| 112 | + void updateAllLocalMac(); |
| 113 | + |
| 114 | + void macRefreshStateDB(int vlan, std::string kmac); |
| 115 | + |
| 116 | + void updateMclagRemoteMac(struct m_fdb_info *info); |
| 117 | + |
| 118 | + void updateMclagRemoteMacPort(int ifindex, int vlan, std::string mac); |
| 119 | + |
| 120 | + void macUpdateMclagRemoteCache(struct m_fdb_info *info); |
| 121 | + |
| 122 | + bool checkImetExist(std::string key, uint32_t vni); |
| 123 | + |
| 124 | + bool checkDelImet(std::string key, uint32_t vni); |
| 125 | + |
| 126 | + struct m_mac_info |
| 127 | + { |
| 128 | + std::string vtep; |
| 129 | + std::string type; |
| 130 | + unsigned int vni; |
| 131 | + std::string ifname; |
| 132 | + }; |
| 133 | + std::unordered_map<std::string, m_mac_info> m_mac; |
| 134 | + |
| 135 | + struct m_imet_info |
| 136 | + { |
| 137 | + unsigned int vni; |
| 138 | + }; |
| 139 | + std::unordered_map<std::string, m_imet_info> m_imet_route; |
| 140 | + |
| 141 | + struct intf |
| 142 | + { |
| 143 | + std::string ifname; |
| 144 | + unsigned int vni; |
| 145 | + }; |
| 146 | + std::unordered_map<int, intf> m_intf_info; |
| 147 | + |
| 148 | + void addLocalMac(std::string key, std::string op); |
| 149 | + void macAddVxlan(std::string key, struct in_addr vtep, std::string type, uint32_t vni, std::string intf_name); |
| 150 | + void macDelVxlan(std::string auxkey); |
| 151 | + void macDelVxlanDB(std::string key); |
| 152 | + void imetAddRoute(struct in_addr vtep, std::string ifname, uint32_t vni); |
| 153 | + void imetDelRoute(struct in_addr vtep, std::string ifname, uint32_t vni); |
| 154 | + void onMsgNbr(int nlmsg_type, struct nl_object *obj); |
| 155 | + void onMsgLink(int nlmsg_type, struct nl_object *obj); |
| 156 | +}; |
| 157 | + |
| 158 | +} |
| 159 | + |
| 160 | +#endif |
| 161 | + |
0 commit comments