diff mbox series

[ovs-dev,v3] compat: Add compat fix for old kernels

Message ID 20191106073446.3292-1-roid@mellanox.com
State Accepted
Commit c0a1df2e3f209fbf3c61b66a719b90e41636ef52
Headers show
Series [ovs-dev,v3] compat: Add compat fix for old kernels | expand

Commit Message

Roi Dayan Nov. 6, 2019, 7:34 a.m. UTC
In kernels older than 4.8, struct tcf_t didn't have the firstuse.
If openvswitch is compiled with the compat pkt_cls.h then there is
a struct size mismatch between openvswitch and the kernel which cause
parsing netlink actions to fail.
After this commit parsing the netlink actions pass even if compiled with
the compat pkt_cls.h.

Signed-off-by: Roi Dayan <roid@mellanox.com>
---

Notes:
    v2->v3:
    - use AC_CHECK_MEMBER macro instead of AC_COMPILE_IFELSE
    
    v1->v2:
    - fix mix of tabs and spaces in acinclude.m4

 acinclude.m4            | 2 ++
 include/linux/pkt_cls.h | 2 ++
 2 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index a0507cfe019e..bc5b1c667eff 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -185,6 +185,8 @@  AC_DEFUN([OVS_CHECK_LINUX_TC], [
     [AC_DEFINE([HAVE_TCA_FLOWER_KEY_ENC_IP_TTL_MASK], [1],
                [Define to 1 if TCA_FLOWER_KEY_ENC_IP_TTL_MASK is available.])])
 
+  AC_CHECK_MEMBERS([struct tcf_t.firstuse], [], [], [#include <linux/pkt_cls.h>])
+
   AC_COMPILE_IFELSE([
     AC_LANG_PROGRAM([#include <linux/tc_act/tc_vlan.h>], [
         int x = TCA_VLAN_PUSH_VLAN_PRIORITY;
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index 4adea59e7c36..2f7e328c48c8 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -64,7 +64,9 @@  struct tcf_t {
 	__u64   install;
 	__u64   lastuse;
 	__u64   expires;
+#ifdef HAVE_STRUCT_TCF_T_FIRSTUSE
 	__u64   firstuse;
+#endif
 };
 
 #define tc_gen \