- memset(&nf_options, 0, sizeof nf_options);
- dpif_get_netflow_ids(br->dpif, &nf_options.engine_type,
- &nf_options.engine_id);
- nf_options.active_timeout = -1;
-
- if (cfg_has("netflow.%s.engine-type", br->name)) {
- nf_options.engine_type = cfg_get_int(0, "netflow.%s.engine-type",
- br->name);
- }
- if (cfg_has("netflow.%s.engine-id", br->name)) {
- nf_options.engine_id = cfg_get_int(0, "netflow.%s.engine-id",
- br->name);
- }
- if (cfg_has("netflow.%s.active-timeout", br->name)) {
- nf_options.active_timeout = cfg_get_int(0,
- "netflow.%s.active-timeout",
- br->name);
- }
- if (cfg_has("netflow.%s.add-id-to-iface", br->name)) {
- nf_options.add_id_to_iface = cfg_get_bool(0,
- "netflow.%s.add-id-to-iface",
- br->name);
- }
- if (nf_options.add_id_to_iface && nf_options.engine_id > 0x7f) {
- VLOG_WARN("bridge %s: netflow port mangling may conflict with "
- "another vswitch, choose an engine id less than 128",
- br->name);
- }
- if (nf_options.add_id_to_iface && br->n_ports > 508) {
- VLOG_WARN("bridge %s: netflow port mangling will conflict with "
- "another port when more than 508 ports are used",
- br->name);
- }
- svec_init(&nf_options.collectors);
- cfg_get_all_keys(&nf_options.collectors, "netflow.%s.host", br->name);
- if (ofproto_set_netflow(br->ofproto, &nf_options)) {
- VLOG_ERR("bridge %s: problem setting netflow collectors",
- br->name);
- }
- svec_destroy(&nf_options.collectors);
+ if (br->cfg->netflow) {
+ struct ovsrec_netflow *nf_cfg = br->cfg->netflow;
+ struct netflow_options opts;
+
+ memset(&opts, 0, sizeof opts);
+
+ dpif_get_netflow_ids(br->dpif, &opts.engine_type, &opts.engine_id);
+ if (nf_cfg->engine_type) {
+ opts.engine_type = nf_cfg->engine_type;
+ }
+ if (nf_cfg->engine_id) {
+ opts.engine_id = nf_cfg->engine_id;
+ }
+
+ opts.active_timeout = nf_cfg->active_timeout;
+ if (!opts.active_timeout) {
+ opts.active_timeout = -1;
+ } else if (opts.active_timeout < 0) {
+ VLOG_WARN("bridge %s: active timeout interval set to negative "
+ "value, using default instead (%d seconds)", br->name,
+ NF_ACTIVE_TIMEOUT_DEFAULT);
+ opts.active_timeout = -1;
+ }
+
+ opts.add_id_to_iface = nf_cfg->add_id_to_interface;
+ if (opts.add_id_to_iface) {
+ if (opts.engine_id > 0x7f) {
+ VLOG_WARN("bridge %s: netflow port mangling may conflict "
+ "with another vswitch, choose an engine id less "
+ "than 128", br->name);
+ }
+ if (br->n_ports > 508) {
+ VLOG_WARN("bridge %s: netflow port mangling will conflict "
+ "with another port when more than 508 ports are "
+ "used", br->name);
+ }
+ }
+
+ opts.collectors.n = nf_cfg->n_targets;
+ opts.collectors.names = nf_cfg->targets;
+ if (ofproto_set_netflow(br->ofproto, &opts)) {
+ VLOG_ERR("bridge %s: problem setting netflow collectors",
+ br->name);
+ }
+ } else {
+ ofproto_set_netflow(br->ofproto, NULL);
+ }