dissector: Restore paket type if capturing from nlmon device
commitedca6174b09d14c75a7bbc25af122a37ff16ecea
authorTobias Klauser <tklauser@distanz.ch>
Wed, 4 Jun 2014 08:52:53 +0000 (4 10:52 +0200)
committerTobias Klauser <tklauser@distanz.ch>
Wed, 4 Jun 2014 08:52:53 +0000 (4 10:52 +0200)
treea378bbdf9792b774a8d61885569c1df273088204
parent96cbba90a5ccf29c2124b8d4d46ed534861ccf44
dissector: Restore paket type if capturing from nlmon device

The kernel sets the skb pkttype to PACKET_OUTGOING for all packets being
sent through dev_queue_xmit_nit(). However, if capturing packets from an
nlmon device, this causes the information on whether the netlink packet
was sent to kernel- or userspace (PACKET_KERNEL/PACKET_USER) to be
overwritten.

A previous attempt by Daniel Borkmann to fix this in kernel space [1] by
not overwriting the packet type for netlink packets was not regarded as
the proper solution.

[1] http://patchwork.ozlabs.org/patch/338612/

Thus, attempt to fix this in userspace by looking at the pid field of
the netlink packet, which is always 0 for messages to kernel space [2].

[2] http://www.carisma.slowglass.com/~tgr/libnl/doc/core.html#core_netlink_fundamentals

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
dissector.h
netsniff-ng.c