- 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);
+ }
+
+ /* Set sFlow configuration on this bridge. */
+ if (br->cfg->sflow) {
+ const struct ovsrec_sflow *sflow_cfg = br->cfg->sflow;
+ const struct ovsrec_controller *ctrl;
+ struct ofproto_sflow_options oso;
+
+ memset(&oso, 0, sizeof oso);
+
+ oso.targets.n = sflow_cfg->n_targets;
+ oso.targets.names = sflow_cfg->targets;
+
+ oso.sampling_rate = SFL_DEFAULT_SAMPLING_RATE;
+ if (sflow_cfg->sampling) {
+ oso.sampling_rate = *sflow_cfg->sampling;
+ }
+
+ oso.polling_interval = SFL_DEFAULT_POLLING_INTERVAL;
+ if (sflow_cfg->polling) {
+ oso.polling_interval = *sflow_cfg->polling;
+ }
+
+ oso.header_len = SFL_DEFAULT_HEADER_SIZE;
+ if (sflow_cfg->header) {
+ oso.header_len = *sflow_cfg->header;
+ }
+
+ oso.sub_id = sflow_bridge_number++;
+ oso.agent_device = sflow_cfg->agent;
+
+ ctrl = bridge_get_controller(ovs_cfg, br);
+ oso.control_ip = ctrl ? ctrl->local_ip : NULL;
+ ofproto_set_sflow(br->ofproto, &oso);
+
+ svec_destroy(&oso.targets);
+ } else {
+ ofproto_set_sflow(br->ofproto, NULL);
+ }