From 629349ba4ac335bf1bef35184051ee051da21fa7 Mon Sep 17 00:00:00 2001 From: Manish Date: Tue, 3 May 2016 16:42:37 +0530 Subject: [PATCH] Validation checks and diagnostics. For following: - If MPLS label is changing NH, then make sure non MCAST label does not point to Composite NH of type L2 Comp. - Temporarily store peer name in path. Change-Id: I456ef6875e34f074a105f67e8e2866993e0ea30d Partial-bug: #1548265 --- src/vnsw/agent/oper/agent_path.cc | 2 +- src/vnsw/agent/oper/agent_path.h | 1 + src/vnsw/agent/oper/mpls.cc | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vnsw/agent/oper/agent_path.cc b/src/vnsw/agent/oper/agent_path.cc index 2c06f4edd65..307d2cd7245 100644 --- a/src/vnsw/agent/oper/agent_path.cc +++ b/src/vnsw/agent/oper/agent_path.cc @@ -39,7 +39,7 @@ AgentPath::AgentPath(const Peer *peer, AgentRoute *rt): is_subnet_discard_(false), dependant_rt_(rt), path_preference_(), local_ecmp_mpls_label_(rt), composite_nh_key_(NULL), subnet_service_ip_(), arp_mac_(), arp_interface_(NULL), arp_valid_(false), - ecmp_suppressed_(false) { + ecmp_suppressed_(false), peer_str_(peer ? peer->GetName() : "UNKNOWN") { } AgentPath::~AgentPath() { diff --git a/src/vnsw/agent/oper/agent_path.h b/src/vnsw/agent/oper/agent_path.h index 07000a1ce4f..947d86ba085 100644 --- a/src/vnsw/agent/oper/agent_path.h +++ b/src/vnsw/agent/oper/agent_path.h @@ -344,6 +344,7 @@ class AgentPath : public Path { // by taking only one of the nexthop from the path bool ecmp_suppressed_; EcmpLoadBalance ecmp_load_balance_; + std::string peer_str_; DISALLOW_COPY_AND_ASSIGN(AgentPath); }; diff --git a/src/vnsw/agent/oper/mpls.cc b/src/vnsw/agent/oper/mpls.cc index bcd03030d62..de86e7695a5 100644 --- a/src/vnsw/agent/oper/mpls.cc +++ b/src/vnsw/agent/oper/mpls.cc @@ -65,11 +65,20 @@ bool MplsTable::OnChange(DBEntry *entry, const DBRequest *req) { return ret; } +void ValidateNH(const MplsLabel *mpls, NextHop *nh) { + CompositeNH *cnh = dynamic_cast(nh); + if (!cnh) + return; + if (cnh->composite_nh_type() == Composite::L2COMP) + assert(mpls->GetType() == MplsLabel::MCAST_NH); +} + bool MplsTable::ChangeNH(MplsLabel *mpls, NextHop *nh) { if (mpls == NULL) return false; if (mpls->nh_ != nh) { + ValidateNH(mpls, nh); mpls->nh_ = nh; assert(nh); mpls->SyncDependentPath();