The size of mmaped netlink packet is equals to its frame size, so may be different from actual size. It can be checked by the next nlmsg len is 0 or not, and trim it in that case.
Signed-off-by: Ken-ichirou MATSUZAWA <[email protected]> --- proto_nlmsg.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/proto_nlmsg.c b/proto_nlmsg.c index 76253ca..89e93a7 100644 --- a/proto_nlmsg.c +++ b/proto_nlmsg.c @@ -751,18 +751,29 @@ static void nlmsg_print(uint16_t family, struct nlmsghdr *hdr) static void nlmsg(struct pkt_buff *pkt) { struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN); + unsigned int trim_len = pkt_len(pkt); while (hdr) { + trim_len -= hdr->nlmsg_len; nlmsg_print(ntohs(pkt->sll->sll_protocol), hdr); if (!pkt_pull(pkt, NLMSG_ALIGN(hdr->nlmsg_len) - NLMSG_HDRLEN)) break; hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN); - if (hdr && hdr->nlmsg_type != NLMSG_DONE && - (hdr->nlmsg_flags & NLM_F_MULTI)) + if (hdr == NULL) + break; + if (hdr->nlmsg_len == 0) + break; + + if (hdr->nlmsg_type != NLMSG_DONE && + (hdr->nlmsg_flags & NLM_F_MULTI)) tprintf("\n"); } + + /* is a mmaped pkt? */ + if (hdr && hdr->nlmsg_len == 0) + pkt_trim(pkt, trim_len); } static void nlmsg_less(struct pkt_buff *pkt) -- 2.1.4 -- You received this message because you are subscribed to the Google Groups "netsniff-ng" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
