From: Ben Pfaff Date: Fri, 7 May 2010 16:29:02 +0000 (-0700) Subject: ofproto-sflow: Maintain table of ports even when clearing configuration. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d9dc1181e99ca891cb30a44ee709dcf9fb988f;p=openvswitch ofproto-sflow: Maintain table of ports even when clearing configuration. When ofproto_sflow_set_options() fails, it calls ofproto_sflow_clear() to deconfigure the ofproto_sflow object. But ofproto_sflow_clear() deletes all of the object's record of datapath ports. That means that the next call to ofproto_sflow_set_options(), if it succeeds, will believe that the datapath has no ports. This commit fixes the problem by only clearing ofproto_sflow's record of datapath ports when it is destroyed, not just when a configuration error occurs. Reported-by: Neil McKee --- diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index 22d99eb7..60baf0e9 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -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); }