From c0d305f985cb1a8533950d4f17107d9a71635644 Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Tue, 12 May 2020 12:44:06 +0200 Subject: [PATCH 1/2] ovn-northd: Fix leak of lport addresses during DHCPv6 reply handling. 'lrp_networks' never destroyed but constantly overwritten in a loop that handles DHCPv6 replies. In some cases this point leaks several MB per minute making ovn-northd to constantly growing its memory consumption: 399,820,764 bytes in 1,885,947 blocks are definitely lost in loss record 182 of 182 at 0x4839748: malloc (vg_replace_malloc.c:308) by 0x483BD63: realloc (vg_replace_malloc.c:836) by 0x1E7BF8: xrealloc (util.c:149) by 0x152723: add_ipv6_netaddr.isra.0 (ovn-util.c:55) by 0x152F1C: extract_lrp_networks (ovn-util.c:275) by 0x142EE2: build_lrouter_flows (ovn-northd.c:8607) by 0x142EE2: build_lflows.isra.0 (ovn-northd.c:10296) by 0x14E4F8: ovnnb_db_run (ovn-northd.c:11128) by 0x14E4F8: ovn_db_run (ovn-northd.c:11672) by 0x13304D: main (ovn-northd.c:12035) In fact, there is no need to allocate this memory at all, since all the required information is already available in 'op->lrp_networks'. Reported-by: Joe Talerico Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1827769 Fixes: 5c1d2d230773 ("northd: Add logical flows for dhcpv6 pfd parsing") Signed-off-by: Ilya Maximets Acked-by: Mark Michelson Signed-off-by: Numan Siddique --- northd/ovn-northd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index b07e68cfa..c1cdb2280 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -8603,17 +8603,12 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, continue; } - struct lport_addresses lrp_networks; - if (!extract_lrp_networks(op->nbrp, &lrp_networks)) { - continue; - } - - for (size_t i = 0; i < lrp_networks.n_ipv6_addrs; i++) { + for (size_t i = 0; i < op->lrp_networks.n_ipv6_addrs; i++) { ds_clear(&actions); ds_clear(&match); ds_put_format(&match, "ip6.dst == %s && udp.src == 547 &&" " udp.dst == 546", - lrp_networks.ipv6_addrs[i].addr_s); + op->lrp_networks.ipv6_addrs[i].addr_s); ds_put_format(&actions, "reg0 = 0; handle_dhcpv6_reply;"); ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 100, ds_cstr(&match), ds_cstr(&actions)); -- 2.26.2