From owner-dev-commits-src-all@freebsd.org Fri Apr 9 21:21:06 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 56C265BDE61; Fri, 9 Apr 2021 21:21:06 +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 4FH9zQ1vlSz4dZB; Fri, 9 Apr 2021 21:21:06 +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 33C9924978; Fri, 9 Apr 2021 21:21:06 +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 139LL6fj021647; Fri, 9 Apr 2021 21:21:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 139LL6eb021646; Fri, 9 Apr 2021 21:21:06 GMT (envelope-from git) Date: Fri, 9 Apr 2021 21:21:06 GMT Message-Id: <202104092121.139LL6eb021646@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 0c25bf7e7c18 - main - tcp_hostcache: implement tcp_hc_updatemtu() via tcp_hc_update. Locking changes are planned here, and without this change too much copy-and-paste would be between these two functions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0c25bf7e7c1877c88788f63005de525f2847b1d8 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: Fri, 09 Apr 2021 21:21:06 -0000 The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=0c25bf7e7c1877c88788f63005de525f2847b1d8 commit 0c25bf7e7c1877c88788f63005de525f2847b1d8 Author: Gleb Smirnoff AuthorDate: 2021-04-08 21:15:42 +0000 Commit: Gleb Smirnoff CommitDate: 2021-04-09 21:06:44 +0000 tcp_hostcache: implement tcp_hc_updatemtu() via tcp_hc_update. Locking changes are planned here, and without this change too much copy-and-paste would be between these two functions. Reviewed by: rscheff --- sys/netinet/tcp_hostcache.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index 7bc79b781a30..130b08425096 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -559,37 +559,9 @@ tcp_hc_getmtu(struct in_conninfo *inc) void tcp_hc_updatemtu(struct in_conninfo *inc, uint32_t mtu) { - struct hc_metrics *hc_entry; - - if (!V_tcp_use_hostcache) - return; - - /* - * Find the right bucket. - */ - hc_entry = tcp_hc_lookup(inc, true); - - /* - * If we don't have an existing object, try to insert a new one. - */ - if (hc_entry == NULL) { - hc_entry = tcp_hc_insert(inc); - if (hc_entry == NULL) - return; - } - - hc_entry->rmx_mtu = mtu; - - /* - * Put it upfront so we find it faster next time. - */ - TAILQ_REMOVE(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q); - TAILQ_INSERT_HEAD(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q); + struct hc_metrics_lite hcml = { .rmx_mtu = mtu }; - /* - * Unlock bucket row. - */ - THC_UNLOCK(&hc_entry->rmx_head->hch_mtx); + return (tcp_hc_update(inc, &hcml)); } /* @@ -611,6 +583,9 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml) return; } + if (hcml->rmx_mtu != 0) { + hc_entry->rmx_mtu = hcml->rmx_mtu; + } if (hcml->rmx_rtt != 0) { if (hc_entry->rmx_rtt == 0) hc_entry->rmx_rtt = hcml->rmx_rtt;