summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/acl_list.hpp
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2018-02-26 18:36:17 +0100
committerNeale Ranns <nranns@cisco.com>2018-03-06 14:47:28 +0000
commitb5eb3b185fb04bfed3ba6c89323cd82e7d666bae (patch)
treeeadb31b9933e574b601b35329720302ffe4a1ea5 /src/vpp-api/vom/acl_list.hpp
parent3f6ede3ab3df9624ba3682d5bc82c4f2aa2e0506 (diff)
VOM: Fix state reconciliation
This commit also fixes the acl and arp handle for inspector to view internal state of VOM. Change-Id: Ibc8ff6cb51d2a77b4c04993ac7212564b8892337 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vpp-api/vom/acl_list.hpp')
-rw-r--r--src/vpp-api/vom/acl_list.hpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/vpp-api/vom/acl_list.hpp b/src/vpp-api/vom/acl_list.hpp
index ff3eeeb21b2..bd84ce1ea43 100644
--- a/src/vpp-api/vom/acl_list.hpp
+++ b/src/vpp-api/vom/acl_list.hpp
@@ -53,7 +53,8 @@ public:
* Construct a new object matching the desried state
*/
list(const key_t& key)
- : m_key(key)
+ : m_hdl(handle_t::INVALID)
+ , m_key(key)
{
}
@@ -64,10 +65,10 @@ public:
}
list(const key_t& key, const rules_t& rules)
- : m_key(key)
+ : m_hdl(handle_t::INVALID)
+ , m_key(key)
, m_rules(rules)
{
- m_evh.order();
}
/**
@@ -129,7 +130,7 @@ public:
/**
* Return the VPP assign handle
*/
- const handle_t& handle() const { return m_hdl.data(); }
+ const handle_t& handle() const { return (singular()->handle_i()); }
static std::shared_ptr<list> find(const handle_t& handle)
{
@@ -141,12 +142,19 @@ public:
return (m_db.find(key));
}
- static void add(const handle_t& handle, std::shared_ptr<list> sp)
+ static void add(const key_t& key, const HW::item<handle_t>& item)
{
- m_hdl_db[handle] = sp;
+ std::shared_ptr<list> sp = find(key);
+
+ if (sp && item) {
+ m_hdl_db[item.data()] = sp;
+ }
}
- static void remove(const handle_t& handle) { m_hdl_db.erase(handle); }
+ static void remove(const HW::item<handle_t>& item)
+ {
+ m_hdl_db.erase(item.data());
+ }
const key_t& key() const { return m_key; }
@@ -167,11 +175,8 @@ private:
class event_handler : public OM::listener, public inspect::command_handler
{
public:
- event_handler()
- {
- OM::register_listener(this);
- inspect::register_handler({ "acl" }, "ACL lists", this);
- }
+ event_handler();
+
virtual ~event_handler() = default;
/**
@@ -215,9 +220,14 @@ private:
*/
static std::shared_ptr<list> find_or_add(const list& temp)
{
- return (m_db.find_or_add(temp.m_key, temp));
+ return (m_db.find_or_add(temp.key(), temp));
}
+ /**
+ * return the acl-list's handle in the singular instance
+ */
+ const handle_t& handle_i() const { return (m_hdl.data()); }
+
/*
* It's the VOM::OM class that updates call update
*/
@@ -246,7 +256,7 @@ private:
/**
* A map of all ACLs keyed against VPP's handle
*/
- static std::map<const handle_t, std::weak_ptr<list>> m_hdl_db;
+ static std::map<handle_t, std::weak_ptr<list>> m_hdl_db;
/**
* The Key is a user defined identifer for this ACL
@@ -279,7 +289,7 @@ singular_db<typename ACL::list<RULE>::key_t, ACL::list<RULE>> list<RULE>::m_db;
* Definition of the static per-handle DB for ACL Lists
*/
template <typename RULE>
-std::map<const handle_t, std::weak_ptr<ACL::list<RULE>>> list<RULE>::m_hdl_db;
+std::map<handle_t, std::weak_ptr<ACL::list<RULE>>> list<RULE>::m_hdl_db;
template <typename RULE>
typename ACL::list<RULE>::event_handler list<RULE>::m_evh;