OpenSDN source code
interface_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_interface_ksync_h
6 #define vnsw_agent_interface_ksync_h
7 
8 #include <net/ethernet.h>
9 
10 #include <boost/asio.hpp>
11 #include <boost/bind/bind.hpp>
12 
13 #include <db/db_entry.h>
14 #include <db/db_table.h>
15 #include <db/db_table_partition.h>
16 #include <ksync/ksync_entry.h>
17 #include <ksync/ksync_object.h>
18 #include <ksync/ksync_netlink.h>
19 #include <ksync/ksync_sock.h>
20 #include "oper/interface_common.h"
21 #include "vrouter/ksync/agent_ksync_types.h"
22 #include "vr_types.h"
23 
24 using namespace boost::placeholders;
25 
26 void KSyncInterfaceCreate(Interface::Type type, const char *if_name,
27  uint32_t vrf_id, uint32_t &ifindex, uint32_t &fd,
28  MacAddress &mac);
29 void KSyncInterfaceDelete(Interface::Type type, const char *if_name,
30  uint32_t vrf_id, uint32_t ifindex, uint32_t fd);
31 void GetPhyMac(const char *ifname, char *mac);
32 
33 class Timer;
35 
37 public:
38  static const int kDefaultInterfaceMsgSize = KSYNC_DEFAULT_MSG_SIZE;
39 
41  const InterfaceKSyncEntry *entry, uint32_t index);
43  virtual ~InterfaceKSyncEntry();
44 
45  const MacAddress &mac() const {
46  if (parent_.get() == NULL) {
47  return mac_;
48  } else {
49  const InterfaceKSyncEntry *parent =
50  static_cast<const InterfaceKSyncEntry *>(parent_.get());
51  return parent->mac();
52  }
53  }
54  const MacAddress &smac() const {return smac_;}
55 
56  uint32_t interface_id() const {return interface_id_;}
57  const string &interface_name() const {return interface_name_;}
58  bool has_service_vlan() const {return has_service_vlan_;}
59  bool no_arp() const { return no_arp_; }
60  PhysicalInterface::EncapType encap_type() const { return encap_type_; }
61 
62  KSyncDBObject *GetObject() const;
63  virtual bool Sync(DBEntry *e);
64  virtual bool IsLess(const KSyncEntry &rhs) const;
65  virtual std::string ToString() const;
66  virtual int AddMsg(char *buf, int buf_len);
67  virtual int ChangeMsg(char *buf, int buf_len);
68  virtual int DeleteMsg(char *buf, int buf_len);
69  virtual KSyncEntry *UnresolvedReference();
70  void FillObjectLog(sandesh_op::type op, KSyncIntfInfo &info) const;
71  bool drop_new_flows() const {return drop_new_flows_;}
72  bool dhcp_enable() const {return dhcp_enable_;}
73  bool dhcp_enable_v6() const {return dhcp_enable_v6_;}
74  bool layer3_forwarding() const {return layer3_forwarding_;}
75  bool bridging() const {return bridging_;}
76  bool pbb_interface() const {return pbb_interface_;}
77  const MacAddress &pbb_mac() const { return pbb_mac_; }
78 
79  int MsgLen() { return kDefaultInterfaceMsgSize; }
80  bool KSyncEntrySandesh(Sandesh *resp);
81 
82 private:
83  friend class InterfaceKSyncObject;
84  int Encode(sandesh_op::type op, char *buf, int buf_len);
85  void SetKsyncItfSandeshData(KSyncItfSandeshData *data) const;
86 
91  uint32_t fd_; // FD opened for this
92  uint32_t flow_key_nh_id_;
94  uint32_t interface_id_;
95  string interface_name_; // Key
96  uint32_t ip_;
98  bool hc_active_;
105  bool bridging_;
111  size_t os_index_;
119  uint16_t rx_vlan_id_;
120  uint16_t tx_vlan_id_;
121  uint32_t vrf_id_;
126  bool no_arp_;
128  std::string display_name_;
133  std::set<MacAddress> aap_mac_list_;
136  uint32_t isid_;
137  uint32_t pbb_cmac_vrf_;
144  boost::optional<InterfaceOsParams::IfGuid> os_guid_;
145  std::vector<KSyncEntryPtr> xconnect_list_;
147 };
148 
150 public:
151  InterfaceKSyncObject(KSync *parent);
152  virtual ~InterfaceKSyncObject();
153 
154  KSync *ksync() const { return ksync_; }
155 
156  void Init();
157  void InitTest();
158  virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index);
159  virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e);
160  void RegisterDBClients();
161  DBFilterResp DBEntryFilter(const DBEntry *e, const KSyncDBEntry *k);
162 
163 private:
166 };
167 
168 #endif // vnsw_agent_interface_ksync_h
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:15
static bool IsLess(const ShowRoute &lhs, const ShowRoute &rhs, const BgpSandeshContext *bsc, const string &table_name)
bool bridging() const
InetInterface::SubType sub_type_
PhysicalInterface::EncapType encap_type_
bool dhcp_enable() const
PhysicalInterface::SubType subtype_
Interface::Type type_
bool dhcp_enable_v6() const
Interface::MirrorDirection mirror_direction_
VmInterface::FatFlowExcludeList fat_flow_exclude_list_
const MacAddress & mac() const
VmInterface::HbsIntfType hbs_intf_type_
KSyncEntryPtr parent_
bool has_service_vlan() const
VmInterface::ProxyArpMode proxy_arp_mode_
VmInterface::DeviceType vmi_device_type_
const MacAddress & smac() const
bool drop_new_flows() const
InterfaceKSyncObject * ksync_obj_
std::set< MacAddress > aap_mac_list_
KSyncEntryPtr xconnect_
const MacAddress & pbb_mac() const
bool layer3_forwarding() const
std::string display_name_
VmInterface::FatFlowList fat_flow_list_
Interface::Transport transport_
bool pbb_interface() const
DISALLOW_COPY_AND_ASSIGN(InterfaceKSyncEntry)
uint32_t interface_id() const
KSyncEntryPtr qos_config_
VmInterface::VmiType vmi_type_
PhysicalInterface::EncapType encap_type() const
boost::optional< InterfaceOsParams::IfGuid > os_guid_
const string & interface_name() const
std::vector< KSyncEntryPtr > xconnect_list_
DISALLOW_COPY_AND_ASSIGN(InterfaceKSyncObject)
KSync * ksync() const
MirrorDirection
Definition: interface.h:57
boost::intrusive_ptr< KSyncEntry > KSyncEntryPtr
Definition: ksync_entry.h:68
Definition: timer.h:57
void KSyncInterfaceCreate(Interface::Type type, const char *if_name, uint32_t vrf_id, uint32_t &ifindex, uint32_t &fd, MacAddress &mac)
void GetPhyMac(const char *ifname, char *mac)
void KSyncInterfaceDelete(Interface::Type type, const char *if_name, uint32_t vrf_id, uint32_t ifindex, uint32_t fd)
#define KSYNC_DEFAULT_MSG_SIZE
Definition: ksync_sock.h:27
uint8_t type
Definition: load_balance.h:2
static string ToString(PhysicalDevice::ManagementProtocol proto)