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

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