From nobody Wed Aug 17 18:52:14 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M7HFC2VrRz4Yxsk; Wed, 17 Aug 2022 18:52:15 +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 4M7HFC1k0xz4Cb5; Wed, 17 Aug 2022 18:52:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660762335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OOpaXj5zz6Kt07CkDLAIHrLFt/u0XYN85XFARC6vvo0=; b=byGT3qFTn5Dg7yQlmt+/m44EMIyE6WgMGh3+K81GwG+cDNXAqale9O/j+HUlHKl6iU0lGZ 2V0Un3KNljR+Kb9LW+mgFDVuVYiB3sNE4cvs/LsT/WPxRxBiFNtTHmDXhjYqp0nGAOXHec r52VzQ8Zt+rAIgy3uNSxb7Dgl6vMUVjxgefmOAmZ7Vde4lpN2XyTJftJ4ZkEeIo6xfi4Tw hEGlbMlBzM3V6AVyTvJiBriTkMPJiIqyoIxf0iXpNUX54yXOuwbQ9A02rNUKMMHm83oc8I My/JJNQ+QxThEIfaMIZ2GrN6SYrf7/2CJOK9Cb4dPlxPr33X4B7YahgPG5aJRA== 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 4M7HFC09mBz11Lb; Wed, 17 Aug 2022 18:52:15 +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 27HIqEcp012958; Wed, 17 Aug 2022 18:52:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27HIqEP7012957; Wed, 17 Aug 2022 18:52:14 GMT (envelope-from git) Date: Wed, 17 Aug 2022 18:52:14 GMT Message-Id: <202208171852.27HIqEP7012957@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: 160f01f09f4b - main - ip_reass: use callout(9) directly instead of pr_slowtimo List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 160f01f09f4b5a50cd752fe1d55a83f5f2c9f9fc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660762335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OOpaXj5zz6Kt07CkDLAIHrLFt/u0XYN85XFARC6vvo0=; b=BHXoxk2NfM+TEp7MxBGEKzRd/26vIDHgj3sUl7f3+ZzG0easNJMXdrBN+j6G4yPl0tivxO 0hSXtfrMo+e3/k7P2kuz6vBIlpM2jJ0upfqAZnuALAr5dtrdYvmBfosr5p7c0nIjqCATuE g963VJvhMFE0i+4v5eb8xGiRHp00oYttj3Ikc3z1qMRkcuKEZ9u/dHprNVt32NgLbDppd9 ODYyYdQK/hVkyXtWY6G2gt8sGNb/1lRbDGgCQhSndx5CyDZg8HHA6Q1cXU+hT3UtpjsD9H dlR2cDD9mvmLI3hSBd853p0fw2RkEpufXqYrfZ9sBuGOaw3J4TfmIojk9HiVLg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660762335; a=rsa-sha256; cv=none; b=E0vxSaG8DiV3QnyeSegcqlAgRrD2woQov/60cB+13Zn/XwK2HYT9uNSefYPD9FVFTWHM/v F5G3w2dpmegXHy0XQksX5PLOViDYeNLEO1TUsNeGSzaNpHFzs0aj0GjfbQ3CYXaikLWkiZ F69HKIkKTMeUcQh3QvI5u10GCpiK57IycaAiiMAniA7e3qoFW3gY0ZCx3mJRKhXobVLKmg VfQFLX/MbA/0LgaLxU9HV1Kb8SNn2YbypLEnDLVppDS+gsA/VxDYP+L4Tlscjrut6H5Y61 DHd5iYplMyTz6ewIxOGTQ0u9aDp3u3FUWzOT7IAvz2H7GgS3kc+dZ0WLI6EEHQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=160f01f09f4b5a50cd752fe1d55a83f5f2c9f9fc commit 160f01f09f4b5a50cd752fe1d55a83f5f2c9f9fc Author: Gleb Smirnoff AuthorDate: 2022-08-17 18:50:31 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-17 18:50:31 +0000 ip_reass: use callout(9) directly instead of pr_slowtimo Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D36236 --- sys/netinet/in_proto.c | 1 - sys/netinet/ip_input.c | 20 ---------------- sys/netinet/ip_reass.c | 65 ++++++++++++++++++++++++++++++++------------------ sys/netinet/ip_var.h | 1 - 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index b589441b20d3..615b4f1a4080 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -113,7 +113,6 @@ struct protosw inetsw[] = { .pr_domain = &inetdomain, .pr_protocol = IPPROTO_IP, .pr_flags = PR_CAPATTACH, - .pr_slowtimo = ip_slowtimo, .pr_drain = ip_drain, .pr_usrreqs = &nousrreqs }, diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 7fdabf24b2a7..ca451ef48649 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -102,7 +102,6 @@ CTASSERT(sizeof(struct ip) == 20); /* IP reassembly functions are defined in ip_reass.c. */ extern void ipreass_init(void); extern void ipreass_drain(void); -extern void ipreass_slowtimo(void); #ifdef VIMAGE extern void ipreass_destroy(void); #endif @@ -846,25 +845,6 @@ bad: m_freem(m); } -/* - * IP timer processing; - * if a timer expires on a reassembly - * queue, discard it. - */ -void -ip_slowtimo(void) -{ - VNET_ITERATOR_DECL(vnet_iter); - - VNET_LIST_RLOCK_NOSLEEP(); - VNET_FOREACH(vnet_iter) { - CURVNET_SET(vnet_iter); - ipreass_slowtimo(); - CURVNET_RESTORE(); - } - VNET_LIST_RUNLOCK_NOSLEEP(); -} - void ip_drain(void) { diff --git a/sys/netinet/ip_reass.c b/sys/netinet/ip_reass.c index db32e6a312f2..b436d6282206 100644 --- a/sys/netinet/ip_reass.c +++ b/sys/netinet/ip_reass.c @@ -93,7 +93,6 @@ VNET_DEFINE_STATIC(int, ipreass_maxbucketsize); void ipreass_init(void); void ipreass_drain(void); -void ipreass_slowtimo(void); #ifdef VIMAGE void ipreass_destroy(void); #endif @@ -556,6 +555,48 @@ done: #undef GETIP } +/* + * If a timer expires on a reassembly queue, discard it. + */ +static struct callout ipreass_callout; +static void +ipreass_slowtimo(void *arg __unused) +{ + VNET_ITERATOR_DECL(vnet_iter); + struct ipq *fp, *tmp; + + if (atomic_load_int(&nfrags) == 0) + return; + + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + for (int i = 0; i < IPREASS_NHASH; i++) { + if (TAILQ_EMPTY(&V_ipq[i].head)) + continue; + IPQ_LOCK(i); + TAILQ_FOREACH_SAFE(fp, &V_ipq[i].head, ipq_list, tmp) + if (--fp->ipq_ttl == 0) + ipq_timeout(&V_ipq[i], fp); + IPQ_UNLOCK(i); + } + CURVNET_RESTORE(); + } + VNET_LIST_RUNLOCK_NOSLEEP(); + + callout_reset_sbt(&ipreass_callout, SBT_1MS * 500, SBT_1MS * 10, + ipreass_slowtimo, NULL, 0); +} + +static void +ipreass_timer_init(void *arg __unused) +{ + + callout_init(&ipreass_callout, 1); + callout_reset_sbt(&ipreass_callout, SBT_1MS * 500, SBT_1MS * 10, + ipreass_slowtimo, NULL, 0); +} +SYSINIT(ipreass, SI_SUB_VNET_DONE, SI_ORDER_ANY, ipreass_timer_init, NULL); + /* * Initialize IP reassembly structures. */ @@ -585,28 +626,6 @@ ipreass_init(void) } } -/* - * If a timer expires on a reassembly queue, discard it. - */ -void -ipreass_slowtimo(void) -{ - struct ipq *fp, *tmp; - - if (atomic_load_int(&nfrags) == 0) - return; - - for (int i = 0; i < IPREASS_NHASH; i++) { - if (TAILQ_EMPTY(&V_ipq[i].head)) - continue; - IPQ_LOCK(i); - TAILQ_FOREACH_SAFE(fp, &V_ipq[i].head, ipq_list, tmp) - if (--fp->ipq_ttl == 0) - ipq_timeout(&V_ipq[i], fp); - IPQ_UNLOCK(i); - } -} - /* * Drain off all datagram fragments. */ diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index ce0efcfead1b..8711e0291379 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -228,7 +228,6 @@ struct mbuf * ip_reass(struct mbuf *); void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *, struct mbuf *); -void ip_slowtimo(void); void ip_fillid(struct ip *); int rip_ctloutput(struct socket *, struct sockopt *); void rip_ctlinput(int, struct sockaddr *, void *);