OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ha_stale_vn.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 extern "C" {
6 #include <ovsdb_wrapper.h>
7 };
8 
9 #include <oper/vn.h>
10 #include <oper/vrf.h>
11 #include <oper/vxlan.h>
12 #include <ovsdb_types.h>
13 
14 #include <ha_stale_vn.h>
15 #include <ha_stale_dev_vn.h>
16 
17 using namespace OVSDB;
18 
20  const boost::uuids::uuid &uuid) : OvsdbDBEntry(table), uuid_(uuid),
21  vn_name_(""), bridge_table_(NULL) {
22 }
23 
25 }
26 
27 void HaStaleVnEntry::AddMsg(struct ovsdb_idl_txn *txn) {
28  HaStaleVnTable *table = static_cast<HaStaleVnTable *>(table_);
29  if (table->dev_vn_table_ != NULL) {
30  // trigger VnReEval for Any Change
32  }
33 }
34 
35 void HaStaleVnEntry::ChangeMsg(struct ovsdb_idl_txn *txn) {
36  AddMsg(txn);
37 }
38 
39 void HaStaleVnEntry::DeleteMsg(struct ovsdb_idl_txn *txn) {
40  HaStaleVnTable *table = static_cast<HaStaleVnTable *>(table_);
41  if (table->dev_vn_table_ != NULL) {
43  }
44 }
45 
46 bool HaStaleVnEntry::Sync(DBEntry *db_entry) {
47  VnEntry *vn = static_cast<VnEntry *>(db_entry);
48  bool change = false;
49  if (vn_name_ != vn->GetName()) {
50  vn_name_ = vn->GetName();
51  change = true;
52  }
53  if (bridge_table_ != vn->GetVrf()->GetBridgeRouteTable()) {
55  change = true;
56  }
57  return change;
58 }
59 
60 bool HaStaleVnEntry::IsLess(const KSyncEntry &entry) const {
61  const HaStaleVnEntry &vn_entry = static_cast<const HaStaleVnEntry&>(entry);
62  return uuid_ < vn_entry.uuid_;
63 }
64 
66  return NULL;
67 }
68 
69 const std::string &HaStaleVnEntry::vn_name() const {
70  return vn_name_;
71 }
72 
74  return bridge_table_;
75 }
76 
78  OvsdbDBObject(NULL, false), agent_(agent), dev_vn_table_(dev_vn_table) {
80 }
81 
83 }
84 
85 KSyncEntry *HaStaleVnTable::Alloc(const KSyncEntry *key, uint32_t index) {
86  const HaStaleVnEntry *k_entry =
87  static_cast<const HaStaleVnEntry *>(key);
88  HaStaleVnEntry *entry = new HaStaleVnEntry(this, k_entry->uuid_);
89  return entry;
90 }
91 
93  const VnEntry *entry = static_cast<const VnEntry *>(db_entry);
94  HaStaleVnEntry *key = new HaStaleVnEntry(this, entry->GetUuid());
95  return static_cast<KSyncEntry *>(key);
96 }
97 
99  const DBEntry *entry, const OvsdbDBEntry *ovsdb_entry) {
100  const VnEntry *vn = static_cast<const VnEntry *>(entry);
101  // only accept Virtual Networks with non-NULL vrf
102  // and non zero vxlan id
103  if (vn->GetVrf() == NULL || vn->GetVxLanId() == 0) {
104  return DBFilterDelete;
105  }
106  return DBFilterAccept;
107 }
108 
111  // unregister the object if emptytable is called with
112  // object being scheduled for delete
113  if (delete_scheduled()) {
115  }
116 }
117 
119  return agent_;
120 }
121 
123  dev_vn_table_ = NULL;
124 }
125 
int GetVxLanId() const
Definition: vn.cc:727
void ChangeMsg(struct ovsdb_idl_txn *)
Definition: ha_stale_vn.cc:35
OvsdbDBObject * table()
Definition: ovsdb_entry.h:96
DBFilterResp OvsdbDBEntryFilter(const DBEntry *entry, const OvsdbDBEntry *ovsdb_entry)
Definition: ha_stale_vn.cc:98
const std::string & vn_name() const
Definition: ha_stale_vn.cc:69
bool Sync(DBEntry *)
Definition: ha_stale_vn.cc:46
virtual void EmptyTable(void)
Agent * agent() const
Definition: ha_stale_vn.cc:118
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
Definition: agent_route.h:109
bool IsLess(const KSyncEntry &) const
Definition: ha_stale_vn.cc:60
virtual void OvsdbRegisterDBTable(DBTable *tbl)
Definition: ovsdb_object.cc:76
boost::uuids::uuid uuid
VnTable * vn_table() const
Definition: agent.h:495
KSyncEntry * DBToKSyncEntry(const DBEntry *)
Definition: ha_stale_vn.cc:92
static void Unregister(KSyncObject *)
bool delete_scheduled()
Definition: ksync_object.h:146
virtual ~HaStaleVnTable()
Definition: ha_stale_vn.cc:82
virtual void EmptyTable(void)
Definition: ha_stale_vn.cc:109
KSyncEntry * UnresolvedReference()
Definition: ha_stale_vn.cc:65
friend class HaStaleVnEntry
Definition: ha_stale_vn.h:31
AgentRouteTable * bridge_table() const
Definition: ha_stale_vn.cc:73
Definition: agent.h:358
HaStaleVnEntry(HaStaleVnTable *table, const boost::uuids::uuid &uuid)
Definition: ha_stale_vn.cc:19
HaStaleVnTable(Agent *agent, HaStaleDevVnTable *dev_vn_table)
Definition: ha_stale_vn.cc:77
AgentRouteTable * GetBridgeRouteTable() const
Definition: vrf.cc:334
void DeleteMsg(struct ovsdb_idl_txn *)
Definition: ha_stale_vn.cc:39
void VnReEvalEnqueue(const boost::uuids::uuid &vn_uuid)
HaStaleDevVnTable * dev_vn_table_
Definition: ha_stale_vn.h:34
boost::uuids::uuid uuid_
Definition: ha_stale_vn.h:62
Definition: vn.h:151
VrfEntry * GetVrf() const
Definition: vn.h:170
virtual ~HaStaleVnEntry()
Definition: ha_stale_vn.cc:24
std::string vn_name_
Definition: ha_stale_vn.h:63
const boost::uuids::uuid & GetUuid() const
Definition: vn.h:161
const string & GetName() const
Definition: vn.h:162
OvsdbDBObject * table_
Definition: ovsdb_entry.h:110
void AddMsg(struct ovsdb_idl_txn *)
Definition: ha_stale_vn.cc:27
AgentRouteTable * bridge_table_
Definition: ha_stale_vn.h:64
KSyncEntry * Alloc(const KSyncEntry *key, uint32_t index)
Definition: ha_stale_vn.cc:85