22 #include <ovsdb_types.h>
24 using namespace OVSDB;
38 const std::string &name) :
39 OvsdbDBEntry(table), name_(name), device_name_(), vxlan_id_(0),
40 mcast_local_row_list_(), mcast_remote_row_(NULL), delete_ovs_(false),
41 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
46 name_(
UuidToString(entry->vn()->GetUuid())), mcast_local_row_list_(),
47 mcast_remote_row_(NULL), delete_ovs_(false),
48 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
55 mcast_local_row_list_(), mcast_remote_row_(NULL), delete_ovs_(false),
56 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
63 struct ovsdb_idl_row *entry) :
OvsdbDBEntry(table, entry),
66 mcast_remote_row_(NULL), delete_ovs_(false),
67 res_vxlan_id_(table->client_idl()->vxlan_table(), this), del_task_(NULL) {
90 struct ovsdb_idl_row *row =
110 struct ovsdb_idl_row *pl_row = NULL;
114 pl_row, dest_ip.c_str());
137 OvsdbIdlRowList::iterator it;
265 uint32_t active_vxlan_id =
287 uint32_t active_vxlan_id =
311 if (!add_change_in_progress) {
326 Task((entry->table()->client_idl()->agent()->task_scheduler()\
327 ->GetTaskId(
"Agent::KSync")), 0), entry_(entry) {
341 std::set<IntrusiveReferrer>::const_iterator it =
345 for (
int i = 0; i < kEntriesPerIteration; i++) {
389 SandeshLogicalSwitchInfo info;
392 info.set_op(
"Add Requested");
395 info.set_op(
"Delete Requested");
398 info.set_op(
"Add Received");
401 info.set_op(
"Delete Received");
404 info.set_op(
"Add Request with Duplicate tunnel key");
407 info.set_op(
"unknown");
409 info.set_name(
name_);
416 OvsdbIdlRowList::iterator it;
435 OvsdbIdlRowList::iterator it;
475 struct ovsdb_idl_row *row) {
489 struct ovsdb_idl_row *row) {
497 struct ovsdb_idl_row *l_set =
505 OvsdbIdlRowMap::iterator idl_it =
idl_row_map_.find(row);
507 entry = idl_it->second;
512 ", logical switch " + (entry != NULL ? entry->
name() :
""));
518 ", logical switch " + (ls ? std::string(ls) :
""));
542 struct ovsdb_idl_row *row) {
552 OvsdbIdlRowMap::iterator idl_it =
idl_row_map_.find(row);
554 entry = idl_it->second;
559 ", logical switch " + (entry != NULL ? entry->
name() :
""));
573 ", logical switch " + (ls ? std::string(ls) :
""));
594 if (dest_ip.compare(tsn_ip) != 0) {
613 struct ovsdb_idl_row *row) {
623 OvsdbIdlRowMap::iterator idl_it =
idl_row_map_.find(row);
625 entry = idl_it->second;
630 ", logical switch " + (entry != NULL ? entry->
name() :
""));
636 ", logical switch " + (ls ? std::string(ls) :
""));
699 Task((table->client_idl()->agent()->task_scheduler()\
700 ->GetTaskId(
"Agent::KSync")), 0), table_(table), entry_(NULL) {
708 if (kentry == NULL) {
709 kentry =
table_->Next(kentry);
713 while (kentry != NULL) {
716 kentry =
table_->Next(kentry);
722 if (count == kEntriesPerIteration && kentry != NULL) {
740 if (
false == args.
Get(
"name", &
name_)) {
744 if (
false == args.
Get(
"vxlan_id", &vxlan_id)) {
751 const std::string &ip,
753 const std::string &name,
762 if (!
name_.empty()) {
772 if (!
name_.empty()) {
774 if (entry->
name().find(
name_) == std::string::npos) {
792 OvsdbLogicalSwitchEntry lentry;
794 lentry.set_name(entry->
name());
796 lentry.set_vxlan_id(entry->
vxlan_id());
799 lentry.set_vxlan_id_available(res.
VxLanId() != 0);
812 lentry.set_message(
"Waiting for Local Macs Cleanup");
814 OvsdbLogicalSwitchResp *ls_resp =
815 static_cast<OvsdbLogicalSwitchResp *
>(resp);
816 std::vector<OvsdbLogicalSwitchEntry> &lswitch =
817 const_cast<std::vector<OvsdbLogicalSwitchEntry>&
>(
818 ls_resp->get_lswitch());
819 lswitch.push_back(lentry);
831 void OvsdbLogicalSwitchReq::HandleRequest()
const {
834 get_session_remote_port(),
835 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. 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. 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 wrapper over tbb::task to support policies.
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)