From nobody Mon Feb 19 07:52:47 2024 X-Original-To: dev-commits-src-main@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 4TdZX00Jm8z5B0x1; Mon, 19 Feb 2024 07:52:48 +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 4TdZWz6yJcz4GDc; Mon, 19 Feb 2024 07:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708329168; 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=4NxnXhizWRY1FEoyHff1ZAWvdbigMjwEU8pPhTB7LNc=; b=D8ytJV7+7B+LxCJ+H4XqURQOFx+bjrrN9GHfU+MaUuvIU8pZ1ouYIP5sa4s/V9yH6xRnLr G3HeJyVTiQfc4ySt+0aCdNT9wgV67QWHS6OgzWOeghsmNFfsJ+K4FMu3FzlcPIwvKBXKhS B1qlShqEI2GnHZbH+0XzAq4awN1frKtA2/esN/p/plsdbtXeJ9Hm7gs/60SnEgjuofuqj0 QoUPdyOqsFOkzDnpwlVHjWOVhvQJT/pQk3Ha4FIO55wKxOhcm75WQuzKE0zBo5AuQ8/Qy/ kW1o56XQc7Q5+esekYEClPN8gKvzd2nnaD/y32UEo62Afw3DrbOHydVLD4Pq9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708329168; 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=4NxnXhizWRY1FEoyHff1ZAWvdbigMjwEU8pPhTB7LNc=; b=REQynZNVM1e3x9ayUsZLdBaeilupbSHAnMUmk9TB9+uA0uFnA+vNXvNVBHG5OFS3+OdPf7 lZlGg41IP8eZ1ZEtfQdlOrniu89tIzA7Dg/dB3uZBIL9nimtrnjWRWLfz3SXWhYY7J1aiV O6HMt/3FHpehMOOu7X0Y6n2yU3oxfEg3mHAsN/Bun2T3awWqZYwdGVVdDUaualBuHc3IoG jlrAX+QCHfvynR6msdg+jzMQyxI5w0bHsR/4JXx7sGnNQ1mdGX+Xk/EC2c3LEcIFKtikL0 0ZaWZ9onm1w041OYNPyfTeLauQQEVl8bDqUBUpGAZdIcuFasIZWs6o4rNOgwxA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708329168; a=rsa-sha256; cv=none; b=JdDAP5M2JqRrlBvEDebiAMRajLMzfa6/n1uI71biJ6y/VNqPfR4EGIZQ7Bvut2A5kM93D1 0sb2Vv0jkfObQgi8aPXM3ky2pP3Qi9cHgMV1GP/d+dG0MSJvs+Oqr409qR/sJI4wPcitnE xCOGI9X6VXYJ+zmwWlwrMcrFt8XFRRQcFfwNDAESxQ0PJaoG13hn0WOnsMdYKd2hd3AaBM hamfLnuy2955CoEJaBjybfXXTP0CqR7YKugp23hFEepTl97J1yOoME/y26PLE0SL9tAQjM GK47h4d1GpliAM+onRX53tlC+qQQhdTay+SMAWOTeNXjLu4t5zBZGDeBORgDDQ== 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 4TdZWz60s1zQj5; Mon, 19 Feb 2024 07:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41J7qlSm096842; Mon, 19 Feb 2024 07:52:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41J7qlxV096839; Mon, 19 Feb 2024 07:52:47 GMT (envelope-from git) Date: Mon, 19 Feb 2024 07:52:47 GMT Message-Id: <202402190752.41J7qlxV096839@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 03cc3489a02d - main - ndp(8): increase buffer size in rtsock mode List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 03cc3489a02da0eba3b2737210486723d1072b21 Auto-Submitted: auto-generated The branch main has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=03cc3489a02da0eba3b2737210486723d1072b21 commit 03cc3489a02da0eba3b2737210486723d1072b21 Author: Boris Lytochkin AuthorDate: 2024-02-19 07:44:52 +0000 Commit: Andrey V. Elsukov CommitDate: 2024-02-19 07:44:52 +0000 ndp(8): increase buffer size in rtsock mode On a router with many connected devices (~10k+) `ndp -an` can fail with ENOMEM because of some additional NDP records were added between sysctl() buffer size estimate and data fetch calls. Allocate more space based on size estimate: 1/64 (~2%) of additional space, but not less that 4 m_rtmsg structures. Obtained from: Yandex LLC MFC after: 2 weeks Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D43956 --- usr.sbin/ndp/ndp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 9ade2469742e..9d9ae02dc1e2 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -652,6 +652,12 @@ again:; if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) xo_err(1, "sysctl(PF_ROUTE estimate)"); if (needed > 0) { + /* + * Add ~2% additional space in case some records + * will appear between sysctl() calls. + * Round it up so it can fit 4 additional messages at least. + */ + needed += ((needed >> 6) | (sizeof(m_rtmsg) * 4)); if ((buf = malloc(needed)) == NULL) xo_err(1, "malloc"); if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)