Skip to content

Commit

Permalink
Trigger pending chain resolution on routing instance change (and add)
Browse files Browse the repository at this point in the history
Recent change to treat a service chain as pending if the dest routing
instance doesn't have a VN index causes problems if the instance does
not have an index when it's created.

Also fix issue in service_chain_test that causes occasional failures.
Check if DBEnry returned by DBTable::Find is NULL before dynamic_cast.

Change-Id: I971443345699a7909e5247967916ddff0818f78a
Related-bug: 1500698
  • Loading branch information
Nischal Sheth committed Feb 8, 2016
1 parent f0e9050 commit 3ccd103
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/bgp/routing-instance/service_chaining.cc
Expand Up @@ -1096,7 +1096,8 @@ bool ServiceChainMgr<T>::ResolvePendingServiceChain() {

template <typename T>
void ServiceChainMgr<T>::RoutingInstanceCallback(string name, int op) {
if (op == RoutingInstanceMgr::INSTANCE_ADD) StartResolve();
if (op != RoutingInstanceMgr::INSTANCE_DELETE)
StartResolve();
}

template <typename T>
Expand Down
19 changes: 9 additions & 10 deletions src/bgp/test/service_chain_test.cc
Expand Up @@ -600,8 +600,7 @@ class ServiceChainTest : public ::testing::Test {
return table->Size();
}

BgpRoute *RouteLookup(const string &instance_name,
const string &prefix) {
BgpRoute *RouteLookup(const string &instance_name, const string &prefix) {
BgpTable *bgp_table = GetTable(instance_name);
TableT *table = dynamic_cast<TableT *>(bgp_table);
EXPECT_TRUE(table != NULL);
Expand All @@ -612,12 +611,14 @@ class ServiceChainTest : public ::testing::Test {
PrefixT nlri = PrefixT::FromString(prefix, &error);
EXPECT_FALSE(error);
typename TableT::RequestKey key(nlri, NULL);
BgpRoute *rt = dynamic_cast<BgpRoute *>(table->Find(&key));
return rt;
DBEntry *db_entry = table->Find(&key);
if (db_entry == NULL) {
return NULL;
}
return dynamic_cast<BgpRoute *>(db_entry);
}

BgpRoute *VerifyRouteExists(const string &instance,
const string &prefix) {
BgpRoute *VerifyRouteExists(const string &instance, const string &prefix) {
TASK_UTIL_EXPECT_TRUE(RouteLookup(instance, prefix) != NULL);
BgpRoute *rt = RouteLookup(instance, prefix);
if (rt == NULL) {
Expand All @@ -627,13 +628,11 @@ class ServiceChainTest : public ::testing::Test {
return rt;
}

void VerifyRouteNoExists(const string &instance,
const string &prefix) {
void VerifyRouteNoExists(const string &instance, const string &prefix) {
TASK_UTIL_EXPECT_TRUE(RouteLookup(instance, prefix) == NULL);
}

void VerifyRouteIsDeleted(const string &instance,
const string &prefix) {
void VerifyRouteIsDeleted(const string &instance, const string &prefix) {
TASK_UTIL_EXPECT_TRUE(RouteLookup(instance, prefix) != NULL);
BgpRoute *rt = RouteLookup(instance, prefix);
TASK_UTIL_EXPECT_TRUE(rt->IsDeleted());
Expand Down

0 comments on commit 3ccd103

Please sign in to comment.