From owner-dev-commits-src-all@freebsd.org Sat Jan 30 23:28:08 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 99AD04FC826; Sat, 30 Jan 2021 23:28:08 +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 4DSr3r3wSpz3R7t; Sat, 30 Jan 2021 23:28:08 +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 6AAC71DF68; Sat, 30 Jan 2021 23:28:08 +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 10UNS86C074934; Sat, 30 Jan 2021 23:28:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10UNS8Nf074933; Sat, 30 Jan 2021 23:28:08 GMT (envelope-from git) Date: Sat, 30 Jan 2021 23:28:08 GMT Message-Id: <202101302328.10UNS8Nf074933@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: ab6d9aaed76e - main - Move business logic from rebuild_fd_callout() into rebuild_fd(). 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/main X-Git-Reftype: branch X-Git-Commit: ab6d9aaed76ed9f86fd0d938ebb6ea81f5ad6a82 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: Sat, 30 Jan 2021 23:28:08 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=ab6d9aaed76ed9f86fd0d938ebb6ea81f5ad6a82 commit ab6d9aaed76ed9f86fd0d938ebb6ea81f5ad6a82 Author: Alexander V. Chernikov AuthorDate: 2021-01-30 22:32:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-01-30 23:25:57 +0000 Move business logic from rebuild_fd_callout() into rebuild_fd(). This simplifies code a bit and allows for future non-callout callers to request rebuild. MFC after: 3 days --- sys/net/route/fib_algo.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/sys/net/route/fib_algo.c b/sys/net/route/fib_algo.c index 1f040ad259c5..f7a8b3f82431 100644 --- a/sys/net/route/fib_algo.c +++ b/sys/net/route/fib_algo.c @@ -155,6 +155,7 @@ struct fib_data { TAILQ_ENTRY(fib_data) entries; /* list of all fds in vnet */ }; +static bool rebuild_fd(struct fib_data *fd); static void rebuild_fd_callout(void *_data); static void destroy_fd_instance_epoch(epoch_context_t ctx); static enum flm_op_result attach_datapath(struct fib_data *fd); @@ -1011,13 +1012,28 @@ setup_fd_instance(struct fib_lookup_module *flm, struct rib_head *rh, static void rebuild_fd_callout(void *_data) { - struct fib_data *fd, *fd_new, *fd_tmp; + struct fib_data *fd = (struct fib_data *)_data; + + FD_PRINTF(LOG_INFO, fd, "running callout rebuild"); + + CURVNET_SET(fd->fd_vnet); + rebuild_fd(fd); + CURVNET_RESTORE(); +} + +/* + * Tries to create new algo instance based on @fd data. + * Returns true on success. + */ +static bool +rebuild_fd(struct fib_data *fd) +{ + struct fib_data *fd_new, *fd_tmp; struct fib_lookup_module *flm_new = NULL; struct epoch_tracker et; enum flm_op_result result; bool need_rebuild = false; - fd = (struct fib_data *)_data; FIB_MOD_LOCK(); need_rebuild = fd->fd_need_rebuild; @@ -1026,15 +1042,12 @@ rebuild_fd_callout(void *_data) fd->fd_num_changes = 0; FIB_MOD_UNLOCK(); - CURVNET_SET(fd->fd_vnet); - /* First, check if we're still OK to use this algo */ if (!is_algo_fixed(fd->fd_rh)) flm_new = fib_check_best_algo(fd->fd_rh, fd->fd_flm); if ((flm_new == NULL) && (!need_rebuild)) { /* Keep existing algo, no need to rebuild. */ - CURVNET_RESTORE(); - return; + return (true); } if (flm_new == NULL) { @@ -1051,19 +1064,16 @@ rebuild_fd_callout(void *_data) } if (result != FLM_SUCCESS) { FD_PRINTF(LOG_NOTICE, fd, "table rebuild failed"); - CURVNET_RESTORE(); - return; + return (false); } FD_PRINTF(LOG_INFO, fd_new, "switched to new instance"); - /* Remove old instance removal */ - if (fd != NULL) { - NET_EPOCH_ENTER(et); - schedule_destroy_fd_instance(fd, true); - NET_EPOCH_EXIT(et); - } + /* Remove old instance */ + NET_EPOCH_ENTER(et); + schedule_destroy_fd_instance(fd, true); + NET_EPOCH_EXIT(et); - CURVNET_RESTORE(); + return (true); } /*