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") {
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.");
458 vr_limit_itr->second.assign(std::string(
"Normal"));
460 }
else if ( vr_limit_itr->second ==
"TableLimit" ) {
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);
virtual bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
const Interface * GetInterface() const
MplsLabel(Agent *agent, uint32_t label)
MplsTable(DB *db, const std::string &name)
std::string vrf_name() const
void Process(DBClient *client, DBRequest *req)
void EnqueueRouteResync() const
bool IsFabricMulticastLabel(uint32_t label) const
uint32_t GetRefCount() const
virtual void SetKey(const DBRequestKey *key)
void Delete(const DBRequest *req)
virtual bool OnChange(DBEntry *entry, const DBRequest *req)
std::string GetString(const std::string &key) const
const boost::uuids::uuid & GetUuid() const
bool ChangeNH(NextHop *nh)
NextHopTable * nexthop_table() const
DBTableBase * get_table() const
bool ChangeInternal(const DBRequest *req)
SandeshTraceBufferPtr MplsTraceBuf
void Add(const DBRequest *req)
const NextHop * nexthop() const
std::map< std::string, std::string > VrLimitExceeded
std::unique_ptr< DBRequestData > data
boost::shared_ptr< ResourceKey > KeyPtr
AgentDBEntry * FindActiveEntry(const DBEntry *key)
void ReserveLabel(uint32_t start, uint32_t end)
const string & GetName() const
static std::string UuidToString(const boost::uuids::uuid &id)
float vr_limit_high_watermark()
void ReleaseIndex(Resource::Type, uint32_t index)
uint16_t GetVlanTag() const
void FreeReserveLabel(uint32_t start, uint32_t end)
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
MplsTable * mpls_table() const
std::unique_ptr< DBRequestKey > KeyPtr
void SetNHSandeshData(NhSandeshData &data) const
Base class for all Route entries in agent.
const VrfEntry * vrf() const
void ReserveIndex(Resource::Type, uint32_t index)
float vr_limit_low_watermark()
IndexVector< MplsLabel * > label_table_
static DBTableBase * CreateTable(DB *db, const std::string &name)
NextHop::Type GetType() const
void FreeMplsLabelIndex(size_t label)
void ReserveMulticastLabel(uint32_t start, uint32_t end, uint8_t idx)
virtual bool IsLess(const DBEntry &rhs) const
MplsLabel * AllocLabel(const NextHopKey *nh_key)
std::unique_ptr< DBRequestKey > key
uint32_t multicast_label_end_[MAX_XMPP_SERVERS]
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
virtual KeyPtr GetDBRequestKey() const
virtual DBEntry * Add(const DBRequest *req)
#define OPER_TRACE_ENTRY(obj, table,...)
virtual void Process(DBRequest &req)
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
uint32_t vrouter_max_labels() const
AgentDBEntry * Find(const DBEntry *key, bool ret_del)
void SendObjectLog(const AgentDBTable *table, AgentLogEvent::type event) const
virtual uint32_t GetRefCount() const
virtual KeyPtr GetDBRequestKey() const =0
FmgVrfNhMap & fmg_nh_list()
static const uint32_t kInvalidLabel
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
uint32_t CreateRouteLabel(uint32_t label, const NextHopKey *nh_key, const std::string &vrf_name, const std::string &route)
void set_vr_limits_exceeded_map(VrLimitExceeded &vr_limit_exceed_map)
#define MPLS_TRACE(obj,...)
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
uint32_t multicast_label_start_[MAX_XMPP_SERVERS]
VrLimitExceeded & get_vr_limits_exceeded_map()
bool Change(const DBRequest *req)
bool IsFabricMulticastReservedLabel() const
#define LOG(_Level, _Msg)
MplsLabel * FindMplsLabel(uint32_t label)
const std::string & name() const
void set_vrf_name(const std::string &vrf_name)
bool PolicyEnabled() const
virtual bool Delete(DBEntry *entry, const DBRequest *req)
void Notify(DBEntryBase *entry)
const Interface * GetInterface() const
virtual void OnZeroRefcount(AgentDBEntry *e)
virtual std::string ToString() const
virtual NextHopKey * Clone() const =0
ResourceManager * resource_manager() const
void FreeLabel(uint32_t label)
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
size_t InsertAtIndex(uint32_t index, EntryType entry)
const NextHopKey * nh_key() const