diff mbox series

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

Message ID 1564658780-26495-1-git-send-email-dceara@redhat.com
State Accepted
Headers show
Series [ovs-dev,ovn] ovn-northd: Use HMAP_FOR_EACH when adding multicast lflows | expand

Commit Message

Dumitru Ceara Aug. 1, 2019, 11:26 a.m. UTC
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@redhat.com>
---
 northd/ovn-northd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Numan Siddique Aug. 5, 2019, 1:08 p.m. UTC | #1
On Thu, Aug 1, 2019 at 5:09 PM Dumitru Ceara <dceara@redhat.com> wrote:

> 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@redhat.com>
>

Acked-by: Numan Siddique <nusiddiq@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
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Mark Michelson Aug. 5, 2019, 8:41 p.m. UTC | #2
I applied the change to master.

On 8/5/19 9:08 AM, Numan Siddique wrote:
> On Thu, Aug 1, 2019 at 5:09 PM Dumitru Ceara <dceara@redhat.com> wrote:
> 
>> 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@redhat.com>
>>
> 
> Acked-by: Numan Siddique <nusiddiq@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
>>
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

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; ",