From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 4DE0B5A027B for ; Thu, 3 Aug 2023 09:20:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1691047199; bh=0LAOq+0LRvLiTK836L/yZq42SZiLBNOS3rstr/MZOC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QX61m0NVNALeUMh1LwWpkw36GiT0emHrHNT1d1pZ50e3uFGqQDqaw7MfkS2lQnuWP hQQWWb4ICgi7aGvI6e98M/6/fipAnx/25Jh9bsDpVgN4cpttGJBM+Hweldtmzqi98M octgJ0X70bdhVXvdM9a8bdO2Q7eMn5F4RNAFGJcc= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RGgGR6WWqz4wyN; Thu, 3 Aug 2023 17:19:59 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 11/17] netlink: Clearer reasoning about the netlink response buffer size Date: Thu, 3 Aug 2023 17:19:50 +1000 Message-ID: <20230803071956.3198452-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803071956.3198452-1-david@gibson.dropbear.id.au> References: <20230803071956.3198452-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FVA34TXDGBXOI4D7ZAC4ZTTBWWHG4PTD X-Message-ID-Hash: FVA34TXDGBXOI4D7ZAC4ZTTBWWHG4PTD 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 9ff93a4..d5c9439 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