summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2017-11-17 05:08:55 -0800
committerNeale Ranns <nranns@cisco.com>2017-11-17 14:39:53 +0000
commit8ac4ce8547d84c2d581f572b4f51fd34dbf1b01f (patch)
tree98e93c8cd57b551dd229ecaca9d8c2bcf86025dc /src
parentddecfb3d9f5960b69d964f9e870a6ded78a52f1f (diff)
VOM fixes and logger improvements
Change-Id: I5e3fa5e098a8ea26dbc3d3a1dc064e3507e33d8e Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/vom/hw.cpp44
-rw-r--r--src/vpp-api/vom/hw.hpp5
-rw-r--r--src/vpp-api/vom/interface.cpp14
-rw-r--r--src/vpp-api/vom/l3_binding.cpp4
-rw-r--r--src/vpp-api/vom/l3_binding.hpp2
-rw-r--r--src/vpp-api/vom/logger.cpp4
-rw-r--r--src/vpp-api/vom/logger.hpp4
7 files changed, 47 insertions, 30 deletions
diff --git a/src/vpp-api/vom/hw.cpp b/src/vpp-api/vom/hw.cpp
index fee0e869d27..4150d5f481f 100644
--- a/src/vpp-api/vom/hw.cpp
+++ b/src/vpp-api/vom/hw.cpp
@@ -127,9 +127,9 @@ HW::cmd_q::write()
rc_t rc = rc_t::OK;
/*
- * The queue is enabled, Execute each command in the queue.
- * If one execution fails, abort the rest
- */
+ * The queue is enabled, Execute each command in the queue.
+ * If one execution fails, abort the rest
+ */
auto it = m_queue.begin();
while (it != m_queue.end()) {
@@ -139,41 +139,43 @@ HW::cmd_q::write()
if (m_enabled) {
/*
- * before we issue the command we must move it to the pending
- * store
- * ince a async event can be recieved before the command
- * completes
- */
+ * before we issue the command we must move it to the pending
+ * store
+ * ince a async event can be recieved before the command
+ * completes
+ */
m_pending[c.get()] = c;
rc = c->issue(m_conn);
if (rc_t::INPROGRESS == rc) {
/*
- * this command completes asynchronously
- * leave the command in the pending store
- */
+ * this command completes asynchronously
+ * leave the command in the pending store
+ */
} else {
/*
- * the command completed, remove from the pending store
- */
+ * the command completed, remove from the pending store
+ */
m_pending.erase(c.get());
if (rc_t::OK == rc) {
/*
- * move to the next
- */
+ * move to the next
+ */
} else {
/*
- * barf out without issuing the rest
- */
+ * barf out without issuing the rest
+ */
+ VOM_LOG(log_level_t::ERROR) << "Failed to execute: "
+ << c->to_string();
break;
}
}
} else {
/*
- * The HW is disabled, so set each command as succeeded
- */
+ * The HW is disabled, so set each command as succeeded
+ */
c->succeeded();
}
@@ -181,8 +183,8 @@ HW::cmd_q::write()
}
/*
- * erase all objects in the queue
- */
+ * erase all objects in the queue
+ */
m_queue.erase(m_queue.begin(), m_queue.end());
return (rc);
diff --git a/src/vpp-api/vom/hw.hpp b/src/vpp-api/vom/hw.hpp
index eaa7cf09afb..77ae5c36e75 100644
--- a/src/vpp-api/vom/hw.hpp
+++ b/src/vpp-api/vom/hw.hpp
@@ -77,6 +77,11 @@ public:
}
/**
+ * Destructor
+ */
+ ~item() = default;
+
+ /**
* Comparison operator
*/
bool operator==(const item<T>& i) const
diff --git a/src/vpp-api/vom/interface.cpp b/src/vpp-api/vom/interface.cpp
index 1c90a31bb32..8f1023d2273 100644
--- a/src/vpp-api/vom/interface.cpp
+++ b/src/vpp-api/vom/interface.cpp
@@ -54,10 +54,10 @@ interface::interface(const handle_t& handle,
const std::string& name,
interface::type_t type,
interface::admin_state_t state)
- : m_hdl(handle)
+ : m_hdl(handle, rc_t::OK)
, m_name(name)
, m_type(type)
- , m_state(state)
+ , m_state(state, rc_t::OK)
, m_table_id(route::DEFAULT_TABLE)
, m_l2_address(l2_address)
, m_oper(oper_state_t::DOWN)
@@ -278,9 +278,19 @@ interface::update(const interface& desired)
if (rc_t::OK != m_hdl.rc()) {
std::queue<cmd*> cmds;
HW::enqueue(mk_create_cmd(cmds));
+ /*
+ * interface create now, so we can barf early if it fails
+ */
+ HW::write();
}
/*
+ * If the interface is not created do other commands should be issued
+ */
+ if (rc_t::OK != m_hdl.rc())
+ return;
+
+ /*
* change the interface state to that which is deisred
*/
if (m_state.update(desired.m_state)) {
diff --git a/src/vpp-api/vom/l3_binding.cpp b/src/vpp-api/vom/l3_binding.cpp
index 8f90d45eec4..065504cd190 100644
--- a/src/vpp-api/vom/l3_binding.cpp
+++ b/src/vpp-api/vom/l3_binding.cpp
@@ -27,14 +27,14 @@ l3_binding::event_handler l3_binding::m_evh;
l3_binding::l3_binding(const interface& itf, const route::prefix_t& pfx)
: m_itf(itf.singular())
, m_pfx(pfx)
- , m_binding(true)
+ , m_binding(true, rc_t::NOOP)
{
}
l3_binding::l3_binding(const l3_binding& o)
: m_itf(o.m_itf)
, m_pfx(o.m_pfx)
- , m_binding(true)
+ , m_binding(o.m_binding)
{
}
diff --git a/src/vpp-api/vom/l3_binding.hpp b/src/vpp-api/vom/l3_binding.hpp
index 4403760180e..a1470587e94 100644
--- a/src/vpp-api/vom/l3_binding.hpp
+++ b/src/vpp-api/vom/l3_binding.hpp
@@ -167,7 +167,7 @@ private:
/**
* The prefix for this L3 configuration
*/
- const route::prefix_t& m_pfx;
+ const route::prefix_t m_pfx;
/**
* HW configuration for the binding. The bool representing the
diff --git a/src/vpp-api/vom/logger.cpp b/src/vpp-api/vom/logger.cpp
index 1ae55b921cf..07e27499b59 100644
--- a/src/vpp-api/vom/logger.cpp
+++ b/src/vpp-api/vom/logger.cpp
@@ -61,7 +61,7 @@ log_t::set(const std::string& ofile)
}
std::ostream&
-log_t::stream(const char* file, int line)
+log_t::stream(const char* file, int line, const log_level_t& level)
{
auto end = std::chrono::system_clock::now();
auto end_time = std::chrono::system_clock::to_time_t(end);
@@ -77,7 +77,7 @@ log_t::stream(const char* file, int line)
boost::split(dirs, file, boost::is_any_of("/"));
*m_o_stream << std::endl
- << display << "]"
+ << display << " [" << level.to_string() << "]"
<< " " << dirs.back() << ":" << line << ": ";
return (*m_o_stream);
diff --git a/src/vpp-api/vom/logger.hpp b/src/vpp-api/vom/logger.hpp
index 0adc6770e2c..941623e6679 100644
--- a/src/vpp-api/vom/logger.hpp
+++ b/src/vpp-api/vom/logger.hpp
@@ -52,7 +52,7 @@ public:
/**
* Return the stream
*/
- std::ostream& stream(const char* file, int line);
+ std::ostream& stream(const char* file, int line, const log_level_t& level);
/**
* The configured level
@@ -93,7 +93,7 @@ log_t& logger();
#define VOM_LOG(lvl) \
if (lvl >= logger().level()) \
- logger().stream(__FILE__, __LINE__)
+ logger().stream(__FILE__, __LINE__, lvl)
};
/*