OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nexthop.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef vnsw_agent_nexthop_hpp
6 #define vnsw_agent_nexthop_hpp
7 
8 #include <netinet/in.h>
9 #include <net/ethernet.h>
10 
11 #include <cmn/agent_cmn.h>
12 #include <agent_types.h>
13 
14 #include <oper/interface_common.h>
15 #include <oper/vrf.h>
16 #include <oper/ecmp_load_balance.h>
17 
18 class NextHopKey;
19 class MplsLabel;
20 
21 template <typename Member>
22 class MemberList {
23 public:
24  const static uint32_t kInvalidIndex = 0xffff;
25  MemberList(int max_size) : max_size_(max_size), free_index_(0), hash_id(0) {
26  }
27 
29  }
30 
32  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
33  if (mbr_list_[i]) {
34  delete mbr_list_[i];
35  }
36  }
37  }
38 
39  typedef typename std::vector<Member *>::iterator iterator;
40  typedef typename std::vector<Member *>::const_iterator const_iterator;
41 
42  int insert(const Member &mbr) {
43  if (mbr_list_.size() >= kInvalidIndex) {
44  return kInvalidIndex;
45  }
46 
47  if (mbr_list_.size() < free_index_ + 1) {
48  mbr_list_.resize(free_index_ + 1);
49  hash_table_.resize(free_index_ + 1);
50  }
51 
52  Member *entry = new Member(mbr);
53  mbr_list_[free_index_] = entry;
56  return free_index_;
57  }
58 
59  bool remove(const Member &mbr) {
60  uint32_t i = 0;
61  for (i = 0; i < mbr_list_.size(); i++) {
62  if (mbr_list_[i] && *mbr_list_[i] == mbr) {
63  delete mbr_list_[i];
64  mbr_list_[i] = NULL;
65  break;
66  }
67  }
68 
69  if (i == mbr_list_.size()) {
70  return false;
71  }
74  return true;
75  }
76 
77  bool remove(uint32_t index) {
78  if (index >= mbr_list_.size()) {
79  return false;
80  }
81  if (mbr_list_[index] != NULL) {
82  delete mbr_list_[index];
83  mbr_list_[index] = NULL;
86  }
87  return true;
88  }
89 
90  void UpdateHashTable() {
91  hash_table_.clear();
92  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
93  if (mbr_list_[i] == NULL) {
94  hash_table_.push_back(0xffff);
95  continue;
96  }
97  hash_table_.push_back(i);
98  }
99  }
100 
102  uint32_t i;
103  for (i = 0; i < mbr_list_.size(); i++) {
104  if (mbr_list_[i] == NULL) {
105  free_index_ = i;
106  return;
107  }
108  }
109  free_index_ = i;
110  }
111 
112  void UpdateFreeIndex(uint32_t index) {
113  if (index > free_index_) {
114  return;
115  }
116  UpdateFreeIndex();
117  }
118 
119  void replace(std::vector<Member> list) {
120  //Add new elements, which are not presnet in member list
121  typename std::vector<Member>::const_iterator it = list.begin();
122  while (it != list.end()) {
123  Member mem = *it;
124  if (!Find(mem)) {
125  insert(mem);
126  }
127  it++;
128  }
129 
130  //Remove elements present member list, but not in new list
131  iterator mbr_list_iterator = begin();
132  while (mbr_list_iterator != end()) {
133  const Member *member = *mbr_list_iterator;
134  if (!member) {
135  mbr_list_iterator++;
136  continue;
137  }
138  it = list.begin();
139  while (it != list.end()) {
140  const Member *latest_member = &(*it);
141  if (latest_member && *latest_member == *member) {
142  break;
143  }
144  it++;
145  }
146  if (it == list.end()) {
147  remove(*member);
148  }
149  mbr_list_iterator++;
150  }
151  }
152 
153  void clear() {
154  hash_table_.clear();
155  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
156  if (mbr_list_[i]) {
157  delete mbr_list_[i];
158  }
159  }
160  mbr_list_.clear();
161  free_index_ = 0;
162  }
163 
164  size_t HashTableSize() const {
165  return hash_table_.size();
166  }
167 
168  iterator begin() { return iterator(mbr_list_.begin());};
169  iterator end() { return iterator(mbr_list_.end());};
170 
172  return const_iterator(mbr_list_.begin());
173  }
174  const_iterator end() const {
175  return const_iterator(mbr_list_.end());
176  }
177 
178  Member* Find(const Member &mem) const {
179  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
180  if (mbr_list_[i] && *mbr_list_[i] == mem) {
181  return mbr_list_[i];
182  }
183  }
184  return NULL;
185  }
186 
187  Member* Find(const Member &mem, uint32_t &index) const{
188  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
189  if (mbr_list_[i] && *mbr_list_[i] == mem) {
190  index = i;
191  return mbr_list_[i];
192  }
193  }
194  return NULL;
195  }
196 
197  const Member* Get(uint32_t idx) const {
198  return mbr_list_[idx];
199  }
200 
201  size_t size() const {
202  return mbr_list_.size();
203  }
204 
205  uint32_t hash(size_t hash) const {
206  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
207  if (hash_table_[hash % hash_table_.size()] != 0xffff) {
208  return hash_table_[hash % hash_table_.size()];
209  }
210  hash++;
211  }
212  return 0;
213  }
214 
215  uint32_t count() const {
216  int cnt = 0;
217  for (uint32_t i = 0; i < mbr_list_.size(); i++) {
218  if (mbr_list_[i] != NULL)
219  cnt++;
220  }
221 
222  return cnt;
223  }
224 
225 private:
226  std::vector<Member *> mbr_list_;
227  std::vector<uint32_t> hash_table_;
228  uint32_t max_size_;
229  uint32_t free_index_;
230  uint32_t hash_id;
231 };
232 
234 // Class to manage supported tunnel-types
236 class TunnelType {
237 public:
238  // Various tunnel-types supported
239  enum Type {
246  };
247  // Bitmap of supported tunnel types
248  typedef uint32_t TypeBmap;
249  typedef std::list<Type> PriorityList;
250 
251  TunnelType(Type type) : type_(type) { }
253  bool Compare(const TunnelType &rhs) const {
254  return type_ == rhs.type_;
255  }
256  bool IsLess(const TunnelType &rhs) const {
257  return type_ < rhs.type_;
258  }
259 
260  std::string ToString() const {
261  switch (type_) {
262  case MPLS_GRE:
263  return "MPLSoGRE";
264  case MPLS_UDP:
265  return "MPLSoUDP";
266  case VXLAN:
267  return "VXLAN";
268  case NATIVE:
269  return "Native";
270  case MPLS_OVER_MPLS:
271  return "MPLSoMPLS";
272  default:
273  break;
274  }
275  return "UNKNOWN";
276  }
277 
278  static std::string GetString(uint32_t type) {
279  std::ostringstream tunnel_type;
280  if (type & (1 << MPLS_GRE)) {
281  tunnel_type << "MPLSoGRE ";
282  }
283 
284  if (type & (1 << MPLS_UDP)) {
285  tunnel_type << "MPLSoUDP ";
286  }
287 
288  if (type & ( 1 << VXLAN)) {
289  tunnel_type << "VxLAN";
290  }
291 
292  if (type & (1 << NATIVE)) {
293  tunnel_type << "Underlay";
294  }
295 
296  if (type & (1 << MPLS_OVER_MPLS)) {
297  tunnel_type << "MPLSoMPLS";
298  }
299 
300  return tunnel_type.str();
301  }
302 
303  Type GetType() const {return type_;}
305 
307  static Type ComputeType(TypeBmap bmap);
308  static Type DefaultMplsComputeType();
309  static Type DefaultType() {return default_type_;}
310  static TypeBmap DefaultTypeBmap() {return (1 << DefaultType());}
311  static TypeBmap VxlanType() {return (1 << VXLAN);};
312  static TypeBmap MplsType() {return ((1 << MPLS_GRE) | (1 << MPLS_UDP));};
313  static TypeBmap MplsoMplsType() {return (1 << MPLS_OVER_MPLS);};
315  if (type == MPLS_GRE || type == MPLS_UDP)
316  return TunnelType::MplsType();
317  if (type == VXLAN)
318  return TunnelType::VxlanType();
319  return TunnelType::AllType();
320  }
321  static TypeBmap AllType() {return ((1 << MPLS_GRE) | (1 << MPLS_UDP) |
322  (1 << VXLAN));}
323  static TypeBmap GREType() {return (1 << MPLS_GRE);}
324  static TypeBmap UDPType() {return (1 << MPLS_UDP);}
325  static TypeBmap NativeType() {return (1 << NATIVE);}
326  static TypeBmap MPLSType() {return (1 << MPLS_OVER_MPLS);}
327  static bool EncapPrioritySync(const std::vector<std::string> &cfg_list);
328  static void DeletePriorityList();
329 
330 private:
334 };
335 
337 // Base class for NextHop. Implementation of specific NextHop must
338 // derive from this class
340 class NextHop : AgentRefCount<NextHop>, public AgentDBEntry {
341 public:
342  static const uint32_t kInvalidIndex = 0xFFFFFFFF;
343  enum Type {
358  };
359 
360  NextHop(Type type, bool policy) :
361  type_(type), valid_(true), policy_(policy), id_(kInvalidIndex),
362  mpls_label_(), learning_enabled_(false), etree_leaf_(false) {}
363  NextHop(Type type, bool valid, bool policy) :
364  type_(type), valid_(valid), policy_(policy), id_(kInvalidIndex),
365  mpls_label_(), learning_enabled_(false), etree_leaf_(false) {}
366  virtual ~NextHop();
367 
368  virtual std::string ToString() const { return "NH";}
369  virtual void Add(Agent *agent, const DBRequest *req);
370  virtual bool ChangeEntry(const DBRequest *req) = 0;
371  virtual void Change(const DBRequest *req);
372  virtual void Delete(const DBRequest *req) {};
373  virtual void SetKey(const DBRequestKey *key);
374  virtual bool NextHopIsLess(const DBEntry &rhs) const = 0;
375  virtual void SendObjectLog(const NextHopTable *table,
376  AgentLogEvent::type event) const;
377  virtual bool CanAdd() const = 0;
378  virtual bool IsLess(const DBEntry &rhs) const {
379  const NextHop &a = static_cast<const NextHop &>(rhs);
380  if (type_ != a.type_) {
381  return type_ < a.type_;
382  }
383  if (policy_ != a.policy_) {
384  return policy_ < a.policy_;
385  }
386  bool ret = NextHopIsLess(rhs);
387  return ret;
388  }
389 
390  virtual bool DeleteOnZeroRefCount() const {
391  return false;
392  }
393  virtual void OnZeroRefCount() {};
394 
395  uint32_t GetRefCount() const {
397  }
398 
399  void ResetMplsRef() {
400  if (mpls_label_.get() != NULL) {
401  mpls_label_.reset();
402  }
403  }
404 
405  Type GetType() const {return type_;}
406  bool IsValid() const {return valid_;};
407  bool PolicyEnabled() const {return policy_;};
408  uint32_t id() const { return id_;}
409  void set_id(uint32_t index) { id_ = index;}
410 
411  void set_etree_leaf(bool val) {
412  etree_leaf_ = val;
413  }
414 
415  bool etree_leaf() const {
416  return etree_leaf_;
417  }
418 
419  void set_learning_flag(bool val) {
420  learning_enabled_ = val;
421  }
422 
423  bool learning_enabled() const {
424  return learning_enabled_;
425  }
426 
427  bool DBEntrySandesh(Sandesh *sresp, std::string &name) const;
428  void SetNHSandeshData(NhSandeshData &data) const;
429  static void FillObjectLogIntf(const Interface *intf,
430  NextHopObjectLogInfo &info);
431  static void FillObjectLogMac(const unsigned char *m,
432  NextHopObjectLogInfo &info);
433  bool NexthopToInterfacePolicy() const;
434  const MplsLabel *mpls_label() const {
435  return mpls_label_.get();
436  }
437 
438  virtual bool MatchEgressData(const NextHop *nh) const = 0;
439  MplsLabel *AllocateLabel(Agent *agent, const NextHopKey *key);
440  virtual bool NeedMplsLabel() = 0;
441  void PostAdd();
442  void EnqueueResync() const;
443 protected:
445  NextHopObjectLogInfo &info) const;
447  bool valid_;
448  bool policy_;
449  uint32_t id_;
453 private:
455 };
456 
457 class NextHopData : public AgentData {
458 public:
460  NextHopData(bool learning_enabled, bool etree_leaf):
461  learning_enabled_(learning_enabled), etree_leaf_(etree_leaf) {}
462  virtual ~NextHopData() {};
463 protected:
464  bool learning_enabled_;
467 };
468 
469 class NextHopKey : public AgentKey {
470 public:
471  NextHopKey(NextHop::Type type, bool policy) :
472  AgentKey(), type_(type), policy_(policy) { }
473  virtual ~NextHopKey() { };
474 
475  virtual NextHop *AllocEntry() const = 0;
476  virtual NextHopKey *Clone() const = 0;
477  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
478  assert(0);
479  return false;
480  }
481  bool IsEqual(const NextHopKey &rhs) const {
482  if (type_ != rhs.type_) {
483  return false;
484  }
485  if (policy_ != rhs.policy_) {
486  return false;
487  }
488  if (NextHopKeyIsLess(rhs) == false &&
489  rhs.NextHopKeyIsLess(*this) == false) {
490  return true;
491  }
492  return false;
493  }
494 
495  void SetPolicy(bool policy) {
496  policy_ = policy;
497  };
498 
499  NextHop::Type GetType() const {return type_;}
500  bool GetPolicy() const {return policy_;}
501  bool IsLess(const NextHopKey &rhs) const {
502  if (type_ != rhs.type_) {
503  return type_ < rhs.type_;
504  }
505  if (policy_ != rhs.policy_) {
506  return policy_;
507  }
508  return NextHopKeyIsLess(rhs);
509  }
510 protected:
511  friend class NextHop;
513  bool policy_;
514 private:
516 };
517 
519 // Discard NH definition
521 class DiscardNHKey : public NextHopKey {
522 public:
523  DiscardNHKey() : NextHopKey(NextHop::DISCARD, false) { };
524  virtual ~DiscardNHKey() { };
525  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
526  // There is single DiscardNH. There is no field to compare
527  return false;
528  }
529 
530  virtual NextHopKey *Clone() const { return new DiscardNHKey(); }
531 private:
532 
533  virtual NextHop *AllocEntry() const;
534 private:
536 };
537 
538 class DiscardNHData : public NextHopData {
539 public:
541  virtual ~DiscardNHData() {};
542 private:
544 };
545 
546 class DiscardNH : public NextHop {
547 public:
548  DiscardNH() : NextHop(DISCARD, true, false) { };
549  virtual ~DiscardNH() { };
550 
551  virtual std::string ToString() const { return "DISCARD"; };
552  // No change expected to Discard NH */
553  virtual bool ChangeEntry(const DBRequest *req) { return false; };
554  virtual void Delete(const DBRequest *req) {};
555  virtual bool NextHopIsLess(const DBEntry &rhs) const { return false; };
556  virtual void SetKey(const DBRequestKey *key) { NextHop::SetKey(key); };
557  virtual bool CanAdd() const;
558  virtual KeyPtr GetDBRequestKey() const {
559  return DBEntryBase::KeyPtr(new DiscardNHKey());
560  };
561 
562  virtual bool MatchEgressData(const NextHop *nh) const {
563  return false;
564  }
565  virtual bool NeedMplsLabel() { return false; }
566  static void Create();
567 
568 private:
570 };
571 
573 // Bridge Receive NH definition
575 class L2ReceiveNHKey : public NextHopKey {
576 public:
577  L2ReceiveNHKey() : NextHopKey(NextHop::L2_RECEIVE, false) { }
578  virtual ~L2ReceiveNHKey() { }
579  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
580  // There is single Bridge Receive NH. There is no field to compare
581  return false;
582  }
583  virtual NextHopKey *Clone() const { return new L2ReceiveNHKey(); }
584 
585 private:
586 
587  virtual NextHop *AllocEntry() const;
588 private:
590 };
591 
592 class L2ReceiveNHData : public NextHopData {
593 public:
595  virtual ~L2ReceiveNHData() {};
596 private:
598 };
599 
600 class L2ReceiveNH : public NextHop {
601 public:
602  L2ReceiveNH() : NextHop(L2_RECEIVE, true, false) { };
603  virtual ~L2ReceiveNH() { };
604 
605  virtual std::string ToString() const { return "L2-Receive"; };
606  // No change expected to Discard NH */
607  virtual bool ChangeEntry(const DBRequest *req) { return false; };
608  virtual void Delete(const DBRequest *req) {};
609  virtual bool NextHopIsLess(const DBEntry &rhs) const { return false; };
610  virtual void SetKey(const DBRequestKey *key) { NextHop::SetKey(key); };
611  virtual bool CanAdd() const;
612  virtual KeyPtr GetDBRequestKey() const {
613  return DBEntryBase::KeyPtr(new L2ReceiveNHKey());
614  };
615 
616  virtual bool MatchEgressData(const NextHop *nh) const {
617  return false;
618  }
619  virtual bool NeedMplsLabel() { return false; }
620  static void Create();
621 
622 private:
624 };
625 
627 // Receive NH definition
629 class ReceiveNHKey : public NextHopKey {
630 public:
631  ReceiveNHKey(InterfaceKey *intf_key, bool policy) :
632  NextHopKey(NextHop::RECEIVE, policy), intf_key_(intf_key) {
633  }
634  virtual ~ReceiveNHKey() { };
635  virtual NextHop *AllocEntry() const;
636  virtual NextHopKey *Clone() const {
637  return new ReceiveNHKey(intf_key_->Clone(), policy_);
638  }
639 
640 private:
641  friend class ReceiveNH;
642  boost::scoped_ptr<InterfaceKey> intf_key_;
644 };
645 
646 class ReceiveNHData : public NextHopData {
647 public:
649  virtual ~ReceiveNHData() {};
650 
651 private:
652  friend class ReceiveNH;
654 };
655 
656 class ReceiveNH : public NextHop {
657 public:
658  ReceiveNH(Interface *intf, bool policy) :
659  NextHop(RECEIVE, true, policy), interface_(intf) { };
660  virtual ~ReceiveNH() { };
661 
662  virtual void SetKey(const DBRequestKey *key);
663  virtual std::string ToString() const { return "Local Receive"; };
664  // No change expected to Receive NH */
665  virtual bool ChangeEntry(const DBRequest *req) { return false;};
666  virtual void Delete(const DBRequest *req) {};
667  virtual void SendObjectLog(const NextHopTable *table,
668  AgentLogEvent::type event) const;
669  virtual bool CanAdd() const;
670  virtual bool NextHopIsLess(const DBEntry &rhs) const {
671  const ReceiveNH &a = static_cast<const ReceiveNH &>(rhs);
672  return interface_.get() < a.interface_.get();
673  };
674 
675  virtual KeyPtr GetDBRequestKey() const {
676  return DBEntryBase::KeyPtr
677  (new ReceiveNHKey(dynamic_cast<InterfaceKey *>(interface_->GetDBRequestKey().release()),
678  policy_));
679  };
680 
681  static void CreateReq(const string &interface);
682  static void Create(NextHopTable *table, const Interface *intf,
683  bool policy);
684  static void Delete(NextHopTable *table, const Interface *intf,
685  bool policy);
686  const Interface *GetInterface() const {return interface_.get();};
687 
688  virtual bool MatchEgressData(const NextHop *nh) const {
689  return false;
690  }
691 
692  virtual bool NeedMplsLabel() { return false; }
693 private:
696 };
697 
699 // Resolve NH definition
701 class ResolveNHKey : public NextHopKey {
702 public:
703  ResolveNHKey(const InterfaceKey *intf_key, bool policy) :
704  NextHopKey(NextHop::RESOLVE, policy),
705  intf_key_(intf_key->Clone()) { };
706  virtual ~ResolveNHKey() { };
707 
708  virtual NextHop *AllocEntry() const;
709  virtual NextHopKey *Clone() const {
710  return new ResolveNHKey(intf_key_->Clone(), policy_);
711  }
712 private:
713  friend class ResolveNH;
714  boost::scoped_ptr<const InterfaceKey> intf_key_;
716 };
717 
718 class ResolveNHData : public NextHopData {
719 public:
721  virtual ~ResolveNHData() { };
722 
723 private:
724  friend class ResolveNH;
726 };
727 
728 class ResolveNH : public NextHop {
729 public:
730  ResolveNH(const Interface *intf, bool policy) :
731  NextHop(RESOLVE, true, policy), interface_(intf) { };
732  virtual ~ResolveNH() { };
733 
734  virtual std::string ToString() const { return "Resolve"; };
735  // No change expected to Resolve NH */
736  virtual bool ChangeEntry(const DBRequest *req) { return false;};
737  virtual void Delete(const DBRequest *req) {};
738  virtual void SetKey(const DBRequestKey *key) { NextHop::SetKey(key); };
739  virtual bool CanAdd() const;
740  virtual bool NextHopIsLess(const DBEntry &rhs) const {
741  const ResolveNH &a = static_cast<const ResolveNH &>(rhs);
742  return interface_.get() < a.interface_.get();
743  };
744  virtual KeyPtr GetDBRequestKey() const {
745  boost::scoped_ptr<InterfaceKey> intf_key(
746  static_cast<InterfaceKey *>(interface_->GetDBRequestKey().release()));
747  return DBEntryBase::KeyPtr(new ResolveNHKey(intf_key.get(), policy_));
748  };
749  virtual bool DeleteOnZeroRefCount() const {
750  return true;
751  }
752  static void Create(const InterfaceKey *intf, bool policy);
753  static void CreateReq(const InterfaceKey *intf, bool policy);
754  const Interface* get_interface() const { return interface_.get();}
755 
756  virtual bool MatchEgressData(const NextHop *nh) const {
757  return false;
758  }
759  virtual bool NeedMplsLabel() { return false; }
760 
761 private:
764 };
765 
767 // ARP NH definition
769 class ArpNHKey : public NextHopKey {
770 public:
771  ArpNHKey(const string &vrf_name, const Ip4Address &ip, bool policy) :
772  NextHopKey(NextHop::ARP, policy), vrf_key_(vrf_name), dip_(ip) {
773  }
774  virtual ~ArpNHKey() { };
775 
776  virtual NextHop *AllocEntry() const;
777  virtual NextHopKey *Clone() const {
778  return new ArpNHKey(vrf_key_.name_, dip_, policy_);
779  }
780  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
781  const ArpNHKey &key = static_cast<const ArpNHKey &>(rhs);
782  if (vrf_key_.IsEqual(key.vrf_key_) == false) {
783  return vrf_key_.IsLess(key.vrf_key_);
784  }
785 
786  if (dip_ != key.dip_) {
787  return dip_ < key.dip_;
788  }
789 
790  return false;
791  }
792 private:
793  friend class ArpNH;
797 };
798 
799 class ArpNHData : public NextHopData {
800 public:
801  ArpNHData(InterfaceKey *intf_key) :
802  NextHopData(), intf_key_(intf_key),
803  mac_(), resolved_(false), valid_(false) { };
804 
805  ArpNHData(const MacAddress &mac, InterfaceKey *intf_key,
806  bool resolved) : NextHopData(), intf_key_(intf_key), mac_(mac),
807  resolved_(resolved), valid_(true) {
808  }
809  virtual ~ArpNHData() { };
810 
811 private:
812  friend class ArpNH;
813  boost::scoped_ptr<InterfaceKey> intf_key_;
815  bool resolved_;
816  bool valid_;
818 };
819 
820 class ArpNH : public NextHop {
821 public:
822  ArpNH(VrfEntry *vrf, const Ip4Address &ip) :
823  NextHop(ARP, false, false), vrf_(vrf, this), ip_(ip), interface_(), mac_() {};
824  virtual ~ArpNH() { };
825 
826  virtual std::string ToString() { return "ARP"; }
827  virtual bool NextHopIsLess(const DBEntry &rhs) const;
828  virtual void SetKey(const DBRequestKey *key);
829  virtual bool ChangeEntry(const DBRequest *req);
830  virtual void Delete(const DBRequest *req) {};
831  virtual KeyPtr GetDBRequestKey() const;
832  virtual void SendObjectLog(const NextHopTable *table,
833  AgentLogEvent::type event) const;
834  virtual bool CanAdd() const;
835 
836  const MacAddress &GetMac() const {return mac_;};
837  const Interface *GetInterface() const {return interface_.get();};
838  const boost::uuids::uuid &GetIfUuid() const;
839  const uint32_t vrf_id() const;
840  const Ip4Address *GetIp() const {return &ip_;};
841  const VrfEntry *GetVrf() const {return vrf_.get();};
842  bool GetResolveState() const {return valid_;}
843  virtual bool DeleteOnZeroRefCount() const {
844  return true;
845  }
846 
847  virtual bool MatchEgressData(const NextHop *nh) const {
848  const ArpNH *arp_nh = dynamic_cast<const ArpNH *>(nh);
849  if (arp_nh && vrf_ == arp_nh->vrf_ && ip_ == arp_nh->ip_) {
850  return true;
851  }
852  return false;
853  }
854  virtual bool NeedMplsLabel() { return false; }
855 
856 private:
862 };
863 
865 // NDP NH definition
867 class NdpNHKey : public NextHopKey {
868 public:
869  NdpNHKey(const string &vrf_name, const IpAddress &ip, bool policy) :
870  NextHopKey(NextHop::NDP, policy), vrf_key_(vrf_name), dip_(ip) {
871  }
872  virtual ~NdpNHKey() { };
873 
874  virtual NextHop *AllocEntry() const;
875  virtual NextHopKey *Clone() const {
876  return new NdpNHKey(vrf_key_.name_, dip_, policy_);
877  }
878  string ToString() {
879  return vrf_key_.name_ + dip_.to_string();
880  }
881 private:
882  friend class NdpNH;
886 };
887 
888 class NdpNHData : public NextHopData {
889 public:
890  NdpNHData(InterfaceKey *intf_key) :
891  NextHopData(), intf_key_(intf_key),
892  mac_(), resolved_(false), valid_(false) { };
893 
894  NdpNHData(const MacAddress &mac, InterfaceKey *intf_key,
895  bool resolved) : NextHopData(), intf_key_(intf_key), mac_(mac),
896  resolved_(resolved), valid_(true) {
897  }
898  virtual ~NdpNHData() { };
899 
900 private:
901  friend class NdpNH;
902  boost::scoped_ptr<InterfaceKey> intf_key_;
904  bool resolved_;
905  bool valid_;
907 };
908 
909 class NdpNH : public NextHop {
910 public:
911  NdpNH(VrfEntry *vrf, const IpAddress &ip) :
912  NextHop(NDP, false, false), vrf_(vrf, this), ip_(ip), interface_(), mac_() {};
913  virtual ~NdpNH() { };
914 
915  virtual std::string ToString() { return "NDP"; }
916  virtual bool NextHopIsLess(const DBEntry &rhs) const;
917  virtual void SetKey(const DBRequestKey *key);
918  virtual bool ChangeEntry(const DBRequest *req);
919  virtual void Delete(const DBRequest *req) {};
920  virtual KeyPtr GetDBRequestKey() const;
921  virtual void SendObjectLog(const NextHopTable *table,
922  AgentLogEvent::type event) const;
923  virtual bool CanAdd() const;
924 
925  const MacAddress &GetMac() const {return mac_;};
926  const Interface *GetInterface() const {return interface_.get();};
927  const boost::uuids::uuid &GetIfUuid() const;
928  const uint32_t vrf_id() const;
929  const IpAddress *GetIp() const {return &ip_;};
930  const VrfEntry *GetVrf() const {return vrf_.get();};
931  bool GetResolveState() const {return valid_;}
932  virtual bool DeleteOnZeroRefCount() const {
933  return true;
934  }
935 
936  virtual bool MatchEgressData(const NextHop *nh) const {
937  const NdpNH *ndp_nh = dynamic_cast<const NdpNH *>(nh);
938  if (ndp_nh && vrf_ == ndp_nh->vrf_ && ip_ == ndp_nh->ip_) {
939  return true;
940  }
941  return false;
942  }
943  virtual bool NeedMplsLabel() { return false; }
944 
945 private:
951 };
952 
954 // Tunnel NH definition
956 class TunnelNHKey : public NextHopKey {
957 public:
958  TunnelNHKey(const string &vrf_name,
959  const Ip4Address &sip,
960  const Ip4Address &dip,
961  bool policy,
963  const MacAddress &rewrite_dmac = MacAddress()) :
964  NextHopKey(NextHop::TUNNEL, policy), vrf_key_(vrf_name), sip_(sip),
966  };
967  virtual ~TunnelNHKey() { };
968 
969  virtual NextHop *AllocEntry() const;
970  virtual NextHopKey *Clone() const {
971  return new TunnelNHKey(vrf_key_.name_, sip_, dip_,
973  rewrite_dmac_);
974  }
975 
976  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
977  const TunnelNHKey &key = static_cast<const TunnelNHKey &>(rhs);
978  if (vrf_key_.IsEqual(key.vrf_key_) == false) {
979  return vrf_key_.IsLess(key.vrf_key_);
980  }
981 
982  if (sip_ != key.sip_) {
983  return sip_ < key.sip_;
984  }
985 
986  if (dip_ != key.dip_) {
987  return dip_ < key.dip_;
988  }
989 
990  if (rewrite_dmac_ != key.rewrite_dmac_) {
991  return rewrite_dmac_ < key.rewrite_dmac_;
992  }
993 
994  return tunnel_type_.IsLess(key.tunnel_type_);
995  }
996  void set_tunnel_type(TunnelType tunnel_type) {
997  tunnel_type_ = tunnel_type;
998  }
999  const Ip4Address& dip() const {
1000  return dip_;
1001  }
1003  return rewrite_dmac_;
1004  }
1005 protected:
1006  friend class TunnelNH;
1012 private:
1014 };
1015 
1016 class TunnelNHData : public NextHopData {
1017 public:
1019  virtual ~TunnelNHData() { };
1020 private:
1021  friend class TunnelNH;
1023 };
1024 
1026 // Labelled Tunnel NH definition
1029 public:
1030  LabelledTunnelNHKey(const string &vrf_name,
1031  const Ip4Address &sip,
1032  const Ip4Address &dip,
1033  bool policy,
1034  TunnelType type,
1035  const MacAddress &rewrite_dmac = MacAddress(),
1036  uint32_t label = 3) :
1037  TunnelNHKey(vrf_name, sip, dip, policy, type, rewrite_dmac),
1038  transport_mpls_label_(label) {
1039  };
1040  virtual ~LabelledTunnelNHKey() { };
1041 
1042  virtual NextHop *AllocEntry() const;
1043  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
1044  const LabelledTunnelNHKey &key = static_cast<const LabelledTunnelNHKey &>(rhs);
1045  if (vrf_key_.IsEqual(key.vrf_key_) == false) {
1046  return vrf_key_.IsLess(key.vrf_key_);
1047  }
1048 
1049  if (sip_ != key.sip_) {
1050  return sip_ < key.sip_;
1051  }
1052 
1053  if (dip_ != key.dip_) {
1054  return dip_ < key.dip_;
1055  }
1056 
1057  if (rewrite_dmac_ != key.rewrite_dmac_) {
1058  return rewrite_dmac_ < key.rewrite_dmac_;
1059  }
1061  }
1062  virtual NextHopKey *Clone() const {
1066  }
1067 private:
1069  friend class LabelledTunnelNH;
1071 };
1072 
1074 public:
1076  virtual ~LabelledTunnelNHData() { };
1077 private:
1078  friend class LabelledTunnelNH;
1080 };
1081 
1082 class PBBNHKey : public NextHopKey {
1083 public:
1084  PBBNHKey(const string &vrf_name, const MacAddress &dest_bmac, uint32_t isid):
1085  NextHopKey(NextHop::PBB, false), vrf_key_(vrf_name),
1086  dest_bmac_(dest_bmac), isid_(isid) {
1087  };
1088  virtual ~PBBNHKey() { };
1089 
1090  virtual NextHop *AllocEntry() const;
1091  virtual NextHopKey *Clone() const {
1092  return new PBBNHKey(vrf_key_.name_, dest_bmac_, isid_);
1093  }
1094 
1095  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
1096  const PBBNHKey &key = static_cast<const PBBNHKey &>(rhs);
1097  if (vrf_key_.IsEqual(key.vrf_key_) == false) {
1098  return vrf_key_.IsLess(key.vrf_key_);
1099  }
1100 
1101  if (dest_bmac_ != key.dest_bmac_) {
1102  return dest_bmac_ < key.dest_bmac_;
1103  }
1104 
1105  return isid_ < key.isid_;
1106  }
1107 
1108  const MacAddress dest_bmac() const {
1109  return dest_bmac_;
1110  }
1111 private:
1112  friend class PBBNH;
1115  uint32_t isid_;
1116  uint32_t label_;
1119 };
1120 
1121 class PBBNHData : public NextHopData {
1122 public:
1124  virtual ~PBBNHData() { };
1125 private:
1126  friend class PBBNH;
1128 };
1129 
1130 class PBBNH : public NextHop {
1131 public:
1132  PBBNH(VrfEntry *vrf, const MacAddress &dmac, uint32_t isid);
1133  virtual ~PBBNH();
1134 
1135  virtual std::string ToString() const {
1136  return "PBB to " + dest_bmac_.ToString();
1137  }
1138  virtual bool NextHopIsLess(const DBEntry &rhs) const;
1139  virtual void SetKey(const DBRequestKey *key);
1140  virtual bool ChangeEntry(const DBRequest *req);
1141  virtual void Delete(const DBRequest *req);
1142  virtual KeyPtr GetDBRequestKey() const;
1143  virtual bool CanAdd() const;
1144 
1145  const uint32_t vrf_id() const;
1146  const VrfEntry *vrf() const {return vrf_.get();};
1147  const MacAddress dest_bmac() const {return dest_bmac_;};
1148  const uint32_t isid() const { return isid_;};
1149  virtual void SendObjectLog(const NextHopTable *table,
1150  AgentLogEvent::type event) const;
1151  virtual bool DeleteOnZeroRefCount() const {
1152  return true;
1153  }
1154 
1155  virtual bool MatchEgressData(const NextHop *nh) const {
1156  const PBBNH *pbb_nh = dynamic_cast<const PBBNH *>(nh);
1157  if (pbb_nh && vrf_ == pbb_nh->vrf_ && dest_bmac_ == pbb_nh->dest_bmac_) {
1158  return true;
1159  }
1160  return false;
1161  }
1162 
1163  uint32_t label() const {
1164  return label_;
1165  }
1166 
1167  const NextHop *child_nh() const {
1168  return child_nh_.get();
1169  }
1170  virtual bool NeedMplsLabel() { return false; }
1171 private:
1174  uint32_t isid_;
1175  uint32_t label_;
1178 };
1179 
1180 
1182 // Interface NH definition
1185  enum Type {
1187  INET4 = 1,
1188  BRIDGE = 2,
1190  INET6 = 8,
1192  };
1193 };
1194 
1195 class InterfaceNHKey : public NextHopKey {
1196 public:
1197  InterfaceNHKey(InterfaceKey *intf, bool policy, uint8_t flags,
1198  const MacAddress &mac) :
1199  NextHopKey(NextHop::INTERFACE, policy), intf_key_(intf),
1200  flags_(flags), dmac_(mac) {
1201  //TODO evpn changes remove this, just extra check
1202  assert((flags != (InterfaceNHFlags::INVALID)) ||
1203  (flags == (InterfaceNHFlags::INET4)) ||
1206  (flags ==
1208  }
1209 
1210  virtual ~InterfaceNHKey() {};
1211  const boost::uuids::uuid &GetUuid() const {return intf_key_->uuid_;};
1212  const std::string& name() const { return intf_key_->name_;};
1213  const Interface::Type &intf_type() const {return intf_key_->type_;}
1214  const InterfaceKey *intf_key() const { return intf_key_.get(); }
1215  void set_flags(uint8_t flags) {flags_ = flags;}
1216  const uint8_t &flags() const { return flags_; }
1217  const MacAddress &dmac() const { return dmac_; }
1218 
1219  virtual NextHop *AllocEntry() const;
1220  virtual NextHopKey *Clone() const {
1221  //TODO evpn changes remove this, just extra check
1222  assert((flags_ != (InterfaceNHFlags::INVALID)) ||
1226  (flags_ ==
1228  return new InterfaceNHKey(intf_key_->Clone(), policy_, flags_, dmac_);
1229  }
1230  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
1231  const InterfaceNHKey &key = static_cast<const InterfaceNHKey &>(rhs);
1232  if (intf_key_->IsEqual(*key.intf_key_.get()) == false) {
1233  return intf_key_->IsLess(*key.intf_key_.get());
1234  }
1235 
1236  if (flags_ != key.flags_) {
1237  return flags_ < key.flags_;
1238  }
1239 
1240  return dmac_ < key.dmac_;
1241  }
1242 
1243 private:
1244  friend class InterfaceNH;
1245  boost::scoped_ptr<InterfaceKey> intf_key_;
1246  uint8_t flags_;
1248 };
1249 
1251 public:
1252  InterfaceNHData(const string vrf_name) :
1253  NextHopData(), vrf_key_(vrf_name), layer2_control_word_(false) { }
1254  InterfaceNHData(const string vrf_name, bool learning_enabled, bool etree_leaf,
1255  bool layer2_control_word):
1256  NextHopData(learning_enabled, etree_leaf), vrf_key_(vrf_name),
1257  layer2_control_word_(layer2_control_word) {}
1258  virtual ~InterfaceNHData() { }
1259 
1260 private:
1261  friend class InterfaceNH;
1265 };
1266 
1267 class InterfaceNH : public NextHop {
1268 public:
1269  InterfaceNH(Interface *intf, bool policy, uint8_t flags,
1270  const MacAddress &mac) :
1271  NextHop(INTERFACE, true, policy), interface_(intf),
1272  flags_(flags), dmac_(mac), vrf_(NULL, this),
1273  delete_on_zero_refcount_(false) { };
1274  InterfaceNH(Interface *intf, bool policy, const MacAddress &mac) :
1275  NextHop(INTERFACE, true, policy), interface_(intf),
1276  flags_(InterfaceNHFlags::INET4), dmac_(mac), vrf_(NULL, this),
1277  delete_on_zero_refcount_(false) {};
1278  virtual ~InterfaceNH() { };
1279 
1280  virtual std::string ToString() const {
1281  return "InterfaceNH : " + interface_->name();
1282  };
1283  virtual bool NextHopIsLess(const DBEntry &rhs) const;
1284  virtual void SetKey(const DBRequestKey *key);
1285  virtual bool ChangeEntry(const DBRequest *req);
1286  virtual void Delete(const DBRequest *req) {};
1287  virtual KeyPtr GetDBRequestKey() const;
1288  virtual bool CanAdd() const;
1289  virtual bool NeedMplsLabel();
1290  virtual void SendObjectLog(const NextHopTable *table,
1291  AgentLogEvent::type event) const;
1292 
1293  const Interface *GetInterface() const {return interface_.get();};
1294  const MacAddress &GetDMac() const {return dmac_;};
1295  bool IsVxlanRouting() const {
1297  }
1299  bool IsBridge() const { return flags_ & InterfaceNHFlags::BRIDGE; };
1300  uint8_t GetFlags() const {return flags_;};
1301  const boost::uuids::uuid &GetIfUuid() const;
1302  const VrfEntry *GetVrf() const {return vrf_.get();};
1303 
1304  static void CreateMulticastVmInterfaceNH(const boost::uuids::uuid &intf_uuid,
1305  const MacAddress &dmac,
1306  const string &vrf_name,
1307  const string &intf_name);
1308  static void DeleteMulticastVmInterfaceNH(const boost::uuids::uuid &intf_uuid,
1309  const MacAddress &dmac,
1310  const std::string &intf_name);
1311  static void CreateL2VmInterfaceNH(const boost::uuids::uuid &intf_uuid,
1312  const MacAddress &dmac,
1313  const string &vrf_name,
1314  bool learning_enabled,
1315  bool etree_leaf,
1316  bool layer2_control_word,
1317  const std::string &intf_name);
1318  static void DeleteL2InterfaceNH(const boost::uuids::uuid &intf_uuid,
1319  const MacAddress &mac,
1320  const std::string &intf_name);
1321  static void CreateL3VmInterfaceNH(const boost::uuids::uuid &intf_uuid,
1322  const MacAddress &dmac,
1323  const string &vrf_name,
1324  bool learning_enabled,
1325  const std::string &intf_name);
1326  static void DeleteL3InterfaceNH(const boost::uuids::uuid &intf_uuid,
1327  const MacAddress &mac,
1328  const std::string &intf_name);
1329  static void DeleteNH(const boost::uuids::uuid &intf_uuid,
1330  bool policy, uint8_t flags,
1331  const MacAddress &mac, const std::string &intf_name);
1332  static void CreatePacketInterfaceNh(Agent *agent, const string &ifname);
1333  static void CreateInetInterfaceNextHop(const string &ifname,
1334  const string &vrf_name,
1335  const MacAddress &mac);
1336  static void DeleteInetInterfaceNextHop(const string &ifname,
1337  const MacAddress &mac);
1338  static void CreatePhysicalInterfaceNh(const string &ifname,
1339  const MacAddress &mac);
1340  static void DeletePhysicalInterfaceNh(const string &ifname,
1341  const MacAddress &mac);
1342  virtual bool DeleteOnZeroRefCount() const {
1343  return delete_on_zero_refcount_;
1344  }
1345 
1348  }
1349 
1350  virtual bool MatchEgressData(const NextHop *nh) const {
1351  const InterfaceNH *intf_nh =
1352  dynamic_cast<const InterfaceNH *>(nh);
1353  if (intf_nh && interface_ == intf_nh->interface_) {
1354  return true;
1355  }
1356  return false;
1357  }
1358 
1359  bool layer2_control_word() const {
1360  return layer2_control_word_;
1361  }
1362 
1363 private:
1365  uint8_t flags_;
1371 };
1372 
1374 // VRF NH definition
1376 class VrfNHKey : public NextHopKey {
1377 public:
1378  VrfNHKey(const string &vrf_name, bool policy, bool bridge_nh) :
1379  NextHopKey(NextHop::VRF, policy), vrf_key_(vrf_name), policy_(policy),
1380  bridge_nh_(bridge_nh) {
1381  }
1382  virtual ~VrfNHKey() { }
1383 
1384  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
1385  const VrfNHKey &key = static_cast<const VrfNHKey &>(rhs);
1386  if (vrf_key_.IsEqual(key.vrf_key_) == false) {
1387  return vrf_key_.IsLess(key.vrf_key_);
1388  }
1389 
1390  if (policy_ != key.policy_) {
1391  return policy_ < key.policy_;
1392  }
1393  return bridge_nh_ < key.bridge_nh_;
1394  }
1395 
1396  virtual NextHop *AllocEntry() const;
1397  virtual NextHopKey *Clone() const {
1398  return new VrfNHKey(vrf_key_.name_, policy_, bridge_nh_);
1399  }
1400  const std::string &GetVrfName() const { return vrf_key_.name_; }
1401  const bool &GetBridgeNh() const { return bridge_nh_; }
1402 
1403 private:
1404  friend class VrfNH;
1406  bool policy_;
1409 };
1410 
1411 class VrfNHData : public NextHopData {
1412 public:
1413  VrfNHData(bool flood_unknown_unicast, bool learning_enabled,
1414  bool layer2_control_word):
1415  NextHopData(learning_enabled, true),
1416  flood_unknown_unicast_(flood_unknown_unicast),
1417  layer2_control_word_(layer2_control_word) {}
1418  virtual ~VrfNHData() { }
1419 private:
1420  friend class VrfNH;
1424 };
1425 
1426 class VrfNH : public NextHop {
1427 public:
1428  VrfNH(VrfEntry *vrf, bool policy, bool bridge_nh_):
1429  NextHop(VRF, true, policy), vrf_(vrf, this), bridge_nh_(bridge_nh_),
1430  flood_unknown_unicast_(false) {}
1431  virtual ~VrfNH() { };
1432 
1433  virtual std::string ToString() const { return "VrfNH"; };
1434  virtual bool NextHopIsLess(const DBEntry &rhs) const;
1435  virtual void SetKey(const DBRequestKey *key);
1436  // No change expected for VRF Nexthop
1437  virtual bool ChangeEntry(const DBRequest *req);
1438  virtual void Delete(const DBRequest *req) {};
1439  virtual KeyPtr GetDBRequestKey() const;
1440  virtual void SendObjectLog(const NextHopTable *table,
1441  AgentLogEvent::type event) const;
1442  virtual bool CanAdd() const;
1443 
1444  const VrfEntry *GetVrf() const {return vrf_.get();};
1445  virtual bool DeleteOnZeroRefCount() const {
1446  return true;
1447  }
1448  bool bridge_nh() const { return bridge_nh_; }
1449  bool flood_unknown_unicast() const {
1450  return flood_unknown_unicast_;
1451  }
1452 
1453  virtual bool MatchEgressData(const NextHop *nh) const {
1454  const VrfNH *vrf_nh = dynamic_cast<const VrfNH *>(nh);
1455  if (vrf_nh && vrf_ == vrf_nh->vrf_) {
1456  return true;
1457  }
1458  return false;
1459  }
1460 
1461  bool layer2_control_word() const {
1462  return layer2_control_word_;
1463  }
1464  virtual bool NeedMplsLabel() { return true; }
1465 
1466 private:
1468  // NH created by VXLAN
1473 };
1474 
1476 // VLAN NH definition
1478 class VlanNHKey : public NextHopKey {
1479 public:
1480  VlanNHKey(const boost::uuids::uuid &vm_port_uuid, uint16_t vlan_tag) :
1481  NextHopKey(NextHop::VLAN, false),
1482  intf_key_(new VmInterfaceKey(AgentKey::ADD_DEL_CHANGE, vm_port_uuid,
1483  "")),
1484  vlan_tag_(vlan_tag) {
1485  }
1486  VlanNHKey(InterfaceKey *key, uint16_t vlan_tag) :
1487  NextHopKey(NextHop::VLAN, false), intf_key_(key), vlan_tag_(vlan_tag) {
1488  }
1489 
1490  virtual ~VlanNHKey() {}
1491  virtual NextHop *AllocEntry() const;
1492  virtual NextHopKey *Clone() const {
1493  return new VlanNHKey(intf_key_->Clone(), vlan_tag_);
1494  }
1495  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const {
1496  const VlanNHKey &key = static_cast<const VlanNHKey &>(rhs);
1497  if (intf_key_->IsEqual(*key.intf_key_.get()) == false) {
1498  return intf_key_->IsLess(*key.intf_key_.get());
1499  }
1500 
1501  return vlan_tag_ < key.vlan_tag_;
1502  }
1503  const boost::uuids::uuid& GetUuid() const {return intf_key_->uuid_;}
1504  const std::string& name() const { return intf_key_->name_;}
1505  const uint16_t vlan_tag() const { return vlan_tag_; }
1506 private:
1507  friend class VlanNH;
1508  boost::scoped_ptr<InterfaceKey> intf_key_;
1509  uint16_t vlan_tag_;
1511 };
1512 
1513 class VlanNHData : public NextHopData {
1514 public:
1515  VlanNHData(const string vrf_name, const MacAddress &smac,
1516  const MacAddress &dmac):
1517  NextHopData(), smac_(smac), dmac_(dmac), vrf_key_(vrf_name) {}
1518  virtual ~VlanNHData() { }
1519 private:
1520  friend class VlanNH;
1525 };
1526 
1527 class VlanNH : public NextHop {
1528 public:
1529  VlanNH(Interface *intf, uint32_t vlan_tag):
1530  NextHop(VLAN, true, false), interface_(intf), vlan_tag_(vlan_tag),
1531  smac_(), dmac_(), vrf_(NULL, this) { };
1532  virtual ~VlanNH() { };
1533 
1534  bool NextHopIsLess(const DBEntry &rhs) const;
1535  virtual void SetKey(const DBRequestKey *key);
1536  virtual KeyPtr GetDBRequestKey() const;
1537  virtual void Delete(const DBRequest *req) {};
1538  virtual bool ChangeEntry(const DBRequest *req);
1539  virtual void SendObjectLog(const NextHopTable *table,
1540  AgentLogEvent::type event) const;
1541  virtual bool CanAdd() const;
1542 
1543  const Interface *GetInterface() const {return interface_.get();};
1544  uint16_t GetVlanTag() const {return vlan_tag_;};
1545  const boost::uuids::uuid &GetIfUuid() const;
1546  const VrfEntry *GetVrf() const {return vrf_.get();};
1547  const MacAddress &GetSMac() const {return smac_;};
1548  const MacAddress &GetDMac() const {return dmac_;};
1549  static VlanNH *Find(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag);
1550 
1551  static void Create(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag,
1552  const std::string &vrf_name, const MacAddress &smac,
1553  const MacAddress &dmac);
1554  static void Delete(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag);
1555  static void CreateReq(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag,
1556  const std::string &vrf_name, const MacAddress &smac,
1557  const MacAddress &dmac);
1558  static void DeleteReq(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag);
1559 
1560  virtual bool MatchEgressData(const NextHop *nh) const {
1561  const VlanNH *vlan_nh = dynamic_cast<const VlanNH *>(nh);
1562  if (vlan_nh && interface_ == vlan_nh->interface_) {
1563  return true;
1564  }
1565  return false;
1566  }
1567  virtual bool NeedMplsLabel() { return true; }
1568 
1569 private:
1571  uint16_t vlan_tag_;
1576 };
1577 
1579 // Component NH definition
1581 //TODO Shift this to class CompositeNH
1582 struct Composite {
1583  enum Type {
1596  LU_ECMP // label unicast ecmp
1597  };
1598 };
1599 //TODO remove defines
1600 #define COMPOSITETYPE Composite::Type
1601 
1603 public:
1604  ComponentNH(uint32_t label, const NextHop *nh):
1605  label_(label), nh_(nh) {}
1606  ComponentNH():label_(0), nh_(NULL) {}
1607 
1608  ComponentNH(uint32_t label, NextHop *nh): label_(label), nh_(nh) {
1609  }
1610 
1611  bool operator == (const ComponentNH &rhs) const {
1612  if (label_ == rhs.label_ && nh_.get() == rhs.nh_.get()) {
1613  return true;
1614  }
1615 
1616  return false;
1617  }
1618 
1619  std::string ToString() {
1620  return nh_->ToString();
1621  }
1622 
1623  const NextHop* nh() const {
1624  return nh_.get();
1625  }
1626 
1627  uint32_t label() const {
1628  return label_;
1629  }
1630 private:
1631  uint32_t label_;
1634 };
1635 
1636 typedef boost::shared_ptr<const ComponentNH> ComponentNHPtr;
1637 typedef std::vector<ComponentNHPtr> ComponentNHList;
1638 
1640 typedef boost::shared_ptr<const ComponentNHKey> ComponentNHKeyPtr;
1641 typedef std::vector<ComponentNHKeyPtr> ComponentNHKeyList;
1642 
1644 public:
1645  ComponentNHKey(int label, std::unique_ptr<const NextHopKey> key) :
1646  label_(label), nh_key_(std::move(key)) { }
1647  ComponentNHKey(int label, Composite::Type type, bool policy,
1648  const ComponentNHKeyList &component_nh_list,
1649  const std::string &vrf_name);
1650  ComponentNHKey(int label, const boost::uuids::uuid &intf_uuid,
1651  uint8_t flags, const MacAddress &mac):
1652  label_(label),
1653  nh_key_(new InterfaceNHKey(
1654  new VmInterfaceKey(AgentKey::ADD_DEL_CHANGE, intf_uuid, ""),
1655  false, flags, mac)) {
1656  }
1657  ComponentNHKey(int label, uint8_t tag, const boost::uuids::uuid &intf_uuid):
1658  label_(label), nh_key_(new VlanNHKey(intf_uuid, tag)) {
1659  }
1660 
1661  ComponentNHKey(int label, const string &vrf_name, const Ip4Address &sip,
1662  const Ip4Address &dip, bool policy, TunnelType::TypeBmap bmap) :
1663  label_(label), nh_key_(new TunnelNHKey(vrf_name, sip, dip, policy,
1664  TunnelType::ComputeType(bmap))) {
1665  }
1666 
1667  virtual ~ComponentNHKey() { }
1668 
1669  bool operator == (const ComponentNHKey &rhs) const {
1670  if (label_ != rhs.label_) {
1671  return false;
1672  }
1673  return nh_key_->IsEqual(*(rhs.nh_key_.get()));
1674  }
1675 
1676  uint32_t label() const { return label_; }
1677  const NextHopKey* nh_key() const { return nh_key_.get(); }
1678 private:
1679  uint32_t label_;
1680  std::unique_ptr<const NextHopKey> nh_key_;
1682 };
1683 
1684 class CompositeNHKey : public NextHopKey {
1685 public:
1687  const ComponentNHKeyList &component_nh_key_list,
1688  const std::string &vrf_name) :
1689  NextHopKey(NextHop::COMPOSITE, policy),
1690  composite_nh_type_(type), component_nh_key_list_(component_nh_key_list),
1691  vrf_key_(vrf_name){
1692 
1693  validate_mcast_src_ = true;
1694  }
1695 
1697  const ComponentNHKeyList &component_nh_key_list,
1698  const std::string &vrf_name) :
1699  NextHopKey(NextHop::COMPOSITE, policy),
1700  composite_nh_type_(type), validate_mcast_src_(validate_mcast_src),
1701  component_nh_key_list_(component_nh_key_list), vrf_key_(vrf_name){
1702  }
1703 
1704  virtual CompositeNHKey *Clone() const;
1705 
1706  virtual ~CompositeNHKey() {
1707  }
1708  virtual NextHop *AllocEntry() const;
1709  virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const;
1710 
1711  ComponentNHKeyList::const_iterator begin() const {
1712  return component_nh_key_list_.begin();
1713  }
1714 
1715  ComponentNHKeyList::const_iterator end() const {
1716  return component_nh_key_list_.end();
1717  }
1718 
1719  const ComponentNHKeyList& component_nh_key_list() const {
1720  return component_nh_key_list_;
1721  }
1722  bool Reorder(Agent *agent, uint32_t label, const NextHop *nh);
1723  void CreateTunnelNH(Agent *agent);
1724  void CreateTunnelNHReq(Agent *agent);
1725  void ChangeTunnelType(TunnelType::Type tunnel_type);
1728 
1729  void ReplaceLocalNexthop(const ComponentNHKeyList &new_comp_nh);
1730 private:
1731  friend class CompositeNH;
1732  bool ExpandLocalCompositeNH(Agent *agent);
1733  void insert(ComponentNHKeyPtr nh_key);
1734  void erase(ComponentNHKeyPtr nh_key);
1735  bool find(ComponentNHKeyPtr nh_key);
1736 
1739  ComponentNHKeyList component_nh_key_list_;
1742 };
1743 
1745 public:
1747  layer2_control_word_(false),
1748  component_nh_key_list_(ComponentNHKeyList()) {}
1749  CompositeNHData(bool pbb_nh, bool learning_enabled, bool layer2_control_word) :
1750  NextHopData(learning_enabled, true), pbb_nh_(pbb_nh),
1751  layer2_control_word_(layer2_control_word),
1752  component_nh_key_list_(ComponentNHKeyList()) {}
1753  CompositeNHData(const ComponentNHKeyList &component_nh_key_list) :
1754  NextHopData(), pbb_nh_(false), layer2_control_word_(false),
1755  component_nh_key_list_(component_nh_key_list) {}
1756 private:
1757  friend class CompositeNH;
1758  bool pbb_nh_;
1760  ComponentNHKeyList component_nh_key_list_;
1762 };
1763 
1764 //Composite NH
1765 //* Key of composite NH is list of component NH key(mpls label + Nexthop Key)
1766 //* In data part we maintain list of component NH(mpls label + Nexthop reference)
1767 //* In case of ECMP composite NH ordering of component NH is important, since
1768 // flows would be pointing to one of component NH, and any change in
1769 // composite NH should not disturb flow which have been already setup.
1770 // If one of the component NH gets deleted, then a empty component NH
1771 // would be installed, which would resulting in kernel trapping flow
1772 // which are pointing to that component NH
1773 //* In case of multicast composite NH ordering of the component NH is not
1774 // important
1775 class CompositeNH : public NextHop {
1776 public:
1777  static const uint32_t kInvalidComponentNHIdx = 0xFFFFFFFF;
1779  const ComponentNHKeyList &component_nh_key_list, VrfEntry *vrf):
1780  NextHop(COMPOSITE, policy), composite_nh_type_(type),
1781  component_nh_key_list_(component_nh_key_list), vrf_(vrf, this),
1782  pbb_nh_(false) {
1783  validate_mcast_src_= true;
1785  }
1786 
1788  const ComponentNHKeyList &component_nh_key_list, VrfEntry *vrf):
1789  NextHop(COMPOSITE, policy), composite_nh_type_(type),
1790  validate_mcast_src_(validate_mcast_src),
1791  component_nh_key_list_(component_nh_key_list), vrf_(vrf, this),
1792  pbb_nh_(false) {
1794  }
1795 
1796  virtual ~CompositeNH() { };
1797  virtual std::string ToString() const { return "Composite NH"; };
1798  virtual bool NextHopIsLess(const DBEntry &rhs) const;
1799  virtual void SetKey(const DBRequestKey *key);
1800  virtual bool ChangeEntry(const DBRequest *req);
1801  virtual void Delete(const DBRequest *req);
1802  virtual KeyPtr GetDBRequestKey() const;
1803  virtual bool CanAdd() const;
1804 
1805  virtual void SendObjectLog(const NextHopTable *table,
1806  AgentLogEvent::type event) const;
1807  ComponentNHList::const_iterator begin() const {
1808  return component_nh_list_.begin();
1809  }
1810 
1811  ComponentNHList::const_iterator end() const {
1812  return component_nh_list_.end();
1813  }
1814 
1815  size_t ComponentNHCount() const {
1816  return component_nh_list_.size();
1817  }
1818  uint32_t ActiveComponentNHCount() const {
1819  uint32_t idx = 0;
1820  uint32_t active_count = 0;
1821  while (idx < component_nh_list_.size()) {
1822  if (component_nh_list_[idx].get() != NULL) {
1823  active_count++;
1824  }
1825  idx++;
1826  }
1827  return active_count;
1828  }
1829 
1830  uint32_t PickMember(uint32_t seed, uint32_t affinity_index,
1831  bool ingress) const;
1832  const NextHop* GetNH(uint32_t idx) const {
1833  if (idx >= component_nh_list_.size()) {
1834  return NULL;
1835  }
1836  if (component_nh_list_[idx].get() == NULL) {
1837  return NULL;
1838  }
1839  return (*component_nh_list_[idx]).nh();
1840  }
1841 
1843  return composite_nh_type_;
1844  }
1845 
1848  }
1849 
1850  bool validate_mcast_src() const {
1851  return validate_mcast_src_;
1852  }
1853 
1854  bool GetOldNH(const CompositeNHData *data, ComponentNH &);
1855 
1856  virtual bool DeleteOnZeroRefCount() const {
1857  return true;
1858  }
1859  virtual void OnZeroRefCount() {
1860  return;
1861  }
1862  ComponentNHKeyList AddComponentNHKey(ComponentNHKeyPtr component_nh_key,
1863  bool &comp_nh_policy) const;
1864  ComponentNHKeyList DeleteComponentNHKey(ComponentNHKeyPtr
1865  component_nh_key,
1866  bool &comp_nh_new_policy) const;
1867  bool UpdateComponentNHKey(uint32_t label, NextHopKey *nh_key,
1868  ComponentNHKeyList &component_nh_key_list, bool &comp_nh_policy) const;
1869  const ComponentNHList& component_nh_list() const {
1870  return component_nh_list_;
1871  }
1872  const ComponentNHKeyList& component_nh_key_list() const {
1873  return component_nh_key_list_;
1874  }
1875  const VrfEntry* vrf() const {
1876  return vrf_.get();
1877  }
1878  uint32_t hash(uint32_t seed, bool ingress) const {
1879  size_t size = component_nh_list_.size();
1880  if (size == 0) {
1881  return kInvalidComponentNHIdx;
1882  }
1883  uint32_t idx = seed % size;
1884  while (component_nh_list_[idx].get() == NULL ||
1885  component_nh_list_[idx]->nh() == NULL ||
1886  component_nh_list_[idx]->nh()->IsActive() == false ||
1887  (ingress == false &&
1888  component_nh_list_[idx]->nh()->GetType() == NextHop::TUNNEL)) {
1889  idx = (idx + 1) % size;
1890  if (idx == seed % size) {
1891  idx = kInvalidComponentNHIdx;
1892  break;
1893  }
1894  }
1895  return idx;
1896  }
1897  bool HasVmInterface(const VmInterface *vmi) const;
1898  bool GetIndex(ComponentNH &nh, uint32_t &idx) const;
1899  const ComponentNH* Get(uint32_t idx) const {
1900  return component_nh_list_[idx].get();
1901  }
1903  const NextHop *GetLocalNextHop() const;
1904 
1905  virtual bool MatchEgressData(const NextHop *nh) const {
1906  return false;
1907  }
1908  virtual bool NeedMplsLabel() { return false; }
1909  uint8_t EcmpHashFieldInUse() const {
1911  }
1913  void UpdateEcmpHashFieldsUponRouteDelete(Agent *agent, const string &vrf_name);
1914  bool pbb_nh() const {
1915  return pbb_nh_;
1916  }
1917 
1918  bool layer2_control_word() const {
1919  return layer2_control_word_;
1920  }
1921 
1923 
1924 private:
1925  void CreateComponentNH(Agent *agent, TunnelType::Type type) const;
1926  void ChangeComponentNHKeyTunnelType(ComponentNHKeyList &component_nh_list,
1927  TunnelType::Type type) const;
1929  // For relaxing source check in vrouter for mcast data packets
1930  // in R5.1 where support is for source outside contrail for <*,G>.
1932  ComponentNHKeyList component_nh_key_list_;
1933  ComponentNHList component_nh_list_;
1936  bool pbb_nh_;
1939 };
1940 
1942 // NextHop DBTable definition
1944 class NextHopTable : public AgentDBTable {
1945 public:
1946  static const uint32_t kRpfDisableIndex = 0;
1947  static const uint32_t kRpfDiscardIndex = 2;
1948 
1949  NextHopTable(DB *db, const std::string &name);
1950  virtual ~NextHopTable();
1951 
1952  virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
1953  virtual size_t Hash(const DBEntry *entry) const {return 0;};
1954  virtual size_t Hash(const DBRequestKey *key) const {return 0;};
1956  const std::string &context);
1957 
1958  virtual DBEntry *Add(const DBRequest *req);
1959  virtual bool OnChange(DBEntry *entry, const DBRequest *req);
1960  virtual bool Resync(DBEntry *entry, const DBRequest *req);
1961  virtual bool Delete(DBEntry *entry, const DBRequest *req);
1962 
1963  virtual void OnZeroRefcount(AgentDBEntry *e);
1964  void Process(DBRequest &req);
1965  Interface *FindInterface(const InterfaceKey &key) const;
1966  VrfEntry *FindVrfEntry(const VrfKey &key) const;
1967  static DBTableBase *CreateTable(DB *db, const std::string &name);
1969 
1970  void set_discard_nh(NextHop *nh) { discard_nh_ = nh; }
1971  NextHop *discard_nh() const {return discard_nh_;}
1972 
1975  // NextHop index managing routines
1976  void FreeInterfaceId(size_t index) { index_table_.Remove(index); }
1977  NextHop *FindNextHop(size_t index);
1978  uint32_t ReserveIndex();
1979  void CheckVrNexthopLimit();
1980  uint32_t NhIndexCount() { return index_table_.InUseIndexCount(); }
1981  void AddWithoutAlloc(DBEntry *entry);
1982  void RemoveWithoutDelete(DBEntry *entry);
1983 private:
1984  NextHop *AllocWithKey(const DBRequestKey *k) const;
1985  virtual std::unique_ptr<DBEntry> GetEntry(const DBRequestKey *key) const;
1986 
1992 };
1993 #endif // vnsw_agent_nexthop_hpp
uint32_t PickMember(uint32_t seed, uint32_t affinity_index, bool ingress) const
Definition: nexthop.cc:1861
virtual std::string ToString() const
Definition: nexthop.h:605
static PriorityList priority_list_
Definition: nexthop.h:332
uint32_t TypeBmap
Definition: nexthop.h:248
virtual std::string ToString() const
Definition: nexthop.h:663
const ComponentNH * Get(uint32_t idx) const
Definition: nexthop.h:1899
static void FillObjectLogMac(const unsigned char *m, NextHopObjectLogInfo &info)
Definition: nexthop.cc:253
const NextHop * nh() const
Definition: nexthop.h:1623
static void Create()
Definition: nexthop.cc:1626
const Interface * GetInterface() const
Definition: nexthop.h:1293
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:2874
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:2112
ArpNH(VrfEntry *vrf, const Ip4Address &ip)
Definition: nexthop.h:822
virtual std::string ToString() const
Definition: nexthop.h:1135
bool IsEqual(const NextHopKey &rhs) const
Definition: nexthop.h:481
virtual ~VrfNH()
Definition: nexthop.h:1431
uint16_t vlan_tag_
Definition: nexthop.h:1509
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:562
const bool & GetBridgeNh() const
Definition: nexthop.h:1401
MacAddress rewrite_dmac_
Definition: nexthop.h:1011
uint32_t free_index_
Definition: nexthop.h:229
Interface * FindInterface(const InterfaceKey &key) const
Definition: nexthop.cc:358
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:943
void ReplaceLocalNexthop(const ComponentNHKeyList &new_comp_nh)
Definition: nexthop.cc:1774
bool GetOldNH(const CompositeNHData *data, ComponentNH &)
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:2842
NdpNH(VrfEntry *vrf, const IpAddress &ip)
Definition: nexthop.h:911
MemberList(int max_size)
Definition: nexthop.h:25
DISALLOW_COPY_AND_ASSIGN(ReceiveNH)
const Interface * GetFirstLocalEcmpMemberInterface() const
Definition: nexthop.cc:1837
L2ReceiveNH()
Definition: nexthop.h:602
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.h:738
static void CreateReq(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag, const std::string &vrf_name, const MacAddress &smac, const MacAddress &dmac)
Definition: nexthop.cc:1729
~TunnelType()
Definition: nexthop.h:252
NextHopTable(DB *db, const std::string &name)
Definition: nexthop.cc:278
void UpdateEcmpHashFieldsUponRouteDelete(Agent *agent, const string &vrf_name)
Definition: nexthop.cc:2355
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:509
uint8_t flags
Definition: db_entry.h:86
ComponentNHKeyList component_nh_key_list_
Definition: nexthop.h:1932
const VrfEntry * GetVrf() const
Definition: nexthop.h:1546
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:1350
DISALLOW_COPY_AND_ASSIGN(VrfNH)
iterator end()
Definition: nexthop.h:169
NextHop * discard_nh_
Definition: nexthop.h:1987
VlanNHKey(InterfaceKey *key, uint16_t vlan_tag)
Definition: nexthop.h:1486
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:1674
CompositeNHKey(COMPOSITETYPE type, bool policy, const ComponentNHKeyList &component_nh_key_list, const std::string &vrf_name)
Definition: nexthop.h:1686
MemberList()
Definition: nexthop.h:28
const Ip4Address & dip() const
Definition: nexthop.h:999
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:737
DISALLOW_COPY_AND_ASSIGN(ComponentNH)
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:525
TunnelType tunnel_type_
Definition: nexthop.h:1010
virtual bool NeedMplsLabel()
Definition: nexthop.h:759
ComponentNH(uint32_t label, const NextHop *nh)
Definition: nexthop.h:1604
void set_flags(uint8_t flags)
Definition: nexthop.h:1215
static void CreateReq(const InterfaceKey *intf, bool policy)
Definition: nexthop.cc:1590
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:970
uint32_t hash_id
Definition: nexthop.h:230
virtual ~PBBNHKey()
Definition: nexthop.h:1088
const MacAddress & GetSMac() const
Definition: nexthop.h:1547
uint32_t GetRefCount() const
Definition: agent_db.h:54
Definition: vrf.h:86
static Type default_type_
Definition: nexthop.h:333
bool learning_enabled() const
Definition: nexthop.h:423
uint32_t isid_
Definition: nexthop.h:1174
NextHop * FindNextHop(size_t index)
Definition: nexthop.cc:3447
virtual ~VlanNHKey()
Definition: nexthop.h:1490
const uint32_t vrf_id() const
Definition: nexthop.cc:505
static const uint32_t kInvalidComponentNHIdx
Definition: nexthop.h:1777
const VrfEntry * GetVrf() const
Definition: nexthop.h:1302
bool layer2_control_word_
Definition: nexthop.h:1759
uint32_t NhIndexCount()
Definition: nexthop.h:1980
VrfKey vrf_key_
Definition: nexthop.h:794
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:1155
COMPOSITETYPE composite_nh_type_
Definition: nexthop.h:1737
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.h:665
virtual bool CanAdd() const
Definition: nexthop.cc:1636
virtual void Add(Agent *agent, const DBRequest *req)
Definition: nexthop.cc:109
virtual ~ResolveNHKey()
Definition: nexthop.h:706
virtual ~ArpNHKey()
Definition: nexthop.h:774
DISALLOW_COPY_AND_ASSIGN(VlanNHData)
static void DeleteReq(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag)
Definition: nexthop.cc:1738
virtual bool MatchEgressData(const NextHop *nh) const =0
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:932
NextHop::Type type_
Definition: nexthop.h:512
CompositeNHData(const ComponentNHKeyList &component_nh_key_list)
Definition: nexthop.h:1753
void set_id(uint32_t index)
Definition: nexthop.h:409
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:576
static std::string GetString(uint32_t type)
Definition: nexthop.h:278
NextHop * l2_receive_nh() const
Definition: nexthop.h:1974
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:1755
InterfaceNH(Interface *intf, bool policy, const MacAddress &mac)
Definition: nexthop.h:1274
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.h:740
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:1043
void UpdateFreeIndex()
Definition: nexthop.h:101
MplsLabel * AllocateLabel(Agent *agent, const NextHopKey *key)
Definition: nexthop.cc:105
virtual bool CanAdd() const
Definition: nexthop.cc:911
InterfaceRef interface_
Definition: nexthop.h:1570
DISALLOW_COPY_AND_ASSIGN(ArpNH)
const VrfEntry * GetVrf() const
Definition: nexthop.h:1444
DISALLOW_COPY_AND_ASSIGN(NextHopData)
Ip4Address ip_
Definition: nexthop.h:858
const MacAddress & GetMac() const
Definition: nexthop.h:836
static TypeBmap MPLSType()
Definition: nexthop.h:326
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:453
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.h:675
void SetType(TunnelType::Type type)
Definition: nexthop.h:304
virtual ~ResolveNHData()
Definition: nexthop.h:721
uint8_t HashFieldsToUse() const
VrfEntryRef vrf_
Definition: nexthop.h:857
virtual bool CanAdd() const
Definition: nexthop.cc:1622
DISALLOW_COPY_AND_ASSIGN(InterfaceNH)
void EnqueueResync() const
Definition: nexthop.cc:135
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:1095
virtual NextHopKey * Clone() const
Definition: nexthop.h:970
virtual bool Delete(DBEntry *entry, const DBRequest *req)
Definition: nexthop.cc:344
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:2041
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:463
DISALLOW_COPY_AND_ASSIGN(PBBNH)
bool valid_
Definition: nexthop.h:905
bool layer2_control_word_
Definition: nexthop.h:1937
const MacAddress & GetDMac() const
Definition: nexthop.h:1548
bool GetResolveState() const
Definition: nexthop.h:931
VrfKey vrf_key_
Definition: nexthop.h:1405
virtual ~TunnelNHData()
Definition: nexthop.h:1019
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.cc:2596
void CreateTunnelNHReq(Agent *agent)
Definition: nexthop.cc:2383
const Interface * GetInterface() const
Definition: nexthop.h:926
DISALLOW_COPY_AND_ASSIGN(VlanNH)
bool validate_mcast_src() const
Definition: nexthop.h:1727
MacAddress mac_
Definition: nexthop.h:949
const IpAddress * GetIp() const
Definition: nexthop.h:929
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:936
bool flood_unknown_unicast_
Definition: nexthop.h:1421
bool etree_leaf_
Definition: nexthop.h:452
uint8_t flags_
Definition: nexthop.h:1365
const boost::uuids::uuid & GetIfUuid() const
Definition: nexthop.cc:619
static DBTableBase * CreateTable(DB *db, const std::string &name)
Definition: nexthop.cc:352
VrfEntryRef vrf_
Definition: nexthop.h:1934
bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:1651
DISALLOW_COPY_AND_ASSIGN(LabelledTunnelNHData)
virtual ~PBBNH()
Definition: nexthop.cc:2820
boost::asio::ip::address IpAddress
Definition: address.h:13
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1573
Type GetType() const
Definition: nexthop.h:303
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1645
bool bridge_nh_
Definition: nexthop.h:1407
boost::scoped_ptr< const InterfaceKey > intf_key_
Definition: nexthop.h:714
MacAddress dmac_
Definition: nexthop.h:1522
VlanNHData(const string vrf_name, const MacAddress &smac, const MacAddress &dmac)
Definition: nexthop.h:1515
DISALLOW_COPY_AND_ASSIGN(LabelledTunnelNHKey)
ArpNHData(const MacAddress &mac, InterfaceKey *intf_key, bool resolved)
Definition: nexthop.h:805
void set_etree_leaf(bool val)
Definition: nexthop.h:411
bool valid_
Definition: nexthop.h:816
const VrfEntry * GetVrf() const
Definition: nexthop.h:930
bool layer2_control_word() const
Definition: nexthop.h:1918
uint32_t transport_mpls_label_
Definition: nexthop.h:1068
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.h:609
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:1666
virtual ~NdpNHData()
Definition: nexthop.h:898
string ToString()
Definition: nexthop.h:878
const MacAddress & GetMac() const
Definition: nexthop.h:925
bool IsVxlanRouting() const
Definition: nexthop.h:1295
DISALLOW_COPY_AND_ASSIGN(PBBNHData)
virtual ~VrfNHData()
Definition: nexthop.h:1418
bool policy_
Definition: nexthop.h:513
DISALLOW_COPY_AND_ASSIGN(L2ReceiveNH)
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:691
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.h:556
virtual ~ReceiveNHKey()
Definition: nexthop.h:634
DISALLOW_COPY_AND_ASSIGN(NextHopKey)
IpAddress ip_
Definition: nexthop.h:947
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:579
int insert(const Member &mbr)
Definition: nexthop.h:42
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:1230
void CreateComponentNH(Agent *agent, TunnelType::Type type) const
Definition: nexthop.cc:2197
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:976
bool validate_mcast_src_
Definition: nexthop.h:1931
const boost::uuids::uuid & GetUuid() const
Definition: nexthop.h:1211
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:749
DISALLOW_COPY_AND_ASSIGN(NdpNHData)
uint32_t GetRefCount() const
Definition: nexthop.h:395
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:847
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.h:555
uint32_t label() const
Definition: nexthop.h:1627
uint32_t label_
Definition: nexthop.h:1679
virtual bool NeedMplsLabel()
Definition: nexthop.h:692
MacAddress dmac_
Definition: nexthop.h:1247
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:1537
const NextHop * GetLocalNextHop() const
Definition: nexthop.cc:1798
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:936
virtual bool CanAdd() const
Definition: nexthop.cc:444
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.h:607
virtual bool NeedMplsLabel()
Definition: nexthop.h:854
VrfKey vrf_key_
Definition: nexthop.h:1007
boost::uuids::uuid uuid
virtual ~L2ReceiveNHData()
Definition: nexthop.h:595
TunnelNHKey(const string &vrf_name, const Ip4Address &sip, const Ip4Address &dip, bool policy, TunnelType type, const MacAddress &rewrite_dmac=MacAddress())
Definition: nexthop.h:958
static TypeBmap MplsType()
Definition: nexthop.h:312
static void DeleteMulticastVmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const std::string &intf_name)
Definition: nexthop.cc:797
InterfaceNHKey(InterfaceKey *intf, bool policy, uint8_t flags, const MacAddress &mac)
Definition: nexthop.h:1197
bool layer2_control_word() const
Definition: nexthop.h:1359
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:558
static VlanNH * Find(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag)
Definition: nexthop.cc:1750
virtual DBEntry * Add(const DBRequest *req)
Definition: nexthop.cc:306
virtual ~InterfaceNHData()
Definition: nexthop.h:1258
uint32_t hash(size_t hash) const
Definition: nexthop.h:205
boost::shared_ptr< const ComponentNHKey > ComponentNHKeyPtr
Definition: nexthop.h:1639
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:1286
static void CreateInetInterfaceNextHop(const string &ifname, const string &vrf_name, const MacAddress &mac)
Definition: nexthop.cc:817
bool NexthopToInterfacePolicy() const
Definition: nexthop.cc:262
bool IsBridge() const
Definition: nexthop.h:1299
virtual ~NextHopData()
Definition: nexthop.h:462
void insert(ComponentNHKeyPtr nh_key)
Definition: nexthop.cc:2416
CompositeNH(COMPOSITETYPE type, bool policy, const ComponentNHKeyList &component_nh_key_list, VrfEntry *vrf)
Definition: nexthop.h:1778
std::vector< Member * > mbr_list_
Definition: nexthop.h:226
DISALLOW_COPY_AND_ASSIGN(ResolveNH)
uint16_t GetVlanTag() const
Definition: nexthop.h:1544
uint32_t label_
Definition: nexthop.h:1116
virtual ~CompositeNHKey()
Definition: nexthop.h:1706
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:554
bool etree_leaf() const
Definition: nexthop.h:415
MacAddress dmac_
Definition: nexthop.h:1573
const Member * Get(uint32_t idx) const
Definition: nexthop.h:197
uint8_t EcmpHashFieldInUse() const
Definition: nexthop.h:1909
size_t HashTableSize() const
Definition: nexthop.h:164
virtual std::string ToString() const
Definition: nexthop.h:368
virtual NextHopKey * Clone() const
Definition: nexthop.h:530
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.h:744
MacAddress mac_
Definition: nexthop.h:903
size_t InUseIndexCount()
Definition: index_vector.h:89
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:438
MacAddress dest_bmac_
Definition: nexthop.h:1173
uint32_t max_size_
Definition: nexthop.h:228
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
const_iterator end() const
Definition: nexthop.h:174
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:1151
void SetNHSandeshData(NhSandeshData &data) const
Definition: nexthop.cc:3172
Type GetType() const
Definition: nexthop.h:405
virtual ~NdpNH()
Definition: nexthop.h:913
const VrfEntry * vrf() const
Definition: nexthop.h:1875
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:683
VrfKey vrf_key_
Definition: nexthop.h:1740
virtual NextHopKey * Clone() const
Definition: nexthop.h:1397
virtual bool CanAdd() const
Definition: nexthop.cc:1501
const std::string & name() const
Definition: nexthop.h:1504
bool GetPolicy() const
Definition: nexthop.h:500
static void Create()
Definition: nexthop.cc:1608
ArpNHKey(const string &vrf_name, const Ip4Address &ip, bool policy)
Definition: nexthop.h:771
virtual CompositeNHKey * Clone() const
Definition: nexthop.cc:2398
Ip4Address dip_
Definition: nexthop.h:795
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1510
virtual ~NextHopTable()
Definition: nexthop.cc:285
const uint32_t vrf_id() const
Definition: nexthop.cc:610
bool layer2_control_word_
Definition: nexthop.h:1263
Member * Find(const Member &mem, uint32_t &index) const
Definition: nexthop.h:187
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:1495
static Type DefaultMplsComputeType()
static const uint32_t kInvalidIndex
Definition: nexthop.h:342
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
Definition: nexthop.h:1641
virtual bool OnChange(DBEntry *entry, const DBRequest *req)
Definition: nexthop.cc:321
void set_discard_nh(NextHop *nh)
Definition: nexthop.h:1970
DISALLOW_COPY_AND_ASSIGN(CompositeNHKey)
std::string ToString() const
Definition: mac_address.cc:53
virtual bool NeedMplsLabel()=0
static bool EncapPrioritySync(const std::vector< std::string > &cfg_list)
Definition: nexthop.cc:58
static NextHopTable * nexthop_table_
Definition: nexthop.h:1990
static TypeBmap MplsoMplsType()
Definition: nexthop.h:313
Ip4Address sip_
Definition: nexthop.h:1008
void AddWithoutAlloc(DBEntry *entry)
Definition: nexthop.cc:381
const Ip4Address * GetIp() const
Definition: nexthop.h:840
NextHopConstRef nh_
Definition: nexthop.h:1117
const Interface * GetInterface() const
Definition: nexthop.h:837
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:471
ComponentNHKey(int label, std::unique_ptr< const NextHopKey > key)
Definition: nexthop.h:1645
MacAddress mac_
Definition: nexthop.h:860
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:1661
MplsLabelRef mpls_label_
Definition: nexthop.h:450
virtual std::string ToString()
Definition: nexthop.h:826
InterfaceNH(Interface *intf, bool policy, uint8_t flags, const MacAddress &mac)
Definition: nexthop.h:1269
MacAddress dmac_
Definition: nexthop.h:1366
NextHop::Type GetType() const
Definition: nexthop.h:499
void Remove(size_t index)
Definition: index_vector.h:78
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:1445
static NextHopTable * GetInstance()
Definition: nexthop.h:1968
const std::string & name() const
Definition: nexthop.h:1212
Definition: db.h:24
boost::scoped_ptr< InterfaceKey > intf_key_
Definition: nexthop.h:642
virtual bool CanAdd() const
Definition: nexthop.cc:1790
virtual std::string ToString() const
Definition: nexthop.h:551
uint32_t label() const
Definition: nexthop.h:1163
uint8_t GetFlags() const
Definition: nexthop.h:1300
ComponentNHKeyList component_nh_key_list_
Definition: nexthop.h:1760
virtual bool NeedMplsLabel()
Definition: nexthop.h:943
virtual NextHop * AllocEntry() const =0
VrfEntryRef vrf_
Definition: nexthop.h:946
string name_
Definition: vrf.h:38
Type type_
Definition: nexthop.h:331
virtual std::string ToString() const
Definition: nexthop.h:1280
const boost::uuids::uuid & GetUuid() const
Definition: nexthop.h:1503
DISALLOW_COPY_AND_ASSIGN(NdpNHKey)
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:1522
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.h:612
MacAddress smac_
Definition: nexthop.h:1572
const boost::uuids::uuid & GetIfUuid() const
Definition: nexthop.cc:514
static const uint32_t kRpfDiscardIndex
Definition: nexthop.h:1947
bool IsValid() const
Definition: nexthop.h:406
bool validate_mcast_src() const
Definition: nexthop.h:1850
bool resolved_
Definition: nexthop.h:815
PBBNHKey(const string &vrf_name, const MacAddress &dest_bmac, uint32_t isid)
Definition: nexthop.h:1084
PBBNHData()
Definition: nexthop.h:1123
boost::scoped_ptr< InterfaceKey > intf_key_
Definition: nexthop.h:902
ComponentNHKeyList::const_iterator end() const
Definition: nexthop.h:1715
uint32_t label_
Definition: nexthop.h:1175
const InterfaceKey * intf_key() const
Definition: nexthop.h:1214
std::list< Type > PriorityList
Definition: nexthop.h:249
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:700
virtual size_t Hash(const DBRequestKey *key) const
Definition: nexthop.h:1954
static void CreateReq(const string &interface)
NextHopData()
Definition: nexthop.h:459
uint8_t type
Definition: load_balance.h:109
VlanNHKey(const boost::uuids::uuid &vm_port_uuid, uint16_t vlan_tag)
Definition: nexthop.h:1480
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:614
void clear()
Definition: nexthop.h:153
void UpdateHashTable()
Definition: nexthop.h:90
static void DeletePriorityList()
Definition: nexthop.cc:77
NextHopKey(NextHop::Type type, bool policy)
Definition: nexthop.h:471
uint32_t label_
Definition: nexthop.h:1631
void set_validate_mcast_src(bool validate_mcast_src)
Definition: nexthop.h:1846
boost::intrusive_ptr< MplsLabel > MplsLabelRef
Definition: agent.h:94
bool valid_
Definition: nexthop.h:447
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.h:558
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.h:553
virtual ~CompositeNH()
Definition: nexthop.h:1796
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
Definition: nexthop.cc:3473
Definition: agent.h:358
static void CreateMulticastVmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const string &vrf_name, const string &intf_name)
Definition: nexthop.cc:788
DISALLOW_COPY_AND_ASSIGN(ResolveNHKey)
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:780
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:669
static void Create(NextHopTable *table, const Interface *intf, bool policy)
Definition: nexthop.cc:1530
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:926
uint8_t flags_
Definition: nexthop.h:1246
Definition: vrf.h:22
virtual ~LabelledTunnelNHData()
Definition: nexthop.h:1076
virtual ~NdpNHKey()
Definition: nexthop.h:872
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1254
DiscardNHKey()
Definition: nexthop.h:523
const NextHop * child_nh() const
Definition: nexthop.h:1167
static const uint32_t kRpfDisableIndex
Definition: nexthop.h:1946
virtual ~L2ReceiveNH()
Definition: nexthop.h:603
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:948
void set_l2_receive_nh(NextHop *nh)
Definition: nexthop.h:1973
NextHop * l2_receive_nh_
Definition: nexthop.h:1988
VrfKey vrf_key_
Definition: nexthop.h:883
VrfKey vrf_key_
Definition: nexthop.h:1113
virtual ~DiscardNHKey()
Definition: nexthop.h:524
const_iterator begin() const
Definition: nexthop.h:171
NextHop * AllocWithKey(const DBRequestKey *k) const
Definition: nexthop.cc:297
uint32_t isid_
Definition: nexthop.h:1115
virtual bool NeedMplsLabel()
Definition: nexthop.h:1567
bool policy_
Definition: nexthop.h:448
void ResetMplsRef()
Definition: nexthop.h:399
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:1438
DISALLOW_COPY_AND_ASSIGN(ArpNHData)
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1014
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:518
DISALLOW_COPY_AND_ASSIGN(ReceiveNHKey)
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:1905
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:883
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:2865
void set_learning_flag(bool val)
Definition: nexthop.h:419
std::string ToString() const
Definition: nexthop.h:260
uint32_t label() const
Definition: nexthop.h:1676
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:1856
void PostAdd()
Definition: nexthop.cc:123
virtual bool NeedMplsLabel()
Definition: nexthop.h:1464
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:1560
Definition: nexthop.h:820
static void FillObjectLogIntf(const Interface *intf, NextHopObjectLogInfo &info)
Definition: nexthop.cc:226
void RemoveWithoutDelete(DBEntry *entry)
Definition: nexthop.cc:374
Definition: nexthop.h:909
bool IsEqual(const VrfKey &rhs) const
Definition: vrf.h:31
virtual ~ArpNH()
Definition: nexthop.h:824
virtual bool CanAdd() const
Definition: nexthop.cc:1579
void replace(std::vector< Member > list)
Definition: nexthop.h:119
bool IsLess(const NextHopKey &rhs) const
Definition: nexthop.h:501
void ChangeComponentNHKeyTunnelType(ComponentNHKeyList &component_nh_list, TunnelType::Type type) const
Definition: nexthop.cc:2257
DISALLOW_COPY_AND_ASSIGN(ComponentNHKey)
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1618
static TypeBmap AllType()
Definition: nexthop.h:321
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:568
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.h:670
bool learning_enabled_
Definition: nexthop.h:462
InterfaceNHData(const string vrf_name)
Definition: nexthop.h:1252
const uint32_t isid() const
Definition: nexthop.h:1148
EcmpHashFields & CompEcmpHashFields()
Definition: nexthop.h:1912
uint16_t vlan_tag_
Definition: nexthop.h:1571
boost::intrusive_ptr< const Interface > InterfaceConstRef
Definition: agent.h:51
ComponentNHKeyList DeleteComponentNHKey(ComponentNHKeyPtr component_nh_key, bool &comp_nh_new_policy) const
Definition: nexthop.cc:2555
const Interface * GetInterface() const
Definition: nexthop.h:686
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:608
virtual bool CanAdd() const
Definition: nexthop.cc:660
bool bridge_nh() const
Definition: nexthop.h:1448
bool resolved_
Definition: nexthop.h:904
static void Create(const InterfaceKey *intf, bool policy)
Definition: nexthop.cc:1583
DISALLOW_COPY_AND_ASSIGN(PBBNHKey)
const ComponentNHList & component_nh_list() const
Definition: nexthop.h:1869
bool UpdateComponentNHKey(uint32_t label, NextHopKey *nh_key, ComponentNHKeyList &component_nh_key_list, bool &comp_nh_policy) const
Definition: nexthop.cc:2454
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1907
virtual bool NeedMplsLabel()
Definition: nexthop.h:1170
DISALLOW_COPY_AND_ASSIGN(InterfaceNHData)
DISALLOW_COPY_AND_ASSIGN(ReceiveNHData)
ReceiveNH(Interface *intf, bool policy)
Definition: nexthop.h:658
NdpNHData(InterfaceKey *intf_key)
Definition: nexthop.h:890
NextHop * discard_nh() const
Definition: nexthop.h:1971
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
Definition: agent_db.h:18
virtual NextHopKey * Clone() const
Definition: nexthop.h:777
VrfEntryRef vrf_
Definition: nexthop.h:1574
InterfaceRef interface_
Definition: nexthop.h:694
virtual bool NextHopIsLess(const DBEntry &rhs) const =0
virtual NextHopKey * Clone() const
Definition: nexthop.h:1062
iterator begin()
Definition: nexthop.h:168
const std::string & name() const
Definition: db_table.h:110
virtual std::string ToString() const
Definition: nexthop.h:734
ComponentNH(uint32_t label, NextHop *nh)
Definition: nexthop.h:1608
const std::string & GetVrfName() const
Definition: nexthop.h:1400
InterfaceRef interface_
Definition: nexthop.h:1364
virtual ~DiscardNH()
Definition: nexthop.h:549
bool operator==(const ComponentNHKey &rhs) const
Definition: nexthop.h:1669
COMPOSITETYPE composite_nh_type() const
Definition: nexthop.h:1842
COMPOSITETYPE composite_nh_type() const
Definition: nexthop.h:1726
virtual NextHopKey * Clone() const
Definition: nexthop.h:1220
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:1558
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:2836
uint32_t count() const
Definition: nexthop.h:215
virtual bool Resync(DBEntry *entry, const DBRequest *req)
Definition: nexthop.cc:337
bool HasVmInterface(const VmInterface *vmi) const
Definition: nexthop.cc:1813
DISALLOW_COPY_AND_ASSIGN(VlanNHKey)
virtual void OnZeroRefCount()
Definition: nexthop.h:1859
DISALLOW_COPY_AND_ASSIGN(TunnelNHKey)
InterfaceNHData(const string vrf_name, bool learning_enabled, bool etree_leaf, bool layer2_control_word)
Definition: nexthop.h:1254
CompositeNHData(bool pbb_nh, bool learning_enabled, bool layer2_control_word)
Definition: nexthop.h:1749
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:98
size_t size() const
Definition: nexthop.h:201
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.cc:1932
virtual ~InterfaceNH()
Definition: nexthop.h:1278
EcmpHashFields comp_ecmp_hash_fields_
Definition: nexthop.h:1935
ComponentNHList component_nh_list_
Definition: nexthop.h:1933
MacAddress smac_
Definition: nexthop.h:1521
Member * Find(const Member &mem) const
Definition: nexthop.h:178
bool Compare(const TunnelType &rhs) const
Definition: nexthop.h:253
InterfaceRef interface_
Definition: nexthop.h:948
static TypeBmap NativeType()
Definition: nexthop.h:325
static Type ComputeType(TypeBmap bmap)
Definition: nexthop.cc:33
void CreateTunnelNH(Agent *agent)
Definition: nexthop.cc:2368
static TypeBmap UDPType()
Definition: nexthop.h:324
VrfEntryRef vrf_
Definition: nexthop.h:1172
InterfaceRef interface_
Definition: nexthop.h:859
virtual void Change(const DBRequest *req)
Definition: nexthop.cc:113
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
virtual NextHopKey * Clone() const
Definition: nexthop.h:1492
VlanNH(Interface *intf, uint32_t vlan_tag)
Definition: nexthop.h:1529
DISALLOW_COPY_AND_ASSIGN(VrfNHData)
bool policy_
Definition: nexthop.h:1406
virtual bool ChangeEntry(const DBRequest *req)=0
Type type_
Definition: nexthop.h:446
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:688
bool flood_unknown_unicast_
Definition: nexthop.h:1470
static void DeleteNH(const boost::uuids::uuid &intf_uuid, bool policy, uint8_t flags, const MacAddress &mac, const std::string &intf_name)
Definition: nexthop.cc:805
DISALLOW_COPY_AND_ASSIGN(L2ReceiveNHKey)
void Delete()
Definition: db_entry.cc:131
ComponentNHList::const_iterator begin() const
Definition: nexthop.h:1807
boost::scoped_ptr< InterfaceKey > intf_key_
Definition: nexthop.h:1508
VrfNHData(bool flood_unknown_unicast, bool learning_enabled, bool layer2_control_word)
Definition: nexthop.h:1413
Ip4Address dip_
Definition: nexthop.h:1009
const MacAddress dest_bmac() const
Definition: nexthop.h:1108
virtual std::unique_ptr< DBEntry > GetEntry(const DBRequestKey *key) const
Definition: nexthop.cc:302
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:666
ArpNHData(InterfaceKey *intf_key)
Definition: nexthop.h:801
bool etree_leaf_
Definition: nexthop.h:465
std::unique_ptr< const NextHopKey > nh_key_
Definition: nexthop.h:1680
virtual bool CanAdd() const
Definition: nexthop.cc:1604
static void DeleteL2InterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &mac, const std::string &intf_name)
Definition: nexthop.cc:781
VrfEntryRef vrf_
Definition: nexthop.h:1367
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:543
VrfNH(VrfEntry *vrf, bool policy, bool bridge_nh_)
Definition: nexthop.h:1428
void set_tunnel_type(TunnelType tunnel_type)
Definition: nexthop.h:996
virtual ~L2ReceiveNHKey()
Definition: nexthop.h:578
MacAddress dest_bmac_
Definition: nexthop.h:1114
bool pbb_nh_
Definition: nexthop.h:1936
bool layer2_control_word_
Definition: nexthop.h:1422
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:616
bool ExpandLocalCompositeNH(Agent *agent)
Definition: nexthop.cc:2652
PBBNH(VrfEntry *vrf, const MacAddress &dmac, uint32_t isid)
Definition: nexthop.cc:2815
virtual ~PBBNHData()
Definition: nexthop.h:1124
ResolveNH(const Interface *intf, bool policy)
Definition: nexthop.h:730
uint32_t hash(uint32_t seed, bool ingress) const
Definition: nexthop.h:1878
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:648
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:1600
uint32_t id() const
Definition: nexthop.h:408
static void DeletePhysicalInterfaceNh(const string &ifname, const MacAddress &mac)
Definition: nexthop.cc:874
virtual bool NextHopIsLess(const DBEntry &rhs) const
Definition: nexthop.cc:2119
std::string ToString()
Definition: nexthop.h:1619
ResolveNHKey(const InterfaceKey *intf_key, bool policy)
Definition: nexthop.h:703
const MacAddress & GetDMac() const
Definition: nexthop.h:1294
uint32_t id_
Definition: nexthop.h:449
virtual ~NextHopKey()
Definition: nexthop.h:473
virtual ~ArpNHData()
Definition: nexthop.h:809
DISALLOW_COPY_AND_ASSIGN(DiscardNHKey)
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.h:610
bool IsLess(const VrfKey &rhs) const
Definition: vrf.h:27
bool validate_mcast_src_
Definition: nexthop.h:1738
static void CreatePacketInterfaceNh(Agent *agent, const string &ifname)
Definition: nexthop.cc:847
virtual ~DiscardNHData()
Definition: nexthop.h:541
static void CreatePhysicalInterfaceNh(const string &ifname, const MacAddress &mac)
Definition: nexthop.cc:865
bool IsLess(const TunnelType &rhs) const
Definition: nexthop.h:256
uint32_t ReserveIndex()
Definition: nexthop.cc:289
virtual NextHopKey * Clone() const
Definition: nexthop.h:875
static TypeBmap GREType()
Definition: nexthop.h:323
virtual bool CanAdd() const
Definition: nexthop.cc:549
virtual NextHopKey * Clone() const
Definition: nexthop.h:583
static void DeleteInetInterfaceNextHop(const string &ifname, const MacAddress &mac)
Definition: nexthop.cc:833
IndexVector< NextHop * > index_table_
Definition: nexthop.h:1989
const VrfEntry * GetVrf() const
Definition: nexthop.h:841
void UpdateFreeIndex(uint32_t index)
Definition: nexthop.h:112
void Process(DBRequest &req)
Definition: nexthop.cc:367
boost::intrusive_ptr< const NextHop > NextHopConstRef
Definition: agent.h:126
bool layer2_control_word_
Definition: nexthop.h:1369
ComponentNHKeyList::const_iterator begin() const
Definition: nexthop.h:1711
std::vector< Member * >::iterator iterator
Definition: nexthop.h:39
ComponentNHKeyList AddComponentNHKey(ComponentNHKeyPtr component_nh_key, bool &comp_nh_policy) const
Definition: nexthop.cc:2485
virtual ~NextHop()
Definition: nexthop.cc:92
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:372
static void CreateL2VmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const string &vrf_name, bool learning_enabled, bool etree_leaf, bool layer2_control_word, const std::string &intf_name)
Definition: nexthop.cc:768
Definition: mpls.h:52
virtual ~ReceiveNHData()
Definition: nexthop.h:649
size_t ComponentNHCount() const
Definition: nexthop.h:1815
NextHop(Type type, bool valid, bool policy)
Definition: nexthop.h:363
virtual NextHopKey * Clone() const
Definition: nexthop.h:1091
void FillObjectLog(AgentLogEvent::type event, NextHopObjectLogInfo &info) const
Definition: nexthop.cc:142
DISALLOW_COPY_AND_ASSIGN(NdpNH)
uint32_t ActiveComponentNHCount() const
Definition: nexthop.h:1818
#define COMPOSITETYPE
Definition: nexthop.h:1600
bool operator==(const ComponentNH &rhs) const
Definition: nexthop.h:1611
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:623
std::vector< uint32_t > hash_table_
Definition: nexthop.h:227
const boost::uuids::uuid & GetIfUuid() const
Definition: nexthop.cc:730
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:756
virtual bool ChangeEntry(const DBRequest *req)
Definition: nexthop.h:736
CompositeNHKey(COMPOSITETYPE type, bool validate_mcast_src, bool policy, const ComponentNHKeyList &component_nh_key_list, const std::string &vrf_name)
Definition: nexthop.h:1696
NextHop(Type type, bool policy)
Definition: nexthop.h:360
bool Reorder(Agent *agent, uint32_t label, const NextHop *nh)
Definition: nexthop.cc:2740
virtual std::string ToString()
Definition: nexthop.h:915
InterfaceConstRef interface_
Definition: nexthop.h:762
DISALLOW_COPY_AND_ASSIGN(NextHop)
CompositeNH * ChangeTunnelType(Agent *agent, TunnelType::Type type) const
Definition: nexthop.cc:2302
virtual bool CanAdd() const =0
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:84
bool IsActive() const
Definition: agent_db.cc:27
void FreeInterfaceId(size_t index)
Definition: nexthop.h:1976
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:843
virtual void OnZeroRefCount()
Definition: nexthop.h:393
const MacAddress & rewrite_dmac()
Definition: nexthop.h:1002
bool layer2_control_word_
Definition: nexthop.h:1471
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:830
virtual std::string ToString() const
Definition: nexthop.h:1797
virtual std::string ToString() const
Definition: nexthop.h:1433
static void CreateL3VmInterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &dmac, const string &vrf_name, bool learning_enabled, const std::string &intf_name)
Definition: nexthop.cc:750
bool layer2_control_word() const
Definition: nexthop.h:1461
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:1384
CompositeNH(COMPOSITETYPE type, bool validate_mcast_src, bool policy, const ComponentNHKeyList &component_nh_key_list, VrfEntry *vrf)
Definition: nexthop.h:1787
bool pbb_nh() const
Definition: nexthop.h:1914
NextHopData(bool learning_enabled, bool etree_leaf)
Definition: nexthop.h:460
bool GetIndex(ComponentNH &nh, uint32_t &idx) const
Definition: nexthop.cc:2335
const Interface * get_interface() const
Definition: nexthop.h:754
NextHopConstRef child_nh_
Definition: nexthop.h:1176
DiscardNH()
Definition: nexthop.h:548
static void SetDefaultType(Type type)
Definition: nexthop.h:306
VrfNHKey(const string &vrf_name, bool policy, bool bridge_nh)
Definition: nexthop.h:1378
virtual bool NeedMplsLabel()
Definition: nexthop.h:565
DISALLOW_COPY_AND_ASSIGN(L2ReceiveNHData)
bool PolicyEnabled() const
Definition: nexthop.h:407
void erase(ComponentNHKeyPtr nh_key)
Definition: nexthop.cc:2438
const NextHopKey * nh_key() const
Definition: nexthop.h:1677
DISALLOW_COPY_AND_ASSIGN(NextHopTable)
boost::intrusive_ptr< Interface > InterfaceRef
Definition: agent.h:49
virtual NextHopKey * Clone() const
Definition: nexthop.h:636
std::vector< ComponentNHPtr > ComponentNHList
Definition: nexthop.h:1637
virtual void Delete(const DBRequest *req)
Definition: nexthop.h:919
void ChangeTunnelType(TunnelType::Type tunnel_type)
Definition: nexthop.cc:1914
NdpNHData(const MacAddress &mac, InterfaceKey *intf_key, bool resolved)
Definition: nexthop.h:894
void SetPolicy(bool policy)
Definition: nexthop.h:495
static void DeleteL3InterfaceNH(const boost::uuids::uuid &intf_uuid, const MacAddress &mac, const std::string &intf_name)
Definition: nexthop.cc:761
const uint8_t & flags() const
Definition: nexthop.h:1216
ComponentNHKeyList component_nh_key_list_
Definition: nexthop.h:1739
const Interface::Type & intf_type() const
Definition: nexthop.h:1213
static const uint32_t kInvalidIndex
Definition: nexthop.h:24
const NextHop * GetNH(uint32_t idx) const
Definition: nexthop.h:1832
ComponentNHList::const_iterator end() const
Definition: nexthop.h:1811
bool find(ComponentNHKeyPtr nh_key)
Definition: nexthop.cc:2403
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
Definition: nexthop.cc:293
bool delete_on_zero_refcount_
Definition: nexthop.h:1368
const VrfEntry * vrf() const
Definition: nexthop.h:1146
virtual ~ResolveNH()
Definition: nexthop.h:732
static TypeBmap GetTunnelBmap(TunnelType::Type type)
Definition: nexthop.h:314
LabelledTunnelNHKey(const string &vrf_name, const Ip4Address &sip, const Ip4Address &dip, bool policy, TunnelType type, const MacAddress &rewrite_dmac=MacAddress(), uint32_t label=3)
Definition: nexthop.h:1030
virtual ~TunnelNHKey()
Definition: nexthop.h:967
virtual ~ReceiveNH()
Definition: nexthop.h:660
virtual bool NeedMplsLabel()
Definition: nexthop.h:619
void set_delete_on_zero_refcount(bool val)
Definition: nexthop.h:1346
virtual void OnZeroRefcount(AgentDBEntry *e)
Definition: nexthop.cc:388
virtual ~VlanNHData()
Definition: nexthop.h:1518
boost::scoped_ptr< InterfaceKey > intf_key_
Definition: nexthop.h:1245
bool learning_enabled_
Definition: nexthop.h:451
ComponentNHKey(int label, const boost::uuids::uuid &intf_uuid, uint8_t flags, const MacAddress &mac)
Definition: nexthop.h:1650
ComponentNHKey(int label, const string &vrf_name, const Ip4Address &sip, const Ip4Address &dip, bool policy, TunnelType::TypeBmap bmap)
Definition: nexthop.h:1661
boost::shared_ptr< const ComponentNH > ComponentNHPtr
Definition: nexthop.h:1636
virtual ~ComponentNHKey()
Definition: nexthop.h:1667
DISALLOW_COPY_AND_ASSIGN(DiscardNHData)
ReceiveNHKey(InterfaceKey *intf_key, bool policy)
Definition: nexthop.h:631
const Interface * GetInterface() const
Definition: nexthop.h:1543
std::vector< Member * >::const_iterator const_iterator
Definition: nexthop.h:40
virtual ~LabelledTunnelNHKey()
Definition: nexthop.h:1040
const ComponentNHKeyList & component_nh_key_list() const
Definition: nexthop.h:1719
bool is_multicastNH() const
Definition: nexthop.h:1298
VrfEntry * FindVrfEntry(const VrfKey &key) const
Definition: nexthop.cc:363
virtual bool MatchEgressData(const NextHop *nh) const
Definition: nexthop.h:1453
virtual void SendObjectLog(const NextHopTable *table, AgentLogEvent::type event) const
Definition: nexthop.cc:2917
ComponentNHKey(int label, uint8_t tag, const boost::uuids::uuid &intf_uuid)
Definition: nexthop.h:1657
DISALLOW_COPY_AND_ASSIGN(ResolveNHData)
COMPOSITETYPE composite_nh_type_
Definition: nexthop.h:1928
VrfKey vrf_key_
Definition: nexthop.h:1523
virtual ~VlanNH()
Definition: nexthop.h:1532
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
Definition: nexthop.cc:3455
virtual ~VrfNHKey()
Definition: nexthop.h:1382
virtual NextHopKey * Clone() const =0
DISALLOW_COPY_AND_ASSIGN(CompositeNH)
static TypeBmap VxlanType()
Definition: nexthop.h:311
DISALLOW_COPY_AND_ASSIGN(TunnelNHData)
void CheckVrNexthopLimit()
Definition: nexthop.cc:408
bool GetResolveState() const
Definition: nexthop.h:842
DISALLOW_COPY_AND_ASSIGN(CompositeNHData)
VrfKey vrf_key_
Definition: nexthop.h:1262
virtual bool NeedMplsLabel()
Definition: nexthop.cc:898
const MacAddress dest_bmac() const
Definition: nexthop.h:1147
DISALLOW_COPY_AND_ASSIGN(DiscardNH)
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:390
NdpNHKey(const string &vrf_name, const IpAddress &ip, bool policy)
Definition: nexthop.h:869
IpAddress dip_
Definition: nexthop.h:884
static TypeBmap DefaultTypeBmap()
Definition: nexthop.h:310
virtual NextHop * AllocEntry() const
Definition: nexthop.cc:920
~MemberList()
Definition: nexthop.h:31
boost::scoped_ptr< InterfaceKey > intf_key_
Definition: nexthop.h:813
DISALLOW_COPY_AND_ASSIGN(ArpNHKey)
const uint16_t vlan_tag() const
Definition: nexthop.h:1505
VrfEntryRef vrf_
Definition: nexthop.h:1467
virtual bool IsLess(const DBEntry &rhs) const
Definition: nexthop.h:378
MacAddress mac_
Definition: nexthop.h:814
virtual size_t Hash(const DBEntry *entry) const
Definition: nexthop.h:1953
const uint32_t vrf_id() const
Definition: nexthop.cc:2870
static void Create(const boost::uuids::uuid &intf_uuid, uint16_t vlan_tag, const std::string &vrf_name, const MacAddress &smac, const MacAddress &dmac)
Definition: nexthop.cc:1703
virtual bool NextHopKeyIsLess(const NextHopKey &rhs) const
Definition: nexthop.h:477
bool bridge_nh_
Definition: nexthop.h:1469
DISALLOW_COPY_AND_ASSIGN(VrfNHKey)
bool flood_unknown_unicast() const
Definition: nexthop.h:1449
virtual bool NeedMplsLabel()
Definition: nexthop.h:1908
const MacAddress & dmac() const
Definition: nexthop.h:1217
const boost::uuids::uuid & GetIfUuid() const
Definition: nexthop.cc:1698
virtual KeyPtr GetDBRequestKey() const
Definition: nexthop.cc:2183
virtual bool DeleteOnZeroRefCount() const
Definition: nexthop.h:1342
const MplsLabel * mpls_label() const
Definition: nexthop.h:434
NextHopConstRef nh_
Definition: nexthop.h:1632
virtual bool CanAdd() const
Definition: nexthop.cc:2823
TunnelType(Type type)
Definition: nexthop.h:251
virtual NextHopKey * Clone() const
Definition: nexthop.h:709
static Type DefaultType()
Definition: nexthop.h:309
const ComponentNHKeyList & component_nh_key_list() const
Definition: nexthop.h:1872
virtual void SetKey(const DBRequestKey *key)
Definition: nexthop.cc:2856
virtual ~InterfaceNHKey()
Definition: nexthop.h:1210