Guard any access to an IPFIX row referenced from
Flow_Sample_Collector_Set by a test that the reference is not NULL.
Factorized that check into macro __VALID_FSCS.

Signed-off-by: Romain Lenglet <[email protected]>
---
 vswitchd/bridge.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 555f45d..8e43df3 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -988,6 +988,8 @@ bridge_configure_sflow(struct bridge *br, int 
*sflow_bridge_number)
 static void
 bridge_configure_ipfix(struct bridge *br)
 {
+#define __VALID_FSCS(fscs) (fscs->ipfix && fscs->bridge == br->cfg)
+
     const struct ovsrec_ipfix *be_cfg = br->cfg->ipfix;
     const struct ovsrec_flow_sample_collector_set *fe_cfg;
     struct ofproto_ipfix_bridge_exporter_options be_opts;
@@ -995,7 +997,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 (__VALID_FSCS(fe_cfg)) {
             n_fe_opts++;
         }
     }
@@ -1035,7 +1037,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 (__VALID_FSCS(fe_cfg)) {
                 opts->collector_set_id = fe_cfg->id;
                 sset_init(&opts->targets);
                 sset_add_array(&opts->targets, fe_cfg->ipfix->targets,
@@ -1065,6 +1067,8 @@ bridge_configure_ipfix(struct bridge *br)
         }
         free(fe_opts);
     }
+
+#undef __VALID_FSCS
 }
 
 static void
-- 
1.7.9.5
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to