]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ss: small optim in tcp_show_info()
authorEric Dumazet <edumazet@google.com>
Wed, 6 May 2015 18:33:23 +0000 (11:33 -0700)
committerStephen Hemminger <shemming@brocade.com>
Mon, 11 May 2015 16:15:08 +0000 (09:15 -0700)
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>
misc/ss.c

index 46dbb39aba87157a806650d6a2973f43ddee4fb2..68961fcc92f8a6ad4ab40e0ecd2dbe4049c78093 100644 (file)
--- 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]);