From nobody Wed Mar 01 14:29:43 2023 X-Original-To: dev-commits-src-branches@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 4PRc7q4ykYz3twJL; Wed, 1 Mar 2023 14:29:43 +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 4PRc7q4PDxz3JbN; Wed, 1 Mar 2023 14:29:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677680983; 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=RR7DdxSzI8sA5Q6EpmhZQEkhrEIc4cjAzWYzE++4of8=; b=Nl6BsRtQNw6h5sKX2fYUWK5mVUzBFpKxDsCf1dGPuMtqe4XIjtPx+r1Uu+s/YrzNmTI+Bo pBDxgzeuZ+F9yDN+RvTQlDErkRuz9YrpnymQGHOXtzwVwHAEpsoYuBsjLNsW8RdOvC7NB0 pXVrufzgmKaKadmz+9YygjNyq6GRua4gCNhNQr1GWxq76gyeXVpf1GDqEQc8td64K5p9+Y UrR6DgCO07frHosUewvHyrmFhr7fC2qVBU+vGUX5GOfk9A5rW6qjVOsFg17RkFqnA8O5NA CXL50SSU+b9ObEG2srPjDQMshLTbY2SnhWbiRJduH3QGd80HkYAQm+0O5iPpKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677680983; 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=RR7DdxSzI8sA5Q6EpmhZQEkhrEIc4cjAzWYzE++4of8=; b=i1N5TUVNlvLjuSlq4V1vvYm97jkMI2e6h6+/lx+Ng9w4JRzSzgF45w49C5blukjlxl0d63 0+cAGUwgMhXsE9EE9vK3MGTlRGQbUVnAxkFMxMtudniMJi7vq2PlmyVfJJWUOaCsY4yR0n xMNvYUtUTG7OQUvUWkCc5nAAPfqktqesWWkDN8evBT9GRd3TeVVKuOlzjiFZA2ykG9e+sC 0+3iD8aV6GaTQc7iFOl1pI3/0dz6H7JF0OKEYXb0621Ill+JzAHG4T1hI7H2MtWgnTaskb EzL39AUhrKz80HjVQniHwphqBc9+TzhLe+SKVhkojvr4SEw3QUMh9aPa74ltdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677680983; a=rsa-sha256; cv=none; b=yDy8mTv2dN1YwHXbDAcEQdnkEajPJX2aF7CNJeGv4Gy+/KPZ2iDKH7wJVySufURpuUDj2X 8dwEjruuR847B7AeQ94FPT/w+lMaoGFYfR/BGBbbmQ5l6MiX4Wiv/WRJ2qmjcKXc8N462v L6YfrAwSirgObIYqE7VuWsxVZBmt/G+44EhP4uR8UHgpIYsAJcbDf3K0nkHBlExlUxoNfB vfNW5daZOOQH7dTDodcBGShPWttDvP7tkC4l5XRYTfzh4o3VMwUeSibs+rEC1JVuSaTc9o WBkAFpTdcvl3NY9n/HufRrw8YSIiXePM+EcwwPVhEJzZK77w1N/zf4ShBtABKQ== 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 4PRc7q3SC6zd4b; Wed, 1 Mar 2023 14:29:43 +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 321EThfY088378; Wed, 1 Mar 2023 14:29:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 321EThH4088377; Wed, 1 Mar 2023 14:29:43 GMT (envelope-from git) Date: Wed, 1 Mar 2023 14:29:43 GMT Message-Id: <202303011429.321EThH4088377@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: b656161b84dc - stable/13 - netlink: make the maximum allowed netlink socket buffer runtime tunable. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: b656161b84dce0322ab00d7958267fa47cda6318 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=b656161b84dce0322ab00d7958267fa47cda6318 commit b656161b84dce0322ab00d7958267fa47cda6318 Author: Alexander V. Chernikov AuthorDate: 2023-02-27 10:44:54 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-03-01 14:28:47 +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 (cherry picked from commit 28a5d88f7091d1fc72f4f1bd8562d3c8b15883f5) --- share/man/man4/netlink.4 | 6 ++++++ sys/kern/uipc_socket.c | 3 ++- sys/netlink/netlink_domain.c | 25 ++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/share/man/man4/netlink.4 b/share/man/man4/netlink.4 index a5cde2852158..e1a0c4b12933 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/kern/uipc_socket.c b/sys/kern/uipc_socket.c index fdf718de2483..5b1e572d786f 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2976,12 +2976,13 @@ sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen) return (0); } +u_long nl_maxsockbuf = 512 * 1024 * 1024; /* 512M, XXX: init based on physmem */ + u_long sogetmaxbuf(struct socket *so) { if (so->so_proto->pr_domain->dom_family != PF_NETLINK) return (sb_max); - u_long nl_maxsockbuf = 512 * 1024 * 1024; /* 512M, XXX: init based on physmem */ return ((priv_check(curthread, PRIV_NET_ROUTE) == 0) ? nl_maxsockbuf : sb_max); } diff --git a/sys/netlink/netlink_domain.c b/sys/netlink/netlink_domain.c index c451274b1e63..348788434175 100644 --- a/sys/netlink/netlink_domain.c +++ b/sys/netlink/netlink_domain.c @@ -76,9 +76,12 @@ SYSCTL_ULONG(_net_netlink, OID_AUTO, recvspace, CTLFLAG_RW, &nl_recvspace, 0, "Default netlink socket receive space"); extern u_long sb_max_adj; -#if 0 -static u_long nl_maxsockbuf = 512 * 1024 * 1024; /* 512M, XXX: init based on physmem */ -#endif +extern u_long nl_maxsockbuf; +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) @@ -673,6 +676,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); +} + #if 0 static int nl_setsbopt(struct socket *so, struct sockopt *sopt)