5 #include <boost/uuid/uuid_io.hpp>
27 agent_(agent), label_(label), free_label_(false) {
106 if (cnh && cnh->
vrf()) {
110 FmgVrfNhMap::iterator temp_it;
129 mpls_label_.begin(); iter != mpls_label_.end(); iter++) {
145 MplsResp *resp =
static_cast<MplsResp *
>(sresp);
147 MplsSandeshData data;
150 std::vector<MplsSandeshData> &list =
151 const_cast<std::vector<MplsSandeshData>&
>(resp->get_mpls_list());
152 list.push_back(data);
159 MplsObjectLogInfo info;
160 string str, type_str, nh_type;
161 info.set_type(type_str);
162 info.set_label((
int)
label_);
164 case AgentLogEvent::ADD:
165 str.assign(
"Addition ");
167 case AgentLogEvent::DEL:
168 str.assign(
"Deletion ");
172 case AgentLogEvent::CHANGE:
173 str.assign(
"Modification ");
176 str.assign(
"Unknown");
185 string policy_str(
"Disabled");
191 nh_type.assign(
"INTERFACE");
195 policy_str.assign(
"Enabled");
197 info.set_policy(policy_str);
200 nh_type.assign(
"VLAN");
201 vlan_nh =
static_cast<const VlanNH *
>(nh);
206 nh_type.assign(
"Composite");
209 nh_type.assign(
"unknown");
213 info.set_nh_type(nh_type);
217 switch(intf->
type()) {
219 if_type_str.assign(
"VM_INTERFACE");
222 if_type_str.assign(
"Invalid");
225 info.set_intf_type(if_type_str);
227 info.set_intf_name(intf->
name());
261 Allocate(key).get()))->index());
279 req.
data.reset(data);
287 return std::unique_ptr<DBEntry>(
static_cast<DBEntry *
>(mpls));
337 req.
data.reset(NULL);
342 const std::string &vrf_name,
343 const std::string &route) {
346 resource_manager(), vrf_name,
349 Allocate(key).get()))->index());
362 req.
data.reset(data);
379 for (uint32_t i = start; i <= end; i++) {
387 for (uint32_t i = start; i <= end; i++) {
417 agent()->resource_manager(),
420 Allocate(rkey).get()))->index());
431 req.
data.reset(data);
445 VrLimitExceeded::iterator vr_limit_itr = vr_limits.find(
"vr_mpls_labels");
446 if (vr_limit_itr->second ==
"Normal") {
448 agent()->vrouter_max_labels())/100) ) {
449 vr_limit_itr->second.assign(std::string(
"Exceeded"));
450 LOG(ERROR,
"Vrouter Mpls Labels Exceeded.");
452 }
else if ( vr_limit_itr->second ==
"Exceeded") {
454 vr_limit_itr->second.assign(std::string(
"TableLimit"));
455 LOG(ERROR,
"Vrouter Mpls Lablels Table Limit Reached. Skip Label Add.");
457 agent()->vrouter_max_labels())/100) ) {
458 vr_limit_itr->second.assign(std::string(
"Normal"));
460 }
else if ( vr_limit_itr->second ==
"TableLimit" ) {
462 ((
agent()->vrouter_max_labels()*95)/100) ) {
463 vr_limit_itr->second.assign(std::string(
"Exceeded"));
464 LOG(ERROR,
"Vrouter Mpls Labels Exceeded.");
471 const std::string &context) {
477 void MplsReq::HandleRequest()
const {
480 sand->DoSandesh(sand);
std::map< std::string, std::string > VrLimitExceeded
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
#define OPER_TRACE_ENTRY(obj, table,...)
AgentDBEntry * FindActiveEntry(const DBEntry *key)
AgentDBEntry * Find(const DBEntry *key, bool ret_del)
uint32_t GetRefCount() const
Base class for all Route entries in agent.
void EnqueueRouteResync() const
std::string GetString(const std::string &key) const
ResourceManager * resource_manager() const
void set_vr_limits_exceeded_map(VrLimitExceeded &vr_limit_exceed_map)
VrLimitExceeded & get_vr_limits_exceeded_map()
NextHopTable * nexthop_table() const
MplsTable * mpls_table() const
const VrfEntry * vrf() const
std::unique_ptr< DBRequestKey > KeyPtr
DBTableBase * get_table() const
virtual KeyPtr GetDBRequestKey() const =0
const std::string & name() const
void Notify(DBEntryBase *entry)
void Process(DBClient *client, DBRequest *req)
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
size_t InsertAtIndex(uint32_t index, EntryType entry)
const Interface * GetInterface() const
const std::string & name() const
const boost::uuids::uuid & GetUuid() const
const NextHopKey * nh_key() const
void set_vrf_name(const std::string &vrf_name)
std::string vrf_name() const
void SendObjectLog(const AgentDBTable *table, AgentLogEvent::type event) const
void Add(const DBRequest *req)
virtual void SetKey(const DBRequestKey *key)
virtual bool IsLess(const DBEntry &rhs) const
virtual KeyPtr GetDBRequestKey() const
MplsLabel(Agent *agent, uint32_t label)
bool ChangeNH(NextHop *nh)
virtual std::string ToString() const
const NextHop * nexthop() const
bool Change(const DBRequest *req)
FmgVrfNhMap & fmg_nh_list()
void Delete(const DBRequest *req)
virtual uint32_t GetRefCount() const
bool ChangeInternal(const DBRequest *req)
bool IsFabricMulticastReservedLabel() const
virtual bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
void FreeLabel(uint32_t label)
void ReserveLabel(uint32_t start, uint32_t end)
virtual void Process(DBRequest &req)
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
void FreeMplsLabelIndex(size_t label)
static const uint32_t kInvalidLabel
MplsLabel * AllocLabel(const NextHopKey *nh_key)
uint32_t CreateRouteLabel(uint32_t label, const NextHopKey *nh_key, const std::string &vrf_name, const std::string &route)
void FreeReserveLabel(uint32_t start, uint32_t end)
static DBTableBase * CreateTable(DB *db, const std::string &name)
bool IsFabricMulticastLabel(uint32_t label) const
uint32_t multicast_label_start_[MAX_XMPP_SERVERS]
MplsLabel * FindMplsLabel(uint32_t label)
virtual bool Delete(DBEntry *entry, const DBRequest *req)
MplsTable(DB *db, const std::string &name)
virtual void OnZeroRefcount(AgentDBEntry *e)
virtual DBEntry * Add(const DBRequest *req)
uint32_t multicast_label_end_[MAX_XMPP_SERVERS]
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
void ReserveMulticastLabel(uint32_t start, uint32_t end, uint8_t idx)
virtual bool OnChange(DBEntry *entry, const DBRequest *req)
IndexVector< MplsLabel * > label_table_
NextHop::Type GetType() const
virtual NextHopKey * Clone() const =0
bool PolicyEnabled() const
void SetNHSandeshData(NhSandeshData &data) const
void ReleaseIndex(Resource::Type, uint32_t index)
void ReserveIndex(Resource::Type, uint32_t index)
boost::shared_ptr< ResourceKey > KeyPtr
const Interface * GetInterface() const
uint16_t GetVlanTag() const
const string & GetName() const
#define LOG(_Level, _Msg)
SandeshTraceBufferPtr MplsTraceBuf(SandeshTraceBufferCreate("MplsTrace", 1000))
#define MPLS_TRACE(obj,...)
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
static std::string UuidToString(const boost::uuids::uuid &id)
std::unique_ptr< DBRequestKey > key
std::unique_ptr< DBRequestData > data