40 interface_listener_id_ = agent()->interface_table()->Register(
46 agent()->interface_table()->Unregister(interface_listener_id_);
52 bool composite_nh_modified =
false;
59 if (vm_itf->
vn() == NULL) {
76 composite_nh_modified = DeleteCompositeNH(vm_itf->
vxlan_id(), nh_key);
78 composite_nh_modified = AddCompositeNH(vm_itf->
vxlan_id(), nh_key);
89 DeleteCompositeNH(vm_itf->
vxlan_id(), nh_key_op);
93 if (composite_nh_modified) {
103 VxlanCompositeNHList::iterator it = vxlan_composite_nh_map_.find(vxlan_id);
104 if (it != vxlan_composite_nh_map_.end()) {
105 ComponentNHKeyList::iterator list_it = it->second.begin();
106 for (; list_it != it->second.end(); list_it++) {
107 if (*list_it == NULL) {
110 if (**list_it == *nh_key) {
113 it->second.erase(list_it);
123 VxlanCompositeNHList::iterator it = vxlan_composite_nh_map_.find(vxlan_id);
124 if (it != vxlan_composite_nh_map_.end()) {
125 ComponentNHKeyList::const_iterator list_it = it->second.begin();
126 for (; list_it != it->second.end(); list_it++) {
127 if (*list_it == NULL) {
130 if (**list_it == *nh_key) {
135 it->second.push_back(nh_key);
139 list.push_back(nh_key);
148 return std::unique_ptr<DBEntry>(
static_cast<DBEntry *
>(vxlan_id));
152 agent()->ConcurrencyCheck();
155 Input(tpart, NULL, &req);
162 ChangeHandler(vxlan_id, req);
170 ret = ChangeHandler(vxlan_id, req);
185 VxlanCompositeNHList::iterator it =
186 vxlan_composite_nh_map_.find(vxlan_id->
vxlan_id());
187 if (it != vxlan_composite_nh_map_.end()) {
197 list.push_back(nh_ptr);
201 (agent()->nexthop_table()->FindActiveEntry(&nh_key));
209 if (vxlan_id->
nh_ != nh) {
225 return static_cast<VxLanId *
>(FindActiveEntry(&key));
230 return static_cast<VxLanId *
>(FindActiveEntryNoLock(&key));
243 const std::string &vrf,
bool flood_unknown_unicast,
244 bool mirror_destination,
bool learning_enabled,
248 Delete(vxlan_id, vn);
255 ConfigTree::iterator it = config_tree_.lower_bound(
256 ConfigKey(vxlan_id, boost::uuids::nil_uuid()));
258 if (it == config_tree_.end() || it->first.vxlan_id_ != vxlan_id) {
259 config_tree_.insert(make_pair(
ConfigKey(vxlan_id, vn),
261 true, mirror_destination,
263 Create(vxlan_id, vrf, flood_unknown_unicast, mirror_destination,
264 learning_enabled, bridge);
265 return Find(vxlan_id);
269 it = config_tree_.find(
ConfigKey(vxlan_id, vn));
270 if (it != config_tree_.end()) {
271 it->second.vrf_ = vrf;
272 it->second.flood_unknown_unicast_ = flood_unknown_unicast;
273 it->second.mirror_destination_ = mirror_destination;
274 it->second.learning_enabled_ = learning_enabled;
275 it->second.bridge_ = bridge;
278 if (it->second.active_) {
279 Create(vxlan_id, vrf, flood_unknown_unicast, mirror_destination,
280 learning_enabled, bridge);
281 return Find(vxlan_id);
288 config_tree_.insert(make_pair(
ConfigKey(vxlan_id, vn),
290 false, mirror_destination,
297 ConfigTree::iterator it = config_tree_.find(
ConfigKey(vxlan_id, vn));
299 if (it == config_tree_.end()) {
304 bool active = it->second.active_;
305 config_tree_.erase(it);
310 it = config_tree_.lower_bound(
311 ConfigKey(vxlan_id, boost::uuids::nil_uuid()));
313 if (it == config_tree_.end() || it->first.vxlan_id_ != vxlan_id)
316 it->second.active_ =
true;
317 Create(vxlan_id, it->second.vrf_, it->second.flood_unknown_unicast_,
318 it->second.mirror_destination_, it->second.learning_enabled_,
320 agent()->vn_table()->ResyncReq(it->first.vn_);
331 bool flood_unknown_unicast,
bool mirror_destination,
332 bool learning_enable,
bool bridge) {
334 if (mirror_destination) {
335 VxlanCompositeNHList::iterator it =
336 vxlan_composite_nh_map_.find(vxlan_id);
337 if (it != vxlan_composite_nh_map_.end()) {
339 it->second, vrf_name));
344 list.push_back(nh_ptr);
350 nh_req.
key.reset(
new VrfNHKey(vrf_name,
false, bridge));
351 nh_req.
data.reset(
new VrfNHData(flood_unknown_unicast, learning_enable,
365 req.
data.reset(NULL);
366 VxlanCompositeNHList::iterator it = vxlan_composite_nh_map_.find(vxlan_id);
367 if (it != vxlan_composite_nh_map_.end()) {
368 vxlan_composite_nh_map_.erase(it);
374 VxLanResp *resp =
static_cast<VxLanResp *
>(sresp);
376 VxLanSandeshData data;
377 data.set_vxlan_id(vxlan_id_);
378 nh_->SetNHSandeshData(data.nh);
379 std::vector<VxLanSandeshData> &list =
380 const_cast<std::vector<VxLanSandeshData>&
>(resp->get_vxlan_list());
381 list.push_back(data);
388 VxLanObjectLogInfo info;
391 info.set_vxlan_id((
int)vxlan_id_);
393 case AgentLogEvent::ADD:
394 str.assign(
"Addition ");
396 case AgentLogEvent::DEL:
397 str.assign(
"Deletion ");
401 case AgentLogEvent::CHANGE:
402 str.assign(
"Modification ");
405 str.assign(
"Unknown");
413 nh_type.assign(
"VRF");
414 const VrfNH *vrf_nh =
static_cast<const VrfNH *
>(nh);
419 nh_type.assign(
"unknown");
423 info.set_nh_type(nh_type);
427 void VxLanReq::HandleRequest()
const {
429 sand->DoSandesh(sand);
433 const std::string &context) {
444 const string &active,
const string &context) :
446 agent_(agent), vxlan_id_(vxlan_id), vn_(vn), active_(active),
447 context_(context) { }
450 std::string
Description()
const {
return "VxLanConfigSandeshTask"; }
462 VxLanConfigResp *resp =
new VxLanConfigResp();
463 vector<VxLanConfigEntry> &list =
464 const_cast<vector<VxLanConfigEntry>&
>(resp->get_vxlan_config_entries());
467 if (vn_.empty() ==
false) {
472 VxLanTable::ConfigTree::const_iterator it = tree.begin();
473 while (it != tree.end()) {
474 VxLanConfigEntry entry;
475 if (vxlan_id_ != 0) {
476 if (vxlan_id_ != it->first.vxlan_id_) {
482 if (u != boost::uuids::nil_uuid() && u != it->first.vn_) {
487 if (active_.empty() ==
false) {
488 if ((active_ ==
"true" || active_ ==
"yes" || active_ ==
"active")
489 && (it->second.active_ !=
true)) {
494 if ((active_ ==
"false" || active_ ==
"no" || active_ ==
"inactive")
495 && (it->second.active_ !=
false)) {
501 entry.set_vxlan_id(it->first.vxlan_id_);
503 entry.set_vrf(it->second.vrf_);
504 entry.set_flood_unknown_unicast(it->second.flood_unknown_unicast_);
505 entry.set_active(it->second.active_);
506 list.push_back(entry);
509 resp->set_context(context_);
510 resp->set_more(
false);
515 void VxLanConfigReq::HandleRequest()
const {
519 get_active(), context());
bool DeleteCompositeNH(uint32_t vxlan_id, ComponentNHKeyPtr nh_key)
virtual void OnZeroRefcount(AgentDBEntry *e)
const MacAddress & vm_mac() const
void SendObjectLog(const AgentDBTable *table, AgentLogEvent::type event) const
static Agent * GetInstance()
static boost::uuids::uuid StringToUuid(const std::string &str)
virtual DBEntry * Add(const DBRequest *req)
std::string GetString(const std::string &key) const
const boost::uuids::uuid & GetUuid() const
const VrfEntry * GetVrf() const
NextHopTable * nexthop_table() const
static DBTableBase * CreateTable(DB *db, const std::string &name)
std::unique_ptr< DBRequestData > data
AgentDBEntry * FindActiveEntry(const DBEntry *key)
boost::shared_ptr< const ComponentNHKey > ComponentNHKeyPtr
VxLanConfigSandeshTask(Agent *agent, uint32_t vxlan_id, const string &vn, const string &active, const string &context)
const string & GetName() const
static std::string UuidToString(const boost::uuids::uuid &id)
std::map< ConfigKey, ConfigEntry, ConfigKey > ConfigTree
std::unique_ptr< DBRequestKey > KeyPtr
bool learning_enabled() const
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
bool flood_unknown_unicast() const
uint32_t vxlan_id() const
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
virtual KeyPtr GetDBRequestKey() const
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
void Process(DBRequest &req)
static const uint32_t kInvalidvxlan_id
TaskScheduler * task_scheduler() const
bool mirror_destination() const
virtual bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task...
void Enqueue(Task *task)
Enqueues a task for running. Starts task if all policy rules are met else puts task in waitq...
uint32_t label_op() const
std::string Description() const
std::unique_ptr< DBRequestKey > key
bool vxlan_routing_vn() const
void Create(uint32_t vxlan_id, const std::string &vrf_name, bool flood_unknown_unicast, bool mirror_destination, bool learning_enabled, bool bridge)
VxLanId * Locate(uint32_t vxlan_id, const boost::uuids::uuid &vn, const std::string &vrf, bool flood_unknown_unicast, bool mirror_destination, bool learning_enabled, bool bridge)
std::pair< uint32_t, ComponentNHKeyList > VxlanCompositeNHEntry
#define OPER_TRACE_ENTRY(obj, table,...)
void VmInterfaceNotify(DBTablePartBase *partition, DBEntryBase *e)
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
const VnEntry * vn() const
#define DISALLOW_COPY_AND_ASSIGN(_Class)
static const uint32_t kInvalidLabel
virtual bool Delete(DBEntry *entry, const DBRequest *req)
uint32_t vxlan_id() const
bool AddCompositeNH(uint32_t vxlan_id, ComponentNHKeyPtr nh_key)
VxLanId * Find(uint32_t vxlan_id)
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
void Process(DBRequest &req)
#define AGENT_SANDESH_TASKNAME
~VxLanConfigSandeshTask()
bool ChangeHandler(VxLanId *vxlan_id, const DBRequest *req)
virtual void SetKey(const DBRequestKey *key)
Task is a wrapper over tbb::task to support policies.
const bool mirror_destination() const
VxLanId * FindNoLock(uint32_t vxlan_id)
virtual bool OnChange(DBEntry *entry, const DBRequest *req)