From 930a87b5325c1fb1ee3ad7d42213bc795be87adf Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 13 Aug 2014 17:34:48 +0200 Subject: dissector: check for correct netlink linktype It's supposed to be LINKTYPE_NETLINK, not AF_NETLINK as otherwise the pkt_type fixup cannot be done correctly. Signed-off-by: Daniel Borkmann Signed-off-by: Tobias Klauser --- dissector.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'dissector.h') diff --git a/dissector.h b/dissector.h index c78ea48..8cb4234 100644 --- a/dissector.h +++ b/dissector.h @@ -16,6 +16,7 @@ #include "ring.h" #include "tprintf.h" +#include "linktype.h" #define PRINT_NORM 0 #define PRINT_LESS 1 @@ -56,6 +57,7 @@ static inline void __show_frame_hdr(uint8_t *packet, size_t len, int linktype, char tmp[IFNAMSIZ]; union tpacket_uhdr hdr; uint8_t pkttype = s_ll->sll_pkttype; + bool is_nl; if (mode == PRINT_NONE) return; @@ -66,7 +68,8 @@ static inline void __show_frame_hdr(uint8_t *packet, size_t len, int linktype, * it originally was set in the kernel. Thus, use nlmsghdr->nlmsg_pid to * restore the type. */ - if (linktype == AF_NETLINK && len >= sizeof(struct nlmsghdr)) { + is_nl = (linktype == LINKTYPE_NETLINK && len >= sizeof(struct nlmsghdr)); + if (is_nl && pkttype == PACKET_OUTGOING) { struct nlmsghdr *hdr = (struct nlmsghdr *) packet; pkttype = hdr->nlmsg_pid == 0 ? PACKET_KERNEL : PACKET_USER; } -- cgit v1.2.3-54-g00ecf