VOM: route-domain find() fix 83/10383/2
authorNeale Ranns <neale.ranns@cisco.com>
Thu, 25 Jan 2018 15:28:19 +0000 (07:28 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 2 Feb 2018 16:08:01 +0000 (16:08 +0000)
Change-Id: I5b7117f3568e3ba979baa15521b2cfc180abb682
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
src/vpp-api/vom/route.cpp
src/vpp-api/vom/route_domain.cpp
src/vpp-api/vom/route_domain.hpp

index 3b86fb2..780881e 100644 (file)
@@ -403,7 +403,7 @@ ip_route::event_handler::handle_populate(const client_db::key_t& key)
      * populating the route domain here
      */
     route_domain rd_temp(payload.table_id);
-    std::shared_ptr<route_domain> rd = route_domain::find(rd_temp);
+    std::shared_ptr<route_domain> rd = route_domain::find(payload.table_id);
     if (!rd) {
       OM::commit(key, rd_temp);
     }
@@ -450,7 +450,7 @@ ip_route::event_handler::handle_populate(const client_db::key_t& key)
 
     prefix_t pfx(1, payload.address, payload.address_length);
     route_domain rd_temp(payload.table_id);
-    std::shared_ptr<route_domain> rd = route_domain::find(rd_temp);
+    std::shared_ptr<route_domain> rd = route_domain::find(payload.table_id);
     if (!rd) {
       OM::commit(key, rd_temp);
     }
index e8c1e59..626a9cd 100644 (file)
@@ -108,28 +108,9 @@ route_domain::to_string() const
 }
 
 std::shared_ptr<route_domain>
-route_domain::find(const route_domain& temp)
+route_domain::find(const key_t& k)
 {
-  std::shared_ptr<route_domain> rd;
-
-  auto it = m_db.cbegin();
-
-  while (it != m_db.cend()) {
-    /*
- * The key in the DB is a pair of the interface's name and prefix.
- * If the keys match, save the L3-config
- */
-    auto key = it->first;
-
-    if (temp.table_id() == key) {
-      rd = it->second.lock();
-      break;
-    }
-
-    ++it;
-  }
-
-  return (rd);
+  return (m_db.find(k));
 }
 
 void
index 7d83154..19a3c18 100644 (file)
@@ -81,7 +81,7 @@ public:
   /**
    * Find the instnace of the route domain in the OM
    */
-  static std::shared_ptr<route_domain> find(const route_domain& temp);
+  static std::shared_ptr<route_domain> find(const key_t& temp);
 
   /**
    * Dump all route-doamin into the stream provided