OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
flow_mgmt_dbclient.cc
Go to the documentation of this file.
2 #include "pkt/flow_mgmt.h"
4 #include "oper/ecmp.h"
5 #include <oper/tunnel_nh.h>
6 
9  (boost::bind(&FlowMgmtDbClient::AclNotify, this, _1, _2));
10 
12  (boost::bind(&FlowMgmtDbClient::InterfaceNotify, this, _1, _2));
13 
15  (boost::bind(&FlowMgmtDbClient::VnNotify, this, _1, _2));
16 
18  (boost::bind(&FlowMgmtDbClient::VrfNotify, this, _1, _2));
19 
21  (boost::bind(&FlowMgmtDbClient::NhNotify, this, _1, _2));
22  return;
23 }
24 
32 }
33 
35  agent_(agent),
36  mgr_(mgr),
37  acl_listener_id_(),
38  interface_listener_id_(),
39  vn_listener_id_(),
40  vm_listener_id_(),
41  vrf_listener_id_(),
42  nh_listener_id_() {
43 }
44 
46 }
47 
48 void FlowMgmtDbClient::AddEvent(const DBEntry *entry, FlowMgmtState *state) {
49  mgr_->AddDBEntryEvent(entry, state->gen_id_);
50 }
51 
53  state->gen_id_++;
54  state->deleted_ = true;
55  mgr_->DeleteDBEntryEvent(entry, state->gen_id_);
56 }
57 
59  FlowMgmtState *state) {
60  mgr_->DeleteDBEntryEvent(entry, state->gen_id_);
61 }
62 
64  mgr_->ChangeDBEntryEvent(entry, state->gen_id_);
65 }
66 
68  FlowMgmtState *state) {
69  mgr_->RouteNHChangeEvent(entry, state->gen_id_);
70 }
71 
73 // Interface notification handler
75 static DBState *ValidateGenId(DBTableBase *table, DBEntry *entry,
76  DBTableBase::ListenerId id, uint32_t gen_id) {
78  static_cast<FlowMgmtDbClient::FlowMgmtState *>(entry->GetState(table,
79  id));
80  if (state == NULL)
81  return NULL;
82 
83  // If DBEntry is re-added in meanwhile, we do not want to free DBState
84  if (state->deleted_ == false)
85  return NULL;
86 
87  if (state->gen_id_ > gen_id)
88  return NULL;
89 
90  return state;
91 }
92 
93 void FlowMgmtDbClient::FreeInterfaceState(Interface *intf, uint32_t gen_id) {
94  VmInterface *vm_port = dynamic_cast<VmInterface *>(intf);
95  if (vm_port == NULL)
96  return;
97 
98  DBState *state = ValidateGenId(intf->get_table(), intf,
99  interface_listener_id_, gen_id);
100  if (state == NULL)
101  return;
102 
104  delete state;
105 }
106 
108  Interface *intf = static_cast<Interface *>(e);
109  if (intf->type() != Interface::VM_INTERFACE) {
110  return;
111  }
112 
113  VmInterface *vm_port = static_cast<VmInterface *>(intf);
114  if (vm_port->device_type() == VmInterface::VMI_ON_LR)
115  return;
116 
117  const VnEntry *new_vn = vm_port->vn();
118 
119  VmIntfFlowHandlerState *state = static_cast<VmIntfFlowHandlerState *>
120  (e->GetState(part->parent(), interface_listener_id_));
121  if (intf->IsDeleted()) {
122  if (state) {
123  DeleteEvent(vm_port, state);
124  }
125  return;
126  }
127 
128  const VmInterface::SecurityGroupEntryList &new_sg_l = vm_port->sg_list();
129  bool changed = false;
130 
131  if (state == NULL) {
132  state = new VmIntfFlowHandlerState(NULL);
133  e->SetState(part->parent(), interface_listener_id_, state);
134  // Force change for first time
135  state->policy_ = vm_port->policy_enabled();
136  state->sg_l_ = new_sg_l;
137  state->vn_ = new_vn;
138  state->vrf_assign_acl_ = vm_port->vrf_assign_acl();
139  state->is_vn_qos_config_ = vm_port->is_vn_qos_config();
140  state->qos_config_ = vm_port->qos_config();
141  state->fw_policy_list_ = vm_port->fw_policy_list();
142  state->fwaas_fw_policy_list_ = vm_port->fwaas_fw_policy_list();
143  if (vm_port->forwarding_vrf()) {
144  state->forwarding_vrf_id_ = vm_port->forwarding_vrf()->vrf_id();
145  }
146  changed = true;
147  } else {
148  if (state->deleted_) {
149  state->deleted_ = false;
150  changed = true;
151  }
152 
153  if (state->vn_.get() != new_vn) {
154  changed = true;
155  state->vn_ = new_vn;
156  }
157  if (state->policy_ != vm_port->policy_enabled()) {
158  changed = true;
159  state->policy_ = vm_port->policy_enabled();
160  }
161  if (state->sg_l_.list_ != new_sg_l.list_) {
162  changed = true;
163  state->sg_l_ = new_sg_l;
164  }
165  if (state->vrf_assign_acl_.get() != vm_port->vrf_assign_acl()) {
166  changed = true;
167  state->vrf_assign_acl_ = vm_port->vrf_assign_acl();
168  }
169  if (state->is_vn_qos_config_ != vm_port->is_vn_qos_config()) {
170  state->is_vn_qos_config_ = vm_port->is_vn_qos_config();
171  changed = true;
172  }
173  if (state->qos_config_.get() != vm_port->qos_config()) {
174  state->qos_config_ = vm_port->qos_config();
175  changed = true;
176  }
177 
178  if (state->fw_policy_list_ != vm_port->fw_policy_list()) {
179  state->fw_policy_list_ = vm_port->fw_policy_list();
180  changed = true;
181  }
182 
183  if (state->fwaas_fw_policy_list_ != vm_port->fwaas_fw_policy_list()) {
184  state->fwaas_fw_policy_list_ = vm_port->fwaas_fw_policy_list();
185  changed = true;
186  }
187 
188  uint32_t forwarding_vrf_id = VrfEntry::kInvalidIndex;
189  if (vm_port->forwarding_vrf()) {
190  forwarding_vrf_id = vm_port->forwarding_vrf()->vrf_id();
191  }
192 
193  if (state->forwarding_vrf_id_ != forwarding_vrf_id) {
194  state->forwarding_vrf_id_ = forwarding_vrf_id;
195  DeleteAllFlow(vm_port, state);
196  changed = true;
197  }
198  }
199 
200  if (changed) {
201  AddEvent(vm_port, state);
202  }
203 }
204 
206 // VN notification handler
208 void FlowMgmtDbClient::FreeVnState(VnEntry *vn, uint32_t gen_id) {
209  DBState *state = ValidateGenId(vn->get_table(), vn, vn_listener_id_,
210  gen_id);
211  if (state == NULL)
212  return;
213 
215  delete state;
216 }
217 
219  // Add/Delete Acl:
220  // Resync all Vn flows with new VN network policies
221  VnEntry *vn = static_cast<VnEntry *>(e);
222  VnFlowHandlerState *state = static_cast<VnFlowHandlerState *>
223  (e->GetState(part->parent(), vn_listener_id_));
224  AclDBEntryConstRef acl = NULL;
225  AclDBEntryConstRef macl = NULL;
226  AclDBEntryConstRef mcacl = NULL;
227  bool enable_rpf = true;
228  bool flood_unknown_unicast = false;
229 
230  if (vn->IsDeleted()) {
231  if (state) {
232  DeleteEvent(vn, state);
233  }
234  return;
235  }
236 
237  bool changed = false;
238  if (state != NULL) {
239  acl = state->acl_;
240  macl = state->macl_;
241  mcacl = state->mcacl_;
242  enable_rpf = state->enable_rpf_;
243  flood_unknown_unicast = state->flood_unknown_unicast_;
244  }
245 
246  const AclDBEntry *new_acl = vn->GetAcl();
247  const AclDBEntry *new_macl = vn->GetMirrorAcl();
248  const AclDBEntry *new_mcacl = vn->GetMirrorCfgAcl();
249  bool new_enable_rpf = vn->enable_rpf();
250  bool new_flood_unknown_unicast = vn->flood_unknown_unicast();
251 
252  if (state == NULL) {
253  state = new VnFlowHandlerState(new_acl, new_macl, new_mcacl,
254  new_enable_rpf,
255  new_flood_unknown_unicast);
256  e->SetState(part->parent(), vn_listener_id_, state);
257  changed = true;
258  }
259 
260  if (acl != new_acl || macl != new_macl || mcacl !=new_mcacl ||
261  enable_rpf != new_enable_rpf ||
262  flood_unknown_unicast != new_flood_unknown_unicast) {
263  state->acl_ = new_acl;
264  state->macl_ = new_macl;
265  state->mcacl_ = new_mcacl;
266  state->enable_rpf_ = new_enable_rpf;
267  state->flood_unknown_unicast_ = new_flood_unknown_unicast;
268  changed = true;
269  }
270 
271  if (state->deleted_) {
272  state->deleted_ = false;
273  changed = true;
274  }
275 
276  if (changed) {
277  AddEvent(vn, state);
278  }
279 }
280 
282 // ACL notification handler
284 void FlowMgmtDbClient::FreeAclState(AclDBEntry *acl, uint32_t gen_id) {
285  DBState *state = ValidateGenId(acl->get_table(), acl, acl_listener_id_,
286  gen_id);
287  if (state == NULL)
288  return;
289 
290  acl->ClearState(acl->get_table(), acl_listener_id_);
291  delete state;
292 }
293 
295  AclDBEntry *acl = static_cast<AclDBEntry *>(e);
296  AclFlowHandlerState *state =
297  static_cast<AclFlowHandlerState *>(e->GetState(part->parent(),
299  if (e->IsDeleted()) {
300  if (state) {
301  DeleteEvent(acl, state);
302  }
303  return;
304  }
305 
306  if (!state) {
307  state = new AclFlowHandlerState();
308  e->SetState(part->parent(), acl_listener_id_, state);
309  }
310  state->deleted_ = false;
311  AddEvent(acl, state);
312 }
313 
315 // NH notification handler
317 void FlowMgmtDbClient::FreeNhState(NextHop *nh, uint32_t gen_id) {
318  DBState *state = ValidateGenId(nh->get_table(), nh, nh_listener_id_,
319  gen_id);
320  if (state == NULL)
321  return;
322 
324  delete state;
325 }
326 
328  NextHop *nh = static_cast<NextHop *>(e);
329  NhFlowHandlerState *state =
330  static_cast<NhFlowHandlerState *>(e->GetState(part->parent(),
331  nh_listener_id_));
332  bool is_tunnel_nh = false;
333  bool changed = false;
334  uint8_t curr_valid_encap_size = 0;
335  uint8_t new_valid_encap_size = 0;
336  if (nh->GetType() == NextHop::TUNNEL && agent_->is_l3mh()) {
337  const TunnelNH *tunnel_nh =
338  dynamic_cast<const TunnelNH *>(nh);
339  if (tunnel_nh) {
340  is_tunnel_nh = true;
341  TunnelNH::EncapDataList encap_list = tunnel_nh->GetEncapDataList();
342  for (uint8_t i = 0; i < tunnel_nh->GetEncapDataList().size(); i++) {
343  if (encap_list[i].get()->valid_)
344  new_valid_encap_size++;
345  }
346  }
347  }
348 
349  if (nh->IsDeleted()) {
350  if (state) {
351  DeleteEvent(nh, state);
352  }
353  return;
354  }
355 
356  if (state != NULL && is_tunnel_nh && agent_->is_l3mh() ) {
357  curr_valid_encap_size = state->valid_encap_size_;
358  }
359 
360  if (!state) {
361  state = new NhFlowHandlerState(new_valid_encap_size);
362  nh->SetState(part->parent(), nh_listener_id_, state);
363  changed = true;
364  }
365 
366  if (is_tunnel_nh && agent_->is_l3mh() && new_valid_encap_size != curr_valid_encap_size ) {
367  state->valid_encap_size_ = new_valid_encap_size;
368  changed = true;
369  }
370 
371  if (state->deleted_) {
372  state->deleted_ = false;
373  changed = true;
374  }
375 
376  if (changed) {
377  AddEvent(nh, state);
378  }
379 }
380 
382 // VRF Notification handlers
384 void FlowMgmtDbClient::FreeVrfState(VrfEntry *vrf, uint32_t gen_id) {
385  if (vrf->IsDeleted() == false)
386  return;
387 
388  VrfFlowHandlerState *state = static_cast<VrfFlowHandlerState *>
389  (ValidateGenId(vrf->get_table(), vrf, vrf_listener_id_, gen_id));
390  if (state == NULL)
391  return;
392  if (state->Unregister(vrf)) {
393  vrf->ClearState(vrf->get_table(), vrf_listener_id_);
394  delete state;
395  }
396 }
397 
399  // Register to the Inet4 Unicast Table
400  InetUnicastAgentRouteTable *inet_table =
401  static_cast<InetUnicastAgentRouteTable *>
402  (vrf->GetInet4UnicastRouteTable());
403  if (inet_table) {
404  if (inet_table->Size() != 0)
405  return false;
407  inet_table->Unregister(inet_listener_id_);
408  FLOW_TRACE(RouteTableListener,
409  "ROUTE-TABLE-UNREGISTER",
410  vrf->GetName(),
411  inet_table->GetTableName(),
414  }
415  }
416 
417  inet_table = static_cast<InetUnicastAgentRouteTable *>
418  (vrf->GetInet6UnicastRouteTable());
419  if (inet_table) {
420  if (inet_table->Size() != 0)
421  return false;
423  inet_table->Unregister(inet6_listener_id_);
424  FLOW_TRACE(RouteTableListener,
425  "ROUTE-TABLE-UNREGISTER",
426  vrf->GetName(),
427  inet_table->GetTableName(),
430  }
431  }
432 
433  // Register to the Bridge Unicast Table
434  BridgeAgentRouteTable *bridge_table =
435  static_cast<BridgeAgentRouteTable *>
436  (vrf->GetBridgeRouteTable());
437  if (bridge_table) {
438  if (bridge_table->Size() != 0)
439  return false;
441  bridge_table->Unregister(bridge_listener_id_);
442  FLOW_TRACE(RouteTableListener,
443  "ROUTE-TABLE-UNREGISTER",
444  vrf->GetName(),
445  bridge_table->GetTableName(),
448  }
449  }
450 
451  return true;
452 }
453 
455  VrfEntry *vrf) {
456  // Register to the Inet4 Unicast Table
457  InetUnicastAgentRouteTable *inet_table =
458  static_cast<InetUnicastAgentRouteTable *>
459  (vrf->GetInet4UnicastRouteTable());
460 
461  inet_listener_id_ =
462  inet_table->Register(boost::bind(&FlowMgmtDbClient::RouteNotify, client,
463  this, Agent::INET4_UNICAST, _1, _2));
464  FLOW_TRACE(RouteTableListener,
465  "ROUTE-TABLE-REGISTER",
466  vrf->GetName(),
467  inet_table->GetTableName(),
468  inet_listener_id_);
469 
470  inet_table = static_cast<InetUnicastAgentRouteTable *>
471  (vrf->GetInet6UnicastRouteTable());
472  inet6_listener_id_ =
473  inet_table->Register(boost::bind(&FlowMgmtDbClient::RouteNotify, client,
474  this, Agent::INET6_UNICAST, _1, _2));
475  FLOW_TRACE(RouteTableListener,
476  "ROUTE-TABLE-REGISTER",
477  vrf->GetName(),
478  inet_table->GetTableName(),
479  inet6_listener_id_);
480 
481  // Register to the Bridge Unicast Table
482  BridgeAgentRouteTable *bridge_table =
483  static_cast<BridgeAgentRouteTable *>
484  (vrf->GetBridgeRouteTable());
485  bridge_listener_id_ =
486  bridge_table->Register(boost::bind(&FlowMgmtDbClient::RouteNotify,
487  client, this, Agent::BRIDGE, _1,
488  _2));
489  FLOW_TRACE(RouteTableListener,
490  "ROUTE-TABLE-REGISTER",
491  vrf->GetName(),
492  bridge_table->GetTableName(),
493  bridge_listener_id_);
494 }
495 
497  VrfEntry *vrf = static_cast<VrfEntry *>(e);
498  VrfFlowHandlerState *state = static_cast<VrfFlowHandlerState *>
499  (e->GetState(part->parent(), vrf_listener_id_));
500  if (vrf->IsDeleted()) {
501  if (state ) {
502  state->deleted_ = true;
503  DeleteEvent(vrf, state);
504  }
505  return;
506  }
507  if (state == NULL) {
508  state = new VrfFlowHandlerState();
509  state->Register(this, vrf);
510  vrf->SetState(part->parent(), vrf_listener_id_, state);
511  AddEvent(vrf, state);
512  }
513  state->deleted_ = false;
514  return;
515 }
516 
518 // FlowTableRequest handlers for Routes
521  const SecurityGroupList &sg_list, bool deleted) {
522  std::vector<std::string> vn_list;
523  if (path) {
524  path->GetDestinationVnList(&vn_list);
525  }
526  InetUnicastRouteEntry *inet = dynamic_cast<InetUnicastRouteEntry *>(entry);
527  if (inet) {
529  inet->vrf()->GetName(),
530  inet->prefix_address().to_string(),
531  inet->prefix_length(),
532  vn_list,
533  inet->IsDeleted(),
534  deleted,
535  sg_list.size(),
536  sg_list);
537  }
538 
539  BridgeRouteEntry *bridge = dynamic_cast<BridgeRouteEntry *>(entry);
540  if (bridge) {
542  bridge->vrf()->GetName(),
543  bridge->prefix_address().ToString(),
544  bridge->prefix_length(),
545  vn_list,
546  bridge->IsDeleted(),
547  deleted,
548  sg_list.size(),
549  sg_list);
550  }
551 }
552 
553 void FlowMgmtDbClient::FreeRouteState(AgentRoute *route, uint32_t gen_id) {
554  if (route->IsDeleted() == false)
555  return;
556 
557  VrfEntry *vrf = route->vrf();
558  VrfFlowHandlerState *vrf_state = static_cast<VrfFlowHandlerState *>
559  (vrf->GetState(vrf->get_table(), vrf_listener_id_));
560  if (vrf_state == NULL)
561  return;
562 
564  if (dynamic_cast<InetUnicastRouteEntry *>(route)) {
565  if (route->GetTableType() == Agent::INET4_UNICAST)
566  id = vrf_state->inet_listener_id_;
567  else
568  id = vrf_state->inet6_listener_id_;
569  } else if (dynamic_cast<BridgeRouteEntry *>(route)) {
570  id = vrf_state->bridge_listener_id_;
571  } else {
572  return;
573  }
574 
575  DBState *state = ValidateGenId(route->get_table(), route, id, gen_id);
576  if (state == NULL)
577  return;
578 
579  route->ClearState(route->get_table(), id);
580  delete state;
581 }
582 
584  RouteFlowHandlerState *state) {
585  bool ret = false;
587 
588  //Maintain a list of interface to fixed-ip mapping for
589  //a given route, we need this map because there can be
590  //multiple path from different local vm path peer.
591  //If the route has fixed-ip change then all the the flows
592  //dependent on this route will be reevaluated.
593  for(Route::PathList::const_iterator it = rt->GetPathList().begin();
594  it != rt->GetPathList().end(); it++) {
595  const AgentPath *path = static_cast<const AgentPath *>(it.operator->());
596  const Peer *peer = path->peer();
597  if (peer && peer->GetType() != Peer::LOCAL_VM_PORT_PEER) {
598  continue;
599  }
600 
601  if (path->nexthop() == NULL ||
602  path->nexthop()->GetType() != NextHop::INTERFACE) {
603  continue;
604  }
605 
606  const InterfaceNH *nh = static_cast<InterfaceNH *>(path->nexthop());
607  InterfaceConstRef intf = nh->GetInterface();
608 
609  IpAddress new_fixed_ip = path->GetFixedIp();
610  if (new_fixed_ip == Ip4Address(0)) {
611  continue;
612  }
613 
614  new_map.insert(RouteFlowHandlerState::FixedIpEntry(intf, new_fixed_ip));
615 
616  RouteFlowHandlerState::FixedIpMap::const_iterator old_it =
617  state->fixed_ip_map_.find(intf);
618  if (old_it != state->fixed_ip_map_.end()) {
619  if (new_fixed_ip != old_it->second) {
620  ret = true;
621  }
622  }
623  }
624 
625  //Check if any path has been deleted
626  RouteFlowHandlerState::FixedIpMap::const_iterator old_it =
627  state->fixed_ip_map_.begin();
628  for (;old_it != state->fixed_ip_map_.end(); old_it++) {
629  if (new_map.find(old_it->first) == new_map.end()) {
630  ret = true;
631  break;
632  }
633  }
634 
635  state->fixed_ip_map_ = new_map;
636  return ret;
637 }
638 
641  DBTablePartBase *partition, DBEntryBase *e) {
642  DBTableBase::ListenerId id = vrf_state->GetListenerId(type);
643  RouteFlowHandlerState *state =
644  static_cast<RouteFlowHandlerState *>(e->GetState(partition->parent(),
645  id));
646  AgentRoute *route = static_cast<AgentRoute *>(e);
647  const AgentPath *path = route->GetActivePath();
648  SecurityGroupList new_sg_l;
649  // Get new sg-list. Sort, the sg-list to aid in comparison
650  if (path) {
651  new_sg_l = route->GetActivePath()->sg_list();
652  sort(new_sg_l.begin(), new_sg_l.end());
653  }
654  TraceMsg(route, path, new_sg_l, vrf_state->deleted_);
655 
656  if (route->IsDeleted()) {
657  if (state) {
658  DeleteEvent(route, state);
659  }
660  return;
661  }
662 
663  if (vrf_state->deleted_) {
664  // ignore route add/change for delete notified VRF.
665  return;
666  }
667 
668  if (route->is_multicast()) {
669  return;
670  }
671 
672  bool new_route = false;
673  if (state == NULL) {
674  state = new RouteFlowHandlerState();
675  route->SetState(partition->parent(), id, state);
676  AddEvent(route, state);
677  new_route = true;
678  } else {
679  if (state->deleted_) {
680  state->deleted_ = false;
681  new_route = true;
682  }
683  }
684 
685  bool changed = false;
686  bool inet_rt_nh_changed = false;
687  // Handle SG change
688  if (state->sg_l_ != new_sg_l) {
689  state->sg_l_ = new_sg_l;
690  changed = true;
691  }
692 
693  InetUnicastRouteEntry *inet_route =
694  dynamic_cast<InetUnicastRouteEntry *>(route);
695  //Trigger RPF NH sync, if active nexthop changes
696  const NextHop *active_nh = route->GetActiveNextHop();
697  const NextHop *local_nh = NULL;
698  if (active_nh && (active_nh->GetType() == NextHop::COMPOSITE)) {
699  //If destination is ecmp, all remote flow would
700  //have RPF NH set to that local component NH
701  local_nh = EcmpData::GetLocalNextHop(route);
702  }
703 
704  if ((state->active_nh_ != active_nh) || (state->local_nh_ != local_nh)) {
705  state->active_nh_ = active_nh;
706  state->local_nh_ = local_nh;
707  /* NH change can result in change of DMAC for the following routes, if
708  * they point to L2 flows.So we need to delete these L2 flows to trigger
709  * packet to be trapped again for flows which will have the new DMAC.
710  * The InetRoutes whose NH change has to be tracked are
711  * Ipv4 InetRoutes which have prefix < 32
712  * Ipv6 InetRoutes which have prefix < 128
713  */
714  if (inet_route) {
715  uint8_t plen = inet_route->prefix_length();
716  if ((inet_route->prefix_address().is_v4() && plen < 32) ||
717  (inet_route->prefix_address().is_v6() && plen < 128)) {
718  inet_rt_nh_changed = true;
719  } else {
720  new_route = true;
721  }
722  } else {
723  new_route = true;
724  }
725  }
726 
727  if (HandleTrackingIpChange(route, state)) {
728  //Tracking IP change can result in flow change
729  //i.e in case of NAT new reverse flow might be
730  //created, hence enqueue a ADD event so that flow will
731  //be reevaluated.
732  new_route = true;
733  }
734 
735  if (state->ecmp_load_balance_ != path->ecmp_load_balance()) {
736  state->ecmp_load_balance_ = path->ecmp_load_balance();
737  changed = true;
738  }
739 
740  if (state->tags_l_ != path->tag_list()) {
741  state->tags_l_ = path->tag_list();
742  changed = true;
743  }
744 
745  if (state->tunnel_bmap_ != path->tunnel_bmap()) {
746  state->tunnel_bmap_ = path->tunnel_bmap();
747  changed = true;
748  }
749 
750  if (new_route == true) {
751  AddEvent(route, state);
752  } else if (inet_rt_nh_changed == true) {
753  RouteNHChangeEvent(route, state);
754  } else if (changed == true) {
755  ChangeEvent(route, state);
756  }
757 }
758 
760 // FlowTableRequest message handler
762 bool FlowMgmtDbClient::FreeDBState(const DBEntry *entry, uint32_t gen_id) {
763  if (dynamic_cast<const Interface *>(entry)) {
764  DBTable *table = agent_->interface_table();
765  Interface *intf = static_cast<Interface *>(table->Find(entry));
766  FreeInterfaceState(intf, gen_id);
767  return true;
768  }
769 
770  if (dynamic_cast<const VnEntry *>(entry)) {
771  DBTable *table = agent_->vn_table();
772  VnEntry *vn = static_cast<VnEntry *>(table->Find(entry));
773  FreeVnState(vn, gen_id);
774  return true;
775  }
776 
777  if (dynamic_cast<const AclDBEntry *>(entry)) {
778  DBTable *table = agent_->acl_table();
779  AclDBEntry *acl = static_cast<AclDBEntry *> (table->Find(entry));
780  FreeAclState(acl, gen_id);
781  return true;
782  }
783 
784  if (dynamic_cast<const NextHop *>(entry)) {
785  DBTable *table = agent_->nexthop_table();
786  NextHop *nh = static_cast<NextHop *> (table->Find(entry));
787  FreeNhState(nh, gen_id);
788  return true;
789  }
790 
791  if (dynamic_cast<const VrfEntry *>(entry)) {
792  DBTable *table = agent_->vrf_table();
793  VrfEntry *vrf = static_cast<VrfEntry *> (table->Find(entry));
794  FreeVrfState(vrf, gen_id);
795  return true;
796  }
797 
798  if (dynamic_cast<const AgentRoute *>(entry)) {
799  VrfEntry *vrf = (static_cast<const AgentRoute *>(entry))->vrf();
800  AgentRoute *rt = NULL;
801  if (dynamic_cast<const InetUnicastRouteEntry *>(entry)) {
802  DBTable *table = NULL;
803  if ((dynamic_cast<const AgentRoute *>(entry))->GetTableType()
805  table = vrf->GetInet4UnicastRouteTable();
806  else
807  table = vrf->GetInet6UnicastRouteTable();
808  rt = static_cast<AgentRoute *>(table->Find(entry));
809  } else {
810  DBTable *table = vrf->GetBridgeRouteTable();
811  rt = static_cast<AgentRoute *>(table->Find(entry));
812  }
813  FreeRouteState(rt, gen_id);
814  return true;
815  }
816 
817  assert(0);
818  return true;
819 }
uint8_t prefix_length() const
!
boost::intrusive_ptr< const AclDBEntry > AclDBEntryConstRef
Definition: agent.h:143
const Interface * GetInterface() const
Definition: nexthop.h:1293
void DeleteDBEntryEvent(const DBEntry *entry, uint32_t gen_id)
Definition: flow_mgmt.cc:216
FlowMgmtDbClient(Agent *agent, FlowMgmtManager *mgr)
Type type() const
Definition: interface.h:112
bool enable_rpf() const
Definition: vn.h:198
std::pair< InterfaceConstRef, IpAddress > FixedIpEntry
const AgentQosConfig * qos_config() const
Definition: interface.h:140
DBTableBase::ListenerId inet6_listener_id_
Definition: vrf.h:86
const TagList & tag_list() const
Definition: agent_path.h:249
static const NextHop * GetLocalNextHop(const AgentRoute *rt)
Definition: ecmp.cc:496
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
Definition: db_entry.cc:37
void FreeVrfState(VrfEntry *vrf, uint32_t gen_id)
const AclDBEntry * GetAcl() const
Definition: vn.h:167
void DeleteEvent(const DBEntry *entry, FlowMgmtState *state)
NextHopTable * nexthop_table() const
Definition: agent.h:475
DBTableBase * get_table() const
Definition: db_entry.cc:119
void InterfaceNotify(DBTablePartBase *part, DBEntryBase *e)
VmInterface::DeviceType device_type() const
bool is_l3mh() const
Definition: agent.h:725
static DBState * ValidateGenId(DBTableBase *table, DBEntry *entry, DBTableBase::ListenerId id, uint32_t gen_id)
bool IsDeleted() const
Definition: db_entry.h:49
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
Definition: db_entry.cc:22
boost::asio::ip::address IpAddress
Definition: address.h:13
std::vector< int > SecurityGroupList
Definition: agent.h:201
int ListenerId
Definition: db_table.h:62
bool is_multicast() const
Definition: agent_route.h:274
void FreeNhState(NextHop *nh, uint32_t gen_id)
virtual std::string GetTableName() const
Definition: bridge_route.h:20
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
Definition: vrf.cc:319
DBTableBase * parent()
InterfaceTable * interface_table() const
Definition: agent.h:465
void Register(FlowMgmtDbClient *client, VrfEntry *vrf)
VnTable * vn_table() const
Definition: agent.h:495
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable() const
Definition: vrf.cc:338
const string & GetName() const
Definition: vrf.h:100
void ChangeDBEntryEvent(const DBEntry *entry, uint32_t gen_id)
Definition: flow_mgmt.cc:209
void FreeRouteState(AgentRoute *route, uint32_t gen_id)
Type GetType() const
Definition: nexthop.h:405
Base class for all Route entries in agent.
Definition: agent_route.h:224
DBTableBase::ListenerId bridge_listener_id_
void Unregister(ListenerId listener)
Definition: db_table.cc:186
void DeleteAllFlow(const DBEntry *entry, FlowMgmtState *state)
std::string ToString() const
Definition: mac_address.cc:53
bool flood_unknown_unicast() const
Definition: vn.h:199
void RouteNHChangeEvent(const DBEntry *entry, uint32_t gen_id)
Definition: flow_mgmt.cc:223
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
Definition: db_table.cc:181
const Type GetType() const
Definition: peer.h:87
void AclNotify(DBTablePartBase *part, DBEntryBase *e)
const AgentPath * GetActivePath() const
Definition: agent_route.cc:876
NextHop * nexthop() const
Definition: agent_path.cc:87
virtual Agent::RouteTableType GetTableType() const =0
virtual size_t Size() const
Definition: db_table.cc:507
bool HandleTrackingIpChange(const AgentRoute *rt, RouteFlowHandlerState *state)
DBTableBase::ListenerId GetListenerId(Agent::RouteTableType type)
void Unregister(FlowMgmtDbClient *client, VrfEntry *vrf)
const SecurityGroupEntryList & sg_list() const
uint8_t type
Definition: load_balance.h:109
Definition: agent.h:358
VmInterface::SecurityGroupEntryList sg_l_
const FirewallPolicyList & fwaas_fw_policy_list() const
DBTableBase::ListenerId vn_listener_id_
const NextHop * GetActiveNextHop() const
Definition: agent_route.cc:881
const AclDBEntry * GetMirrorAcl() const
Definition: vn.h:168
DBTableBase::ListenerId vm_listener_id_
DBTableBase::ListenerId interface_listener_id_
const Peer * peer() const
Definition: agent_path.h:263
void VnNotify(DBTablePartBase *part, DBEntryBase *e)
boost::intrusive_ptr< const Interface > InterfaceConstRef
Definition: agent.h:51
AgentRouteTable * GetBridgeRouteTable() const
Definition: vrf.cc:334
#define FLOW_TRACE(obj,...)
Definition: flow_mgmt.h:377
const VnEntry * vn() const
bool policy_enabled() const
Definition: peer.h:44
const uint32_t vrf_id() const
Definition: vrf.h:99
void AddDBEntryEvent(const DBEntry *entry, uint32_t gen_id)
Definition: flow_mgmt.cc:203
void ClearState(DBTableBase *tbl_base, ListenerId listener)
Definition: db_entry.cc:73
const AclDBEntry * vrf_assign_acl() const
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Definition: agent_route.h:375
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
void FreeVnState(VnEntry *vn, uint32_t gen_id)
Definition: vn.h:151
VrfTable * vrf_table() const
Definition: agent.h:485
bool FreeDBState(const DBEntry *entry, uint32_t gen_id)
void FreeAclState(AclDBEntry *acl, uint32_t gen_id)
void VrfNotify(DBTablePartBase *part, DBEntryBase *e)
const IpAddress & GetFixedIp() const
Definition: agent_path.h:362
std::map< InterfaceConstRef, IpAddress > FixedIpMap
virtual string GetTableName() const
const EncapDataList GetEncapDataList() const
Definition: tunnel_nh.h:70
DBTableBase::ListenerId vrf_listener_id_
DBTableBase::ListenerId nh_listener_id_
uint8_t prefix_length() const
The length of L3 IP prefix (if present) associated with this L2 address.
Definition: bridge_route.h:130
bool is_vn_qos_config() const
void FreeInterfaceState(Interface *intf, uint32_t gen_id)
DBTableBase::ListenerId acl_listener_id_
DBTableBase::ListenerId inet_listener_id_
static const int kInvalidId
Definition: db_table.h:64
DBEntry * Find(const DBEntry *entry)
Definition: db_table.cc:469
std::vector< EncapDataPtr > EncapDataList
Definition: tunnel_nh.h:69
static const uint32_t kInvalidIndex
Definition: vrf.h:88
VrfEntry * vrf() const
Definition: agent_route.h:275
void ChangeEvent(const DBEntry *entry, FlowMgmtState *state)
const FirewallPolicyList & fw_policy_list() const
void NhNotify(DBTablePartBase *part, DBEntryBase *e)
VrfEntry * forwarding_vrf() const
void RouteNHChangeEvent(const DBEntry *entry, FlowMgmtState *state)
FlowMgmtManager * mgr_
RouteTableType
Definition: agent.h:415
uint32_t tunnel_bmap() const
Definition: agent_path.h:267
void RouteNotify(VrfFlowHandlerState *vrf_state, Agent::RouteTableType type, DBTablePartBase *partition, DBEntryBase *e)
AclTable * acl_table() const
Definition: agent.h:515
void AddEvent(const DBEntry *entry, FlowMgmtState *state)
void GetDestinationVnList(std::vector< std::string > *vn_list) const
Definition: agent_path.cc:1713
const SecurityGroupList & sg_list() const
Definition: agent_path.h:248
VmTable * vm_table() const
Definition: agent.h:490
Definition: acl.h:92
void TraceMsg(AgentRoute *entry, const AgentPath *path, const SecurityGroupList &sg_list, bool deleted)
const EcmpLoadBalance & ecmp_load_balance() const
Definition: agent_path.h:365
const AclDBEntry * GetMirrorCfgAcl() const
Definition: vn.h:169
const PathList & GetPathList() const
Definition: route.h:46