-
Notifications
You must be signed in to change notification settings - Fork 390
/
ovsdb_client_idl.h
141 lines (120 loc) · 4.53 KB
/
ovsdb_client_idl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
*/
#ifndef SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_CLIENT_IDL_H_
#define SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_CLIENT_IDL_H_
#include <assert.h>
#include <boost/intrusive_ptr.hpp>
#include <tbb/atomic.h>
#include <cmn/agent_cmn.h>
#include <cmn/agent.h>
#include <agent_types.h>
extern SandeshTraceBufferPtr OvsdbTraceBuf;
extern SandeshTraceBufferPtr OvsdbPktTraceBuf;
#define OVSDB_TRACE(obj, ...)\
do {\
Ovsdb##obj::TraceMsg(OvsdbTraceBuf, __FILE__, __LINE__, __VA_ARGS__);\
} while(false);
#define OVSDB_PKT_TRACE(obj, ...)\
do {\
Ovsdb##obj::TraceMsg(OvsdbPktTraceBuf, __FILE__, __LINE__, __VA_ARGS__);\
} while(false);
class OvsPeer;
class OvsPeerManager;
class KSyncObjectManager;
namespace OVSDB {
class OvsdbClientSession;
class VMInterfaceKSyncObject;
class PhysicalSwitchTable;
class LogicalSwitchTable;
class PhysicalPortTable;
class PhysicalLocatorTable;
class VlanPortBindingTable;
class PhysicalLocatorTable;
class UnicastMacLocalOvsdb;
class VrfOvsdbObject;
class VnOvsdbObject;
class OvsdbEntryBase;
class OvsdbClientIdl;
typedef boost::intrusive_ptr<OvsdbClientIdl> OvsdbClientIdlPtr;
class OvsdbClientIdl {
public:
enum Op {
OVSDB_DEL = 0,
OVSDB_ADD,
OVSDB_INVALID_OP
};
enum EntryType {
OVSDB_PHYSICAL_SWITCH = 0,
OVSDB_LOGICAL_SWITCH,
OVSDB_PHYSICAL_PORT,
OVSDB_PHYSICAL_LOCATOR,
OVSDB_UCAST_MAC_LOCAL,
OVSDB_UCAST_MAC_REMOTE,
OVSDB_PHYSICAL_LOCATOR_SET,
OVSDB_MCAST_MAC_LOCAL,
OVSDB_MCAST_MAC_REMOTE,
OVSDB_TYPE_COUNT
};
typedef boost::function<void(OvsdbClientIdl::Op, struct ovsdb_idl_row *)> NotifyCB;
typedef std::map<struct ovsdb_idl_txn *, OvsdbEntryBase *> PendingTxnMap;
OvsdbClientIdl(OvsdbClientSession *session, Agent *agent, OvsPeerManager *manager);
virtual ~OvsdbClientIdl();
// Send request to start monitoring OVSDB server
void SendMointorReq();
// Send encode json rpc messgage to OVSDB server
void SendJsonRpc(struct jsonrpc_msg *msg);
// Process the recevied message and trigger update to ovsdb client
void MessageProcess(const u_int8_t *buf, std::size_t len);
// Create a OVSDB transaction to start encoding an update
struct ovsdb_idl_txn *CreateTxn(OvsdbEntryBase *entry);
// Delete the OVSDB transaction
void DeleteTxn(struct ovsdb_idl_txn *txn);
void Register(EntryType type, NotifyCB cb) {callback_[type] = cb;}
void UnRegister(EntryType type) {callback_[type] = NULL;}
// Notify Delete followed by add for a given ovsdb_idl_row
void NotifyDelAdd(struct ovsdb_idl_row *row);
// Get TOR Service Node IP
Ip4Address tsn_ip();
KSyncObjectManager *ksync_obj_manager();
OvsPeer *route_peer();
Agent *agent() {return agent_;}
VMInterfaceKSyncObject *vm_interface_table();
PhysicalSwitchTable *physical_switch_table();
LogicalSwitchTable *logical_switch_table();
PhysicalPortTable *physical_port_table();
PhysicalLocatorTable *physical_locator_table();
VlanPortBindingTable *vlan_port_table();
UnicastMacLocalOvsdb *unicast_mac_local_ovsdb();
VrfOvsdbObject *vrf_ovsdb();
VnOvsdbObject *vn_ovsdb();
void trigger_deletion();
private:
friend void ovsdb_wrapper_idl_callback(void *, int, struct ovsdb_idl_row *);
friend void ovsdb_wrapper_idl_txn_ack(void *, struct ovsdb_idl_txn *);
friend void intrusive_ptr_add_ref(OvsdbClientIdl *p);
friend void intrusive_ptr_release(OvsdbClientIdl *p);
struct ovsdb_idl *idl_;
struct json_parser * parser_;
const struct vteprec_global *vtep_global_;
OvsdbClientSession *session_;
Agent *agent_;
NotifyCB callback_[OVSDB_TYPE_COUNT];
PendingTxnMap pending_txn_;
bool deleted_;
OvsPeerManager *manager_;
tbb::atomic<int> refcount_;
std::auto_ptr<OvsPeer> route_peer_;
std::auto_ptr<VMInterfaceKSyncObject> vm_interface_table_;
std::auto_ptr<PhysicalSwitchTable> physical_switch_table_;
std::auto_ptr<LogicalSwitchTable> logical_switch_table_;
std::auto_ptr<PhysicalPortTable> physical_port_table_;
std::auto_ptr<PhysicalLocatorTable> physical_locator_table_;
std::auto_ptr<VlanPortBindingTable> vlan_port_table_;
std::auto_ptr<UnicastMacLocalOvsdb> unicast_mac_local_ovsdb_;
std::auto_ptr<VrfOvsdbObject> vrf_ovsdb_;
std::auto_ptr<VnOvsdbObject> vn_ovsdb_;
DISALLOW_COPY_AND_ASSIGN(OvsdbClientIdl);
};
}; // namespace OVSDB
#endif // SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_CLIENT_IDL_H_