netlink: adjust decode_nlmsgerr for extended ACK reporting

Extended ACK reporting introduced by linux kernel commit
v4.11-rc5-1382-g2d4bc93.

* netlink.h (NLM_F_CAPPED): New macro.
* netlink.c (decode_payload): Pass
nlmsghdr->nlmsg_flags & NLM_F_CAPPED to decode_nlmsgerr.
(decode_nlmsgerr): Adjust the length pass to
decode_nlmsghdr_with_payload.
This commit is contained in:
JingPiao Chen 2017-07-19 17:17:36 +08:00 committed by Dmitry V. Levin
parent 9ec9ad9c0f
commit 9c9e061536
2 changed files with 14 additions and 3 deletions

View File

@ -297,7 +297,8 @@ decode_nlmsgerr(struct tcb *const tcp,
const int fd,
const int family,
kernel_ulong_t addr,
kernel_ulong_t len)
kernel_ulong_t len,
const bool capped)
{
struct nlmsgerr err;
@ -322,8 +323,13 @@ decode_nlmsgerr(struct tcb *const tcp,
if (len) {
tprints(", msg=");
if (fetch_nlmsghdr(tcp, &err.msg, addr, len)) {
unsigned int payload =
capped ? sizeof(err.msg) : err.msg.nlmsg_len;
if (payload > len)
payload = len;
decode_nlmsghdr_with_payload(tcp, fd, family,
&err.msg, addr, len);
&err.msg, addr, payload);
}
}
@ -344,7 +350,8 @@ decode_payload(struct tcb *const tcp,
const kernel_ulong_t len)
{
if (nlmsghdr->nlmsg_type == NLMSG_ERROR) {
decode_nlmsgerr(tcp, fd, family, addr, len);
decode_nlmsgerr(tcp, fd, family, addr, len,
nlmsghdr->nlmsg_flags & NLM_F_CAPPED);
return;
}

View File

@ -36,6 +36,10 @@
# define NETLINK_SOCK_DIAG 4
#endif
#ifndef NLM_F_CAPPED
# define NLM_F_CAPPED 0x100
#endif
#undef NLMSG_HDRLEN
#define NLMSG_HDRLEN ((unsigned int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))