From owner-dev-commits-src-all@freebsd.org Sun Mar 28 20:50:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 144925AE1B8; Sun, 28 Mar 2021 20:50:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F7nsc0kyWz3M9C; Sun, 28 Mar 2021 20:50:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E1D7269C3; Sun, 28 Mar 2021 20:50:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12SKoRZK012034; Sun, 28 Mar 2021 20:50:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12SKoR9P012033; Sun, 28 Mar 2021 20:50:27 GMT (envelope-from git) Date: Sun, 28 Mar 2021 20:50:27 GMT Message-Id: <202103282050.12SKoR9P012033@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 411cbdb1f298 - releng/13.0 - Plug nexthop group refcount leak. In case with batch route delete via rib_walk_del(), when some paths from the multipath route gets deleted, old multipath group were not freed. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 411cbdb1f298880a0100a633cd0508b70ac4c924 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Mar 2021 20:50:29 -0000 The branch releng/13.0 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=411cbdb1f298880a0100a633cd0508b70ac4c924 commit 411cbdb1f298880a0100a633cd0508b70ac4c924 Author: Alexander V. Chernikov AuthorDate: 2021-03-24 23:51:45 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-03-28 20:40:48 +0000 Plug nexthop group refcount leak. In case with batch route delete via rib_walk_del(), when some paths from the multipath route gets deleted, old multipath group were not freed. PR: 254496 Reported by: Zhenlei Huang Approved by: re (gjb) (cherry picked from commit 47c00a9835926e96e562c67fa28e4432e99d9c56) --- sys/net/route/route_ctl.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c index 58b89c28f945..af3853041ac6 100644 --- a/sys/net/route/route_ctl.c +++ b/sys/net/route/route_ctl.c @@ -130,6 +130,7 @@ vnet_rtzone_destroy() static void destroy_rtentry(struct rtentry *rt) { +#ifdef VIMAGE struct nhop_object *nh = rt->rt_nhop; /* @@ -146,9 +147,10 @@ destroy_rtentry(struct rtentry *rt) } #endif CURVNET_SET(nhop_get_vnet(nh)); +#endif /* Unreference nexthop */ - nhop_free_any(nh); + nhop_free_any(rt->rt_nhop); uma_zfree(V_rtzone, rt); @@ -1252,7 +1254,6 @@ rt_checkdelroute(struct radix_node *rn, void *arg) struct rt_delinfo *di; struct rt_addrinfo *info; struct rtentry *rt; - int error; di = (struct rt_delinfo *)arg; rt = (struct rtentry *)rn; @@ -1261,7 +1262,8 @@ rt_checkdelroute(struct radix_node *rn, void *arg) info->rti_info[RTAX_DST] = rt_key(rt); info->rti_info[RTAX_NETMASK] = rt_mask(rt); - error = rt_unlinkrte(di->rnh, info, &di->rc); + if (rt_unlinkrte(di->rnh, info, &di->rc) != 0) + return (0); /* * Add deleted rtentries to the list to GC them @@ -1270,10 +1272,18 @@ rt_checkdelroute(struct radix_node *rn, void *arg) * XXX: Delayed notifications not implemented * for nexthop updates. */ - if ((error == 0) && (di->rc.rc_cmd == RTM_DELETE)) { + if (di->rc.rc_cmd == RTM_DELETE) { /* Add to the list and return */ rt->rt_chain = di->head; di->head = rt; +#ifdef ROUTE_MPATH + } else { + /* + * RTM_CHANGE to a diferent nexthop or nexthop group. + * Free old multipath group. + */ + nhop_free_any(di->rc.rc_nh_old); +#endif } return (0);