OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prouter_uve_table.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
3  */
4 
7 #include <uve/agent_uve_base.h>
8 
9 using boost::uuids::nil_uuid;
10 
12  ("ProuterUve", 500));
13 
14 ProuterUveTable::ProuterUveTable(Agent *agent, uint32_t default_intvl)
15  : uve_prouter_map_(), uve_phy_interface_map_(), agent_(agent),
16  physical_device_listener_id_(DBTableBase::kInvalidId),
17  interface_listener_id_(DBTableBase::kInvalidId),
18  pr_timer_last_visited_(nil_uuid()),
19  pr_timer_(TimerManager::CreateTimer
20  (*(agent->event_manager())->io_service(),
21  "ProuterUveTimer",
22  TaskScheduler::GetInstance()->GetTaskId(kTaskDBExclude), 0)),
23  pi_timer_last_visited_(""),
24  pi_timer_(TimerManager::CreateTimer
25  (*(agent->event_manager())->io_service(),
26  "PIUveTimer",
27  TaskScheduler::GetInstance()->GetTaskId(kTaskDBExclude), 0)),
28  li_timer_last_visited_(nil_uuid()),
29  li_timer_(TimerManager::CreateTimer
30  (*(agent->event_manager())->io_service(),
31  "LIUveTimer",
32  TaskScheduler::GetInstance()->GetTaskId(kTaskDBExclude), 0)) {
33 
34  pr_timer_->Start(default_intvl,
35  boost::bind(&ProuterUveTable::TimerExpiry, this));
36  pi_timer_->Start(default_intvl,
37  boost::bind(&ProuterUveTable::PITimerExpiry, this));
38  li_timer_->Start(default_intvl,
39  boost::bind(&ProuterUveTable::LITimerExpiry, this));
40 }
41 
46 }
47 
49  if (timer) {
50  timer->Cancel();
52  }
53 }
54 
56  UveProuterMap::iterator it = uve_prouter_map_.lower_bound
58  if (it == uve_prouter_map_.end()) {
59  pr_timer_last_visited_ = nil_uuid();
60  return true;
61  }
62 
63  uint32_t count = 0;
64  while (it != uve_prouter_map_.end() &&
66  ProuterUveEntry* entry = it->second.get();
67  UveProuterMap::iterator prev = it;
68  it++;
69  count++;
70 
71  if (entry->deleted_) {
72  SendProuterDeleteMsg(entry);
73  if (!entry->renewed_) {
74  uve_prouter_map_.erase(prev);
76  } else {
77  entry->deleted_ = false;
78  entry->renewed_ = false;
79  entry->changed_ = false;
80  SendProuterMsg(entry);
81  }
82  } else if (entry->changed_) {
83  SendProuterMsg(entry);
84  entry->changed_ = false;
85  /* Clear renew flag to be on safer side. Not really required */
86  entry->renewed_ = false;
87  }
88  }
89 
90  if (it == uve_prouter_map_.end()) {
91  pr_timer_last_visited_ = nil_uuid();
93  } else {
94  pr_timer_last_visited_ = it->first;
96  }
97  /* Return true to trigger auto-restart of timer */
98  return true;
99 }
100 
102  UvePhyInterfaceMap::iterator it = uve_phy_interface_map_.lower_bound
104  if (it == uve_phy_interface_map_.end()) {
106  return true;
107  }
108 
109  uint32_t count = 0;
110  while (it != uve_phy_interface_map_.end() &&
112  PhyInterfaceUveEntry* entry = it->second.get();
113  string cfg_name = it->first;
114  UvePhyInterfaceMap::iterator prev = it;
115  it++;
116  count++;
117 
118  if (entry->deleted_) {
120  if (!entry->renewed_) {
121  uve_phy_interface_map_.erase(prev);
122  } else {
123  entry->deleted_ = false;
124  entry->renewed_ = false;
125  entry->changed_ = false;
126  SendPhysicalInterfaceMsg(cfg_name, entry);
127  }
128  } else if (entry->changed_) {
129  SendPhysicalInterfaceMsg(cfg_name, entry);
130  entry->changed_ = false;
131  /* Clear renew flag to be on safer side. Not really required */
132  entry->renewed_ = false;
133  }
134  }
135 
136  if (it == uve_phy_interface_map_.end()) {
139  } else {
140  pi_timer_last_visited_ = it->first;
142  }
143  /* Return true to trigger auto-restart of timer */
144  return true;
145 }
146 
148  LogicalInterfaceMap::iterator it = uve_logical_interface_map_.lower_bound
150  if (it == uve_logical_interface_map_.end()) {
151  li_timer_last_visited_ = nil_uuid();
152  return true;
153  }
154 
155  uint32_t count = 0;
156  while (it != uve_logical_interface_map_.end() &&
158  LogicalInterfaceUveEntry* entry = it->second.get();
159  boost::uuids::uuid u = it->first;
160  LogicalInterfaceMap::iterator prev = it;
161  it++;
162  count++;
163 
164  if (entry->deleted_) {
166  if (!entry->renewed_) {
167  uve_logical_interface_map_.erase(prev);
168  } else {
169  entry->deleted_ = false;
170  entry->renewed_ = false;
171  entry->changed_ = false;
172  SendLogicalInterfaceMsg(u, entry);
173  }
174  } else if (entry->changed_) {
175  SendLogicalInterfaceMsg(u, entry);
176  entry->changed_ = false;
177  /* Clear renew flag to be on safer side. Not really required */
178  entry->renewed_ = false;
179  }
180  }
181 
182  if (it == uve_logical_interface_map_.end()) {
183  li_timer_last_visited_ = nil_uuid();
185  } else {
186  li_timer_last_visited_ = it->first;
188  }
189  /* Return true to trigger auto-restart of timer */
190  return true;
191 }
192 
193 void ProuterUveTable::set_expiry_time(int time, Timer *timer) {
194  if (time != timer->time()) {
195  timer->Reschedule(time);
196  }
197 }
198 
200  (const Interface *pintf) :
201  uuid_(pintf->GetUuid()), logical_interface_set_(), changed_(true),
202  deleted_(false), renewed_(false) {
203  Update(pintf);
204 }
205 
207 }
208 
210  name_(p->name()), uuid_(p->uuid()), physical_interface_set_(),
211  changed_(true), deleted_(false), renewed_(false), mastership_(p->master()) {
212 }
213 
215  (const LogicalInterface *li) : name_(li->name()), vlan_(kInvalidVlanId),
216  vmi_list_(), changed_(true), deleted_(false), renewed_(false) {
217  Update(li);
218 }
219 
221  (const LogicalInterface *li) {
222  const VlanLogicalInterface *vlif = dynamic_cast
223  <const VlanLogicalInterface *>(li);
224  if (vlif) {
225  vlan_ = vlif->vlan();
226  } else {
227  vlan_ = kInvalidVlanId;
228  }
229  changed_ = true;
230 }
231 
233 }
234 
236  physical_interface_set_.clear();
237  logical_interface_set_.clear();
238  deleted_ = true;
239  renewed_ = false;
240 }
241 
243  (const Interface *itf) {
244  InterfaceSet::iterator it = physical_interface_set_.find(itf->name());
245  if (it == physical_interface_set_.end()) {
246  physical_interface_set_.insert(itf->name());
247  changed_ = true;
248  }
249 }
250 
252  (const Interface *itf) {
253  InterfaceSet::iterator it = physical_interface_set_.find(itf->name());
254  if (it != physical_interface_set_.end()) {
255  physical_interface_set_.erase(it);
256  changed_ = true;
257  }
258 }
259 
261  (const LogicalInterface *itf) {
262  LogicalInterfaceSet::iterator it = logical_interface_set_.find
263  (itf->GetUuid());
264  if (it == logical_interface_set_.end()) {
265  logical_interface_set_.insert(itf->GetUuid());
266  }
267 }
268 
270  (const LogicalInterface *itf) {
271  bool deleted = false;
272  LogicalInterfaceSet::iterator it = logical_interface_set_.find(itf->
273  GetUuid());
274  if (it != logical_interface_set_.end()) {
275  logical_interface_set_.erase(it);
276  deleted = true;
277  }
278  return deleted;
279 }
280 
282  (const PhysicalDevice *pr) {
283  ProuterUveEntryPtr uve(new ProuterUveEntry(pr));
284  return uve;
285 }
286 
289  UveProuterMap::const_iterator it = uve_prouter_map_.find(u);
290  if (it == uve_prouter_map_.end()) {
291  return NULL;
292  }
293  return it->second.get();
294 }
295 
297  NameToPhyInterfaceUveEntry(const string &name) const {
298  UvePhyInterfaceMap::const_iterator it = uve_phy_interface_map_.find(name);
299  if (it != uve_phy_interface_map_.end()) {
300  return it->second.get();
301  }
302  return NULL;
303 }
304 
305 const Interface *ProuterUveTable::NameToInterface(const string &name) const {
306  PhysicalInterfaceKey phy_key(name);
307  Interface *intf = static_cast<PhysicalInterface *>
308  (agent_->interface_table()->FindActiveEntry(&phy_key));
309  if (intf == NULL) {
310  RemotePhysicalInterfaceKey rem_key(name);
311  intf = static_cast<RemotePhysicalInterface *>
312  (agent_->interface_table()->FindActiveEntry(&rem_key));
313  }
314  return intf;
315 }
316 
318  (const Interface *intf) {
319  PhysicalDevice *pde = NULL;
320  const RemotePhysicalInterface *rpintf;
321  const PhysicalInterface *pintf;
322  if (intf->type() == Interface::REMOTE_PHYSICAL) {
323  rpintf = static_cast<const RemotePhysicalInterface *>(intf);
324  pde = rpintf->physical_device();
325  } else if (intf->type() == Interface::PHYSICAL) {
326  pintf = static_cast<const PhysicalInterface *>(intf);
327  pde = pintf->physical_device();
328  }
329  return pde;
330 }
331 
333  (vector<string> &vmi_list) const {
334  ProuterUveTable::InterfaceSet::iterator vit = vmi_list_.begin();
335  while (vit != vmi_list_.end()) {
336  vmi_list.push_back((*vit));
337  ++vit;
338  }
339  return;
340 }
341 
343  (vector<string> &list) const {
344  ProuterUveTable::LogicalInterfaceSet::iterator it =
345  logical_interface_set_.begin();
346  while (it != logical_interface_set_.end()) {
347  list.push_back((to_string(*it)));
348  ++it;
349  }
350  return;
351 }
352 
354  ProuterData *uve) const {
355  vector<string> phy_if_list;
356  vector<string> logical_list;
357  vector<string> empty_agent_list;
358  /* We are using hostname instead of fq-name because Prouter UVE sent by
359  * other modules to send topology information uses hostname and we want
360  * both these information to be seen in same UVE */
361  uve->set_name(entry->name_);
362  uve->set_uuid(to_string(entry->uuid_));
363  uve->set_agent_name(agent_->agent_name());
364  InterfaceSet::iterator pit = entry->physical_interface_set_.begin();
365  while (pit != entry->physical_interface_set_.end()) {
366  phy_if_list.push_back(*pit);
367  ++pit;
368  }
369  uve->set_physical_interface_list(phy_if_list);
370 
371 
372  LogicalInterfaceSet::const_iterator lit = entry->logical_interface_set_.
373  begin();
374 
375  while (lit != entry->logical_interface_set_.end()) {
376  logical_list.push_back(to_string(*lit));
377  ++lit;
378  }
379  uve->set_logical_interface_list(logical_list);
380  if (entry->mastership_) {
381  vector<string> agent_list;
382  agent_list.push_back(agent_->agent_name());
383  if (agent_->tsn_enabled()) {
384  uve->set_tsn_agent_list(agent_list);
385  } else if (agent_->tor_agent_enabled()) {
386  uve->set_connected_agent_list(agent_list);
387  }
388  } else {
389  /* Send Empty list */
390  if (agent_->tsn_enabled()) {
391  uve->set_tsn_agent_list(empty_agent_list);
392  } else if (agent_->tor_agent_enabled()) {
393  uve->set_connected_agent_list(empty_agent_list);
394  }
395  }
396  vnsConstants vnsVrouterType;
397  if (agent_->vcpe_gateway_mode()) {
398  uve->set_gateway_mode(vnsVrouterType.VrouterAgentGatewayModeMap.at
399  (VrouterAgentGatewayMode::VCPE));
400  } else if ((agent_->server_gateway_mode()) ||
401  (agent_->pbb_gateway_mode())) {
402  uve->set_gateway_mode(vnsVrouterType.VrouterAgentGatewayModeMap.at
403  (VrouterAgentGatewayMode::SERVER));
404  } else {
405  uve->set_gateway_mode(vnsVrouterType.VrouterAgentGatewayModeMap.at
407  }
408 }
409 
411  ProuterData uve;
412  FrameProuterMsg(entry, &uve);
413  DispatchProuterMsg(uve);
414  return true;
415 }
416 
418  ProuterData uve;
419  uve.set_name(e->name_);
420  uve.set_deleted(true);
421  DispatchProuterMsg(uve);
422 }
423 
425  if (pde && !pde->IsDeleted()) {
427  if (entry) {
428  entry->changed_ = true;
429  }
430  }
431 }
432 
434  const PhysicalDevice *pde = InterfaceToProuter(pi);
436 }
437 
438 void ProuterUveTable::DispatchProuterMsg(const ProuterData &uve) {
439  UveProuterAgent::Send(uve);
440 }
441 
443  vector<string> plist;
444  UveProuterMap::iterator it = uve_prouter_map_.begin();
445  while (it != uve_prouter_map_.end()) {
446  ProuterUveEntry* entry = it->second.get();
447  plist.push_back(entry->name_);
448  ++it;
449  }
451 }
452 
454  (const PhysicalDevice *p) {
455  ProuterUveEntryPtr uve = Allocate(p);
456  pair<UveProuterMap::iterator, bool> ret;
457  ret = uve_prouter_map_.insert(UveProuterPair(p->uuid(), uve));
458  UveProuterMap::iterator it = ret.first;
459  ProuterUveEntry *entry = it->second.get();
460  entry->changed_ = true;
461  entry->mastership_ = p->master();
462  if (entry->deleted_) {
463  entry->renewed_ = true;
464  }
465  if (!entry->renewed_) {
467  }
468  return entry;
469 }
470 
472  UveProuterMap::iterator it = uve_prouter_map_.find(p->uuid());
473  if (it == uve_prouter_map_.end()) {
474  return;
475  }
476 
477  ProuterUveEntry* entry = it->second.get();
478  /* Reset all the non-key fields of entry so that it has proper values in
479  * case it gets reused. Also update deleted_ and renewed_ flags */
480  entry->Reset();
481 }
482 
484  LogicalInterfaceMap::iterator it = uve_logical_interface_map_.find(itf->
485  GetUuid());
486  if (it != uve_logical_interface_map_.end()) {
487  LogicalInterfaceUveEntry *entry = it->second.get();
488  entry->deleted_ = true;
489  }
490 }
491 
493  LogicalInterfaceMap::iterator it = uve_logical_interface_map_.find(itf->
494  GetUuid());
495  if (it == uve_logical_interface_map_.end()) {
498  uve));
499  return;
500  } else {
501  LogicalInterfaceUveEntry *entry = it->second.get();
502  entry->Update(itf);
503  }
504 }
505 
507  UvePhyInterfaceMap::iterator it = uve_phy_interface_map_.find(pintf->
508  name());
509  PhyInterfaceUveEntry *entry = NULL;
510  if (it != uve_phy_interface_map_.end()) {
511  entry = it->second.get();
512  entry->deleted_ = true;
513  }
514 }
515 
517  const LogicalInterface *intf) {
518  UvePhyInterfaceMap::iterator it = uve_phy_interface_map_.find(pintf->
519  name());
520  PhyInterfaceUveEntry *ientry = NULL;
521  if (it == uve_phy_interface_map_.end()) {
524  entry));
525  ientry = entry.get();
526  } else {
527  ientry = it->second.get();
528  }
529  LogicalInterfaceSet::iterator lit = ientry->logical_interface_set_.
530  find(intf->GetUuid());
531  if (lit == ientry->logical_interface_set_.end()) {
532  ientry->logical_interface_set_.insert(intf->GetUuid());
533  ientry->changed_ = true;
534  }
535 }
536 
538  (const PhysicalDevice *p, const LogicalInterface *intf) {
539  UveProuterMap::iterator it = uve_prouter_map_.find(p->uuid());
540  if (it == uve_prouter_map_.end()) {
541  return;
542  }
543 
544  ProuterUveEntry* entry = it->second.get();
545  entry->AddLogicalInterface(intf);
546  entry->changed_ = true;
547 }
548 
550  const LogicalInterface *intf) {
552  if (entry != NULL) {
553  LogicalInterfaceSet::iterator it = entry->logical_interface_set_.
554  find(intf->GetUuid());
555  if (it != entry->logical_interface_set_.end()) {
556  entry->logical_interface_set_.erase(it);
557  entry->changed_ = true;
558  }
559  }
560 }
561 
563  (const boost::uuids::uuid &u, const LogicalInterface *intf) {
564  UveProuterMap::iterator it = uve_prouter_map_.find(u);
565  if (it == uve_prouter_map_.end()) {
566  return;
567  }
568 
569  ProuterUveEntry* entry = it->second.get();
570  bool deleted = entry->DeleteLogicalInterface(intf);
571  if (deleted) {
572  entry->changed_ = true;
573  }
574 }
575 
577  DBEntryBase *e) {
578  const PhysicalDevice *pr = static_cast<const PhysicalDevice *>(e);
579  PhysicalDeviceState *state = static_cast<PhysicalDeviceState *>
580  (e->GetState(partition->parent(), physical_device_listener_id_));
581  if (e->IsDeleted()) {
582  if (state) {
583  /* Uve Msg send is part of Delete API */
584  DeleteHandler(pr);
586  delete state;
587  }
588  } else {
589  if (!state) {
590  state = new PhysicalDeviceState();
592  state);
593  /* Uve Msg send is part of Add API */
594  AddHandler(pr);
595  } else {
596  /* For Change notifications send only the msg */
598  entry->mastership_ = pr->master();
599  entry->changed_ = true;
600  }
601  }
602 }
603 
605  const boost::uuids::uuid &u) {
607  if (!entry) {
608  return;
609  }
610  entry->DeletePhysicalInterface(intf);
611  entry->changed_ = true;
612 }
613 
615  UvePhyInterfaceMap::iterator it = uve_phy_interface_map_.find(intf->name());
616  if (it == uve_phy_interface_map_.end()) {
618  uve_phy_interface_map_.insert(UvePhyInterfacePair(intf->name(), uve));
619  return;
620  }
621  PhyInterfaceUveEntry *entry = it->second.get();
622  entry->Update(intf);
623 }
624 
626  const boost::uuids::uuid &u) {
627  if (intf->IsDeleted()) {
628  MarkDeletedPhysical(intf);
629  }
630  /* Ignore notifications for PhysicalInterface if it has no
631  PhysicalDevice */
632  if (u == nil_uuid()) {
633  return;
634  }
636  if (entry == NULL) {
637  /* We hit this condition when physical-device is deleted before
638  * physical interface */
639  return;
640  }
641  if (intf->IsDeleted()) {
642  entry->DeletePhysicalInterface(intf);
643  } else {
644  entry->AddPhysicalInterface(intf);
645  }
646 }
647 
650  const boost::uuids::uuid li = vmi->logical_interface();
651  LogicalInterfaceMap::iterator it = uve_logical_interface_map_.find(li);
652  if (it != uve_logical_interface_map_.end()) {
653  entry = it->second.get();
654  } else {
655  LogicalInterface *intf;
656  VlanLogicalInterfaceKey key(li, "");
657  intf = static_cast<LogicalInterface *>
659  if (!intf) {
660  return;
661  }
664  entry = uve.get();
665  }
666  InterfaceSet::iterator vit = entry->vmi_list_.find(vmi->cfg_name());
667  if (vit == entry->vmi_list_.end()) {
668  entry->vmi_list_.insert(vmi->cfg_name());
669  entry->changed_ = true;
670  }
671 }
672 
674  const VmInterface *vmi) {
675  LogicalInterfaceMap::iterator it = uve_logical_interface_map_.find(li);
676  if (it != uve_logical_interface_map_.end()) {
677  LogicalInterfaceUveEntry *entry = it->second.get();
678  ProuterUveTable::InterfaceSet::iterator vit = entry->vmi_list_.find
679  (vmi->cfg_name());
680  if (vit != entry->vmi_list_.end()) {
681  entry->vmi_list_.erase(vit);
682  entry->changed_ = true;
683  }
684  }
685 }
686 
688  DBEntryBase *e) {
689  VmInterfaceState *state = static_cast<VmInterfaceState *>
690  (e->GetState(partition->parent(), interface_listener_id_));
691  const VmInterface *intf = static_cast<const VmInterface *>(e);
692  if (e->IsDeleted()) {
693  if (state) {
695  e->ClearState(partition->parent(), interface_listener_id_);
696  delete state;
697  }
698  return;
699  }
700  if (!state) {
701  state = new VmInterfaceState();
702  e->SetState(partition->parent(), interface_listener_id_, state);
703  }
704  if (state->logical_interface_ != intf->logical_interface()) {
705  if (state->logical_interface_ != nil_uuid()) {
707  }
708  state->logical_interface_ = intf->logical_interface();
709  }
710  if (intf->logical_interface() != nil_uuid()) {
711  VMInterfaceAdd(intf);
712  }
713 }
714 
716  DBEntryBase *e) {
717  const Interface *intf = static_cast<const Interface *>(e);
718  const LogicalInterface *lintf = NULL;
719  const RemotePhysicalInterface *rpintf = NULL;
720  const PhysicalInterface *pintf = NULL;
721  const Interface *physical_interface = NULL;
722  PhysicalDevice *pde = NULL;
723  if (intf->type() == Interface::REMOTE_PHYSICAL) {
724  rpintf = static_cast<const RemotePhysicalInterface *>(intf);
725  pde = rpintf->physical_device();
726  } else if (intf->type() == Interface::LOGICAL) {
727  lintf = static_cast<const LogicalInterface *>(intf);
728  physical_interface = lintf->physical_interface();
729  pde = lintf->physical_device();
730  } else if (intf->type() == Interface::PHYSICAL) {
731  pintf = static_cast<const PhysicalInterface *>(intf);
732  /* Ignore PhysicalInterface notifications if it is not of subtype
733  * CONFIG */
734  if (pintf->subtype() != PhysicalInterface::CONFIG) {
735  return;
736  }
737  pde = pintf->physical_device();
738  } else if (intf->type() == Interface::VM_INTERFACE) {
739  VmInterfaceHandler(partition, e);
740  return;
741  } else {
742  /* Ignore notifications for interface which are not
743  RemotePhysical/Logical */
744  return;
745  }
746  ProuterInterfaceState *state = static_cast<ProuterInterfaceState *>
747  (e->GetState(partition->parent(), interface_listener_id_));
748  if (e->IsDeleted()) {
749  if (state) {
750  if (pintf) {
752  } else if (rpintf) {
754  } else if (lintf) {
755  if (!state->physical_interface_.empty()) {
757  lintf);
758  }
759  if (state->physical_device_ != nil_uuid()) {
761  lintf);
762  }
763  MarkDeletedLogical(lintf);
764  }
765  e->ClearState(partition->parent(), interface_listener_id_);
766  delete state;
767  }
768  } else {
769  if (!state) {
770  state = new ProuterInterfaceState();
771  e->SetState(partition->parent(), interface_listener_id_, state);
772  }
773  boost::uuids::uuid pde_uuid = nil_uuid();
774  if (pde) {
775  pde_uuid = pde->uuid();
776  }
777  string pname;
778  if (physical_interface) {
779  pname = physical_interface->name();
780  }
781  if (intf->type() == Interface::LOGICAL) {
782  if (state->physical_interface_ != pname) {
783  if (!state->physical_interface_.empty()) {
785  lintf);
786  }
787  if (physical_interface) {
788  AddLogicalToPhysical(physical_interface, lintf);
789  }
790  state->physical_interface_ = pname;
791  }
792  if (state->physical_device_ != pde_uuid) {
793  if (state->physical_device_ != nil_uuid()) {
795  lintf);
796  }
797  if (!physical_interface && pde) {
798  AddProuterLogicalInterface(pde, lintf);
799  }
800  state->physical_device_ = pde_uuid;
801  }
803  } else {
804  if (state->physical_device_ != pde_uuid) {
805  if (state->physical_device_ != nil_uuid()) {
807  }
808  if (pde) {
809  if (pintf) {
810  PhysicalInterfaceHandler(pintf, pde->uuid());
811  } else if (rpintf) {
812  PhysicalInterfaceHandler(rpintf, pde->uuid());
813  }
814  }
815  state->physical_device_ = pde_uuid;
816  }
818  }
819  }
820 }
821 
825  (boost::bind(&ProuterUveTable::PhysicalDeviceNotify, this, _1, _2));
826 
827  InterfaceTable *i_table = agent_->interface_table();
829  (boost::bind(&ProuterUveTable::InterfaceNotify, this, _1, _2));
830 }
831 
835  Unregister(physical_device_listener_id_);
838 }
839 
840 void ProuterUveTable::SendLogicalInterfaceDeleteMsg(const string &config_name) {
841  UveLogicalInterfaceAgent uve;
842  uve.set_name(config_name);
843  uve.set_deleted(true);
845 }
846 
848  LogicalInterfaceUveEntry *entry) {
849  UveLogicalInterfaceAgent uve;
850  vector<string> list;
851 
852  uve.set_name(to_string(u));
853  uve.set_config_name(entry->name_);
854  uve.set_vlan(entry->vlan_);
855 
856  entry->FillVmInterfaceList(list);
857  uve.set_vm_interface_list(list);
858 
860 }
861 
863  (const UveLogicalInterfaceAgent &uve) {
864  UveLogicalInterfaceAgentTrace::Send(uve);
865 }
866 
868  UvePhysicalInterfaceAgent uve;
869  uve.set_name(cfg_name);
870  uve.set_deleted(true);
872 }
873 
874 void ProuterUveTable::SendPhysicalInterfaceMsg(const string &cfg_name,
875  PhyInterfaceUveEntry *entry) {
876  UvePhysicalInterfaceAgent uve;
877  vector<string> list;
878 
879  uve.set_name(cfg_name);
880  uve.set_uuid(to_string(entry->uuid_));
881 
882  entry->FillLogicalInterfaceList(list);
883  uve.set_logical_interface_list(list);
884 
886 }
887 
889  (const UvePhysicalInterfaceAgent &uve) {
890  UvePhysicalInterfaceAgentTrace::Send(uve);
891 }
892 
894 {
896  if (entry == NULL) {
897  string status = " false";
898  if (value) {
899  status.assign(" true");
900  }
901  string msg = "Mastership update failed for " + to_string(u) + status;
902  PROUTER_UVE_TRACE(msg);
903  return;
904  }
905  if (entry->mastership_ != value) {
906  entry->mastership_ = value;
907  entry->changed_ = true;
908  }
909 }
uint16_t vlan() const
void VMInterfaceRemove(const boost::uuids::uuid &li, const VmInterface *vmi)
virtual void DispatchProuterMsg(const ProuterData &uve)
Type type() const
Definition: interface.h:112
uint32_t incremental_interval() const
VrouterUveEntryBase * vrouter_uve_entry() const
bool tsn_enabled() const
Definition: agent.h:1162
PhysicalDevice * physical_device() const
virtual void DispatchPhysicalInterfaceMsg(const UvePhysicalInterfaceAgent &uve)
void MarkPhysicalDeviceChanged(const PhysicalDevice *pde)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
Definition: task.h:178
void SendPhysicalInterfaceDeleteMsg(const std::string &cfg_name)
#define kTaskDBExclude
Definition: agent.h:336
LogicalInterfaceSet logical_interface_set_
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
Definition: db_entry.cc:37
boost::shared_ptr< ProuterUveEntry > ProuterUveEntryPtr
uint32_t default_interval() const
bool tor_agent_enabled() const
Definition: agent.h:1164
const PhysicalDevice * InterfaceToProuter(const Interface *intf)
const boost::uuids::uuid & GetUuid() const
Definition: interface.h:113
void AddLogicalInterface(const LogicalInterface *itf)
void SendLogicalInterfaceDeleteMsg(const std::string &config_name)
boost::uuids::uuid pr_timer_last_visited_
AgentUveBase * uve() const
Definition: agent.cc:909
SubType subtype() const
void DeleteHandler(const PhysicalDevice *p)
PhysicalDeviceTable * physical_device_table() const
Definition: agent.h:628
std::pair< std::string, PhyInterfaceUveEntryPtr > UvePhyInterfacePair
bool IsDeleted() const
Definition: db_entry.h:49
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
Definition: db_entry.cc:22
void Update(const Interface *pintf)
void SendLogicalInterfaceMsg(const boost::uuids::uuid &u, LogicalInterfaceUveEntry *entry)
#define PROUTER_UVE_TRACE(...)
bool pbb_gateway_mode() const
Definition: agent.h:1170
DBTableBase * parent()
static const uint32_t kUveCountPerTimer
AgentDBEntry * FindActiveEntry(const DBEntry *key)
Definition: agent_db.cc:110
InterfaceTable * interface_table() const
Definition: agent.h:465
boost::uuids::uuid uuid
Interface * physical_interface() const
static const uint16_t kInvalidVlanId
ProuterUveTable(Agent *agent, uint32_t default_intvl)
const boost::uuids::uuid & uuid() const
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
Definition: sandesh_trace.h:18
SandeshTraceBufferPtr ProuterUveTraceBuf
void MarkDeletedLogical(const LogicalInterface *pintf)
void InterfaceNotify(DBTablePartBase *partition, DBEntryBase *e)
boost::shared_ptr< LogicalInterfaceUveEntry > LogicalInterfaceUveEntryPtr
void Unregister(ListenerId listener)
Definition: db_table.cc:186
void TimerCleanup(Timer *timer)
void UpdateMastership(const boost::uuids::uuid &u, bool value)
bool server_gateway_mode() const
Definition: agent.h:1168
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
Definition: db_table.cc:181
std::pair< boost::uuids::uuid, ProuterUveEntryPtr > UveProuterPair
UveProuterMap uve_prouter_map_
ProuterUveEntry * PDEntryToProuterUveEntry(const boost::uuids::uuid &u) const
void AddUpdatePhysicalInterface(const Interface *intf)
ProuterUveEntry * AddHandler(const PhysicalDevice *p)
UvePhyInterfaceMap uve_phy_interface_map_
void FillVmInterfaceList(std::vector< std::string > &vmi_list) const
void DeletePhysicalInterface(const Interface *itf)
DBTableBase::ListenerId interface_listener_id_
void DeletePhysicalFromProuter(const Interface *i, const boost::uuids::uuid &u)
const Interface * NameToInterface(const std::string &name) const
Definition: agent.h:358
bool vcpe_gateway_mode() const
Definition: agent.h:1169
bool master() const
void MarkDeletedPhysical(const Interface *pintf)
PhysicalDevice * physical_device() const
void Update(const LogicalInterface *li)
void AddPhysicalInterface(const Interface *itf)
void FillLogicalInterfaceList(std::vector< std::string > &list) const
boost::uuids::uuid li_timer_last_visited_
void AddUpdateLogicalInterface(const LogicalInterface *i)
const std::string & agent_name() const
Definition: agent.h:878
void PhysicalDeviceNotify(DBTablePartBase *partition, DBEntryBase *e)
void ClearState(DBTableBase *tbl_base, ListenerId listener)
Definition: db_entry.cc:73
DBTableBase::ListenerId physical_device_listener_id_
void SendPhysicalInterfaceMsg(const std::string &name, PhyInterfaceUveEntry *entry)
void DeleteLogicalFromPhysical(const std::string &name, const LogicalInterface *i)
bool Cancel()
Definition: timer.cc:150
std::pair< boost::uuids::uuid, LogicalInterfaceUveEntryPtr > LogicalInterfacePair
const boost::uuids::uuid & logical_interface() const
bool DeleteLogicalInterface(const LogicalInterface *itf)
void set_expiry_time(int time, Timer *timer)
void PhysicalInterfaceHandler(const Interface *i, const boost::uuids::uuid &u)
void SendProuterVrouterAssociation()
boost::shared_ptr< PhyInterfaceUveEntry > PhyInterfaceUveEntryPtr
void SendProuterDeleteMsg(ProuterUveEntry *e)
void VmInterfaceHandler(DBTablePartBase *partition, DBEntryBase *e)
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
Definition: timer.cc:108
void SendVrouterProuterAssociation(const std::vector< std::string > &list)
void FrameProuterMsg(ProuterUveEntry *entry, ProuterData *uve) const
const std::string & cfg_name() const
static const int kInvalidId
Definition: db_table.h:64
PhyInterfaceUveEntry * NameToPhyInterfaceUveEntry(const std::string &name) const
bool SendProuterMsg(ProuterUveEntry *entry)
const std::string & name() const
Definition: interface.h:114
PhysicalDevice * physical_device() const
LogicalInterfaceMap uve_logical_interface_map_
bool Reschedule(int time)
Definition: timer.cc:137
void VMInterfaceAdd(const VmInterface *vmi)
virtual void DispatchLogicalInterfaceMsg(const UveLogicalInterfaceAgent &u)
Definition: timer.h:54
std::string pi_timer_last_visited_
void SendProuterMsgFromPhyInterface(const Interface *pi)
void DeleteProuterLogicalInterface(const boost::uuids::uuid &u, const LogicalInterface *intf)
ProuterUveEntry(const PhysicalDevice *p)
PhyInterfaceUveEntry(const Interface *pintf)
ProuterUveEntryPtr Allocate(const PhysicalDevice *pr)
void AddLogicalToPhysical(const Interface *p, const LogicalInterface *i)
LogicalInterfaceUveEntry(const LogicalInterface *li)
int time() const
Definition: timer.h:96
void AddProuterLogicalInterface(const PhysicalDevice *p, const LogicalInterface *intf)
virtual ~ProuterUveTable()
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
Definition: sandesh_trace.h:46
static bool DeleteTimer(Timer *Timer)
Definition: timer.cc:222