17 #include "vr_bridge.h"
23 MacLearningEntry(vrf_id),mac_learning_table_(table), key_(vrf_id, mac), index_(index) {
67 if (
vrf()->IsActive() ==
false) {
71 if (vm_intf->
vn() == NULL) {
75 if (vm_intf->
vn() == NULL) {
90 vm_intf->
vn()->
GetName(), sg_list, tag_list,
118 uint32_t isid =
vrf_->isid();
119 std::string bmac_vrf_name =
vrf_->bmac_vrf_name();
132 partition_(partition), pool_(pool),
155 agent_(agent), id_(id),
156 add_request_queue_(this, proto->add_tokens()),
157 change_request_queue_(this, proto->change_tokens()),
158 delete_request_queue_(this, proto->delete_tokens()) {
177 switch(ptr->event()) {
183 Add(ptr->mac_learning_entry());
187 Resync(ptr->mac_learning_entry());
191 Delete(ptr->mac_learning_entry());
196 mac_learning_db_client()->FreeDBState(ptr->db_entry(),
222 std::pair<MacLearningEntryTable::iterator, bool> it =
224 if (it.second ==
false) {
227 ptr->CopyToken(it.first->second.get());
228 if (it.first->second->deleted() ==
false) {
244 if (ptr->deleted() ==
true) {
278 switch(req->event()) {
306 return it->second.get();
327 std::string resp_ctx,
331 GetTaskId(
"Agent::MacLearningSandeshTask")), 0),
332 agent_(agent), resp_(resp), resp_data_(resp_ctx), partition_id_(0),
333 vrf_id_(0), mac_(
MacAddress::ZeroMac()), exact_match_(false),
334 user_given_mac_(mac) {
345 size_t n = std::count(key.begin(), key.end(), ch);
350 std::stringstream ss(key);
353 if (getline(ss, item, ch)) {
356 if (getline(ss, item, ch)) {
357 std::istringstream(item) >>
vrf_id_;
359 if (getline(ss, item, ch)) {
362 if (getline(ss, item, ch)) {
370 std::stringstream ss;
391 std::vector<SandeshMacEntry>& list =
392 const_cast<std::vector<SandeshMacEntry>&
>(
resp_->get_mac_entry_list());
393 uint32_t entries_count = 0;
402 MacLearningPartition::MacLearningEntryTable::const_iterator it;
425 aging_entry = at->
Find(it->second.get());
428 SandeshMacEntry data;
431 list.push_back(data);
438 mac_ = it->first.mac_;
469 if (partition_id_ < agent_->params()->mac_learning_thread_count()) {
483 void FetchMacEntry::HandleRequest()
const {
486 std::ostringstream str;
490 bool exact_match =
false;
491 if (get_vrf_id() != 0 || get_mac() != agent->
NullString()) {
498 MacEntryResp *resp =
new MacEntryResp();
503 scheduler->Enqueue(task);
506 void NextMacEntrySet::HandleRequest()
const {
509 MacEntryResp *resp =
new MacEntryResp();
virtual ~MacLearningPartition()
void Enqueue(MacLearningMgmtRequestPtr &ptr)
static const MacAddress & ZeroMac()
void Add(MacLearningEntryPtr ptr)
MacLearningEntryRemote(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index, const IpAddress remote_ip)
void AddToken(TokenPtr ptr)
const MacAddress & mac() const
static Agent * GetInstance()
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
MacAgingPartition * aging_partition() const
boost::shared_ptr< MacLearningMgmtRequest > MacLearningMgmtRequestPtr
MacLearningRequestQueue change_request_queue_
virtual ~MacLearningSandeshResp()
MacLearningPartition * partition_
boost::asio::ip::address IpAddress
MacLearningProto * mac_learning_proto() const
MacAddress user_given_mac_
virtual bool TokenCheck()
const Peer * mac_learning_peer() const
MacLearningRequestQueue delete_request_queue_
std::vector< int > SecurityGroupList
void EnqueueMgmtReq(MacLearningEntryPtr ptr, bool add)
boost::shared_ptr< MacAgingPartition > aging_partition_
MacLearningModule * mac_learning_module() const
MacAgingTable * Find(uint32_t id)
const string & GetName() const
virtual void AddWithToken()
MacLearningRequestQueue(MacLearningPartition *partition, TokenPool *pool)
bool RequestHandler(MacLearningEntryRequestPtr ptr)
std::string ToString() const
const MacAgingEntry * Find(MacLearningEntry *me) const
const MacLearningPartition * GetPartition()
MacLearningSandeshResp(Agent *agent, MacEntryResp *resp, std::string resp_ctx, std::string key, const MacAddress &mac)
MacLearningPartition * mac_learning_table_
void MayBeStartRunner(TokenPool *pool)
virtual bool HandleEvent(MacLearningEntryRequestPtr ptr)
static TaskScheduler * GetInstance()
void Enqueue(Task *task)
Enqueues a task for running. Starts task if all policy rules are met else puts task in waitq...
MacLearningEntryPBB(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index, const MacAddress &bmac)
bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task...
bool SetMacKey(string key)
static const std::string & NullString()
std::pair< MacLearningKey, MacLearningEntryPtr > MacLearningEntryPair
boost::intrusive_ptr< const Interface > InterfaceConstRef
boost::shared_ptr< MacLearningEntryRequest > MacLearningEntryRequestPtr
const VnEntry * vn() const
AgentParam * params() const
std::set< std::string > VnListType
void ReleaseToken(const MacLearningKey &key)
static const char kDelimiter
boost::asio::ip::address_v4 Ip4Address
MacLearningPartition(Agent *agent, MacLearningProto *proto, uint32_t id)
VrfTable * vrf_table() const
void Enqueue(MacLearningEntryRequestPtr ptr)
MacPbbLearningEntry(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index)
virtual void ReleaseToken()
MacLearningEntryLocal(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index, InterfaceConstRef intf)
void set_context(std::string context)
void Delete(MacLearningEntryPtr ptr)
void EnqueueToTable(MacLearningEntryRequestPtr req)
uint32_t l2_label() const
void SendResponse(SandeshResponse *resp)
void FillSandesh(SandeshMacEntry *sme) const
void Resync(MacLearningEntryPtr ptr)
uint32_t mac_learning_thread_count() const
const string & GetName() const
void SetStartRunnerFunc(StartRunnerFunc start_runner_fn)
static const uint32_t kMaxResponse
MacLearningEntryTable mac_learning_table_
EvpnAgentRouteTable * fabric_evpn_table() const
MacLearningRequestQueue add_request_queue_
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
TokenPool * change_tokens()
bool ProcessProto(boost::shared_ptr< PktInfo > msg_info)
Task is a wrapper over tbb::task to support policies.
void CopySgIdList(SecurityGroupList *sg_id_list) const
void Enqueue(MacLearningEntryRequestPtr req)
MacLearningMgmtManager * mac_learning_mgmt() const
virtual void set_more(const bool val)=0
MacLearningEntry * Find(const MacLearningKey &key)
boost::shared_ptr< MacLearningEntry > MacLearningEntryPtr
std::vector< int > TagList
MacLearningEntryPtr TestGet(const MacLearningKey &key)
void CopyTagIdList(TagList *tag_id_list) const
static void AddRemoteVmRouteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)