X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto-sflow.c;h=c74c7360ef5e4db6b738421655cd693880ad943f;hb=f2d9c30bdf455d8ce6dbf2188c1330e4b33d7d1f;hp=22d99eb7cf87797a3f0ee39a8f3a1a6dbb284b4e;hpb=5586445e9945574da85f96976ca650e19b8216c1;p=openvswitch diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index 22d99eb7..c74c7360 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -30,10 +30,10 @@ #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. */ @@ -239,9 +239,6 @@ success: 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; @@ -251,11 +248,6 @@ ofproto_sflow_clear(struct ofproto_sflow *os) 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); } @@ -282,7 +274,13 @@ void 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); } @@ -356,7 +354,7 @@ ofproto_sflow_del_port(struct ofproto_sflow *os, uint16_t odp_port) } netdev_close(osp->netdev); free(osp); - port_array_set(&os->ports, odp_port, NULL); + port_array_delete(&os->ports, odp_port); } } @@ -417,7 +415,7 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, 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, @@ -599,7 +597,7 @@ ofproto_sflow_run(struct ofproto_sflow *os) 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; } } @@ -609,6 +607,6 @@ void 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); } }