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  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef vnsw_agent_interface_ksync_h
7 #define vnsw_agent_interface_ksync_h
8 
9 #include <net/ethernet.h>
10 
11 #include <boost/asio.hpp>
12 #include <boost/bind/bind.hpp>
13 
14 #include <db/db_entry.h>
15 #include <db/db_table.h>
16 #include <db/db_table_partition.h>
17 #include <ksync/ksync_entry.h>
18 #include <ksync/ksync_object.h>
19 #include <ksync/ksync_netlink.h>
20 #include <ksync/ksync_sock.h>
21 #include "oper/interface_common.h"
22 #include "vrouter/ksync/agent_ksync_types.h"
23 #include "vr_types.h"
24 
25 using namespace boost::placeholders;
26 
27 void KSyncInterfaceCreate(Interface::Type type, const char *if_name,
28  uint32_t vrf_id, uint32_t &ifindex, uint32_t &fd,
29  MacAddress &mac);
30 void KSyncInterfaceDelete(Interface::Type type, const char *if_name,
31  uint32_t vrf_id, uint32_t ifindex, uint32_t fd);
32 void GetPhyMac(const char *ifname, char *mac);
33 
34 class Timer;
36 
38 public:
39  static const int kDefaultInterfaceMsgSize = KSYNC_DEFAULT_MSG_SIZE;
40 
42  const InterfaceKSyncEntry *entry, uint32_t index);
44  virtual ~InterfaceKSyncEntry();
45 
46  const MacAddress &mac() const {
47  if (parent_.get() == NULL) {
48  return mac_;
49  } else {
50  const InterfaceKSyncEntry *parent =
51  static_cast<const InterfaceKSyncEntry *>(parent_.get());
52  return parent->mac();
53  }
54  }
55  const MacAddress &smac() const {return smac_;}
56 
57  uint32_t interface_id() const {return interface_id_;}
58  const string &interface_name() const {return interface_name_;}
59  bool has_service_vlan() const {return has_service_vlan_;}
60  bool no_arp() const { return no_arp_; }
61  PhysicalInterface::EncapType encap_type() const { return encap_type_; }
62 
63  KSyncDBObject *GetObject() const;
64  virtual bool Sync(DBEntry *e);
65  virtual bool IsLess(const KSyncEntry &rhs) const;
66  virtual std::string ToString() const;
67  virtual int AddMsg(char *buf, int buf_len);
68  virtual int ChangeMsg(char *buf, int buf_len);
69  virtual int DeleteMsg(char *buf, int buf_len);
70  virtual KSyncEntry *UnresolvedReference();
71  void FillObjectLog(sandesh_op::type op, KSyncIntfInfo &info) const;
72  bool drop_new_flows() const {return drop_new_flows_;}
73  bool dhcp_enable() const {return dhcp_enable_;}
74  bool dhcp_enable_v6() const {return dhcp_enable_v6_;}
75  bool layer3_forwarding() const {return layer3_forwarding_;}
76  bool bridging() const {return bridging_;}
77  bool pbb_interface() const {return pbb_interface_;}
78  const MacAddress &pbb_mac() const { return pbb_mac_; }
79 
80  int MsgLen() { return kDefaultInterfaceMsgSize; }
81  bool KSyncEntrySandesh(Sandesh *resp);
82 
83 private:
84  friend class InterfaceKSyncObject;
85  int Encode(sandesh_op::type op, char *buf, int buf_len);
86  void SetKsyncItfSandeshData(KSyncItfSandeshData *data) const;
87 
92  uint32_t fd_; // FD opened for this
93  uint32_t flow_key_nh_id_;
95  uint32_t interface_id_;
96  string interface_name_; // Key
97  uint32_t ip_;
99  bool hc_active_;
106  bool bridging_;
112  size_t os_index_;
120  uint16_t rx_vlan_id_;
121  uint16_t tx_vlan_id_;
122  uint32_t vrf_id_;
127  bool no_arp_;
129  std::string display_name_;
134  std::set<MacAddress> aap_mac_list_;
137  uint32_t isid_;
138  uint32_t pbb_cmac_vrf_;
145  boost::optional<InterfaceOsParams::IfGuid> os_guid_;
146  std::vector<KSyncEntryPtr> xconnect_list_;
148 };
149 
151 public:
152  InterfaceKSyncObject(KSync *parent);
153  virtual ~InterfaceKSyncObject();
154 
155  KSync *ksync() const { return ksync_; }
156 
157  void Init();
158  void InitTest();
159  virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index);
160  virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e);
161  void RegisterDBClients();
162  DBFilterResp DBEntryFilter(const DBEntry *e, const KSyncDBEntry *k);
163 
164 private:
167 };
168 
169 #endif // vnsw_agent_interface_ksync_h
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:16
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:58
boost::intrusive_ptr< KSyncEntry > KSyncEntryPtr
Definition: ksync_entry.h:69
Definition: timer.h:58
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:28
uint8_t type
Definition: load_balance.h:2
static string ToString(PhysicalDevice::ManagementProtocol proto)