OpenSDN source code
ha_stale_dev_vn.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_HA_STALE_DEV_VN_H_
7 #define SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_HA_STALE_DEV_VN_H_
8 
9 #include <base/lifetime.h>
10 #include <ovsdb_entry.h>
11 #include <ovsdb_object.h>
13 
14 namespace OVSDB {
15 class HaStaleL2RouteTable;
16 class HaStaleL2RouteEntry;
17 class HaStaleVnTable;
18 class ConnectionStateEntry;
19 
21 public:
22  static const uint32_t kStaleTimerJobInterval = 100; // in millisecond
23  static const uint32_t kNumEntriesPerIteration = 100; // in millisecond
24 
25  typedef boost::function<void(void)> StaleClearL2EntryCb;
26  struct StaleL2Entry {
28  : time_stamp(t), entry(e) {
29  }
30 
31  uint64_t time_stamp;
33 
34  bool operator <(const StaleL2Entry &rhs) const {
35  if (time_stamp != rhs.time_stamp) {
36  return time_stamp < rhs.time_stamp;
37  }
38 
39  return entry < rhs.entry;
40  }
41  };
42  typedef std::map<StaleL2Entry, StaleClearL2EntryCb> CbMap;
45  std::string &dev_name);
46  virtual ~HaStaleDevVnTable();
47 
48  KSyncEntry *Alloc(const KSyncEntry *key, uint32_t index);
51  const OvsdbDBEntry *ovsdb_entry);
52 
53  Agent *agent() const;
54  void DeleteTableDone();
55  virtual void EmptyTable();
56 
57  void VnReEvalEnqueue(const boost::uuids::uuid &vn_uuid);
58  bool VnReEval(const boost::uuids::uuid &vn_uuid);
59 
60  OvsPeer *route_peer() const;
61  const std::string &dev_name() const;
62  ConnectionStateEntry *state() const;
63  uint64_t time_stamp() const { return time_stamp_;}
64 
67  void StaleClearDelEntry(uint64_t time_stamp, HaStaleL2RouteEntry *entry);
68 
69 private:
70  friend class HaStaleDevVnEntry;
71 
72  bool StaleClearTimerCb();
73 
76  std::unique_ptr<OvsPeer> route_peer_;
77  std::string dev_name_;
79  // Additionaly listen to VN table for VN-VRF link updates
81  // entries for which the timer is running to clear stale entries
83  // time stamp represented by iteration count of interval
84  // kStaleTimerJobInterval should always be non-zero and start with 1
85  uint64_t time_stamp_;
87  // reeval queue used to trigger updates on change in VN-VRF link
88  // this is required VN object cannot trigger a re-eval on dev-vn
89  // object in line as dev-vn object needs to check for resolution
90  // of vn object.
93 };
94 
96 public:
99 
100  bool Add();
101  bool Change();
102  bool Delete();
103 
104  bool Sync(DBEntry*);
105  bool IsLess(const KSyncEntry&) const;
106  std::string ToString() const {return "Ha Stale Dev VN Entry";}
108 
110 
112  const boost::uuids::uuid &vn_uuid() const { return vn_uuid_; }
113 
114  Agent *agent() const;
115  OvsPeer *route_peer() const;
116  const std::string &dev_name() const;
117  ConnectionStateEntry *state() const;
118  IpAddress dev_ip() const;
119  const std::string &vn_name() const;
120  uint32_t vxlan_id() const;
121 
122 private:
123  friend class HaStaleDevVnTable;
126  // hold pointer to old l2_table which is already
127  // scheduled for deletion, this delete can be
128  // triggered due to delete or change of entry
129  // so we hold the ksync state to wait for an Ack
130  // on table cleanup and move the ksync state
131  // machine when HaStaleL2RouteTable triggerack
132  // at the time of table delete complete
136  std::string vn_name_;
137  uint32_t vxlan_id_;
139 };
140 
141 };
142 
143 #endif //SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_HA_STALE_DEV_VN_H_
144 
boost::asio::ip::address IpAddress
Definition: address.h:14
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge,...
Definition: agent_route.h:110
Definition: agent.h:361
IpAddress dev_ip() const
HaStaleL2RouteTable * l2_table() const
const std::string & dev_name() const
ConnectionStateEntry * state() const
std::string ToString() const
void TriggerAck(HaStaleL2RouteTable *table)
HaStaleL2RouteTable * l2_table_
bool IsLess(const KSyncEntry &) const
boost::uuids::uuid vn_uuid_
const boost::uuids::uuid & vn_uuid() const
HaStaleL2RouteTable * old_l2_table_
const std::string & vn_name() const
AgentRouteTable * oper_bridge_table_
KSyncEntry * UnresolvedReference()
DISALLOW_COPY_AND_ASSIGN(HaStaleDevVnEntry)
HaStaleDevVnEntry(OvsdbDBObject *table, const boost::uuids::uuid &vn_uuid)
OvsPeer * route_peer() const
DBFilterResp OvsdbDBEntryFilter(const DBEntry *entry, const OvsdbDBEntry *ovsdb_entry)
static const uint32_t kStaleTimerJobInterval
HaStaleVnTable * vn_table_
std::unique_ptr< OvsPeer > route_peer_
const std::string & dev_name() const
void StaleClearDelEntry(uint64_t time_stamp, HaStaleL2RouteEntry *entry)
void VnReEvalEnqueue(const boost::uuids::uuid &vn_uuid)
uint64_t time_stamp() const
HaStaleDevVnTable(Agent *agent, OvsPeerManager *manager, ConnectionStateEntry *state, std::string &dev_name)
boost::function< void(void)> StaleClearL2EntryCb
void StaleClearAddEntry(uint64_t time_stamp, HaStaleL2RouteEntry *entry, StaleClearL2EntryCb cb)
std::map< StaleL2Entry, StaleClearL2EntryCb > CbMap
OvsPeerManager * manager_
DISALLOW_COPY_AND_ASSIGN(HaStaleDevVnTable)
ConnectionStateEntry * state() const
static const uint32_t kNumEntriesPerIteration
KSyncEntry * DBToKSyncEntry(const DBEntry *)
KSyncEntry * Alloc(const KSyncEntry *key, uint32_t index)
bool VnReEval(const boost::uuids::uuid &vn_uuid)
WorkQueue< boost::uuids::uuid > * vn_reeval_queue_
ConnectionStateEntryPtr state_
OvsPeer * route_peer() const
OvsdbDBObject * table()
Definition: ovsdb_entry.h:97
Definition: timer.h:58
Definition: agent.h:44
boost::intrusive_ptr< ConnectionStateEntry > ConnectionStateEntryPtr
StaleL2Entry(uint64_t t, HaStaleL2RouteEntry *e)
bool operator<(const StaleL2Entry &rhs) const
boost::uuids::uuid uuid