[ovs-dev] [PATCH ovn] ovn-northd: Fix memory leak in case of distributed NAT.

Numan Siddique numans at ovn.org
Thu May 14 07:44:00 UTC 2020


On Wed, May 13, 2020 at 4:57 PM Ilya Maximets <i.maximets at ovn.org> wrote:

> On 5/13/20 12:19 PM, Dumitru Ceara wrote:
> > In function get_nat_addresses(), memory reserved for c_addresses is not
> > freed in case of distributed NAT (i.e., central_ip_address == false):
> >
> > ==22493== 36 bytes in 2 blocks are definitely lost in loss record 176
> > of 444
> > ==22493==    at 0x4C29DAD: malloc (vg_replace_malloc.c:308)
> > ==22493==    by 0x4C2C100: realloc (vg_replace_malloc.c:836)
> > ==22493==    by 0x4E3E9D: xrealloc (util.c:149)
> > ==22493==    by 0x47EEBB: ds_reserve (dynamic-string.c:63)
> > ==22493==    by 0x47F32E: ds_put_format_valist (dynamic-string.c:161)
> > ==22493==    by 0x47F258: ds_put_format (dynamic-string.c:142)
> > ==22493==    by 0x40D74E: get_nat_addresses (ovn-northd.c:2337)
> > ==22493==    by 0x40F75B: ovn_port_update_sbrec (ovn-northd.c:2981)
> > ==22493==    by 0x4112E8: build_ports (ovn-northd.c:3505)
> > ==22493==    by 0x42922C: ovnnb_db_run (ovn-northd.c:11138)
> > ==22493==    by 0x42A49D: ovn_db_run (ovn-northd.c:11692)
> > ==22493==    by 0x42B484: main (ovn-northd.c:12055)
> >
> > To fix this we always call ds_destroy(&c_addresses).
> >
> > Fixes: 7b1f4dabfb60 ("ovn: Gratuitous ARP for distributed NAT rules")
> > Signed-off-by: Dumitru Ceara <dceara at redhat.com>
> > ---
> >  northd/ovn-northd.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
> > index b25152d..965de05 100644
> > --- a/northd/ovn-northd.c
> > +++ b/northd/ovn-northd.c
> > @@ -2424,6 +2424,7 @@ get_nat_addresses(const struct ovn_port *op,
> size_t *n)
> >      }
> >
> >      *n = n_nats;
> > +    ds_destroy(&c_addresses);
> >


If 'central_ip_address' is false, there would be a memory leak.

Thanks. I applied this patch to master and branch-20.03

Numan


>


> >      return addresses;
> >  }
> >
>
> I'm not sure what this function does exactly, but from the memory usage
> perspective
> this patch looks good to me.
>
Acked-by: Ilya Maximets <i.maximets at ovn.org>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>


More information about the dev mailing list