Line data Source code
1 : /*
2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3 : * Copyright Contributors to the OpenSDN project
4 : */
5 :
6 : #ifndef ctrlplane_ksync_sock_user_h
7 : #define ctrlplane_ksync_sock_user_h
8 :
9 : #include <queue>
10 : #include <mutex>
11 :
12 : #include <boost/asio.hpp>
13 : #include <boost/asio/buffer.hpp>
14 :
15 : #include <boost/unordered_map.hpp>
16 : #include "ksync_sock.h"
17 :
18 : #include "nl_util.h"
19 : #include "vr_types.h"
20 : #include "vr_flow.h"
21 : #include "vr_bridge.h"
22 :
23 : using boost::asio::ip::udp;
24 :
25 : class MockDumpHandlerBase;
26 :
27 : class vrouter_ops_test : public vrouter_ops {
28 : private:
29 : virtual void Process(SandeshContext *context);
30 : };
31 :
32 : class KSyncUserSockContext : public AgentSandeshContext {
33 : public:
34 22365 : KSyncUserSockContext(uint32_t num) : seqno_(num) {}
35 22365 : virtual ~KSyncUserSockContext() {}
36 22502 : uint32_t GetSeqNum() { return seqno_; }
37 : virtual void IfMsgHandler(vr_interface_req *req);
38 : virtual void NHMsgHandler(vr_nexthop_req *req);
39 : virtual void RouteMsgHandler(vr_route_req *req);
40 : virtual void MplsMsgHandler(vr_mpls_req *req);
41 : virtual void MirrorMsgHandler(vr_mirror_req *req);
42 0 : virtual int VrResponseMsgHandler(vr_response *req) {return 0;};
43 : virtual void FlowMsgHandler(vr_flow_req *req);
44 : virtual void VrfAssignMsgHandler(vr_vrf_assign_req *req);
45 : virtual void VrfMsgHandler(vr_vrf_req *req);
46 : virtual void VrfStatsMsgHandler(vr_vrf_stats_req *req);
47 : virtual void DropStatsMsgHandler(vr_drop_stats_req *req);
48 : virtual void VxLanMsgHandler(vr_vxlan_req *req);
49 : virtual void QosConfigMsgHandler(vr_qos_map_req *req);
50 : virtual void ForwardingClassMsgHandler(vr_fc_map_req *req);
51 : virtual void VrouterOpsMsgHandler(vrouter_ops *req);
52 0 : virtual void Process() {}
53 : private:
54 : uint32_t seqno_;
55 : };
56 :
57 : struct TestRouteCmp {
58 59303 : bool operator()(const vr_route_req &lhs, const vr_route_req &rhs) const {
59 59303 : if (lhs.get_rtr_family() != rhs.get_rtr_family()) {
60 10305 : return lhs.get_rtr_family() < rhs.get_rtr_family();
61 : }
62 48998 : if (lhs.get_rtr_vrf_id() != rhs.get_rtr_vrf_id()) {
63 19310 : return lhs.get_rtr_vrf_id() < rhs.get_rtr_vrf_id();
64 : }
65 29688 : if (lhs.get_rtr_family() == AF_BRIDGE) {
66 12133 : return lhs.get_rtr_mac() < rhs.get_rtr_mac();
67 : }
68 17555 : if (lhs.get_rtr_prefix_len() != rhs.get_rtr_prefix_len()) {
69 2969 : return lhs.get_rtr_prefix_len() < rhs.get_rtr_prefix_len();
70 : }
71 14586 : return lhs.get_rtr_prefix() < rhs.get_rtr_prefix();
72 : }
73 : };
74 :
75 : struct TestVrfAssignCmp {
76 0 : bool operator() (const vr_vrf_assign_req &lhs, const vr_vrf_assign_req &rhs) const {
77 0 : if (lhs.get_var_vif_index() != rhs.get_var_vif_index()) {
78 0 : return lhs.get_var_vif_index() < rhs.get_var_vif_index();
79 : }
80 :
81 0 : return lhs.get_var_vlan_id() < rhs.get_var_vlan_id();
82 : }
83 : };
84 :
85 : //this class stores all netlink sandesh messages in a map
86 : //used for unit testing or userspace datapath integration
87 : class KSyncSockTypeMap : public KSyncSock {
88 : public:
89 : enum KSyncSockEntryType {
90 : KSYNC_FLOW_ENTRY_TYPE = 0,
91 : KSYNC_MAX_ENTRY_TYPE
92 : };
93 :
94 4 : KSyncSockTypeMap(boost::asio::io_context &ios) : KSyncSock(), sock_(ios), ksync_error_() {
95 2 : block_msg_processing_ = false;
96 2 : is_incremental_index_ = false;
97 2 : }
98 0 : ~KSyncSockTypeMap() {
99 0 : assert(nh_map.size() == 0);
100 0 : assert(flow_map.size() == 0);
101 0 : assert(if_map.size() == 0);
102 0 : assert(rt_tree.size() == 0);
103 0 : assert(mpls_map.size() == 0);
104 0 : assert(mirror_map.size() == 0);
105 0 : assert(vrf_assign_tree.size() == 0);
106 0 : assert(vxlan_map.size() == 0);
107 0 : singleton_ = NULL;
108 0 : }
109 :
110 : typedef std::map<int, vr_nexthop_req> ksync_map_nh;
111 : ksync_map_nh nh_map;
112 : typedef boost::unordered_map<int, vr_flow_req> ksync_map_flow;
113 : ksync_map_flow flow_map;
114 : typedef std::map<int, vr_interface_req> ksync_map_if;
115 : ksync_map_if if_map;
116 : typedef std::set<vr_route_req, TestRouteCmp> ksync_rt_tree;
117 : ksync_rt_tree rt_tree;
118 : typedef std::map<int, vr_mpls_req> ksync_map_mpls;
119 : ksync_map_mpls mpls_map;
120 : typedef std::map<int, vr_mirror_req> ksync_map_mirror;
121 : ksync_map_mirror mirror_map;
122 : typedef std::set<vr_vrf_assign_req, TestVrfAssignCmp> ksync_vrf_assign_tree;
123 : ksync_vrf_assign_tree vrf_assign_tree;
124 : typedef std::map<int, vr_vrf_stats_req> ksync_map_vrf_stats;
125 : ksync_map_vrf_stats vrf_stats_map;
126 : vr_drop_stats_req drop_stats;
127 : vrouter_ops ksync_vrouter_ops;
128 : typedef std::map<int, vr_vxlan_req> ksync_map_vxlan;
129 : ksync_map_vxlan vxlan_map;
130 : typedef std::map<int, vr_vrf_req> ksync_map_vrf;
131 : ksync_map_vrf vrf_map;
132 : typedef std::queue<KSyncUserSockContext *> ksync_map_ctx_queue;
133 : ksync_map_ctx_queue ctx_queue_;
134 : std::mutex ctx_queue_lock_;
135 :
136 : virtual uint32_t GetSeqno(char *data);
137 : virtual bool IsMoreData(char *data);
138 : virtual bool BulkDecoder(char *data, KSyncBulkSandeshContext *ctxt);
139 : virtual bool Decoder(char *data, AgentSandeshContext *ctxt);
140 : virtual bool Validate(char *data);
141 : virtual void AsyncReceive(boost::asio::mutable_buffers_1, HandlerCb);
142 : virtual void AsyncSendTo(KSyncBufferList *iovec, uint32_t seq_no,
143 : HandlerCb cb);
144 : virtual std::size_t SendTo(KSyncBufferList *iovec, uint32_t seq_no);
145 : virtual void Receive(boost::asio::mutable_buffers_1);
146 :
147 : void PurgeTxBuffer();
148 : void ProcessSandesh(const uint8_t *, std::size_t, KSyncUserSockContext *);
149 4 : static void set_error_code(int code) { error_code_ = code; }
150 2 : static int error_code() { return error_code_; }
151 : static void SimulateResponse(uint32_t, int, int);
152 : static void SendNetlinkDoneMsg(uint32_t seq_num);
153 : static void IfDumpResponse(uint32_t);
154 : static void IfNetlinkMsgSend(uint32_t seq_num, ksync_map_if::const_iterator it);
155 : static void IfStatsUpdate(int, int, int, int, int, int, int);
156 : static void IfStatsSet(int, int, int, int, int, int, int);
157 : static void InterfaceAdd(int id, int flags = 0, int mac_size = 6);
158 : static void InterfaceDelete(int id);
159 : static void NHAdd(int id, int flags = 0);
160 : static void NHDelete(int id);
161 : static void MplsAdd(int id);
162 : static void MplsDelete(int id);
163 : static void MirrorAdd(int id);
164 : static void MirrorDelete(int id);
165 : static void RouteAdd(vr_route_req &req);
166 : static void RouteDelete(vr_route_req &req);
167 : static void VrfAssignAdd(vr_vrf_assign_req &req);
168 : static void VrfAssignDelete(vr_vrf_assign_req &req);
169 : static void VrfAdd(vr_vrf_req &req);
170 : static void VrfDelete(vr_vrf_req &req);
171 : static void VrfStatsAdd(int vrf_id);
172 : static void VrfStatsUpdate(int vrf_id, const vr_vrf_stats_req &req);
173 : static void VrfStatsDelete(int vrf_id);
174 : static void VxlanAdd(int id);
175 : static void VxlanDelete(int id);
176 :
177 : static void SetDropStats(const vr_drop_stats_req &req);
178 : static void SetVRouterOps(const vrouter_ops &req);
179 : static int IfCount();
180 : static int NHCount();
181 : static int MplsCount();
182 : static int RouteCount();
183 : static int VxLanCount();
184 80325 : static KSyncSockTypeMap *GetKSyncSockTypeMap() { return singleton_; };
185 : static void Init(boost::asio::io_context &ios);
186 : static void Shutdown();
187 : static vr_flow_entry *FlowMmapAlloc(int size);
188 : static void FlowMmapFree();
189 : static vr_flow_entry *GetFlowEntry(int idx);
190 : static void SetFlowEntry(vr_flow_req *req, bool set);
191 : static void IncrFlowStats(int idx, int pkts, int bytes);
192 : static void SetTcpFlag(int idx, uint32_t flags);
193 : static void SetOFlowStats(int idx, uint8_t pkts, uint16_t bytes);
194 : static void SetFlowTcpFlags(int idx, uint16_t flags);
195 : static void SetEvictedFlag(int idx);
196 : static void ResetEvictedFlag(int idx);
197 : static void FlowNatResponse(uint32_t seq_num, vr_flow_req *req, int code = 0);
198 : static void SetUnderlaySourcePort(int idx, int port);
199 : vr_bridge_entry* BridgeMmapAlloc(int size);
200 : void BridgeMmapFree();
201 : vr_bridge_entry* GetBridgeEntry(int idx);
202 : void SetBridgeEntry(uint32_t idx, vr_route_req *req, bool set);
203 : void UpdateBridgeEntryInactiveFlag(int idx, bool set);
204 : friend class MockDumpHandlerBase;
205 : friend class RouteDumpHandler;
206 : friend class VrfAssignDumpHandler;
207 : friend class VrfDumpHandler;
208 : void SetBlockMsgProcessing(bool enable);
209 11251 : bool IsBlockMsgProcessing() {
210 11251 : std::scoped_lock lock(ctx_queue_lock_);
211 11251 : return block_msg_processing_;
212 11251 : }
213 :
214 8 : void set_is_incremental_index(bool incremental) {
215 8 : is_incremental_index_ = incremental;
216 8 : }
217 :
218 154 : bool is_incremental_index() { return is_incremental_index_; }
219 :
220 5 : void SetKSyncError(KSyncSockEntryType type, int ksync_error) {
221 5 : ksync_error_[type] = ksync_error;
222 5 : }
223 :
224 756 : int GetKSyncError(KSyncSockEntryType type) {
225 756 : return ksync_error_[type];
226 : }
227 :
228 : // Add a response in nl_client into tx_buff_list_
229 : void AddNetlinkTxBuff(struct nl_client *cl);
230 : void InitNetlinkDoneMsg(struct nlmsghdr *nlh, uint32_t seq_num);
231 : void DisableReceiveQueue(bool disable);
232 : private:
233 : void PurgeBlockedMsg();
234 : udp::socket sock_;
235 : udp::endpoint local_ep_;
236 : int ksync_error_[KSYNC_MAX_ENTRY_TYPE];
237 : bool block_msg_processing_;
238 : bool is_incremental_index_;
239 : static KSyncSockTypeMap *singleton_;
240 : static vr_flow_entry *flow_table_;
241 : vr_bridge_entry *bridge_table_;
242 : static int error_code_;
243 : // List of nl_client messages to be sent. In case of bulk message, all
244 : // responses are initially put into this list and finally NL_MULTI
245 : // netlink messages are sent
246 : std::vector<struct nl_client> tx_buff_list_;
247 : DISALLOW_COPY_AND_ASSIGN(KSyncSockTypeMap);
248 : };
249 :
250 : class MockDumpHandlerBase {
251 : public:
252 2 : MockDumpHandlerBase() {}
253 2 : virtual ~MockDumpHandlerBase() {}
254 : void SendDumpResponse(uint32_t seq_num, Sandesh *);
255 : void SendGetResponse(uint32_t seq_num, int idx);
256 : virtual Sandesh* GetFirst(Sandesh *) = 0;
257 : virtual Sandesh* GetNext(Sandesh *) = 0;
258 : virtual Sandesh* Get(int idx) = 0;
259 : };
260 :
261 : class IfDumpHandler : public MockDumpHandlerBase {
262 : public:
263 0 : IfDumpHandler() : MockDumpHandlerBase() {}
264 : virtual Sandesh* GetFirst(Sandesh *);
265 : virtual Sandesh* GetNext(Sandesh *);
266 : virtual Sandesh* Get(int idx);
267 : private:
268 : vr_drop_stats_req drop_stats_req;
269 : };
270 :
271 : class NHDumpHandler : public MockDumpHandlerBase {
272 : public:
273 0 : NHDumpHandler() : MockDumpHandlerBase() {}
274 : virtual Sandesh* GetFirst(Sandesh *);
275 : virtual Sandesh* GetNext(Sandesh *);
276 : virtual Sandesh* Get(int idx);
277 : };
278 :
279 : class MplsDumpHandler : public MockDumpHandlerBase {
280 : public:
281 0 : MplsDumpHandler() : MockDumpHandlerBase() {}
282 : virtual Sandesh* GetFirst(Sandesh *);
283 : virtual Sandesh* GetNext(Sandesh *);
284 : virtual Sandesh* Get(int idx);
285 : };
286 :
287 : class MirrorDumpHandler : public MockDumpHandlerBase {
288 : public:
289 0 : MirrorDumpHandler() : MockDumpHandlerBase() {}
290 : virtual Sandesh* GetFirst(Sandesh *);
291 : virtual Sandesh* GetNext(Sandesh *);
292 : virtual Sandesh* Get(int idx);
293 : };
294 :
295 : class RouteDumpHandler : public MockDumpHandlerBase {
296 : public:
297 0 : RouteDumpHandler() : MockDumpHandlerBase() {}
298 : virtual Sandesh* GetFirst(Sandesh *);
299 : virtual Sandesh* GetNext(Sandesh *);
300 : /* GET operation is not supported for vrf assign */
301 0 : virtual Sandesh* Get(int idx) {
302 0 : return NULL;
303 : }
304 : };
305 :
306 : class VrfAssignDumpHandler : public MockDumpHandlerBase {
307 : public:
308 0 : VrfAssignDumpHandler() : MockDumpHandlerBase() {}
309 : virtual Sandesh* GetFirst(Sandesh *);
310 : virtual Sandesh* GetNext(Sandesh *);
311 : /* GET operation is not supported for route */
312 0 : virtual Sandesh* Get(int idx) {
313 0 : return NULL;
314 : }
315 : };
316 :
317 : class VrfDumpHandler : public MockDumpHandlerBase {
318 : public:
319 0 : VrfDumpHandler() : MockDumpHandlerBase() {}
320 : virtual Sandesh* GetFirst(Sandesh *);
321 : virtual Sandesh* GetNext(Sandesh *);
322 : virtual Sandesh* Get(int idx);
323 : };
324 :
325 : class VrfStatsDumpHandler : public MockDumpHandlerBase {
326 : public:
327 0 : VrfStatsDumpHandler() : MockDumpHandlerBase() {}
328 : virtual Sandesh* GetFirst(Sandesh *);
329 : virtual Sandesh* GetNext(Sandesh *);
330 : virtual Sandesh* Get(int idx);
331 : };
332 :
333 : class VxLanDumpHandler : public MockDumpHandlerBase {
334 : public:
335 0 : VxLanDumpHandler() : MockDumpHandlerBase() {}
336 : virtual Sandesh* GetFirst(Sandesh *);
337 : virtual Sandesh* GetNext(Sandesh *);
338 : virtual Sandesh* Get(int idx);
339 : };
340 :
341 : class DropStatsDumpHandler : public MockDumpHandlerBase {
342 : public:
343 0 : DropStatsDumpHandler() : MockDumpHandlerBase() {}
344 0 : virtual Sandesh* GetFirst(Sandesh *) { return NULL; }
345 0 : virtual Sandesh* GetNext(Sandesh *) { return NULL; }
346 0 : virtual Sandesh* Get(int idx) {
347 0 : KSyncSockTypeMap *sock = KSyncSockTypeMap::GetKSyncSockTypeMap();
348 0 : return &sock->drop_stats;
349 : }
350 : };
351 :
352 : class VRouterOpsDumpHandler : public MockDumpHandlerBase {
353 : public:
354 2 : VRouterOpsDumpHandler() : MockDumpHandlerBase() {}
355 0 : virtual Sandesh* GetFirst(Sandesh *) { return NULL;}
356 0 : virtual Sandesh* GetNext(Sandesh *) { return NULL;}
357 2 : virtual Sandesh* Get(int idx) {
358 2 : KSyncSockTypeMap *sock = KSyncSockTypeMap::GetKSyncSockTypeMap();
359 2 : return &sock->ksync_vrouter_ops;
360 : }
361 : };
362 :
363 :
364 : class KSyncUserSockIfContext : public KSyncUserSockContext {
365 : public:
366 764 : KSyncUserSockIfContext(uint32_t seq_num, vr_interface_req *req) : KSyncUserSockContext(seq_num) {
367 764 : if (req) {
368 764 : req_ = new vr_interface_req(*req);
369 : } else {
370 0 : req_ = NULL;
371 : }
372 764 : }
373 1528 : ~KSyncUserSockIfContext() {
374 764 : if (req_) {
375 764 : delete req_;
376 764 : req_ = NULL;
377 : }
378 1528 : }
379 :
380 : virtual void Process();
381 : private:
382 : vr_interface_req *req_;
383 : };
384 :
385 : class KSyncUserSockNHContext : public KSyncUserSockContext {
386 : public:
387 3415 : KSyncUserSockNHContext(uint32_t seq_num, vr_nexthop_req *req) : KSyncUserSockContext(seq_num) {
388 3415 : if (req) {
389 3415 : req_ = new vr_nexthop_req(*req);
390 : } else {
391 0 : req_ = NULL;
392 : }
393 3415 : }
394 6830 : ~KSyncUserSockNHContext() {
395 3415 : if (req_) {
396 3415 : delete req_;
397 3415 : req_ = NULL;
398 : }
399 6830 : }
400 :
401 : virtual void Process();
402 : private:
403 : vr_nexthop_req *req_;
404 : };
405 :
406 : class KSyncUserSockMplsContext : public KSyncUserSockContext {
407 : public:
408 2359 : KSyncUserSockMplsContext(uint32_t seq_num, vr_mpls_req *req) : KSyncUserSockContext(seq_num) {
409 2359 : if (req) {
410 2359 : req_ = new vr_mpls_req(*req);
411 : } else {
412 0 : req_ = NULL;
413 : }
414 2359 : }
415 4718 : ~KSyncUserSockMplsContext() {
416 2359 : if (req_) {
417 2359 : delete req_;
418 2359 : req_ = NULL;
419 : }
420 4718 : }
421 :
422 : virtual void Process();
423 : private:
424 : vr_mpls_req *req_;
425 : };
426 :
427 : class KSyncUserSockFlowContext : public KSyncUserSockContext {
428 : public:
429 378 : KSyncUserSockFlowContext(uint32_t seq_num, vr_flow_req *req) : KSyncUserSockContext(seq_num) {
430 378 : if (req) {
431 378 : req_ = new vr_flow_req(*req);
432 : } else {
433 0 : req_ = NULL;
434 : }
435 378 : }
436 756 : ~KSyncUserSockFlowContext() {
437 378 : if (req_) {
438 378 : delete req_;
439 378 : req_ = NULL;
440 : }
441 756 : }
442 :
443 : virtual void Process();
444 : private:
445 : vr_flow_req *req_;
446 : };
447 :
448 : class KSyncUserSockRouteContext : public KSyncUserSockContext {
449 : public:
450 4051 : KSyncUserSockRouteContext(uint32_t seq_num, vr_route_req *req) :
451 4051 : KSyncUserSockContext(seq_num) {
452 4051 : if (req) {
453 : /* For delete of AF_BRIDGE entries, we need rtr_index of
454 : * vr_route_req to find vr_bridge_entry and reset its flags. The
455 : * rtr_index is configured while doing add of AF_BRIDGE entry. When
456 : * delete of AF_BRIDGE arrives, we do lookup of vr_route_req from
457 : * our tree to figure out the rtr_index */
458 5480 : if ((req->get_h_op() == sandesh_op::DEL) &&
459 1429 : (req->get_rtr_family() == AF_BRIDGE)) {
460 493 : KSyncSockTypeMap *sock = KSyncSockTypeMap::GetKSyncSockTypeMap();
461 : KSyncSockTypeMap::ksync_rt_tree::iterator it =
462 493 : sock->rt_tree.find(*req);
463 493 : assert (it != sock->rt_tree.end());
464 493 : const vr_route_req &tmp_req = *it;
465 493 : req_ = new vr_route_req(tmp_req);
466 : /* Change the operation to DELETE after picking request from
467 : * our tree */
468 493 : req_->set_h_op(sandesh_op::DEL);
469 : } else {
470 3558 : req_ = new vr_route_req(*req);
471 : }
472 : } else {
473 0 : req_ = NULL;
474 : }
475 4051 : }
476 8102 : ~KSyncUserSockRouteContext() {
477 4051 : if (req_) {
478 4051 : delete req_;
479 4051 : req_ = NULL;
480 : }
481 8102 : }
482 :
483 : virtual void Process();
484 : private:
485 : vr_route_req *req_;
486 : };
487 :
488 : class KSyncUserSockVrfAssignContext : public KSyncUserSockContext {
489 : public:
490 0 : KSyncUserSockVrfAssignContext(uint32_t seq_num, vr_vrf_assign_req *req) :
491 0 : KSyncUserSockContext(seq_num) {
492 0 : if (req) {
493 0 : req_ = new vr_vrf_assign_req(*req);
494 : } else {
495 0 : req_ = NULL;
496 : }
497 0 : }
498 0 : ~KSyncUserSockVrfAssignContext() {
499 0 : if (req_) {
500 0 : delete req_;
501 0 : req_ = NULL;
502 : }
503 0 : }
504 :
505 : virtual void Process();
506 : private:
507 : vr_vrf_assign_req *req_;
508 : };
509 :
510 : class KSyncUserSockVrfContext : public KSyncUserSockContext {
511 : public:
512 148 : KSyncUserSockVrfContext(uint32_t seq_num, vr_vrf_req *req) :
513 148 : KSyncUserSockContext(seq_num) {
514 148 : if (req) {
515 148 : req_ = new vr_vrf_req(*req);
516 : } else {
517 0 : req_ = NULL;
518 : }
519 148 : }
520 296 : ~KSyncUserSockVrfContext() {
521 148 : if (req_) {
522 148 : delete req_;
523 148 : req_ = NULL;
524 : }
525 296 : }
526 :
527 : virtual void Process();
528 : private:
529 : vr_vrf_req *req_;
530 : };
531 :
532 : class KSyncUserSockVrfStatsContext : public KSyncUserSockContext {
533 : public:
534 0 : KSyncUserSockVrfStatsContext(uint32_t seq_num, vr_vrf_stats_req *req) : KSyncUserSockContext(seq_num) {
535 0 : if (req) {
536 0 : req_ = new vr_vrf_stats_req(*req);
537 : } else {
538 0 : req_ = NULL;
539 : }
540 0 : }
541 0 : ~KSyncUserSockVrfStatsContext() {
542 0 : if (req_) {
543 0 : delete req_;
544 0 : req_ = NULL;
545 : }
546 0 : }
547 :
548 : virtual void Process();
549 : private:
550 : vr_vrf_stats_req *req_;
551 : };
552 :
553 : class KSyncUserSockVxLanContext : public KSyncUserSockContext {
554 : public:
555 134 : KSyncUserSockVxLanContext(uint32_t seq_num, vr_vxlan_req *req) : KSyncUserSockContext(seq_num) {
556 134 : if (req) {
557 134 : req_ = new vr_vxlan_req(*req);
558 : } else {
559 0 : req_ = NULL;
560 : }
561 134 : }
562 268 : ~KSyncUserSockVxLanContext() {
563 134 : if (req_) {
564 134 : delete req_;
565 134 : req_ = NULL;
566 : }
567 268 : }
568 :
569 : virtual void Process();
570 : private:
571 : vr_vxlan_req *req_;
572 : };
573 :
574 : class KSyncUserSockDropStatsContext : public KSyncUserSockContext {
575 : public:
576 0 : KSyncUserSockDropStatsContext(uint32_t seq_num, vr_drop_stats_req *req) : KSyncUserSockContext(seq_num) {
577 0 : if (req) {
578 0 : req_ = new vr_drop_stats_req(*req);
579 : } else {
580 0 : req_ = NULL;
581 : }
582 0 : }
583 0 : ~KSyncUserSockDropStatsContext() {
584 0 : if (req_) {
585 0 : delete req_;
586 0 : req_ = NULL;
587 : }
588 0 : }
589 :
590 : virtual void Process();
591 : private:
592 : vr_drop_stats_req *req_;
593 : };
594 :
595 : class KSyncUserVrouterOpsContext : public KSyncUserSockContext {
596 : public:
597 2 : KSyncUserVrouterOpsContext(uint32_t seq_num, vrouter_ops *req) :
598 2 : KSyncUserSockContext(seq_num) {
599 2 : if (req) {
600 2 : req_ = new vrouter_ops(*req);
601 : } else {
602 0 : req_ = NULL;
603 : }
604 2 : }
605 4 : ~KSyncUserVrouterOpsContext() {
606 2 : if (req_) {
607 2 : delete req_;
608 2 : req_ = NULL;
609 : }
610 4 : }
611 :
612 : virtual void Process();
613 : private:
614 : vrouter_ops *req_;
615 : };
616 :
617 :
618 : #endif // ctrlplane_ksync_sock_user_h
|