[ovs-dev] [IPFIX FIXES 1/2] ipfix: fix segfault for Flow_Sample_Collector_Set without ipfix
Romain Lenglet
rlenglet at vmware.com
Wed Nov 20 18:57:52 UTC 2013
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 <rlenglet at vmware.com>
---
vswitchd/bridge.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 555f45d..8749514 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -984,6 +984,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 inline 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)
@@ -995,7 +1003,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++;
}
}
@@ -1035,7 +1043,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,
--
1.7.9.5
More information about the dev
mailing list