Skip to content

Commit

Permalink
ipfix: fix segfault for Flow_Sample_Collector_Set without ipfix
Browse files Browse the repository at this point in the history
Guard any access to an IPFIX row referenced from
Flow_Sample_Collector_Set by a test that the reference is not NULL.

Signed-off-by: Romain Lenglet <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
rlenglet authored and blp committed Nov 21, 2013
1 parent a055dee commit b4fa9d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vswitchd/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,14 @@ bridge_configure_sflow(struct bridge *br, int *sflow_bridge_number)
sset_destroy(&oso.targets);
}

/* Returns whether a Flow_Sample_Collector_Set row is valid. */
static bool
ovsrec_fscs_is_valid(const struct ovsrec_flow_sample_collector_set *fscs,
const struct bridge *br)
{
return fscs->ipfix && fscs->bridge == br->cfg;
}

/* Set IPFIX configuration on 'br'. */
static void
bridge_configure_ipfix(struct bridge *br)
Expand All @@ -998,7 +1006,7 @@ bridge_configure_ipfix(struct bridge *br)
size_t n_fe_opts = 0;

OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) {
if (fe_cfg->bridge == br->cfg) {
if (ovsrec_fscs_is_valid(fe_cfg, br)) {
n_fe_opts++;
}
}
Expand Down Expand Up @@ -1038,7 +1046,7 @@ bridge_configure_ipfix(struct bridge *br)
fe_opts = xcalloc(n_fe_opts, sizeof *fe_opts);
opts = fe_opts;
OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) {
if (fe_cfg->bridge == br->cfg) {
if (ovsrec_fscs_is_valid(fe_cfg, br)) {
opts->collector_set_id = fe_cfg->id;
sset_init(&opts->targets);
sset_add_array(&opts->targets, fe_cfg->ipfix->targets,
Expand Down

0 comments on commit b4fa9d4

Please sign in to comment.