From nobody Mon Feb 27 10:57:44 2023 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 4PQHX92R4wz3txgq; Mon, 27 Feb 2023 10:57:45 +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 4PQHX91mc7z4HQC; Mon, 27 Feb 2023 10:57:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677495465; 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=JyMpBdDtrpYX4azGtWswKVitvrpZJ8DmjdlglXy93+I=; b=gbGHsXZoaan+iA1CXgBA1qClq/XRLPLHz0oODpAvLiIYUxMaGq/KbvT1ZU2+aG9sqcx1fk tjWnyJLTXTUkDGrbrPde4LNiwtM0wjZEW7cJ76vca644ahkLrxFe8Oss85+4nkmzFcXlix YO2Oj2iiHDa/w9nBHn8CqsxRwpSUX1b6jyWrFEvgENlYkDoMP9Wc3OPcZjrjR/Mo8Ia7oM ZYiJMPj6zCdG7zxw8JArFU4pVyIH6jMlqZ0cIOxoDeVWx80IOeAbxgm6ZfA5KAp9nW7Q0h FqxqKfXjQwR9fHFmOgAlO6rvveHWXrPpyG2LBOoG0ACiolo4TqGRYfJBSpYkPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677495465; 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=JyMpBdDtrpYX4azGtWswKVitvrpZJ8DmjdlglXy93+I=; b=YQGeoF9wD31MVi8iBrmgQa2F7eHkufRBHm/gtfyuhb5bvHispxSUU89rOo/j1OxFKXE7uY Kv8uvpAW/ZZzLDYDKXdV9kWUUk/0jmJ5aa+p98gWUnbuURqwHTzMkfC7M2C6QwEzxVFI+t QUPxhQKOxOJ5BTNloAHE7FyOY5qt7jep+5kvWl0D7XbMy9a3Av7oZUk3hMbiDBHV8l3tN0 5U/phtJwnb5itqXeyOLn29OoNfxLjPOyTiduWPgp7fUr0EOi3qTY5Owr39vN8FKA9Qy4aY 5hqN2DgSEbHW4b/LrFfaVzxcCYm6VZkepZFAcaz4xDVILVRQ2LMBG0cElg+hkw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677495465; a=rsa-sha256; cv=none; b=o/Ex9wYkEczp/D/GypIuwX7M5nYa6crXQoLlWqGFmWWrV0JFG7YhH0Y563PSZlaFlR0szV N2Hmx4RAkktsqDW6ewVhI0jq22uA7ep+VJP0jlDdPHnmba7NNoxW5Y8JX73t4qamHHIueN xIZ/9U/+l9Y3j0do9APNXdWEZeakUdJynvLJwPkIRF4a0vE2F0LMQx2BAnmchHUBPIJLKr s8J6P3nR7yifMPSMi6mBP6tvnFDogtbxNq3zKnaPdH/DLqD7COYWaLUiNj1iQwwulbTDcr 2tp3LlKMzQ7h8I6eyHihzejX6OXlH+om7h+kvEkxzZDClxuWQYbj5EYqIISoYQ== 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 4PQHX90J28zNrh; Mon, 27 Feb 2023 10:57:45 +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 31RAviLB008738; Mon, 27 Feb 2023 10:57:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31RAviHY008737; Mon, 27 Feb 2023 10:57:44 GMT (envelope-from git) Date: Mon, 27 Feb 2023 10:57:44 GMT Message-Id: <202302271057.31RAviHY008737@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: 28a5d88f7091 - main - netlink: make the maximum allowed netlink socket buffer runtime tunable. 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28a5d88f7091d1fc72f4f1bd8562d3c8b15883f5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=28a5d88f7091d1fc72f4f1bd8562d3c8b15883f5 commit 28a5d88f7091d1fc72f4f1bd8562d3c8b15883f5 Author: Alexander V. Chernikov AuthorDate: 2023-02-27 10:44:54 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-02-27 10:48:31 +0000 netlink: make the maximum allowed netlink socket buffer runtime tunable. Dumping large routng tables (>1M paths with multipath) require the socket buffer which is larger than the currently defined limit. Allow the limit to be set in runtime, similar to kern.ipc.maxsockbuf. Reported by: Marek Zarychta MFC after: 1 day --- share/man/man4/netlink.4 | 6 ++++++ sys/netlink/netlink_domain.c | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/share/man/man4/netlink.4 b/share/man/man4/netlink.4 index fdcc823b01a6..ece4892f481e 100644 --- a/share/man/man4/netlink.4 +++ b/share/man/man4/netlink.4 @@ -280,6 +280,12 @@ Default receive buffer for the netlink socket. Note that the socket recvspace has to be least as long as the longest message that can be received from this socket. .El +.Bl -tag -width indent +.It Va net.netlink.nl_maxsockbuf +Maximum receive buffer for the netlink socket that can be set via +.Dv SO_RCVBUF +socket option. +.El .Sh DEBUGGING Netlink implements per-functional-unit debugging, with different severities controllable via the diff --git a/sys/netlink/netlink_domain.c b/sys/netlink/netlink_domain.c index 5f9120f14308..01023f7244b6 100644 --- a/sys/netlink/netlink_domain.c +++ b/sys/netlink/netlink_domain.c @@ -77,6 +77,11 @@ SYSCTL_ULONG(_net_netlink, OID_AUTO, recvspace, CTLFLAG_RW, &nl_recvspace, 0, extern u_long sb_max_adj; static u_long nl_maxsockbuf = 512 * 1024 * 1024; /* 512M, XXX: init based on physmem */ +static int sysctl_handle_nl_maxsockbuf(SYSCTL_HANDLER_ARGS); +SYSCTL_OID(_net_netlink, OID_AUTO, nl_maxsockbuf, + CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, &nl_maxsockbuf, 0, + sysctl_handle_nl_maxsockbuf, "LU", + "Maximum Netlink socket buffer size"); uint32_t nlp_get_pid(const struct nlpcb *nlp) @@ -675,6 +680,22 @@ nl_ctloutput(struct socket *so, struct sockopt *sopt) return (error); } +static int +sysctl_handle_nl_maxsockbuf(SYSCTL_HANDLER_ARGS) +{ + int error = 0; + u_long tmp_maxsockbuf = nl_maxsockbuf; + + error = sysctl_handle_long(oidp, &tmp_maxsockbuf, arg2, req); + if (error || !req->newptr) + return (error); + if (tmp_maxsockbuf < MSIZE + MCLBYTES) + return (EINVAL); + nl_maxsockbuf = tmp_maxsockbuf; + + return (0); +} + static int nl_setsbopt(struct socket *so, struct sockopt *sopt) {