This patch allows openvswitch kernel module in the OVS tree to be
compiled against the current net-next Linux kernel.  The changes are
due to these upstream commits:

56989f6d856 ("genetlink: mark families as __ro_after_init")
489111e5c25 ("genetlink: statically initialize families")
a07ea4d9941 ("genetlink: no longer support using static family IDs")

struct genl_family initialization is changed be completely static and
to include the new (in Linux 4.6) __ro_after_init attribute.  Compat
code defines it as an empty macro if not defined already.

GENL_ID_GENERATE is no longer defined, but since it was defined as 0,
it is safe to drop it from all initializers also on older Linux
versions.

Tested with current Linux net-next (4.9) and 3.16.

Signed-off-by: Jarno Rajahalme <[email protected]>
---
 acinclude.m4                                |  4 ++--
 datapath/datapath.c                         | 18 +++++++++---------
 datapath/linux/Modules.mk                   |  1 +
 datapath/linux/compat/include/linux/cache.h | 10 ++++++++++
 4 files changed, 22 insertions(+), 11 deletions(-)
 create mode 100644 datapath/linux/compat/include/linux/cache.h

diff --git a/acinclude.m4 b/acinclude.m4
index c4f331c..866e437 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -134,10 +134,10 @@ AC_DEFUN([OVS_CHECK_LINUX], [
     AC_MSG_RESULT([$kversion])
 
     if test "$version" -ge 4; then
-       if test "$version" = 4 && test "$patchlevel" -le 8; then
+       if test "$version" = 4 && test "$patchlevel" -le 9; then
           : # Linux 4.x
        else
-          AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 
newer than 4.8.x is not supported (please refer to the FAQ for advice)])
+          AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 
newer than 4.9.x is not supported (please refer to the FAQ for advice)])
        fi
     elif test "$version" = 3 && test "$patchlevel" -ge 10; then
        : # Linux 3.x
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 3822129..ce2364a 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -682,8 +682,7 @@ static struct genl_ops dp_packet_genl_ops[] = {
        }
 };
 
-static struct genl_family dp_packet_genl_family = {
-       .id = GENL_ID_GENERATE,
+static struct genl_family dp_packet_genl_family __ro_after_init = {
        .hdrsize = sizeof(struct ovs_header),
        .name = OVS_PACKET_FAMILY,
        .version = OVS_PACKET_VERSION,
@@ -692,6 +691,7 @@ static struct genl_family dp_packet_genl_family = {
        .parallel_ops = true,
        .ops = dp_packet_genl_ops,
        .n_ops = ARRAY_SIZE(dp_packet_genl_ops),
+       .module = THIS_MODULE,
 };
 
 static void get_dp_stats(const struct datapath *dp, struct ovs_dp_stats *stats,
@@ -1447,8 +1447,7 @@ static struct genl_ops dp_flow_genl_ops[] = {
        },
 };
 
-static struct genl_family dp_flow_genl_family = {
-       .id = GENL_ID_GENERATE,
+static struct genl_family dp_flow_genl_family __ro_after_init = {
        .hdrsize = sizeof(struct ovs_header),
        .name = OVS_FLOW_FAMILY,
        .version = OVS_FLOW_VERSION,
@@ -1459,6 +1458,7 @@ static struct genl_family dp_flow_genl_family = {
        .n_ops = ARRAY_SIZE(dp_flow_genl_ops),
        .mcgrps = &ovs_dp_flow_multicast_group,
        .n_mcgrps = 1,
+       .module = THIS_MODULE,
 };
 
 static size_t ovs_dp_cmd_msg_size(void)
@@ -1832,8 +1832,7 @@ static struct genl_ops dp_datapath_genl_ops[] = {
        },
 };
 
-static struct genl_family dp_datapath_genl_family = {
-       .id = GENL_ID_GENERATE,
+static struct genl_family dp_datapath_genl_family __ro_after_init = {
        .hdrsize = sizeof(struct ovs_header),
        .name = OVS_DATAPATH_FAMILY,
        .version = OVS_DATAPATH_VERSION,
@@ -1844,6 +1843,7 @@ static struct genl_family dp_datapath_genl_family = {
        .n_ops = ARRAY_SIZE(dp_datapath_genl_ops),
        .mcgrps = &ovs_dp_datapath_multicast_group,
        .n_mcgrps = 1,
+       .module = THIS_MODULE,
 };
 
 /* Called with ovs_mutex or RCU read lock. */
@@ -2254,8 +2254,7 @@ static struct genl_ops dp_vport_genl_ops[] = {
        },
 };
 
-struct genl_family dp_vport_genl_family = {
-       .id = GENL_ID_GENERATE,
+struct genl_family dp_vport_genl_family __ro_after_init = {
        .hdrsize = sizeof(struct ovs_header),
        .name = OVS_VPORT_FAMILY,
        .version = OVS_VPORT_VERSION,
@@ -2266,6 +2265,7 @@ struct genl_family dp_vport_genl_family = {
        .n_ops = ARRAY_SIZE(dp_vport_genl_ops),
        .mcgrps = &ovs_dp_vport_multicast_group,
        .n_mcgrps = 1,
+       .module = THIS_MODULE,
 };
 
 static struct genl_family *dp_genl_families[] = {
@@ -2283,7 +2283,7 @@ static void dp_unregister_genl(int n_families)
                genl_unregister_family(dp_genl_families[i]);
 }
 
-static int dp_register_genl(void)
+static int __init dp_register_genl(void)
 {
        int err;
        int i;
diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
index 26f6d22..985ffed 100644
--- a/datapath/linux/Modules.mk
+++ b/datapath/linux/Modules.mk
@@ -29,6 +29,7 @@ openvswitch_headers += \
        linux/compat/gso.h \
        linux/compat/include/linux/percpu.h \
        linux/compat/include/linux/bug.h \
+       linux/compat/include/linux/cache.h \
        linux/compat/include/linux/compiler.h \
        linux/compat/include/linux/compiler-gcc.h \
        linux/compat/include/linux/cpumask.h \
diff --git a/datapath/linux/compat/include/linux/cache.h 
b/datapath/linux/compat/include/linux/cache.h
new file mode 100644
index 0000000..917defa
--- /dev/null
+++ b/datapath/linux/compat/include/linux/cache.h
@@ -0,0 +1,10 @@
+#ifndef __LINUX_CACHE_WRAPPER_H
+#define __LINUX_CACHE_WRAPPER_H 1
+
+#include_next <linux/cache.h>
+
+#ifndef __ro_after_init
+#define __ro_after_init
+#endif
+
+#endif
-- 
2.1.4

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to