[ovs-dev] [PATCH ovn] ovn-northd: Use HMAP_FOR_EACH when adding multicast lflows

Dumitru Ceara dceara at redhat.com
Thu Aug 1 11:26:20 UTC 2019


There's no need to use HMAP_FOR_EACH_SAFE when we add the logical flows
that correspond to IGMP groups as we don't modify the hashmap in the
loop.

Also, we should reinitialize match and actions only if the flow will be
added.

Fixes: ddc64665b678 ("OVN: Add ovn-northd IGMP support")
Signed-off-by: Dumitru Ceara <dceara at redhat.com>
---
 northd/ovn-northd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index dabd422..880773b 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -5258,12 +5258,9 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
 
     /* Ingress table 17: Add IP multicast flows learnt from IGMP
      * (priority 90). */
-    struct ovn_igmp_group *igmp_group, *next_igmp_group;
-
-    HMAP_FOR_EACH_SAFE (igmp_group, next_igmp_group, hmap_node, igmp_groups) {
-        ds_clear(&match);
-        ds_clear(&actions);
+    struct ovn_igmp_group *igmp_group;
 
+    HMAP_FOR_EACH (igmp_group, hmap_node, igmp_groups) {
         if (!igmp_group->datapath) {
             continue;
         }
@@ -5275,6 +5272,9 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
         }
         mcast_info->active_flows++;
 
+        ds_clear(&match);
+        ds_clear(&actions);
+
         ds_put_format(&match, "eth.mcast && ip4 && ip4.dst == %s ",
                       igmp_group->mcgroup.name);
         ds_put_format(&actions, "outport = \"%s\"; output; ",
-- 
1.8.3.1



More information about the dev mailing list