OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nexthop_ksync.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_nh_ksync_h
6 #define vnsw_agent_nh_ksync_h
7 
8 #include <boost/asio.hpp>
9 #include <boost/bind.hpp>
10 
11 #include <db/db_entry.h>
12 #include <db/db_table.h>
13 #include <db/db_table_partition.h>
14 #include <ksync/ksync_entry.h>
15 #include <ksync/ksync_object.h>
16 #include <ksync/ksync_netlink.h>
18 #include "oper/nexthop.h"
19 
20 #include "vr_nexthop.h"
21 
23 typedef std::vector<InterfaceKSyncEntry> InterfaceKSyncEntryList;
24 
26 public:
27  static const int kDefaultNhMsgSize = 4096;
28  static const int MAX_VR_PHY_INTF = 3;
29  NHKSyncEntry(NHKSyncObject *obj, const NHKSyncEntry *entry,
30  uint32_t index);
31  NHKSyncEntry(NHKSyncObject *obj, const NextHop *nh);
32  virtual ~NHKSyncEntry();
33 
34  const NextHop *nh() { return nh_; }
35  NextHop::Type type() const {return type_;}
37  return static_cast<InterfaceKSyncEntry *>(interface_.get());
38  }
39  std::vector<KSyncEntryPtr> interface_list() const {
40  return interface_list_;
41  }
42  std::vector<int32_t> encap_valid_list() const {
43  return encap_valid_list_;
44  }
46  return static_cast<InterfaceKSyncEntry *>(crypt_interface_.get());
47  }
48  KSyncDBObject *GetObject() const;
49 
50  virtual bool IsLess(const KSyncEntry &rhs) const;
51  virtual std::string ToString() const;
53  virtual bool Sync(DBEntry *e);
54  virtual int AddMsg(char *buf, int buf_len);
55  virtual int ChangeMsg(char *buf, int buf_len);
56  virtual int DeleteMsg(char *buf, int buf_len);
57  void FillObjectLog(sandesh_op::type op, KSyncNhInfo &info) const;
58  uint32_t nh_id() const { return nh_id_;}
59  void SetEncap(InterfaceKSyncEntry *if_ksync, std::vector<int8_t> &encap,
60  const int32_t index=-1);
61  bool is_bridge() const { return is_bridge_; }
62  bool is_vxlan_routing() const { return is_vxlan_routing_; }
63 
64  int MsgLen() {
65  // for larger component NH lists, increase message length
66  return kDefaultNhMsgSize * ((component_nh_list_.size() / 128) + 1);
67  }
68  uint8_t SetEcmpFieldsToUse();
69  bool KSyncEntrySandesh(Sandesh *resp);
71 private:
72  void SetKSyncNhListSandeshData(KSyncNhListSandeshData *data) const;
74  public:
75  KSyncComponentNH(uint32_t label, KSyncEntry *entry) :
76  label_(label), nh_(entry) {
77  }
78 
79  NHKSyncEntry *nh() const {
80  return static_cast<NHKSyncEntry *>(nh_.get());
81  }
82 
83  uint32_t label() const {
84  return label_;
85  }
86  private:
87  uint32_t label_;
89  };
90 
91  typedef std::vector<KSyncComponentNH> KSyncComponentNHList;
92 
93  int Encode(sandesh_op::type op, char *buf, int buf_len);
96  uint32_t vrf_id_;
97  uint32_t label_;
101  uint16_t sport_;
102  uint16_t dport_;
106  bool valid_;
107  bool policy_;
109  bool defer_;
111  const NextHop *nh_;
112  uint16_t vlan_tag_;
119  uint8_t prefix_len_;
120  uint32_t nh_id_;
126  uint32_t isid_;
127  uint32_t pbb_label_;
132  bool crypt_;
136  std::vector<KSyncEntryPtr> interface_list_;
137  std::vector<int32_t> encap_valid_list_;
138  std::vector<MacAddress> dmac_list_;
140 };
141 
142 class NHKSyncObject : public KSyncDBObject {
143 public:
144  static const int kNHIndexCount = NH_TABLE_ENTRIES;
146  virtual ~NHKSyncObject();
147 
148  KSync *ksync() const { return ksync_; }
149 
150  virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index);
151  virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e);
152  void RegisterDBClients();
153 private:
156 };
157 
158 #endif // vnsw_agent_nh_ksync_h
InterfaceKSyncEntry * interface() const
Definition: nexthop_ksync.h:36
virtual int ChangeMsg(char *buf, int buf_len)
bool learning_enabled_
const NextHop * nh_
bool is_vxlan_routing_
std::vector< KSyncEntryPtr > interface_list_
uint16_t sport_
COMPOSITETYPE comp_type_
uint32_t nh_id_
DISALLOW_COPY_AND_ASSIGN(NHKSyncObject)
virtual ~NHKSyncEntry()
NHKSyncObject(KSync *ksync)
MacAddress smac_
TunnelType tunnel_type_
NHKSyncObject * ksync_obj_
Definition: nexthop_ksync.h:94
boost::asio::ip::address IpAddress
Definition: address.h:13
uint32_t nh_id() const
Definition: nexthop_ksync.h:58
KSyncEntryPtr crypt_interface_
MacAddress rewrite_dmac_
std::vector< int32_t > encap_valid_list_
int Encode(sandesh_op::type op, char *buf, int buf_len)
bool flood_unknown_unicast_
void FillObjectLog(sandesh_op::type op, KSyncNhInfo &info) const
uint8_t SetEcmpFieldsToUse()
KSyncComponentNHList component_nh_list_
MacAddress dmac_
KSyncComponentNH(uint32_t label, KSyncEntry *entry)
Definition: nexthop_ksync.h:75
bool is_local_ecmp_nh_
static const int MAX_VR_PHY_INTF
Definition: nexthop_ksync.h:28
NextHop::Type type() const
Definition: nexthop_ksync.h:35
KSyncEntryPtr pbb_child_nh_
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
Definition: nexthop.h:1641
virtual bool Sync(DBEntry *e)
virtual std::string ToString() const
bool KSyncEntrySandesh(Sandesh *resp)
bool crypt_path_available_
void RegisterDBClients()
static const int kNHIndexCount
uint8_t type
Definition: load_balance.h:109
uint8_t prefix_len_
virtual KSyncEntry * DBToKSyncEntry(const DBEntry *e)
TunnelType::Type transport_tunnel_type_
boost::intrusive_ptr< KSyncEntry > KSyncEntryPtr
Definition: ksync_entry.h:68
uint16_t vlan_tag_
std::vector< InterfaceKSyncEntry > InterfaceKSyncEntryList
Definition: nexthop_ksync.h:22
IpAddress sip_
Definition: nexthop_ksync.h:99
KSync * ksync() const
uint32_t isid_
NHKSyncEntry * nh() const
Definition: nexthop_ksync.h:79
KSyncEntryPtr interface_
Definition: nexthop_ksync.h:98
virtual KSyncEntry * UnresolvedReference()
bool layer2_control_word_
DISALLOW_COPY_AND_ASSIGN(NHKSyncEntry)
void SetKSyncNhListSandeshData(KSyncNhListSandeshData *data) const
static const int kDefaultNhMsgSize
Definition: nexthop_ksync.h:27
bool need_pbb_tunnel_
const NextHop * nh()
Definition: nexthop_ksync.h:34
bool is_vxlan_routing() const
Definition: nexthop_ksync.h:62
uint16_t dport_
virtual KSyncEntry * Alloc(const KSyncEntry *entry, uint32_t index)
std::vector< KSyncEntryPtr > interface_list() const
Definition: nexthop_ksync.h:39
#define COMPOSITETYPE
Definition: nexthop.h:1600
std::vector< int32_t > encap_valid_list() const
Definition: nexthop_ksync.h:42
InterfaceKSyncEntry * crypt_interface() const
Definition: nexthop_ksync.h:45
EcmpHashFields ecmp_hash_fieds_
ComponentNHKeyList component_nh_key_list_
virtual int DeleteMsg(char *buf, int buf_len)
virtual int AddMsg(char *buf, int buf_len)
uint32_t pbb_label_
std::vector< KSyncComponentNH > KSyncComponentNHList
Definition: nexthop_ksync.h:91
std::vector< MacAddress > dmac_list_
COMPOSITETYPE CompositeType() const
Definition: nexthop_ksync.h:70
virtual bool IsLess(const KSyncEntry &rhs) const
KSyncDBObject * GetObject() const
NextHop::Type type_
Definition: nexthop_ksync.h:95
bool is_bridge() const
Definition: nexthop_ksync.h:61
virtual ~NHKSyncObject()
IpAddress dip_
bool validate_mcast_src_
uint32_t label_
Definition: nexthop_ksync.h:97
void SetEncap(InterfaceKSyncEntry *if_ksync, std::vector< int8_t > &encap, const int32_t index=-1)
NHKSyncEntry(NHKSyncObject *obj, const NHKSyncEntry *entry, uint32_t index)
uint32_t vrf_id_
Definition: nexthop_ksync.h:96