From: Eric Dumazet Date: Wed, 6 May 2015 18:33:23 +0000 (-0700) Subject: ss: small optim in tcp_show_info() X-Git-Tag: v4.1.0~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=656e8fdd2dc00c79602f5bb8567e7771d21fb692;p=thirdparty%2Fiproute2.git ss: small optim in tcp_show_info() 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 --- diff --git a/misc/ss.c b/misc/ss.c index 46dbb39ab..68961fcc9 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]);