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()) {
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();
}
}
/*
- * erase all objects in the queue
- */
+ * erase all objects in the queue
+ */
m_queue.erase(m_queue.begin(), m_queue.end());
return (rc);
{
}
+ /**
+ * Destructor
+ */
+ ~item() = default;
+
/**
* Comparison operator
*/
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)
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
*/
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)
{
}
/**
* 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
}
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);
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);
/**
* 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
#define VOM_LOG(lvl) \
if (lvl >= logger().level()) \
- logger().stream(__FILE__, __LINE__)
+ logger().stream(__FILE__, __LINE__, lvl)
};
/*