OpenSDN source code
flow_mgmt_tree.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
10 #include <pkt/flow_mgmt.h>
11 
13  Tree::iterator it = tree_.find(key);
14  if (it == tree_.end())
15  return NULL;
16 
17  return it->second;
18 }
19 
21  FlowMgmtEntry *entry = Find(key);
22  if (entry == NULL) {
23  entry = Allocate(key);
24  InsertEntry(key->Clone(), entry);
25  }
26 
27  return entry;
28 }
29 
31  tree_[key] = entry;
32 }
33 
35  Tree::iterator it = tree_.lower_bound(key);
36  if (it == tree_.end())
37  return NULL;
38 
39  return it->first;
40 }
41 
43  if (entry->CanDelete() == false)
44  return false;
45 
46  // Send message only if we have seen DELETE message from FlowTable
47  if (entry->oper_state() == FlowMgmtEntry::OPER_DEL_SEEN) {
48  FreeNotify(key, entry->gen_id());
49  }
50 
51  Tree::iterator it = tree_.find(key);
52  assert(it != tree_.end());
53  FlowMgmtKey *first = it->first;
54  RemoveEntry(it);
55  delete entry;
56  delete first;
57 
58  return true;
59 }
60 
61 void FlowMgmtTree::RemoveEntry(Tree::iterator it) {
62  tree_.erase(it);
63 }
64 
66 // Generic Event handler on tree for add/delete of a flow
69  FlowMgmtKeyNode *node = new FlowMgmtKeyNode();
70  std::pair<FlowMgmtKeyTree::iterator, bool> ret;
71  ret = tree->insert(make_pair(key, node));
72  if (ret.second == false) {
73  delete key;
74  delete node;
75  }
76  return ret.second;
77 }
78 
79 // Adds Flow to a FlowMgmtEntry defined by key. Does not allocate FlowMgmtEntry
80 // if its not already present
82  FlowMgmtKeyNode *node) {
83  FlowMgmtEntry *entry = Locate(key);
84  if (entry == NULL) {
85  return false;
86  }
87 
88  return entry->Add(flow, node);
89 }
90 
92  FlowMgmtKeyNode *node) {
93  Tree::iterator it = tree_.find(key);
94  if (it == tree_.end()) {
95  return false;
96  }
97 
98  FlowMgmtEntry *entry = it->second;
99  bool ret = entry->Delete(flow, node);
100 
101  TryDelete(it->first, entry);
102  return ret;
103 }
104 
106 // Event handler for add/delete/change of an object
108 
109 // Send DBEntry Free message to DB Client module
110 void FlowMgmtTree::FreeNotify(FlowMgmtKey *key, uint32_t gen_id) {
111  assert(key->db_entry() != NULL);
112  FlowEvent::Event event = key->FreeDBEntryEvent();
113  if (event == FlowEvent::INVALID)
114  return;
115  mgr_->FreeDBEntryEvent(event, key, gen_id);
116 }
117 
118 // An object is added/updated. Enqueue REVALUATE for flows dependent on it
120  FlowMgmtEntry *entry = Locate(key);
121  entry->OperEntryAdd(mgr_, req, key);
122  return true;
123 }
124 
126  FlowMgmtKey *key) {
127  FlowMgmtEntry *entry = Find(key);
128  if (entry) {
129  entry->OperEntryChange(mgr_, req, key);
130  }
131  return true;
132 }
133 
134 // Send DELETE Entry message to FlowTable module
136  FlowMgmtKey *key) {
137  FlowMgmtEntry *entry = Find(key);
138  if (entry == NULL) {
139  FreeNotify(key, req->gen_id());
140  return true;
141  }
142 
143  entry->OperEntryDelete(mgr_, req, key);
144  return TryDelete(key, entry);
145 }
146 
148  FlowMgmtEntry *entry = Find(key);
149  if (entry == NULL) {
150  return true;
151  }
152 
153  return TryDelete(key, entry);
154 }
155 
157  assert(key->db_entry() == NULL);
158 }
159 
161  FlowMgmtKeyTree *tree) {
162  if (flow->is_flags_set(FlowEntry::BgpRouterService) == false)
163  return;
164  const VmInterface *vm_intf =
165  dynamic_cast<const VmInterface *>(flow->intf_entry());
166  if (!vm_intf || (flow->bgp_as_a_service_sport() == 0))
167  return;
168 
170  new BgpAsAServiceFlowMgmtKey(vm_intf->GetUuid(),
171  flow->bgp_as_a_service_sport(),
172  index_, NULL, NULL);
173  AddFlowMgmtKey(tree, key);
174 }
175 
177  return new BgpAsAServiceFlowMgmtEntry();
178 }
179 
180 // Update health check on the BgpAsAService entry
182  (Agent *agent, BgpAsAServiceFlowMgmtKey &key,
184  FlowMgmtEntry *entry = Find(&key);
185  if (entry == NULL) {
186  return true;
187  }
188 
189  BgpAsAServiceFlowMgmtEntry *bgpaas_entry =
190  static_cast<BgpAsAServiceFlowMgmtEntry *>(entry);
191  return bgpaas_entry->HealthCheckUpdate(agent, mgr_, key, req);
192 }
193 
195 (BgpAsAServiceFlowMgmtKey &key, const FlowMgmtRequest *req) {
196  FlowMgmtEntry *entry = Find(&key);
197  if (entry == NULL) {
198  return true;
199  }
200 
201  entry->NonOperEntryDelete(mgr_, req, &key);
202  return TryDelete(&key, entry);
203 }
204 
206  Tree::iterator it = tree_.begin();
207  while (it != tree_.end()) {
209  static_cast<BgpAsAServiceFlowMgmtKey *>(it->first);
210  mgr_->BgpAsAServiceNotify(key->uuid(), key->source_port());
211  it++;
212  }
213 }
214 
216  IpAddress dest_ip = IpAddress();
218  dest_ip = flow->key().src_addr;
219  } else {
220  //No reverse flow means no CN to map to so dont add flow key.
221  if (flow->reverse_flow_entry() == NULL)
223  dest_ip = flow->reverse_flow_entry()->key().src_addr;
224  }
225  for (uint8_t count = 0; count < MAX_XMPP_SERVERS; count++) {
226  if (flow->flow_table()->agent()->controller_ifmap_xmpp_server(count) ==
227  dest_ip.to_string()) {
228  return count;
229  }
230  }
232 }
233 
235 // Acl Flow Management
238  const MatchAclParamsList *acl_list) {
239  std::list<MatchAclParams>::const_iterator it;
240  for (it = acl_list->begin(); it != acl_list->end(); it++) {
241  AclFlowMgmtKey *key = new AclFlowMgmtKey(it->acl.get(),
242  &it->ace_id_list);
243  AddFlowMgmtKey(tree, key);
244  }
245 }
246 
248  ExtractKeys(flow, tree, &flow->match_p().m_acl_l);
249  ExtractKeys(flow, tree, &flow->match_p().m_out_acl_l);
250  ExtractKeys(flow, tree, &flow->match_p().sg_policy.m_acl_l);
251  ExtractKeys(flow, tree, &flow->match_p().sg_policy.m_out_acl_l);
254  ExtractKeys(flow, tree, &flow->match_p().m_mirror_acl_l);
255  ExtractKeys(flow, tree, &flow->match_p().m_out_mirror_acl_l);
256  ExtractKeys(flow, tree, &flow->match_p().m_vrf_assign_acl_l);
257  ExtractKeys(flow, tree, &flow->match_p().aps_policy.m_acl_l);
258  ExtractKeys(flow, tree, &flow->match_p().aps_policy.m_out_acl_l);
259  ExtractKeys(flow, tree, &flow->match_p().fwaas_policy.m_acl_l);
261 }
262 
264  return new AclFlowMgmtEntry();
265 }
266 
268  FlowMgmtKey *old_key, FlowMgmtKeyNode *node) {
269  AclFlowMgmtEntry *entry = static_cast<AclFlowMgmtEntry *>(Locate(key));
270  if (entry == NULL) {
271  return false;
272  }
273 
274  AclFlowMgmtKey *acl_key = static_cast<AclFlowMgmtKey *>(key);
275  const AclEntryIDList *old_ace_id_list = NULL;
276  if (old_key) {
277  AclFlowMgmtKey *old_acl_key = static_cast<AclFlowMgmtKey *>(old_key);
278  old_ace_id_list = old_acl_key->ace_id_list();
279  }
280  return entry->Add(acl_key->ace_id_list(), flow, old_ace_id_list, node);
281 }
282 
284  FlowMgmtKeyNode *node) {
285  Tree::iterator it = tree_.find(key);
286  if (it == tree_.end()) {
287  return false;
288  }
289 
290  AclFlowMgmtKey *acl_key = static_cast<AclFlowMgmtKey *>(key);
291  AclFlowMgmtEntry *entry = static_cast<AclFlowMgmtEntry *>(it->second);
292  bool ret = entry->Delete(acl_key->ace_id_list(), flow, node);
293 
294  TryDelete(it->first, entry);
295  return ret;
296 }
297 
299 // VN Flow Management
302  if (flow->vn_entry() == NULL)
303  return;
304  VnFlowMgmtKey *key = new VnFlowMgmtKey(flow->vn_entry());
305  AddFlowMgmtKey(tree, key);
306 }
307 
309  return new VnFlowMgmtEntry();
310 }
311 
313  std::scoped_lock mutex(mutex_);
314  FlowMgmtTree::InsertEntry(key, entry);
315 }
316 
317 void VnFlowMgmtTree::RemoveEntry(Tree::iterator it) {
318  std::scoped_lock mutex(mutex_);
320 }
321 
323  uint32_t *ingress_flow_count,
324  uint32_t *egress_flow_count) {
325  VnFlowMgmtKey key(vn);
326  std::scoped_lock mutex(mutex_);
327  VnFlowMgmtEntry *entry = static_cast<VnFlowMgmtEntry *>(Find(&key));
328  if (entry) {
329  *ingress_flow_count += entry->ingress_flow_count();
330  *egress_flow_count += entry->egress_flow_count();
331  }
332 }
333 
335 // Interface Flow Management
338  std::scoped_lock mutex(mutex_);
339  FlowMgmtTree::InsertEntry(key, entry);
340 }
341 
342 void InterfaceFlowMgmtTree::RemoveEntry(Tree::iterator it) {
343  std::scoped_lock mutex(mutex_);
345 }
346 
348  uint64_t *created,
349  uint64_t *aged,
350  uint32_t *active_flows) {
351  InterfaceFlowMgmtKey key(itf);
352  std::scoped_lock mutex(mutex_);
353  InterfaceFlowMgmtEntry *entry = static_cast<InterfaceFlowMgmtEntry *>
354  (Find(&key));
355  if (entry) {
356  *created += entry->flow_created();
357  *aged += entry->flow_aged();
358  *active_flows += entry->Size();
359  }
360 }
361 
363  FlowMgmtKeyTree *tree) {
364  if (flow->intf_entry() == NULL)
365  return;
366  InterfaceFlowMgmtKey *key =
367  new InterfaceFlowMgmtKey(flow->intf_entry());
368  AddFlowMgmtKey(tree, key);
369 }
370 
372  return new InterfaceFlowMgmtEntry();
373 }
374 
376 // Nh Flow Management
379  if (flow->rpf_nh() == NULL)
380  return;
381  NhFlowMgmtKey *key = new NhFlowMgmtKey(flow->rpf_nh());
382  AddFlowMgmtKey(tree, key);
383 }
384 
386  return new NhFlowMgmtEntry();
387 }
388 
390 // Route Flow Management
393  FlowMgmtKeyNode *node) {
394  bool ret = FlowMgmtTree::Delete(key, flow, node);
395  RouteFlowMgmtKey *route_key = static_cast<RouteFlowMgmtKey *>(key);
396  mgr_->RetryVrfDelete(route_key->vrf_id());
397  return ret;
398 }
399 
401  FlowMgmtKey *key) {
402  Tree::iterator it = tree_.find(key);
403  if (it == tree_.end()) {
404  return;
405  }
406 
407  if (req->db_entry() == NULL) {
408  return;
409  }
410 
411  if (it->first->db_entry()) {
412  assert(it->first->db_entry() == req->db_entry());
413  return;
414  }
415  it->first->set_db_entry(req->db_entry());
416  return;
417 }
418 
420  FlowMgmtKey *key) {
421  // Set the db_entry if it was not set earlier. It is needed to send the
422  // FreeDBState message
423  SetDBEntry(req, key);
424  bool ret = FlowMgmtTree::OperEntryDelete(req, key);
425  RouteFlowMgmtKey *route_key = static_cast<RouteFlowMgmtKey *>(key);
426  mgr_->RetryVrfDelete(route_key->vrf_id());
427  return ret;
428 }
429 
431  FlowMgmtKey *key) {
432  bool ret = FlowMgmtTree::OperEntryAdd(req, key);
433  if (req->db_entry() == NULL)
434  return ret;
435 
436  // Set the DBEntry in the flow-mgmt-entry
437  SetDBEntry(req, key);
438  return ret;
439 }
440 
442 // Inet Route Flow Management
445  uint32_t vrf, const IpAddress &ip,
446  uint8_t plen) {
447  // We do not support renewal of VRF, so skip flow if VRF is deleted
448  VrfEntry *vrfp = mgr_->agent()->vrf_table()->FindVrfFromId(vrf);
449  if (vrfp == NULL) {
450  return;
451  }
452 
453  InetRouteFlowMgmtKey *key = NULL;
454  /*
455  * For L2 flows, plen is found using LPMFind
456  * when route is not found plen is set to -1(255)
457  * in that case key should not be added
458  */
459  if (flow->l3_flow() || (plen != 255)) {
460  if (ip.is_v4()) {
461  Ip4Address ip4 = Address::GetIp4SubnetAddress(ip.to_v4(), plen);
462  key = new InetRouteFlowMgmtKey(vrf, ip4, plen);
463  } else {
464  Ip6Address ip6 = Address::GetIp6SubnetAddress(ip.to_v6(), plen);
465  key = new InetRouteFlowMgmtKey(vrf, ip6, plen);
466  }
467  }
468 
469  if (key) {
470  AddFlowMgmtKey(tree, key);
471  }
472 }
473 
475  const IpAddress &ip,
476  const FlowRouteRefMap *rt_list) {
477  FlowRouteRefMap::const_iterator it;
478  for (it = rt_list->begin(); it != rt_list->end(); it++) {
479  ExtractKeys(flow, tree, it->first, ip, it->second);
480  }
481 }
482 
484  FlowMgmtKeyTree *tree) {
485 
486  if (flow->l3_flow() == false) {
487  // For l2-flows Track INET route for RPF only
488  if (flow->data().rpf_vrf != VrfEntry::kInvalidIndex) {
489  ExtractKeys(flow, tree, flow->data().rpf_vrf,
490  flow->key().src_addr, flow->data().rpf_plen);
491  }
492  return;
493  }
494 
496  ExtractKeys(flow, tree, flow->data().flow_source_vrf,
497  flow->key().src_addr, flow->data().source_plen);
498  }
499 
502  flow->key().src_addr, flow->data().source_plen);
504  flow->key().dst_addr, flow->data().dest_plen);
505  }
506 
507  ExtractKeys(flow, tree, flow->key().src_addr,
508  &flow->data().flow_source_plen_map);
509 
510  if (flow->data().flow_dest_vrf != VrfEntry::kInvalidIndex) {
511  ExtractKeys(flow, tree, flow->data().flow_dest_vrf,
512  flow->key().dst_addr, flow->data().dest_plen);
513  }
514  ExtractKeys(flow, tree, flow->key().dst_addr,
515  &flow->data().flow_dest_plen_map);
516 
518  ExtractKeys(flow, tree, flow->data().src_policy_vrf,
519  flow->key().src_addr, flow->data().src_policy_plen);
520  }
521 
523  ExtractKeys(flow, tree, flow->data().dst_policy_vrf,
524  flow->key().dst_addr, flow->data().dst_policy_plen);
525  }
526 
527 }
528 
530  return new InetRouteFlowMgmtEntry();
531 }
532 
535  InetRouteFlowMgmtKey *next_key = NULL;
536 
537  if (type == Agent::INET4_UNICAST) {
538  InetRouteFlowMgmtKey key(vrf, Ip4Address(0), 0);
539  next_key = static_cast<InetRouteFlowMgmtKey *>(LowerBound(&key));
540  } else if (type == Agent::INET6_UNICAST) {
541  InetRouteFlowMgmtKey key(vrf, Ip6Address(), 0);
542  next_key = static_cast<InetRouteFlowMgmtKey *>(LowerBound(&key));
543  } else {
544  return false;
545  }
546 
547  if (next_key == NULL)
548  return false;
549 
550  if (next_key->vrf_id() != vrf)
551  return false;
552 
553  return true;
554 }
555 
557  FlowMgmtKey *key) {
558  bool ret = RouteFlowMgmtTree::OperEntryAdd(req, key);
559 
560  // A new route is added. This new route can be a longer prefix route for
561  // flows using lower prefix-len (covering routes). So, do a LPM match to
562  // find the covering route and trigger flow re-compute for flows on the
563  // covering route
564  InetRouteFlowMgmtKey *rt_key = static_cast<InetRouteFlowMgmtKey *>(key);
565  AddToLPMTree(rt_key);
566  if (rt_key->plen_ > 0) {
567  InetRouteFlowMgmtKey lpm_key(rt_key->vrf_id_, rt_key->ip_,
568  rt_key->plen_ - 1);
569  InetRouteFlowMgmtKey *covering_route = LPM(&lpm_key);
570  if (covering_route != NULL) {
571  ret = RecomputeCoveringRoute(covering_route, rt_key);
572  }
573  rt_key->plen_ += 1;
574  }
575 
576  return ret;
577 }
578 
580 (InetRouteFlowMgmtKey *covering_route, InetRouteFlowMgmtKey *key) {
581  InetRouteFlowMgmtEntry *entry = dynamic_cast<InetRouteFlowMgmtEntry *>
582  (Find(covering_route));
583  if (entry == NULL) {
584  return true;
585  }
586 
587  return entry->RecomputeCoveringRouteEntry(mgr_, covering_route, key);
588 }
589 
591  FlowMgmtKey *key) {
592  InetRouteFlowMgmtKey *rt_key = static_cast<InetRouteFlowMgmtKey *>(key);
593  DelFromLPMTree(rt_key);
594  return RouteFlowMgmtTree::OperEntryDelete(req, key);
595 }
596 
598  FlowMgmtKey *key) {
599  InetRouteFlowMgmtEntry *entry = static_cast<InetRouteFlowMgmtEntry*>
600  (Find(key));
601  if (entry == NULL) {
602  return true;
603  }
604 
605  return entry->HandleNhChange(mgr_, req, key);
606 }
607 
609 // Bridge Route Flow Management
612  FlowMgmtKeyTree *tree) {
613  if (flow->l3_flow() == true)
614  return;
615 
616  VrfTable *table = mgr_->agent()->vrf_table();
617  uint32_t vrf = flow->data().flow_source_vrf;
618  if (vrf != VrfEntry::kInvalidIndex && table->FindVrfFromId(vrf) != NULL) {
620  new BridgeRouteFlowMgmtKey(vrf, flow->data().smac);
621  AddFlowMgmtKey(tree, key);
622  }
623 
624  vrf = flow->data().flow_dest_vrf;
625  if (vrf != VrfEntry::kInvalidIndex && table->FindVrfFromId(vrf) != NULL) {
627  new BridgeRouteFlowMgmtKey(vrf, flow->data().smac);
628  AddFlowMgmtKey(tree, key);
629  }
630 }
631 
633  return new BridgeRouteFlowMgmtEntry();
634 }
635 
639  BridgeRouteFlowMgmtKey *next_key = static_cast<BridgeRouteFlowMgmtKey *>
640  (LowerBound(&key));
641  if (next_key == NULL)
642  return false;
643 
644  if (next_key->vrf_id() != vrf)
645  return false;
646 
647  return true;
648 }
649 
651 // Vrf Flow Management
654 }
655 
657  const VrfEntry *vrf = static_cast<const VrfEntry *>(key->db_entry());
658  return new VrfFlowMgmtEntry(this, vrf);
659 }
660 
662  FlowMgmtKey *key) {
663  bool ret = FlowMgmtTree::OperEntryAdd(req, key);
664 
665  const VrfEntry *vrf = static_cast<const VrfEntry *>(key->db_entry());
666  VrfIdMap::iterator it = id_map_.find(vrf->vrf_id());
667  if (it != id_map_.end())
668  return ret;
669 
670  id_map_.insert(make_pair(vrf->vrf_id(), vrf));
671  return ret;
672 }
673 
674 void VrfFlowMgmtTree::FreeNotify(FlowMgmtKey *key, uint32_t gen_id) {
675  FlowMgmtTree::FreeNotify(key, gen_id);
676 
677  const VrfEntry *vrf = static_cast<const VrfEntry *>(key->db_entry());
678  VrfIdMap::iterator it = id_map_.find(vrf->vrf_id());
679  if (it != id_map_.end()) {
680  id_map_.erase(it);
681  }
682 }
683 
684 void VrfFlowMgmtTree::RetryDelete(uint32_t vrf_id) {
685  VrfIdMap::iterator it = id_map_.find(vrf_id);
686  if (it == id_map_.end())
687  return;
688 
689  VrfFlowMgmtKey key(it->second);
690  const VrfEntry *vrf = dynamic_cast<const VrfEntry *>(key.db_entry());
691  if (vrf && vrf->AllRouteTablesEmpty()) {
693  }
694 }
695 
697  //If VMI is associated to FIP, then all non floating-ip
698  //traffic would also be dependent FIP VRF route. This is
699  //to ensure that if more specific route gets added preference
700  //would be given to floating-ip
701  //
702  //Assume a sceanrio where traffic is not NATed, then flow would
703  //add a dependency on default route(assume no default route is
704  //present in FIP VRF). Now if FIP VRF is deleted there is no explicit
705  //trigger to delete this dependencyi and hence delay in releasing VRF
706  //reference, hence if default route DB entry is not present
707  //impliticly delete the default route so that flow could get
708  InetRouteFlowMgmtKey key(vrf->vrf_id(), Ip4Address(0), 0);
709  FlowMgmtEntry *route_entry = mgr_->ip4_route_flow_mgmt_tree()->Find(&key);
710  if (route_entry == NULL ||
711  route_entry->oper_state() != FlowMgmtEntry::OPER_NOT_SEEN) {
712  //If entry is not present on it has corresponding DB entry
713  //no need for implicit delete
714  return;
715  }
716 
719  &route_req, &key, mgr_->ip4_route_flow_mgmt_tree());
720 }
721 
723  FlowMgmtKey *key) {
724  const VrfEntry* vrf = static_cast<const VrfEntry *>(req->db_entry());
725  DeleteDefaultRoute(vrf);
726 
727  return FlowMgmtTree::OperEntryDelete(req, key);
728 }
std::vector< AclEntryID > AclEntryIDList
Definition: acl_entry.h:86
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:16
boost::asio::ip::address IpAddress
Definition: address.h:14
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:15
#define MAX_XMPP_SERVERS
Definition: agent.h:292
bool Add(const AclEntryIDList *ace_id_list, FlowEntry *flow, const AclEntryIDList *old_id_list, FlowMgmtKeyNode *node)
bool Delete(const AclEntryIDList *ace_id_list, FlowEntry *flow, FlowMgmtKeyNode *node)
const AclEntryIDList * ace_id_list() const
Definition: flow_mgmt_key.h:99
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree, const MatchAclParamsList *acl_list)
bool Add(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKey *old_key, FlowMgmtKeyNode *node)
bool Delete(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
static Ip4Address GetIp4SubnetAddress(const Ip4Address &prefix, uint16_t plen)
Definition: address.cc:180
static Ip6Address GetIp6SubnetAddress(const Ip6Address &prefix, uint16_t plen)
Definition: address.cc:201
Definition: agent.h:361
RouteTableType
Definition: agent.h:418
@ INET6_UNICAST
Definition: agent.h:424
@ INET4_UNICAST
Definition: agent.h:420
VrfTable * vrf_table() const
Definition: agent.h:488
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
Definition: agent.h:733
virtual bool HealthCheckUpdate(Agent *agent, FlowMgmtManager *mgr, BgpAsAServiceFlowMgmtKey &key, BgpAsAServiceFlowMgmtRequest *req)
const boost::uuids::uuid & uuid() const
uint32_t source_port() const
virtual void FreeNotify(FlowMgmtKey *key, uint32_t gen_id)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
static int GetCNIndex(const FlowEntry *flow)
bool BgpAsAServiceDelete(BgpAsAServiceFlowMgmtKey &key, const FlowMgmtRequest *req)
bool BgpAsAServiceHealthCheckUpdate(Agent *agent, BgpAsAServiceFlowMgmtKey &key, BgpAsAServiceFlowMgmtRequest *req)
static const int kInvalidCnIndex
bool HasVrfFlows(uint32_t vrf_id, Agent::RouteTableType type)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
FlowEntry * reverse_flow_entry()
Definition: flow_entry.h:603
const FlowKey & key() const
Definition: flow_entry.h:595
const Interface * intf_entry() const
Definition: flow_entry.h:653
const NextHop * rpf_nh() const
Definition: flow_entry.h:659
FlowData & data()
Definition: flow_entry.h:596
bool is_flags_set(const FlowEntryFlags &flags) const
Definition: flow_entry.h:611
const MatchPolicy & match_p() const
Definition: flow_entry.h:671
FlowTable * flow_table() const
Definition: flow_entry.h:598
const VnEntry * vn_entry() const
Definition: flow_entry.h:654
const uint32_t bgp_as_a_service_sport() const
Definition: flow_entry.h:661
bool l3_flow() const
Definition: flow_entry.h:599
@ BgpRouterService
Definition: flow_entry.h:550
virtual bool OperEntryAdd(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool CanDelete() const
uint32_t Size() const
uint32_t gen_id() const
virtual bool Add(FlowEntry *flow, FlowMgmtKeyNode *node)
virtual bool NonOperEntryDelete(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool OperEntryChange(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool Delete(FlowEntry *flow, FlowMgmtKeyNode *node)
virtual bool OperEntryDelete(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
State oper_state() const
const DBEntry * db_entry() const
Definition: flow_mgmt_key.h:66
FlowEvent::Event FreeDBEntryEvent() const
virtual FlowMgmtKey * Clone()=0
static bool ProcessEvent(FlowMgmtRequest *req, FlowMgmtKey *key, FlowMgmtTree *tree)
Definition: flow_mgmt.cc:273
void FreeDBEntryEvent(FlowEvent::Event event, FlowMgmtKey *key, uint32_t gen_id)
Definition: flow_mgmt.cc:251
InetRouteFlowMgmtTree * ip4_route_flow_mgmt_tree()
Definition: flow_mgmt.h:326
void BgpAsAServiceNotify(const boost::uuids::uuid &vm_uuid, uint32_t source_port)
Definition: flow_mgmt.cc:92
void RetryVrfDelete(uint32_t vrf_id)
Definition: flow_mgmt.cc:505
Agent * agent() const
Definition: flow_mgmt.h:284
uint32_t gen_id() const
const DBEntry * db_entry() const
virtual bool Delete(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
virtual void InsertEntry(FlowMgmtKey *key, FlowMgmtEntry *entry)
virtual void FreeNotify(FlowMgmtKey *key, uint32_t gen_id)
Tree & tree()
FlowMgmtManager * mgr_
virtual bool OperEntryDelete(const FlowMgmtRequest *req, FlowMgmtKey *key)
FlowMgmtKey * LowerBound(FlowMgmtKey *key)
FlowMgmtEntry * Locate(FlowMgmtKey *key)
virtual FlowMgmtEntry * Allocate(const FlowMgmtKey *key)=0
FlowMgmtEntry * Find(FlowMgmtKey *key)
static bool AddFlowMgmtKey(FlowMgmtKeyTree *tree, FlowMgmtKey *key)
virtual bool RetryDelete(FlowMgmtKey *key)
virtual bool OperEntryChange(const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool OperEntryAdd(const FlowMgmtRequest *req, FlowMgmtKey *key)
bool TryDelete(FlowMgmtKey *key, FlowMgmtEntry *entry)
virtual bool Add(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
virtual void RemoveEntry(Tree::iterator it)
Agent * agent() const
Definition: flow_table.h:208
bool HandleNhChange(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
bool RecomputeCoveringRouteEntry(FlowMgmtManager *mgr, InetRouteFlowMgmtKey *covering_route, InetRouteFlowMgmtKey *key)
bool RouteNHChangeEvent(const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool OperEntryAdd(const FlowMgmtRequest *req, FlowMgmtKey *key)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
void DelFromLPMTree(InetRouteFlowMgmtKey *key)
bool RecomputeCoveringRoute(InetRouteFlowMgmtKey *covering_route, InetRouteFlowMgmtKey *key)
bool HasVrfFlows(uint32_t vrf_id, Agent::RouteTableType type)
virtual bool OperEntryDelete(const FlowMgmtRequest *req, FlowMgmtKey *key)
InetRouteFlowMgmtKey * LPM(const InetRouteFlowMgmtKey *key)
void AddToLPMTree(InetRouteFlowMgmtKey *key)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree, uint32_t vrf, const IpAddress &ip, uint8_t plen)
uint64_t flow_created() const
uint64_t flow_aged() const
void InsertEntry(FlowMgmtKey *key, FlowMgmtEntry *entry)
void RemoveEntry(Tree::iterator it)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
void InterfaceFlowCount(const Interface *itf, uint64_t *created, uint64_t *aged, uint32_t *active_flows)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
const boost::uuids::uuid & GetUuid() const
Definition: interface.h:116
static const MacAddress & ZeroMac()
Definition: mac_address.h:159
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
uint32_t vrf_id() const
virtual bool OperEntryDelete(const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool OperEntryAdd(const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool Delete(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
void SetDBEntry(const FlowMgmtRequest *req, FlowMgmtKey *key)
Definition: vn.h:152
uint32_t ingress_flow_count() const
uint32_t egress_flow_count() const
void RemoveEntry(Tree::iterator it)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
std::mutex mutex_
void InsertEntry(FlowMgmtKey *key, FlowMgmtEntry *entry)
void VnFlowCounters(const VnEntry *vn, uint32_t *ingress_flow_count, uint32_t *egress_flow_count)
FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
Definition: vrf.h:90
static const uint32_t kInvalidIndex
Definition: vrf.h:92
const uint32_t vrf_id() const
Definition: vrf.h:103
bool AllRouteTablesEmpty() const
Definition: vrf.cc:556
virtual void FreeNotify(FlowMgmtKey *key, uint32_t gen_id)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
void DeleteDefaultRoute(const VrfEntry *vrf)
virtual bool OperEntryAdd(const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool OperEntryDelete(const FlowMgmtRequest *req, FlowMgmtKey *key)
void RetryDelete(uint32_t vrf_id)
virtual FlowMgmtEntry * Allocate(const FlowMgmtKey *key)
Definition: vrf.h:272
VrfEntry * FindVrfFromId(size_t index)
Definition: vrf.cc:885
std::list< MatchAclParams > MatchAclParamsList
Definition: flow_entry.h:221
std::map< FlowMgmtKey *, FlowMgmtKeyNode *, FlowMgmtKeyCmp > FlowMgmtKeyTree
uint8_t type
Definition: load_balance.h:2
map< int, int > FlowRouteRefMap
Definition: pkt_flow_info.h:17
MacAddress smac
Definition: flow_entry.h:293
uint32_t src_policy_vrf
Definition: flow_entry.h:328
uint8_t rpf_plen
Definition: flow_entry.h:354
uint32_t src_policy_plen
Definition: flow_entry.h:329
uint32_t acl_assigned_vrf_index_
Definition: flow_entry.h:359
FlowRouteRefMap flow_dest_plen_map
Definition: flow_entry.h:344
uint32_t flow_dest_vrf
Definition: flow_entry.h:308
uint32_t dst_policy_vrf
Definition: flow_entry.h:330
uint32_t rpf_vrf
Definition: flow_entry.h:353
FlowRouteRefMap flow_source_plen_map
Definition: flow_entry.h:343
uint32_t dst_policy_plen
Definition: flow_entry.h:331
uint32_t flow_source_vrf
Definition: flow_entry.h:307
uint8_t source_plen
Definition: flow_entry.h:334
uint8_t dest_plen
Definition: flow_entry.h:335
IpAddress src_addr
Definition: flow_entry.h:214
IpAddress dst_addr
Definition: flow_entry.h:215
SessionPolicy sg_policy
Definition: flow_entry.h:265
SessionPolicy aps_policy
Definition: flow_entry.h:266
MatchAclParamsList m_mirror_acl_l
Definition: flow_entry.h:269
MatchAclParamsList m_vrf_assign_acl_l
Definition: flow_entry.h:275
SessionPolicy fwaas_policy
Definition: flow_entry.h:267
MatchAclParamsList m_out_acl_l
Definition: flow_entry.h:262
MatchAclParamsList m_out_mirror_acl_l
Definition: flow_entry.h:272
MatchAclParamsList m_acl_l
Definition: flow_entry.h:259
MatchAclParamsList m_reverse_out_acl_l
Definition: flow_entry.h:241
MatchAclParamsList m_reverse_acl_l
Definition: flow_entry.h:237
MatchAclParamsList m_acl_l
Definition: flow_entry.h:229
MatchAclParamsList m_out_acl_l
Definition: flow_entry.h:233