OpenSDN source code
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/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 
22 using namespace boost::placeholders;
23 
24 class NHKSyncObject;
25 typedef std::vector<InterfaceKSyncEntry> InterfaceKSyncEntryList;
26 
28 public:
29  static const int kDefaultNhMsgSize = 4096;
30  static const int MAX_VR_PHY_INTF = 3;
31  NHKSyncEntry(NHKSyncObject *obj, const NHKSyncEntry *entry,
32  uint32_t index);
33  NHKSyncEntry(NHKSyncObject *obj, const NextHop *nh);
34  virtual ~NHKSyncEntry();
35 
36  const NextHop *nh() { return nh_; }
37  NextHop::Type type() const {return type_;}
39  return static_cast<InterfaceKSyncEntry *>(interface_.get());
40  }
41  std::vector<KSyncEntryPtr> interface_list() const {
42  return interface_list_;
43  }
44  std::vector<int32_t> encap_valid_list() const {
45  return encap_valid_list_;
46  }
48  return static_cast<InterfaceKSyncEntry *>(crypt_interface_.get());
49  }
50  KSyncDBObject *GetObject() const;
51 
52  virtual bool IsLess(const KSyncEntry &rhs) const;
53  virtual std::string ToString() const;
54  virtual KSyncEntry *UnresolvedReference();
55  virtual bool Sync(DBEntry *e);
56  virtual int AddMsg(char *buf, int buf_len);
57  virtual int ChangeMsg(char *buf, int buf_len);
58  virtual int DeleteMsg(char *buf, int buf_len);
59  void FillObjectLog(sandesh_op::type op, KSyncNhInfo &info) const;
60  uint32_t nh_id() const { return nh_id_;}
61  void SetEncap(InterfaceKSyncEntry *if_ksync, std::vector<int8_t> &encap,
62  const int32_t index=-1);
63  bool is_bridge() const { return is_bridge_; }
64  bool is_vxlan_routing() const { return is_vxlan_routing_; }
65 
66  int MsgLen() {
67  // for larger component NH lists, increase message length
68  return kDefaultNhMsgSize * ((component_nh_list_.size() / 128) + 1);
69  }
70  uint8_t SetEcmpFieldsToUse();
71  bool KSyncEntrySandesh(Sandesh *resp);
72  COMPOSITETYPE CompositeType() const { return comp_type_;}
73 private:
74  void SetKSyncNhListSandeshData(KSyncNhListSandeshData *data) const;
76  public:
77  KSyncComponentNH(uint32_t label, KSyncEntry *entry) :
78  label_(label), nh_(entry) {
79  }
80 
81  NHKSyncEntry *nh() const {
82  return static_cast<NHKSyncEntry *>(nh_.get());
83  }
84 
85  uint32_t label() const {
86  return label_;
87  }
88  private:
89  uint32_t label_;
91  };
92 
93  typedef std::vector<KSyncComponentNH> KSyncComponentNHList;
94 
95  int Encode(sandesh_op::type op, char *buf, int buf_len);
98  uint32_t vrf_id_;
99  uint32_t label_;
103  uint16_t sport_;
104  uint16_t dport_;
108  bool valid_;
109  bool policy_;
111  bool defer_;
113  const NextHop *nh_;
114  uint16_t vlan_tag_;
121  uint8_t prefix_len_;
122  uint32_t nh_id_;
128  uint32_t isid_;
129  uint32_t pbb_label_;
134  bool crypt_;
138  std::vector<KSyncEntryPtr> interface_list_;
139  std::vector<int32_t> encap_valid_list_;
140  std::vector<MacAddress> dmac_list_;
142 };
143 
144 class NHKSyncObject : public KSyncDBObject {
145 public:
146  static const int kNHIndexCount = NH_TABLE_ENTRIES;
147  NHKSyncObject(KSync *ksync);
148  virtual ~NHKSyncObject();
149 
150  KSync *ksync() const { return ksync_; }
151 
152  virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index);
153  virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e);
154  void RegisterDBClients();
155 private:
158 };
159 
160 #endif // vnsw_agent_nh_ksync_h
boost::asio::ip::address IpAddress
Definition: address.h:13
static bool IsLess(const ShowRoute &lhs, const ShowRoute &rhs, const BgpSandeshContext *bsc, const string &table_name)
boost::intrusive_ptr< KSyncEntry > KSyncEntryPtr
Definition: ksync_entry.h:68
NHKSyncEntry * nh() const
Definition: nexthop_ksync.h:81
KSyncComponentNH(uint32_t label, KSyncEntry *entry)
Definition: nexthop_ksync.h:77
NextHop::Type type() const
Definition: nexthop_ksync.h:37
uint32_t label_
Definition: nexthop_ksync.h:99
uint32_t isid_
bool layer2_control_word_
std::vector< KSyncEntryPtr > interface_list_
NextHop::Type type_
Definition: nexthop_ksync.h:97
const NextHop * nh()
Definition: nexthop_ksync.h:36
bool flood_unknown_unicast_
TunnelType::Type transport_tunnel_type_
DISALLOW_COPY_AND_ASSIGN(NHKSyncEntry)
KSyncEntryPtr interface_
KSyncComponentNHList component_nh_list_
bool need_pbb_tunnel_
MacAddress smac_
KSyncEntryPtr pbb_child_nh_
bool learning_enabled_
IpAddress sip_
EcmpHashFields ecmp_hash_fieds_
uint8_t prefix_len_
ComponentNHKeyList component_nh_key_list_
uint16_t vlan_tag_
bool crypt_path_available_
MacAddress rewrite_dmac_
bool validate_mcast_src_
const NextHop * nh_
uint32_t pbb_label_
bool is_local_ecmp_nh_
COMPOSITETYPE comp_type_
uint32_t nh_id() const
Definition: nexthop_ksync.h:60
std::vector< int32_t > encap_valid_list_
std::vector< int32_t > encap_valid_list() const
Definition: nexthop_ksync.h:44
MacAddress dmac_
InterfaceKSyncEntry * interface() const
Definition: nexthop_ksync.h:38
bool is_vxlan_routing() const
Definition: nexthop_ksync.h:64
std::vector< KSyncEntryPtr > interface_list() const
Definition: nexthop_ksync.h:41
NHKSyncObject * ksync_obj_
Definition: nexthop_ksync.h:96
uint16_t dport_
InterfaceKSyncEntry * crypt_interface() const
Definition: nexthop_ksync.h:47
IpAddress dip_
uint32_t vrf_id_
Definition: nexthop_ksync.h:98
KSyncEntryPtr crypt_interface_
bool is_vxlan_routing_
std::vector< KSyncComponentNH > KSyncComponentNHList
Definition: nexthop_ksync.h:93
uint16_t sport_
uint32_t nh_id_
TunnelType tunnel_type_
COMPOSITETYPE CompositeType() const
Definition: nexthop_ksync.h:72
bool is_bridge() const
Definition: nexthop_ksync.h:63
std::vector< MacAddress > dmac_list_
DISALLOW_COPY_AND_ASSIGN(NHKSyncObject)
KSync * ksync() const
uint8_t type
Definition: load_balance.h:2
#define COMPOSITETYPE
Definition: nexthop.h:1600
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
Definition: nexthop.h:1641
std::vector< InterfaceKSyncEntry > InterfaceKSyncEntryList
Definition: nexthop_ksync.h:24
static string ToString(PhysicalDevice::ManagementProtocol proto)