From owner-svn-src-head@freebsd.org Sat May 23 12:15:48 2020 Return-Path: Delivered-To: svn-src-head@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 389FB2CA32E; Sat, 23 May 2020 12:15:48 +0000 (UTC) (envelope-from melifaro@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49Tj4N0nMXz3dwt; Sat, 23 May 2020 12:15:48 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 11D2AFB8B; Sat, 23 May 2020 12:15:48 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04NCFltP035788; Sat, 23 May 2020 12:15:47 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04NCFlRN035787; Sat, 23 May 2020 12:15:47 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202005231215.04NCFlRN035787@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Sat, 23 May 2020 12:15:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361415 - in head/sys/net: . route X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: in head/sys/net: . route X-SVN-Commit-Revision: 361415 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2020 12:15:48 -0000 Author: melifaro Date: Sat May 23 12:15:47 2020 New Revision: 361415 URL: https://svnweb.freebsd.org/changeset/base/361415 Log: Remove refcounting from rtentry. After making rtentry reclamation backed by epoch(9) in r361409, there is no reason in keeping reference counting code. Differential Revision: https://reviews.freebsd.org/D24867 Modified: head/sys/net/route.c head/sys/net/route/route_var.h Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Sat May 23 12:00:46 2020 (r361414) +++ head/sys/net/route.c Sat May 23 12:15:47 2020 (r361415) @@ -439,39 +439,8 @@ rtfree(struct rtentry *rt) RT_LOCK_ASSERT(rt); - /* - * The callers should use RTFREE_LOCKED() or RTFREE(), so - * we should come here exactly with the last reference. - */ - RT_REMREF(rt); - if (rt->rt_refcnt > 0) { - log(LOG_DEBUG, "%s: %p has %d refs\n", __func__, rt, rt->rt_refcnt); - goto done; - } - - /* - * If we are no longer "up" (and ref == 0) - * then we can free the resources associated - * with the route. - */ - if ((rt->rt_flags & RTF_UP) == 0) { - if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT)) - panic("rtfree 2"); -#ifdef DIAGNOSTIC - if (rt->rt_refcnt < 0) { - printf("rtfree: %p not freed (neg refs)\n", rt); - goto done; - } -#endif - epoch_call(net_epoch_preempt, destroy_rtentry_epoch, - &rt->rt_epoch_ctx); - - /* - * FALLTHROUGH to RT_UNLOCK() so the reporting functions - * have consistent behaviour of operating on unlocked entry. - */ - } -done: + epoch_call(net_epoch_preempt, destroy_rtentry_epoch, + &rt->rt_epoch_ctx); RT_UNLOCK(rt); } @@ -958,7 +927,7 @@ rib_walk_del(u_int fibnum, int family, rt_filter_f_t * if (report) rt_routemsg(RTM_DELETE, rt, rt->rt_nhop->nh_ifp, 0, fibnum); - RTFREE_LOCKED(rt); + rtfree(rt); } } @@ -1114,7 +1083,6 @@ rt_unlinkrte(struct rib_head *rnh, struct rt_addrinfo rt = RNTORT(rn); RT_LOCK(rt); - RT_ADDREF(rt); rt->rt_flags &= ~RTF_UP; *perror = 0; @@ -1569,8 +1537,10 @@ add_route(struct rib_head *rnh, struct rt_addrinfo *in } RIB_WUNLOCK(rnh); - if (rt_old != NULL) - RT_UNLOCK(rt_old); + if (rt_old != NULL) { + rt_notifydelete(rt_old, info); + rtfree(rt_old); + } /* * If it still failed to go into the tree, @@ -1582,11 +1552,6 @@ add_route(struct rib_head *rnh, struct rt_addrinfo *in return (EEXIST); } - if (rt_old != NULL) { - rt_notifydelete(rt_old, info); - RTFREE(rt_old); - } - /* * If this protocol has something to add to this then * allow it to do that as well. @@ -1639,7 +1604,7 @@ del_route(struct rib_head *rnh, struct rt_addrinfo *in if (ret_nrt) *ret_nrt = rt; - RTFREE_LOCKED(rt); + rtfree(rt); return (0); } Modified: head/sys/net/route/route_var.h ============================================================================== --- head/sys/net/route/route_var.h Sat May 23 12:00:46 2020 (r361414) +++ head/sys/net/route/route_var.h Sat May 23 12:15:47 2020 (r361415) @@ -143,7 +143,6 @@ struct rtentry { }; int rt_flags; /* up/down?, host/net */ - int rt_refcnt; /* # held references */ u_long rt_weight; /* absolute weight */ u_long rt_expire; /* lifetime for route, e.g. redirect */ #define rt_endzero rt_mtx @@ -161,36 +160,6 @@ struct rtentry { #define RT_UNLOCK_COND(_rt) do { \ if (mtx_owned(&(_rt)->rt_mtx)) \ mtx_unlock(&(_rt)->rt_mtx); \ -} while (0) - -#define RT_ADDREF(_rt) do { \ - RT_LOCK_ASSERT(_rt); \ - KASSERT((_rt)->rt_refcnt >= 0, \ - ("negative refcnt %d", (_rt)->rt_refcnt)); \ - (_rt)->rt_refcnt++; \ -} while (0) - -#define RT_REMREF(_rt) do { \ - RT_LOCK_ASSERT(_rt); \ - KASSERT((_rt)->rt_refcnt > 0, \ - ("bogus refcnt %d", (_rt)->rt_refcnt)); \ - (_rt)->rt_refcnt--; \ -} while (0) - -#define RTFREE_LOCKED(_rt) do { \ - if ((_rt)->rt_refcnt <= 1) \ - rtfree(_rt); \ - else { \ - RT_REMREF(_rt); \ - RT_UNLOCK(_rt); \ - } \ - /* guard against invalid refs */ \ - _rt = 0; \ -} while (0) - -#define RTFREE(_rt) do { \ - RT_LOCK(_rt); \ - RTFREE_LOCKED(_rt); \ } while (0) /*