Commit 656e8fdd authored by Eric Dumazet's avatar Eric Dumazet Committed by Stephen Hemminger

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: default avatarEric Dumazet <edumazet@google.com>
parent 38a7f268
...@@ -1893,8 +1893,8 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r, ...@@ -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 */ /* workaround for older kernels with less fields */
if (len < sizeof(*info)) { if (len < sizeof(*info)) {
info = alloca(sizeof(*info)); info = alloca(sizeof(*info));
memset(info, 0, sizeof(*info));
memcpy(info, RTA_DATA(tb[INET_DIAG_INFO]), len); memcpy(info, RTA_DATA(tb[INET_DIAG_INFO]), len);
memset((char *)info + len, 0, sizeof(*info) - len);
} else } else
info = RTA_DATA(tb[INET_DIAG_INFO]); info = RTA_DATA(tb[INET_DIAG_INFO]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment