OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ksync_vxlan_port.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 #include <cmn/agent_cmn.h>
5 
6 #include <ksync/ksync_index.h>
7 #include <ksync/ksync_entry.h>
8 #include <ksync/ksync_object.h>
9 
10 #include <vnc_cfg_types.h>
11 #include <bgp_schema_types.h>
12 #include <agent_types.h>
13 
14 #include <oper/peer.h>
15 #include <oper/vrf.h>
16 #include <oper/interface_common.h>
17 #include <oper/nexthop.h>
18 #include <oper/multicast.h>
19 #include <oper/vn.h>
20 #include <oper/mirror_table.h>
21 #include <oper/vxlan.h>
22 #include <oper/mpls.h>
23 #include <oper/route_common.h>
24 #include <oper/bridge_route.h>
25 
26 #include "ksync_vxlan.h"
27 #include "ksync_vxlan_bridge.h"
28 #include "ksync_vxlan_port.h"
29 #include "ksync_vxlan_route.h"
30 
32  const KSyncVxlanPortEntry *entry) :
33  KSyncDBEntry(), type_(entry->type_), port_name_(entry->port_name_),
34  bridge_(entry->bridge_), ksync_obj_(obj) {
35 }
36 
38  const Interface *intrface) :
39  KSyncDBEntry(), type_(intrface->type()), port_name_(intrface->name()),
40  bridge_(nullptr), ksync_obj_(obj) {
41 }
42 
44 }
45 
47  return ksync_obj_;
48 }
49 
50 bool KSyncVxlanPortEntry::IsLess(const KSyncEntry &rhs) const {
51  const KSyncVxlanPortEntry &entry = static_cast
52  <const KSyncVxlanPortEntry &>(rhs);
53  return port_name_ < entry.port_name_;
54 }
55 
56 std::string KSyncVxlanPortEntry::ToString() const {
57  std::stringstream s;
58  s << "Interface : " << port_name_;
59  return s.str();
60 }
61 
63  bool ret = false;
65  return ret;
66  }
67 
68  VmInterface *vm_interface = static_cast<VmInterface *>(e);
69  KSyncVxlanBridgeEntry *bridge = nullptr;
70  const VnEntry *vn = static_cast<const VnEntry *>(vm_interface->vn());
71  const VxLanId *vxlan = nullptr;
72  if (vn) {
73  vxlan = vn->vxlan_id_ref();
74  }
75  if (vxlan != nullptr) {
77  KSyncEntry *key = bridge_obj->DBToKSyncEntry(vxlan);
78  bridge = static_cast<KSyncVxlanBridgeEntry *>
79  (bridge_obj->GetReference(key));
80  delete key;
81  assert(bridge);
82  } else {
83  bridge_ = nullptr;
84  }
85 
86  if (bridge_ != bridge) {
87  bridge_ = bridge;
88  ret = true;
89  }
90 
91  return ret;
92 }
93 
96  return nullptr;
97  }
98 
99  if (bridge_ == nullptr) {
100  return KSyncVxlan::defer_entry();
101  }
102 
103  if ((bridge_->IsResolved() == false)) {
104  return bridge_;
105  }
106 
107  return nullptr;
108 }
109 
111  KSyncDBObject("KSyncVxlanPortObject"), ksync_(ksync) {
112 }
113 
116 }
117 
119 }
120 
122 }
123 
125 }
KSyncVxlan * ksync() const
void RegisterDb(DBTableBase *table)
bool IsResolved()
virtual bool IsLess(const KSyncEntry &rhs) const
static KSyncEntry * defer_entry()
Definition: ksync_vxlan.cc:64
virtual ~KSyncVxlanPortEntry()
InterfaceTable * interface_table() const
Definition: agent.h:465
Definition: vxlan.h:14
virtual KSyncEntry * DBToKSyncEntry(const DBEntry *e)=0
uint8_t type
Definition: load_balance.h:109
const KSyncVxlanBridgeEntry * bridge() const
virtual KSyncEntry * UnresolvedReference()
virtual bool Sync(DBEntry *e)
KSyncDBObject * GetObject() const
const VxLanId * vxlan_id_ref() const
Definition: vn.h:189
KSyncVxlanPortObject * ksync_obj_
const VnEntry * vn() const
KSyncEntry * GetReference(const KSyncEntry *key)
Definition: vn.h:151
Agent * agent() const
Definition: ksync_vxlan.h:48
virtual std::string ToString() const
KSyncVxlanBridgeEntry * bridge_
KSyncVxlanPortEntry(KSyncVxlanPortObject *obj, const KSyncVxlanPortEntry *entry)
KSyncVxlanBridgeObject * bridge_obj() const
Definition: ksync_vxlan.cc:40
Interface::Type type_
KSyncVxlanPortObject(KSyncVxlan *ksync)