From: Tonghao Zhang <xiangxia.m....@gmail.com>

When we destroy the flow tables which may contain the flow_mask,
so release the flow mask struct.

Signed-off-by: Tonghao Zhang <xiangxia.m....@gmail.com>
Tested-by: Greg Rose <gvrose8...@gmail.com>
---
 net/openvswitch/flow_table.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index 5df5182..d5d768e 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -295,6 +295,18 @@ static void table_instance_destroy(struct table_instance 
*ti,
        }
 }
 
+static void tbl_mask_array_destroy(struct flow_table *tbl)
+{
+       struct mask_array *ma = ovsl_dereference(tbl->mask_array);
+       int i;
+
+       /* Free the flow-mask and kfree_rcu the NULL is allowed. */
+       for (i = 0; i < ma->max; i++)
+               kfree_rcu(rcu_dereference_raw(ma->masks[i]), rcu);
+
+       kfree_rcu(rcu_dereference_raw(tbl->mask_array), rcu);
+}
+
 /* No need for locking this function is called from RCU callback or
  * error path.
  */
@@ -304,7 +316,7 @@ void ovs_flow_tbl_destroy(struct flow_table *table)
        struct table_instance *ufid_ti = rcu_dereference_raw(table->ufid_ti);
 
        free_percpu(table->mask_cache);
-       kfree_rcu(rcu_dereference_raw(table->mask_array), rcu);
+       tbl_mask_array_destroy(table);
        table_instance_destroy(ti, ufid_ti, false);
 }
 
-- 
1.8.3.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to