From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38EF0C282C2 for ; Wed, 13 Feb 2019 17:46:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1571F222B1 for ; Wed, 13 Feb 2019 17:46:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404532AbfBMRqZ (ORCPT ); Wed, 13 Feb 2019 12:46:25 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:34322 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729117AbfBMRqZ (ORCPT ); Wed, 13 Feb 2019 12:46:25 -0500 Received: from n0-1 by orbyte.nwl.cc with local (Exim 4.91) (envelope-from ) id 1gtyc2-0007Wb-JQ; Wed, 13 Feb 2019 18:46:22 +0100 Date: Wed, 13 Feb 2019 18:46:22 +0100 From: Phil Sutter To: Eric Dumazet Cc: David Ahern , Stephen Hemminger , netdev , Eric Dumazet , Hangbin Liu Subject: Re: [PATCH iproute2] lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() Message-ID: <20190213174622.GD19329@orbyte.nwl.cc> Mail-Followup-To: Phil Sutter , Eric Dumazet , David Ahern , Stephen Hemminger , netdev , Eric Dumazet , Hangbin Liu References: <20190213015841.140383-1-edumazet@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190213015841.140383-1-edumazet@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Eric, On Tue, Feb 12, 2019 at 05:58:41PM -0800, Eric Dumazet wrote: > In the past, we tried to increase the buffer size up to 32 KB in order > to reduce number of syscalls per dump. > > Commit 2d34851cd341 ("lib/libnetlink: re malloc buff if size is not enough") > brought the size back to 4KB because the kernel can not know the application > is ready to receive bigger requests. > > See kernel commits 9063e21fb026 ("netlink: autosize skb lengthes") and > d35c99ff77ec ("netlink: do not enter direct reclaim from netlink_dump()") > for more details. Wouldn't it be better if the kernel recognized MSG_TRUNC and allocated a buffer large enough to hold the full message in that case? I have no idea how hard that would be to implement, but calling recvmsg() with MSG_TRUNC set and not getting the full message length in return is not quite what one expects after reading recvmsg(2). Cheers, Phil