netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Hangbin Liu <haliu@redhat.com>,
	netdev@vger.kernel.org, Michal Kubecek <mkubecek@suse.cz>,
	Hangbin Liu <liuhangbin@gmail.com>
Subject: Re: [PATCHv4 iproute2 2/2] lib/libnetlink: update rtnl_talk to support malloc buff at run time
Date: Mon, 9 Oct 2017 22:25:25 +0200	[thread overview]
Message-ID: <20171009202525.GR32278@orbyte.nwl.cc> (raw)
In-Reply-To: <20171002103708.0572704b@xeon-e3>

Hi Stephen,

On Mon, Oct 02, 2017 at 10:37:08AM -0700, Stephen Hemminger wrote:
> On Thu, 28 Sep 2017 21:33:46 +0800
> Hangbin Liu <haliu@redhat.com> wrote:
> 
> > From: Hangbin Liu <liuhangbin@gmail.com>
> > 
> > This is an update for 460c03f3f3cc ("iplink: double the buffer size also in
> > iplink_get()"). After update, we will not need to double the buffer size
> > every time when VFs number increased.
> > 
> > With call like rtnl_talk(&rth, &req.n, NULL, 0), we can simply remove the
> > length parameter.
> > 
> > With call like rtnl_talk(&rth, nlh, nlh, sizeof(req), I add a new variable
> > answer to avoid overwrite data in nlh, because it may has more info after
> > nlh. also this will avoid nlh buffer not enough issue.
> > 
> > We need to free answer after using.
> > 
> > Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> 
> Most of the uses of rtnl_talk() don't need to this peek and dynamic sizing.
> Can only those places that need that be targeted?

We could probably do that, by having a buffer on stack in __rtnl_talk()
which will be used instead of the allocated one if 'answer' is NULL. Or
maybe even introduce a dedicated API call for the dynamically allocated
receive buffer. But I really doubt that's feasible: AFAICT, that stack
buffer still needs to be reasonably sized since the reply might be
larger than the request (reusing the request buffer would be the most
simple way to tackle this), also there is support for extack which may
bloat the response to arbitrary size. Hangbin has shown in his benchmark
that the overhead of the second syscall is negligible, so why care about
that and increase code complexity even further?

Not saying it's not possible, but I just doubt it's worth the effort.

Cheers, Phil

  reply	other threads:[~2017-10-09 20:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 13:33 [PATCHv4 iproute2 0/2] libnetlink: malloc correct buff at run time Hangbin Liu
2017-09-28 13:33 ` [PATCHv4 iproute2 1/2] lib/libnetlink: re malloc buff if size is not enough Hangbin Liu
2017-09-29 12:55   ` Michal Kubecek
2017-09-29 17:54   ` Stephen Hemminger
2017-09-29 18:20     ` Michal Kubecek
2017-09-30 13:54     ` Hangbin Liu
2017-09-28 13:33 ` [PATCHv4 iproute2 2/2] lib/libnetlink: update rtnl_talk to support malloc buff at run time Hangbin Liu
2017-09-29 13:06   ` Michal Kubecek
2017-10-02 17:37   ` Stephen Hemminger
2017-10-09 20:25     ` Phil Sutter [this message]
2017-10-10  6:41       ` Michal Kubecek
2017-10-10 16:47         ` Stephen Hemminger
2017-10-11 10:40           ` Hangbin Liu
2017-10-11 11:10           ` Phil Sutter
2017-10-11 14:35             ` David Ahern
2017-10-12 16:07             ` Stephen Hemminger
2017-10-13 10:31               ` Phil Sutter
2017-10-25 10:45   ` Stephen Hemminger
2017-10-25 13:16     ` Hangbin Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171009202525.GR32278@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=haliu@redhat.com \
    --cc=liuhangbin@gmail.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).