From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 5D98A5A027B for ; Mon, 24 Jul 2023 08:09:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1690178979; bh=Tby9Cr3NIzrxQF1Ococ7PYNCIJlSFZ/Vhn1Uorh48Vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g62QhEMuZICkNl0tApxXZLc96xW6WDFPf5XUtdr85UZDHmCqE7/M3sbOfwXqQS1f3 sw05MQvze2uWW7grdHMLvSrugK/XNtiWDwIWD52cOv8U8Kh/ePZwC+oaiF8N0b/rk6 dF6XLDRoPtqQNOrE3En2aLpZwoKVMCczrZxOHwv8= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4R8V9v5D44z4wyq; Mon, 24 Jul 2023 16:09:39 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 11/17] netlink: Clearer reasoning about the netlink response buffer size Date: Mon, 24 Jul 2023 16:09:30 +1000 Message-ID: <20230724060936.952659-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724060936.952659-1-david@gibson.dropbear.id.au> References: <20230724060936.952659-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XI4TZHUAGUZ56NLBTYVMW6ZDA232IFNS X-Message-ID-Hash: XI4TZHUAGUZ56NLBTYVMW6ZDA232IFNS X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Currently we set NLBUFSIZ large enough for 8192 netlink headers (128kiB in total), and reference netlink(7). However netlink(7) says nothing about reponse buffer sizes, and the documents which do reference 8192 *bytes* not 8192 headers. Update NLBUFSIZ to 64kiB with a more detailed rationale. Link: https://bugs.passt.top/show_bug.cgi?id=67 Signed-off-by: David Gibson --- netlink.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netlink.c b/netlink.c index cdd65c0..d553ddd 100644 --- a/netlink.c +++ b/netlink.c @@ -35,7 +35,14 @@ #include "log.h" #include "netlink.h" -#define NLBUFSIZ (8192 * sizeof(struct nlmsghdr)) /* See netlink(7) */ +/* Netlink expects a buffer of at least 8kiB or the system page size, + * whichever is larger. 32kiB is recommended for more efficient. + * Since the largest page size on any remotely common Linux setup is + * 64kiB (ppc64), that should cover it. + * + * https://www.kernel.org/doc/html/next/userspace-api/netlink/intro.html#buffer-sizing + */ +#define NLBUFSIZ 65536 /* Socket in init, in target namespace, sequence (just needs to be monotonic) */ int nl_sock = -1; -- 2.41.0