#include "sflow_api.h"
#include "socket-util.h"
#include "timeval.h"
-
-#define THIS_MODULE VLM_sflow
#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(sflow)
+
struct ofproto_sflow_port {
struct netdev *netdev; /* Underlying network device, for stats. */
SFLDataSource_instance dsi; /* sFlow library's notion of port number. */
void
ofproto_sflow_clear(struct ofproto_sflow *os)
{
- struct ofproto_sflow_port *osp;
- unsigned int odp_port;
-
if (os->sflow_agent) {
sfl_agent_release(os->sflow_agent);
os->sflow_agent = NULL;
ofproto_sflow_options_destroy(os->options);
os->options = NULL;
- PORT_ARRAY_FOR_EACH (osp, &os->ports, odp_port) {
- ofproto_sflow_del_port(os, odp_port);
- }
- port_array_clear(&os->ports);
-
/* Turn off sampling to save CPU cycles. */
dpif_set_sflow_probability(os->dpif, 0);
}
ofproto_sflow_destroy(struct ofproto_sflow *os)
{
if (os) {
+ struct ofproto_sflow_port *osp;
+ unsigned int odp_port;
+
ofproto_sflow_clear(os);
+ PORT_ARRAY_FOR_EACH (osp, &os->ports, odp_port) {
+ ofproto_sflow_del_port(os, odp_port);
+ }
port_array_destroy(&os->ports);
free(os);
}
}
netdev_close(osp->netdev);
free(osp);
- port_array_set(&os->ports, odp_port, NULL);
+ port_array_delete(&os->ports, odp_port);
}
}
sfl_agent_release(os->sflow_agent);
}
os->sflow_agent = xcalloc(1, sizeof *os->sflow_agent);
- now = time_now();
+ now = time_wall();
sfl_agent_init(os->sflow_agent,
&agentIP,
options->sub_id,
if (ofproto_sflow_is_enabled(os)) {
time_t now = time_now();
if (now >= os->next_tick) {
- sfl_agent_tick(os->sflow_agent, now);
+ sfl_agent_tick(os->sflow_agent, time_wall());
os->next_tick = now + 1;
}
}
ofproto_sflow_wait(struct ofproto_sflow *os)
{
if (ofproto_sflow_is_enabled(os)) {
- poll_timer_wait(os->next_tick * 1000 - time_msec());
+ poll_timer_wait_until(os->next_tick * 1000LL);
}
}