From: Ben Pfaff Date: Mon, 11 Jan 2010 19:09:14 +0000 (-0800) Subject: sflow: Avoid division by zero if sampling rate is 0. X-Git-Tag: v0.99.1~1^2~8 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=a68813c3dce6597c302c1d112f88b8020c4d2eba;p=sliver-openvswitch.git sflow: Avoid division by zero if sampling rate is 0. Reported by Justin Pettit. --- diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index 45c6c08ad..1815dd9d7 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -359,6 +359,13 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, time_t now; int error; + if (!options->targets.n || !options->sampling_rate) { + /* No point in doing any work if there are no targets or nothing to + * sample. */ + ofproto_sflow_clear(os); + return; + } + options_changed = (!os->options || !ofproto_sflow_options_equal(options, os->options)); @@ -371,7 +378,8 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, error = collectors_create(&options->targets, SFL_DEFAULT_COLLECTOR_PORT, &os->collectors); if (os->collectors == NULL) { - VLOG_WARN_RL(&rl, "no configured collectors, sFlow disabled"); + VLOG_WARN_RL(&rl, "no collectors could be initialized, " + "sFlow disabled"); ofproto_sflow_clear(os); return; }