From 84a2398d1634ffe671d4a6511676802b762d6cd3 Mon Sep 17 00:00:00 2001
From: Jesse Gross <jesse@nicira.com>
Date: Tue, 23 Nov 2010 22:35:15 -0800
Subject: [PATCH] datapath: Add compatibility code for inet_add_protocol().

Kernels earlier than 2.6.32 did not mark struct net_protocol as const
in inet_add_protcol() and inet_del_protocol().  This provides compatibility
code to cast away the constness on these kernels so we can have them be
const on newer kernels.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
---
 datapath/linux-2.6/Modules.mk                        |  1 +
 datapath/linux-2.6/compat-2.6/include/net/protocol.h | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 datapath/linux-2.6/compat-2.6/include/net/protocol.h

diff --git a/datapath/linux-2.6/Modules.mk b/datapath/linux-2.6/Modules.mk
index 380f1c15a..e1e33347b 100644
--- a/datapath/linux-2.6/Modules.mk
+++ b/datapath/linux-2.6/Modules.mk
@@ -48,6 +48,7 @@ openvswitch_headers += \
 	linux-2.6/compat-2.6/include/net/genetlink.h \
 	linux-2.6/compat-2.6/include/net/ip.h \
 	linux-2.6/compat-2.6/include/net/netlink.h \
+	linux-2.6/compat-2.6/include/net/protocol.h \
 	linux-2.6/compat-2.6/include/net/route.h
 
 both_modules += brcompat
diff --git a/datapath/linux-2.6/compat-2.6/include/net/protocol.h b/datapath/linux-2.6/compat-2.6/include/net/protocol.h
new file mode 100644
index 000000000..6ffe0cb0b
--- /dev/null
+++ b/datapath/linux-2.6/compat-2.6/include/net/protocol.h
@@ -0,0 +1,12 @@
+#ifndef __NET_PROTOCOL_WRAPPER_H
+#define __NET_PROTOCOL_WRAPPER_H 1
+
+#include_next <net/protocol.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+#define inet_add_protocol(prot, num) inet_add_protocol((struct net_protocol *)(prot), num)
+#define inet_del_protocol(prot, num) inet_del_protocol((struct net_protocol *)(prot), num)
+#endif
+
+#endif
-- 
2.47.0