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();
506 void NextMacEntrySet::HandleRequest()
const {
509 MacEntryResp *resp =
new MacEntryResp();
boost::asio::ip::address IpAddress
boost::asio::ip::address_v4 Ip4Address
boost::intrusive_ptr< const Interface > InterfaceConstRef
std::vector< int > TagList
std::vector< int > SecurityGroupList
std::set< std::string > VnListType
uint32_t mac_learning_thread_count() const
MacLearningModule * mac_learning_module() const
AgentParam * params() const
MacLearningProto * mac_learning_proto() const
VrfTable * vrf_table() const
const Peer * mac_learning_peer() const
static const std::string & NullString()
EvpnAgentRouteTable * fabric_evpn_table() const
static Agent * GetInstance()
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)
uint32_t l2_label() const
std::string ToString() const
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
static const MacAddress & ZeroMac()
void FillSandesh(SandeshMacEntry *sme) const
MacAgingTable * Find(uint32_t id)
const MacAgingEntry * Find(MacLearningEntry *me) const
MacLearningEntryLocal(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index, InterfaceConstRef intf)
MacLearningEntryPBB(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index, const MacAddress &bmac)
MacLearningEntryRemote(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index, const IpAddress remote_ip)
virtual void ReleaseToken()
void Enqueue(MacLearningMgmtRequestPtr &ptr)
MacLearningMgmtManager * mac_learning_mgmt() const
void Resync(MacLearningEntryPtr ptr)
MacLearningEntry * Find(const MacLearningKey &key)
virtual ~MacLearningPartition()
void ReleaseToken(const MacLearningKey &key)
MacLearningEntryPtr TestGet(const MacLearningKey &key)
MacLearningRequestQueue add_request_queue_
MacAgingPartition * aging_partition() const
void EnqueueMgmtReq(MacLearningEntryPtr ptr, bool add)
std::pair< MacLearningKey, MacLearningEntryPtr > MacLearningEntryPair
void Add(MacLearningEntryPtr ptr)
MacLearningPartition(Agent *agent, MacLearningProto *proto, uint32_t id)
MacLearningRequestQueue change_request_queue_
void Delete(MacLearningEntryPtr ptr)
MacLearningEntryTable mac_learning_table_
void Enqueue(MacLearningEntryRequestPtr req)
void MayBeStartRunner(TokenPool *pool)
boost::shared_ptr< MacAgingPartition > aging_partition_
MacLearningRequestQueue delete_request_queue_
bool RequestHandler(MacLearningEntryRequestPtr ptr)
TokenPool * change_tokens()
MacLearningRequestQueue(MacLearningPartition *partition, TokenPool *pool)
MacLearningPartition * partition_
void Enqueue(MacLearningEntryRequestPtr ptr)
virtual bool HandleEvent(MacLearningEntryRequestPtr ptr)
virtual bool TokenCheck()
static const uint32_t kMaxResponse
static const char kDelimiter
void SendResponse(SandeshResponse *resp)
bool SetMacKey(string key)
MacLearningSandeshResp(Agent *agent, MacEntryResp *resp, std::string resp_ctx, std::string key, const MacAddress &mac)
MacAddress user_given_mac_
bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task.
const MacLearningPartition * GetPartition()
virtual ~MacLearningSandeshResp()
MacLearningPartition * mac_learning_table_
void EnqueueToTable(MacLearningEntryRequestPtr req)
MacPbbLearningEntry(MacLearningPartition *table, uint32_t vrf_id, const MacAddress &mac, uint32_t index)
void AddToken(TokenPtr ptr)
const MacAddress & mac() const
virtual void AddWithToken()
bool ProcessProto(boost::shared_ptr< PktInfo > msg_info)
virtual void set_more(const bool val)=0
void set_context(std::string context)
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()
Task is a wrapper over tbb::task to support policies.
void CopyTagIdList(TagList *tag_id_list) const
const VnEntry * vn() const
void CopySgIdList(SecurityGroupList *sg_id_list) const
const string & GetName() const
void SetStartRunnerFunc(StartRunnerFunc start_runner_fn)
boost::shared_ptr< MacLearningEntry > MacLearningEntryPtr
boost::shared_ptr< MacLearningEntryRequest > MacLearningEntryRequestPtr
boost::shared_ptr< MacLearningMgmtRequest > MacLearningMgmtRequestPtr