Blame SOURCES/0001-linktype-add-netlink-link-dlt-type.patch

6730c1
From 23d2673796e60c7fea6ba218eb084cbd59e7271b Mon Sep 17 00:00:00 2001
6730c1
From: Daniel Borkmann <dborkman@redhat.com>
6730c1
Date: Mon, 18 Nov 2013 15:39:37 -0800
6730c1
Subject: [PATCH] linktype: add netlink link/dlt type
6730c1
6730c1
With Linux 3.11, we have the possibility to debug local netlink traffic
6730c1
[1] i.e.  the workflow looks like this:
6730c1
6730c1
Setup:
6730c1
  modprobe nlmon
6730c1
  ip link add type nlmon
6730c1
  ip link set nlmon0 up
6730c1
6730c1
Capture:
6730c1
  tcpdump -i nlmon0 ...
6730c1
6730c1
Teardown:
6730c1
  ip link set nlmon0 down
6730c1
  ip link del dev nlmon0
6730c1
  rmmod nlmon
6730c1
6730c1
For pcap interoperability, introduce a common link type for netlink
6730c1
captures.
6730c1
---
6730c1
 pcap-common.c |  7 ++++++-
6730c1
 pcap-linux.c  | 13 +++++++++++++
6730c1
 pcap/bpf.h    |  7 ++++++-
6730c1
 3 files changed, 25 insertions(+), 2 deletions(-)
6730c1
6730c1
diff --git a/pcap-common.c b/pcap-common.c
6730c1
index 6175a5a..f26d22e 100644
6730c1
--- a/pcap-common.c
6730c1
+++ b/pcap-common.c
6730c1
@@ -932,7 +932,12 @@
6730c1
  */
6730c1
 #define LINKTYPE_WIRESHARK_UPPER_PDU	252
6730c1
 
6730c1
-#define LINKTYPE_MATCHING_MAX	252		/* highest value in the "matching" range */
6730c1
+/*
6730c1
+ * Link-layer header type for the netlink protocol (nlmon devices).
6730c1
+ */
6730c1
+#define LINKTYPE_NETLINK		253
6730c1
+
6730c1
+#define LINKTYPE_MATCHING_MAX	253		/* highest value in the "matching" range */
6730c1
 
6730c1
 static struct linktype_map {
6730c1
 	int	dlt;
6730c1
diff --git a/pcap-linux.c b/pcap-linux.c
6730c1
index e817382..0651522 100644
6730c1
--- a/pcap-linux.c
6730c1
+++ b/pcap-linux.c
6730c1
@@ -2972,6 +2972,19 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
6730c1
                handle->linktype =  DLT_IEEE802_15_4_NOFCS;
6730c1
                break;
6730c1
 
6730c1
+#ifndef ARPHRD_NETLINK
6730c1
+#define ARPHRD_NETLINK	824
6730c1
+#endif
6730c1
+	case ARPHRD_NETLINK:
6730c1
+		handle->linktype = DLT_NETLINK;
6730c1
+		/*
6730c1
+		 * We need to use cooked mode, so that in sll_protocol we
6730c1
+		 * pick up the netlink protocol type such as NETLINK_ROUTE,
6730c1
+		 * NETLINK_GENERIC, NETLINK_FIB_LOOKUP, etc.
6730c1
+		 */
6730c1
+		handle->cooked = 1;
6730c1
+		break;
6730c1
+
6730c1
 	default:
6730c1
 		handle->linktype = -1;
6730c1
 		break;
6730c1
diff --git a/pcap/bpf.h b/pcap/bpf.h
6730c1
index ad36eb6..8286ed5 100644
6730c1
--- a/pcap/bpf.h
6730c1
+++ b/pcap/bpf.h
6730c1
@@ -1224,7 +1224,12 @@ struct bpf_program {
6730c1
  */
6730c1
 #define DLT_WIRESHARK_UPPER_PDU	252
6730c1
 
6730c1
-#define DLT_MATCHING_MAX	252	/* highest value in the "matching" range */
6730c1
+/*
6730c1
+ * DLT type for the netlink protocol (nlmon devices).
6730c1
+ */
6730c1
+#define DLT_NETLINK		253
6730c1
+
6730c1
+#define DLT_MATCHING_MAX	253	/* highest value in the "matching" range */
6730c1
 
6730c1
 /*
6730c1
  * DLT and savefile link type values are split into a class and
6730c1
-- 
6730c1
2.4.3
6730c1