2 * Minimal wrappers to allow compiling kni on older kernels.
5 #include <linux/version.h>
7 #ifndef RHEL_RELEASE_VERSION
8 #define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
11 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
12 (!(defined(RHEL_RELEASE_CODE) && \
13 RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))
15 #define kstrtoul strict_strtoul
19 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
20 #define HAVE_SIMPLIFIED_PERNET_OPERATIONS
23 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
24 #define sk_sleep(s) ((s)->sk_sleep)
26 #define HAVE_SOCKET_WQ
29 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
30 #define HAVE_STATIC_SOCK_MAP_FD
32 #define kni_sock_map_fd(s) sock_map_fd(s, 0)
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
36 #define HAVE_CHANGE_CARRIER_CB
39 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
40 #define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN)
43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
44 #define HAVE_IOV_ITER_MSGHDR
47 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
48 #define HAVE_KIOCB_MSG_PARAM
49 #define HAVE_REBUILD_HEADER
52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
53 #define HAVE_SK_ALLOC_KERN_PARAM
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || \
57 (defined(RHEL_RELEASE_CODE) && \
58 RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 4))
59 #define HAVE_TRANS_START_HELPER
63 * KNI uses NET_NAME_UNKNOWN macro to select correct version of alloc_netdev()
64 * For old kernels just backported the commit that enables the macro
65 * (685343fc3ba6) but still uses old API, it is required to undefine macro to
66 * select correct version of API, this is safe since KNI doesn't use the value.
67 * This fix is specific to RedHat/CentOS kernels.
69 #if (defined(RHEL_RELEASE_CODE) && \
70 (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 8)) && \
71 (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)))
72 #undef NET_NAME_UNKNOWN
75 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
76 #define HAVE_SIGNAL_FUNCTIONS_OWN_HEADER