OpenSDN source code
ksync_vxlan_port.cc
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 #include <cmn/agent_cmn.h>
6 
7 #include <ksync/ksync_index.h>
8 #include <ksync/ksync_entry.h>
9 #include <ksync/ksync_object.h>
10 
11 #include <vnc_cfg_types.h>
12 #include <bgp_schema_types.h>
13 #include <agent_types.h>
14 
15 #include <oper/peer.h>
16 #include <oper/vrf.h>
17 #include <oper/interface_common.h>
18 #include <oper/nexthop.h>
19 #include <oper/multicast.h>
20 #include <oper/vn.h>
21 #include <oper/mirror_table.h>
22 #include <oper/vxlan.h>
23 #include <oper/mpls.h>
24 #include <oper/route_common.h>
25 #include <oper/bridge_route.h>
26 
27 #include "ksync_vxlan.h"
28 #include "ksync_vxlan_bridge.h"
29 #include "ksync_vxlan_port.h"
30 #include "ksync_vxlan_route.h"
31 
33  const KSyncVxlanPortEntry *entry) :
34  KSyncDBEntry(), type_(entry->type_), port_name_(entry->port_name_),
35  bridge_(entry->bridge_), ksync_obj_(obj) {
36 }
37 
39  const Interface *intrface) :
40  KSyncDBEntry(), type_(intrface->type()), port_name_(intrface->name()),
41  bridge_(nullptr), ksync_obj_(obj) {
42 }
43 
45 }
46 
48  return ksync_obj_;
49 }
50 
51 bool KSyncVxlanPortEntry::IsLess(const KSyncEntry &rhs) const {
52  const KSyncVxlanPortEntry &entry = static_cast
53  <const KSyncVxlanPortEntry &>(rhs);
54  return port_name_ < entry.port_name_;
55 }
56 
57 std::string KSyncVxlanPortEntry::ToString() const {
58  std::stringstream s;
59  s << "Interface : " << port_name_;
60  return s.str();
61 }
62 
64  bool ret = false;
66  return ret;
67  }
68 
69  VmInterface *vm_interface = static_cast<VmInterface *>(e);
70  KSyncVxlanBridgeEntry *bridge = nullptr;
71  const VnEntry *vn = static_cast<const VnEntry *>(vm_interface->vn());
72  const VxLanId *vxlan = nullptr;
73  if (vn) {
74  vxlan = vn->vxlan_id_ref();
75  }
76  if (vxlan != nullptr) {
78  KSyncEntry *key = bridge_obj->DBToKSyncEntry(vxlan);
79  bridge = static_cast<KSyncVxlanBridgeEntry *>
80  (bridge_obj->GetReference(key));
81  delete key;
82  assert(bridge);
83  } else {
84  bridge_ = nullptr;
85  }
86 
87  if (bridge_ != bridge) {
88  bridge_ = bridge;
89  ret = true;
90  }
91 
92  return ret;
93 }
94 
97  return nullptr;
98  }
99 
100  if (bridge_ == nullptr) {
101  return KSyncVxlan::defer_entry();
102  }
103 
104  if ((bridge_->IsResolved() == false)) {
105  return bridge_;
106  }
107 
108  return nullptr;
109 }
110 
112  KSyncDBObject("KSyncVxlanPortObject"), ksync_(ksync) {
113 }
114 
117 }
118 
120 }
121 
123 }
124 
126 }
InterfaceTable * interface_table() const
Definition: agent.h:468
@ VM_INTERFACE
Definition: interface.h:38
void RegisterDb(DBTableBase *table)
bool IsResolved()
KSyncEntry * GetReference(const KSyncEntry *key)
virtual KSyncEntry * DBToKSyncEntry(const DBEntry *e)=0
virtual bool Sync(DBEntry *e)
KSyncVxlanPortEntry(KSyncVxlanPortObject *obj, const KSyncVxlanPortEntry *entry)
KSyncVxlanBridgeEntry * bridge_
KSyncVxlanPortObject * ksync_obj_
virtual ~KSyncVxlanPortEntry()
Interface::Type type_
virtual std::string ToString() const
virtual bool IsLess(const KSyncEntry &rhs) const
virtual KSyncEntry * UnresolvedReference()
const KSyncVxlanBridgeEntry * bridge() const
KSyncDBObject * GetObject() const
KSyncVxlanPortObject(KSyncVxlan *ksync)
KSyncVxlan * ksync() const
Agent * agent() const
Definition: ksync_vxlan.h:49
static KSyncEntry * defer_entry()
Definition: ksync_vxlan.cc:65
KSyncVxlanBridgeObject * bridge_obj() const
Definition: ksync_vxlan.cc:41
const VnEntry * vn() const
Definition: vn.h:152
const VxLanId * vxlan_id_ref() const
Definition: vn.h:193
Definition: vxlan.h:14
uint8_t type
Definition: load_balance.h:2