diff mbox series

[ovs-dev] northd: Fix iteration over vip backends.

Message ID 20201204185030.310678-1-i.maximets@ovn.org
State Accepted
Headers show
Series [ovs-dev] northd: Fix iteration over vip backends. | expand

Commit Message

Ilya Maximets Dec. 4, 2020, 6:50 p.m. UTC
During refactoring, direct access such as 'lb->vips[i].backends[j].op'
was simplified by the presence of the 'backend_nb' pointer. But instead
of the inner one, the index of the outer loop was used.  This forces
northd to only use one backend per vip, and can also lead to invalid
memory accesses.

This change fixes system test:
  24. ovn -- Load balancer health checks

Fixes: f1119c125765 ("northd: Refactor load balancer vip parsing.")
Tested-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 northd/ovn-northd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dumitru Ceara Dec. 4, 2020, 7:40 p.m. UTC | #1
On 12/4/20 7:50 PM, Ilya Maximets wrote:
> During refactoring, direct access such as 'lb->vips[i].backends[j].op'
> was simplified by the presence of the 'backend_nb' pointer. But instead
> of the inner one, the index of the outer loop was used.  This forces
> northd to only use one backend per vip, and can also lead to invalid
> memory accesses.
> 
> This change fixes system test:
>   24. ovn -- Load balancer health checks
> 
> Fixes: f1119c125765 ("northd: Refactor load balancer vip parsing.")
> Tested-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---

Thanks for the fix!

Acked-by: Dumitru Ceara <dceara@redhat.com>
Numan Siddique Dec. 7, 2020, 7:22 a.m. UTC | #2
On Sat, Dec 5, 2020 at 1:10 AM Dumitru Ceara <dceara@redhat.com> wrote:
>
> On 12/4/20 7:50 PM, Ilya Maximets wrote:
> > During refactoring, direct access such as 'lb->vips[i].backends[j].op'
> > was simplified by the presence of the 'backend_nb' pointer. But instead
> > of the inner one, the index of the outer loop was used.  This forces
> > northd to only use one backend per vip, and can also lead to invalid
> > memory accesses.
> >
> > This change fixes system test:
> >   24. ovn -- Load balancer health checks
> >
> > Fixes: f1119c125765 ("northd: Refactor load balancer vip parsing.")
> > Tested-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> > Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> > ---
>
> Thanks for the fix!
>
> Acked-by: Dumitru Ceara <dceara@redhat.com>

Thanks Ilya for the fix and Dumitru for the review. I applied this
patch to master and branch-20.12.

Numan

>
> _______________________________________________
> 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 c0eab429d..403342b0d 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -6949,7 +6949,7 @@  build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
 
             for (size_t j = 0; j < lb_vip_nb->n_backends; j++) {
                 struct ovn_northd_lb_backend *backend_nb =
-                    &lb_vip_nb->backends_nb[i];
+                    &lb_vip_nb->backends_nb[j];
                 if (!backend_nb->op || !backend_nb->svc_mon_src_ip) {
                     continue;
                 }