* [PATCH iproute2] ss: small optim in tcp_show_info()
@ 2015-05-06 18:33 Eric Dumazet
2015-05-11 16:16 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2015-05-06 18:33 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
Kernel can give us smaller tcp_info than our.
We copy the kernel provided structure and fill with 0
the remaining part.
Lets clear only the missing part to save some cycles, as we intend to
slightly increase tcp_info size in the future.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
diff --git a/misc/ss.c b/misc/ss.c
index 46dbb39..68961fc 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1893,8 +1893,8 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
/* workaround for older kernels with less fields */
if (len < sizeof(*info)) {
info = alloca(sizeof(*info));
- memset(info, 0, sizeof(*info));
memcpy(info, RTA_DATA(tb[INET_DIAG_INFO]), len);
+ memset((char *)info + len, 0, sizeof(*info) - len);
} else
info = RTA_DATA(tb[INET_DIAG_INFO]);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] ss: small optim in tcp_show_info()
2015-05-06 18:33 [PATCH iproute2] ss: small optim in tcp_show_info() Eric Dumazet
@ 2015-05-11 16:16 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2015-05-11 16:16 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
On Wed, 06 May 2015 11:33:23 -0700
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> Kernel can give us smaller tcp_info than our.
>
> We copy the kernel provided structure and fill with 0
> the remaining part.
>
> Lets clear only the missing part to save some cycles, as we intend to
> slightly increase tcp_info size in the future.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, I don't think other people will have enough sockets to notice the difference :-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-11 16:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 18:33 [PATCH iproute2] ss: small optim in tcp_show_info() Eric Dumazet
2015-05-11 16:16 ` Stephen Hemminger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.