23 #include <ovsdb_types.h>
25 using namespace OVSDB;
39 const std::string &name) :
40 OvsdbDBEntry(table), name_(name), device_name_(), vxlan_id_(0),
41 mcast_local_row_list_(), mcast_remote_row_(NULL), delete_ovs_(false),
42 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
47 name_(
UuidToString(entry->vn()->GetUuid())), mcast_local_row_list_(),
48 mcast_remote_row_(NULL), delete_ovs_(false),
49 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
56 mcast_local_row_list_(), mcast_remote_row_(NULL), delete_ovs_(false),
57 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
64 struct ovsdb_idl_row *entry) :
OvsdbDBEntry(table, entry),
67 mcast_remote_row_(NULL), delete_ovs_(false),
68 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
91 struct ovsdb_idl_row *row =
111 struct ovsdb_idl_row *pl_row = NULL;
115 pl_row, dest_ip.c_str());
138 OvsdbIdlRowList::iterator it;
266 uint32_t active_vxlan_id =
288 uint32_t active_vxlan_id =
312 if (!add_change_in_progress) {
327 Task((entry->table()->client_idl()->agent()->task_scheduler()\
328 ->GetTaskId(
"Agent::KSync")), 0), entry_(entry) {
342 std::set<IntrusiveReferrer>::const_iterator it =
346 for (
int i = 0; i < kEntriesPerIteration; i++) {
390 SandeshLogicalSwitchInfo info;
393 info.set_op(
"Add Requested");
396 info.set_op(
"Delete Requested");
399 info.set_op(
"Add Received");
402 info.set_op(
"Delete Received");
405 info.set_op(
"Add Request with Duplicate tunnel key");
408 info.set_op(
"unknown");
410 info.set_name(
name_);
417 OvsdbIdlRowList::iterator it;
436 OvsdbIdlRowList::iterator it;
476 struct ovsdb_idl_row *row) {
490 struct ovsdb_idl_row *row) {
498 struct ovsdb_idl_row *l_set =
506 OvsdbIdlRowMap::iterator idl_it =
idl_row_map_.find(row);
508 entry = idl_it->second;
513 ", logical switch " + (entry != NULL ? entry->
name() :
""));
519 ", logical switch " + (ls ? std::string(ls) :
""));
543 struct ovsdb_idl_row *row) {
553 OvsdbIdlRowMap::iterator idl_it =
idl_row_map_.find(row);
555 entry = idl_it->second;
560 ", logical switch " + (entry != NULL ? entry->
name() :
""));
574 ", logical switch " + (ls ? std::string(ls) :
""));
595 if (dest_ip.compare(tsn_ip) != 0) {
614 struct ovsdb_idl_row *row) {
624 OvsdbIdlRowMap::iterator idl_it =
idl_row_map_.find(row);
626 entry = idl_it->second;
631 ", logical switch " + (entry != NULL ? entry->
name() :
""));
637 ", logical switch " + (ls ? std::string(ls) :
""));
700 Task((table->client_idl()->agent()->task_scheduler()\
701 ->GetTaskId(
"Agent::KSync")), 0), table_(table), entry_(NULL) {
709 if (kentry == NULL) {
710 kentry =
table_->Next(kentry);
714 while (kentry != NULL) {
717 kentry =
table_->Next(kentry);
723 if (count == kEntriesPerIteration && kentry != NULL) {
741 if (
false == args.
Get(
"name", &
name_)) {
745 if (
false == args.
Get(
"vxlan_id", &vxlan_id)) {
752 const std::string &ip,
754 const std::string &name,
763 if (!
name_.empty()) {
773 if (!
name_.empty()) {
775 if (entry->
name().find(
name_) == std::string::npos) {
793 OvsdbLogicalSwitchEntry lentry;
795 lentry.set_name(entry->
name());
797 lentry.set_vxlan_id(entry->
vxlan_id());
800 lentry.set_vxlan_id_available(res.
VxLanId() != 0);
813 lentry.set_message(
"Waiting for Local Macs Cleanup");
815 OvsdbLogicalSwitchResp *ls_resp =
816 static_cast<OvsdbLogicalSwitchResp *
>(resp);
817 std::vector<OvsdbLogicalSwitchEntry> &lswitch =
818 const_cast<std::vector<OvsdbLogicalSwitchEntry>&
>(
819 ls_resp->get_lswitch());
820 lswitch.push_back(lentry);
832 void OvsdbLogicalSwitchReq::HandleRequest()
const {
835 get_session_remote_port(),
836 get_name(), get_vxlan_id());
boost::asio::ip::address_v4 Ip4Address
bool Add(const std::string &key, const std::string &val)
bool Get(const std::string &key, std::string *val) const
TaskScheduler * task_scheduler() const
std::string StateString() const
static KSyncEntry * default_defer_entry()
KSyncEntry * Find(const KSyncEntry *key)
void Change(KSyncEntry *entry)
void SafeNotifyEvent(KSyncEntry *entry, KSyncEntry::KSyncEvent event)
KSyncEntry * CreateStale(const KSyncEntry *key)
KSyncEntry * GetReference(const KSyncEntry *key)
bool Run()
Code to execute in a task. Returns true if task is completed. Return false to reschedule the task.
ProcessDeleteOvsReqTask(LogicalSwitchEntry *entry)
virtual ~ProcessDeleteOvsReqTask()
void SendTrace(Trace event) const
bool IsDeleteOvsInProgress() const
OvsdbResourceVxLanId res_vxlan_id_
void DeleteOvs(bool add_change_in_progress)
uint32_t ucast_local_row_list_size() const
void AddMsg(struct ovsdb_idl_txn *)
KSyncEntry * UnresolvedReference()
const std::string & device_name() const
OvsdbResourceVxLanId & res_vxlan_id()
void DeleteMsg(struct ovsdb_idl_txn *)
KSyncEntryPtr physical_switch_
void ChangeMsg(struct ovsdb_idl_txn *)
ProcessDeleteOvsReqTask * del_task_
const std::string & name() const
void DeleteOldMcastRemoteMac()
std::string tor_service_node() const
bool is_mcast_remote_set() const
bool IsLess(const KSyncEntry &) const
OvsdbIdlRowList mcast_local_row_list_
virtual void StaleTimerExpired()
void ReleaseLocatorCreateReference()
virtual ~LogicalSwitchEntry()
struct ovsdb_idl_row * mcast_remote_row_
uint32_t old_mcast_remote_row_list_size() const
Ip4Address & physical_switch_tunnel_ip()
KSyncEntryPtr local_mac_ref_
LogicalSwitchEntry(OvsdbDBObject *table, const std::string &name)
bool is_local_mac_ref_set() const
bool IsLocalMacsRef() const
virtual void NotifyDelete(struct ovsdb_idl_row *)
OvsdbIdlRowList ucast_local_row_list_
KSyncEntryPtr pl_create_ref_
uint32_t mcast_local_row_list_size() const
OvsdbIdlRowList old_mcast_remote_row_list_
std::set< IntrusiveReferrer > back_ref_set_
LogicalSwitchSandeshTask(std::string resp_ctx, AgentSandeshArguments &args)
KSyncObject * GetObject(OvsdbClientSession *session)
FilterResp Filter(KSyncEntry *entry)
virtual ~LogicalSwitchSandeshTask()
SandeshResponse * Alloc()
void EncodeArgs(AgentSandeshArguments &args)
void UpdateResp(KSyncEntry *kentry, SandeshResponse *resp)
ProcessDeleteTableReqTask(LogicalSwitchTable *table)
virtual ~ProcessDeleteTableReqTask()
bool Run()
Code to execute in a task. Returns true if task is completed. Return false to reschedule the task.
KSyncEntry * DBToKSyncEntry(const DBEntry *)
void ProcessDeleteTableReq()
void OvsdbUcastLocalMacNotify(OvsdbClientIdl::Op, struct ovsdb_idl_row *)
virtual ~LogicalSwitchTable()
OvsdbIdlRowMap idl_row_map_
LogicalSwitchTable(OvsdbClientIdl *idl)
void OvsdbMcastRemoteMacNotify(OvsdbClientIdl::Op, struct ovsdb_idl_row *)
KSyncEntry * Alloc(const KSyncEntry *key, uint32_t index)
void OvsdbMcastLocalMacNotify(OvsdbClientIdl::Op, struct ovsdb_idl_row *)
OvsdbDBEntry * AllocOvsEntry(struct ovsdb_idl_row *row)
DBFilterResp OvsdbDBEntryFilter(const DBEntry *entry, const OvsdbDBEntry *ovsdb_entry)
void OvsdbNotify(OvsdbClientIdl::Op, struct ovsdb_idl_row *)
PhysicalSwitchTable * physical_switch_table()
LogicalSwitchTable * logical_switch_table()
UnicastMacLocalOvsdb * unicast_mac_local_ovsdb()
PhysicalLocatorTable * physical_locator_table()
MulticastMacLocalOvsdb * multicast_mac_local_ovsdb()
void Register(EntryType type, NotifyCB cb)
OvsdbClientIdl * client_idl()
struct ovsdb_idl_row * ovs_entry_
virtual void Ack(bool success)
struct ovsdb_idl_row * ovs_entry()
virtual void NotifyDelete(struct ovsdb_idl_row *)
void NotifyAddOvsdb(OvsdbDBEntry *key, struct ovsdb_idl_row *row)
void NotifyDeleteOvsdb(OvsdbDBEntry *key, struct ovsdb_idl_row *row)
OvsdbClientIdl * client_idl()
struct ovsdb_idl_row * ovs_entry()
uint32_t active_vxlan_id() const
bool AcquireVxLanId(uint32_t vxlan_id)
void set_active_vxlan_id(uint32_t vxlan_id)
bool AcquireCreateRequest(KSyncEntry *creator)
void ReleaseCreateRequest(KSyncEntry *creator)
const std::string & device_display_name() const
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
void Enqueue(Task *task)
Enqueues a task for running. Starts task if all policy rules are met else puts task in waitq....
static TaskScheduler * GetInstance()
CancelReturnCode Cancel(Task *task)
Cancels a Task that can be in RUN/WAIT state. The caller needs to ensure that the task exists when Ca...
Task is a class to describe a computational task within OpenSDN control plane applications....
std::pair< void *, void * > IntrusiveReferrer
void intrusive_ptr_del_back_ref(IntrusiveReferrer ref, LogicalSwitchEntry *p)
void intrusive_ptr_add_back_ref(IntrusiveReferrer ref, LogicalSwitchEntry *p)
#define OVSDB_TRACE(obj,...)
void ovsdb_wrapper_delete_mcast_mac_remote(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_mcast_mac_local_logical_switch(struct ovsdb_idl_row *row)
void ovsdb_wrapper_delete_ucast_mac_local(struct ovsdb_idl_row *row)
void ovsdb_wrapper_delete_mcast_mac_local(struct ovsdb_idl_row *row)
void ovsdb_wrapper_add_mcast_mac_remote(struct ovsdb_idl_txn *txn, struct ovsdb_idl_row *row, const char *mac, struct ovsdb_idl_row *ls, struct ovsdb_idl_row *pl, const char *dst_ip)
char * ovsdb_wrapper_ucast_mac_local_mac(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_mcast_mac_local_mac(struct ovsdb_idl_row *row)
int64_t ovsdb_wrapper_logical_switch_tunnel_key(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_mcast_mac_remote_dst_ip(struct ovsdb_idl_row *row)
struct ovsdb_idl_row * ovsdb_wrapper_add_logical_switch(struct ovsdb_idl_txn *, struct ovsdb_idl_row *, const char *, int64_t)
void ovsdb_wrapper_delete_logical_switch(struct ovsdb_idl_row *)
struct ovsdb_idl_row * ovsdb_wrapper_mcast_mac_local_physical_locator_set(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_mcast_mac_remote_logical_switch(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_logical_switch_name(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_ucast_mac_local_logical_switch(struct ovsdb_idl_row *row)
char * ovsdb_wrapper_mcast_mac_remote_mac(struct ovsdb_idl_row *row)
static std::string UuidToString(const boost::uuids::uuid &id)