Re: [PATCHv3 iproute2 1/2] lib/libnetlink: re malloc buff if size is not enough

2017-09-28 Thread Hangbin Liu
Hi Michal, On Thu, Sep 21, 2017 at 09:34:20AM +0200, Michal Kubecek wrote: > I will have to check but IIRC it might be possible to use zero length > for the peek to only check the length which could help you to avoid both > the reallocation and copying the same data from kernel to userspace > twic

Re: [PATCHv3 iproute2 1/2] lib/libnetlink: re malloc buff if size is not enough

2017-09-21 Thread Michal Kubecek
On Thu, Sep 21, 2017 at 03:20:02PM +0800, Hangbin Liu wrote: > > Or maybe we can set buf_len very small first. Then it will force to realloc at > the second time. And the code would like > > int buf_len = 16; > bufp = realloc(buf, buf_len); > /* check bufp and set msg */ > >

Re: [PATCHv3 iproute2 1/2] lib/libnetlink: re malloc buff if size is not enough

2017-09-21 Thread Hangbin Liu
Hi Stephen, On Wed, Sep 20, 2017 at 09:56:05AM -0700, Stephen Hemminger wrote: > > +realloc: > > + bufp = realloc(buf, buf_len); > > + > > + if (bufp == NULL) { > > Minor personal style issue: > To me, blank lines are like paragraphs in writing. > Code reads better assignment and condition che

Re: [PATCHv3 iproute2 1/2] lib/libnetlink: re malloc buff if size is not enough

2017-09-20 Thread Stephen Hemminger
On Wed, 20 Sep 2017 09:43:39 +0800 Hangbin Liu wrote: Thanks for keeping up on this. > +realloc: > + bufp = realloc(buf, buf_len); > + > + if (bufp == NULL) { Minor personal style issue: To me, blank lines are like paragraphs in writing. Code reads better assignment and condition check

[PATCHv3 iproute2 1/2] lib/libnetlink: re malloc buff if size is not enough

2017-09-19 Thread Hangbin Liu
With commit 72b365e8e0fd ("libnetlink: Double the dump buffer size") we doubled the buffer size to support more VFs. But the VFs number is increasing all the time. Some customers even use more than 200 VFs now. We could not double it everytime when the buffer is not enough. Let's just not hard cod