Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit 9d6fd57aaa44fb6742213946533764ddab84c7ed Author: Marek Lindner mareklindner@neomailbox.ch Date: Tue Apr 21 15:51:39 2015 +0800
batman-adv: add missing compat-include folder
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
9d6fd57aaa44fb6742213946533764ddab84c7ed icmp_socket.h => compat-include/linux/atomic.h | 28 ++--- icmp_socket.h => compat-include/linux/bug.h | 31 ++--- icmp_socket.h => compat-include/linux/compiler.h | 31 ++--- compat-include/linux/etherdevice.h | 45 ++++++++ icmp_socket.h => compat-include/linux/export.h | 28 ++--- icmp_socket.h => compat-include/linux/if_ether.h | 26 ++--- compat-include/linux/if_vlan.h | 44 +++++++ compat-include/linux/kconfig.h | 42 +++++++ compat-include/linux/kernel.h | 44 +++++++ compat-include/linux/list.h | 54 +++++++++ compat-include/linux/moduleparam.h | 72 ++++++++++++ icmp_socket.h => compat-include/linux/net.h | 32 +++--- .../linux/netdev_features.h | 28 ++--- compat-include/linux/netdevice.h | 120 ++++++++++++++++++++ compat-include/linux/percpu.h | 48 ++++++++ icmp_socket.h => compat-include/linux/printk.h | 30 ++--- icmp_socket.h => compat-include/linux/random.h | 26 ++--- compat-include/linux/rculist.h | 49 ++++++++ compat-include/linux/rcupdate.h | 54 +++++++++ icmp_socket.h => compat-include/linux/seq_file.h | 29 ++--- compat-include/linux/skbuff.h | 94 +++++++++++++++ icmp_socket.h => compat-include/linux/slab.h | 26 ++--- 22 files changed, 823 insertions(+), 158 deletions(-)
diff --git a/icmp_socket.h b/compat-include/linux/atomic.h similarity index 59% copy from icmp_socket.h copy to compat-include/linux/atomic.h index 0189910..304af51 100644 --- a/icmp_socket.h +++ b/compat-include/linux/atomic.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,17 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" - -#include <linux/types.h> - -struct batadv_icmp_header; -struct batadv_priv; - -#define BATADV_ICMP_SOCKET "socket" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_ATOMIC_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_ATOMIC_H_
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +#include_next <linux/atomic.h> +#endif
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_ATOMIC_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/bug.h similarity index 51% copy from icmp_socket.h copy to compat-include/linux/bug.h index 0189910..66f79f8 100644 --- a/icmp_socket.h +++ b/compat-include/linux/bug.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,26 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_BUG_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_BUG_H_
-#include <linux/types.h> +#include <linux/version.h> +#include_next <linux/bug.h>
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
-#define BATADV_ICMP_SOCKET "socket" +#undef BUILD_BUG_ON +#ifdef __CHECKER__ +#define BUILD_BUG_ON(condition) (0) +#else /* __CHECKER__ */ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) +#endif /* __CHECKER__ */
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 0, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_BUG_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/compiler.h similarity index 51% copy from icmp_socket.h copy to compat-include/linux/compiler.h index 0189910..1717105 100644 --- a/icmp_socket.h +++ b/compat-include/linux/compiler.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,28 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ + +#include <linux/version.h> +#include_next <linux/compiler.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
-#include "main.h" +#define __always_unused __attribute__((unused)) +#define __percpu
-#include <linux/types.h> +#endif /* < KERNEL_VERSION(2, 6, 33) */
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
-#define BATADV_ICMP_SOCKET "socket" +#define __rcu
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(2, 6, 36) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ */ diff --git a/compat-include/linux/etherdevice.h b/compat-include/linux/etherdevice.h new file mode 100644 index 0000000..c20b43c --- /dev/null +++ b/compat-include/linux/etherdevice.h @@ -0,0 +1,45 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_ETHERDEVICE_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_ETHERDEVICE_H_ + +#include <linux/version.h> +#include_next <linux/etherdevice.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) + +#define eth_hw_addr_random(dev) batadv_eth_hw_addr_random(dev) + +static inline void batadv_eth_hw_addr_random(struct net_device *dev) +{ + random_ether_addr(dev->dev_addr); +} + +#endif /* < KERNEL_VERSION(3, 4, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) + +#define ether_addr_equal_unaligned(_a, _b) (memcmp(_a, _b, ETH_ALEN) == 0) +#define ether_addr_copy(_a, _b) memcpy(_a, _b, ETH_ALEN) + +#endif /* < KERNEL_VERSION(3, 14, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_ETHERDEVICE_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/export.h similarity index 59% copy from icmp_socket.h copy to compat-include/linux/export.h index 0189910..3b31a2d 100644 --- a/icmp_socket.h +++ b/compat-include/linux/export.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,17 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" - -#include <linux/types.h> - -struct batadv_icmp_header; -struct batadv_priv; - -#define BATADV_ICMP_SOCKET "socket" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_EXPORT_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_EXPORT_H_
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) +#include_next <linux/export.h> +#endif
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_EXPORT_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/if_ether.h similarity index 58% copy from icmp_socket.h copy to compat-include/linux/if_ether.h index 0189910..5ea164f 100644 --- a/icmp_socket.h +++ b/compat-include/linux/if_ether.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_IF_ETHER_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_IF_ETHER_H_
-#include <linux/types.h> +#include <linux/version.h> +#include_next <linux/if_ether.h>
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
-#define BATADV_ICMP_SOCKET "socket" +#define ETH_P_BATMAN 0x4305
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 8, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IF_ETHER_H_ */ diff --git a/compat-include/linux/if_vlan.h b/compat-include/linux/if_vlan.h new file mode 100644 index 0000000..3b146b4 --- /dev/null +++ b/compat-include/linux/if_vlan.h @@ -0,0 +1,44 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_IF_VLAN_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_IF_VLAN_H_ + +#include <linux/version.h> +#include_next <linux/if_vlan.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + +#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */ +#define VLAN_PRIO_SHIFT 13 + +#endif /* < KERNEL_VERSION(2, 6, 33) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) + +#define vlan_insert_tag(skb, proto, vid) __vlan_put_tag(skb, vid) + +#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) + +#define vlan_insert_tag(skb, proto, vid) vlan_insert_tag(skb, vid) + +#endif /* < KERNEL_VERSION(3, 0, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IF_VLAN_H_ */ diff --git a/compat-include/linux/kconfig.h b/compat-include/linux/kconfig.h new file mode 100644 index 0000000..be8aa02 --- /dev/null +++ b/compat-include/linux/kconfig.h @@ -0,0 +1,42 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_KCONFIG_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_KCONFIG_H_ + +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) +#include_next <linux/kconfig.h> +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) + +#define __ARG_PLACEHOLDER_1 0, +#define config_enabled(cfg) _config_enabled(cfg) +#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) +#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) +#define ___config_enabled(__ignored, val, ...) val + +#define IS_ENABLED(option) \ + (config_enabled(option) || config_enabled(option##_MODULE)) + +#endif /* < KERNEL_VERSION(3, 1, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_KCONFIG_H_ */ diff --git a/compat-include/linux/kernel.h b/compat-include/linux/kernel.h new file mode 100644 index 0000000..81b2862 --- /dev/null +++ b/compat-include/linux/kernel.h @@ -0,0 +1,44 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_KERNEL_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_KERNEL_H_ + +#include <linux/version.h> +#include_next <linux/kernel.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) + +#define kstrtou32(cp, base, v)\ +({\ + unsigned long _v;\ + int _r;\ + _r = strict_strtoul(cp, base, &_v);\ + *(v) = (uint32_t)_v;\ + if ((unsigned long)*(v) != _v)\ + _r = -ERANGE;\ + _r;\ +}) +#define kstrtoul strict_strtoul +#define kstrtol strict_strtol + +#endif /* < KERNEL_VERSION(2, 6, 39) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_KERNEL_H_ */ diff --git a/compat-include/linux/list.h b/compat-include/linux/list.h new file mode 100644 index 0000000..dcd604c --- /dev/null +++ b/compat-include/linux/list.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_LIST_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_LIST_H_ + +#include <linux/version.h> +#include_next <linux/list.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) + +#define hlist_entry_safe(ptr, type, member) \ + ({ typeof(ptr) ____ptr = (ptr); \ + ____ptr ? hlist_entry(____ptr, type, member) : NULL; \ + }) + +#undef hlist_for_each_entry +#define hlist_for_each_entry(pos, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ + pos; \ + pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) + +#undef hlist_for_each_entry_safe +#define hlist_for_each_entry_safe(pos, n, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\ + pos && ({ n = pos->member.next; 1; }); \ + pos = hlist_entry_safe(n, typeof(*pos), member)) + +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) + +#define hlist_add_behind(n, prev) hlist_add_after(prev, n) + +#endif + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_LIST_H_ */ diff --git a/compat-include/linux/moduleparam.h b/compat-include/linux/moduleparam.h new file mode 100644 index 0000000..fd8ac41 --- /dev/null +++ b/compat-include/linux/moduleparam.h @@ -0,0 +1,72 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_MODULEPARAM_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_MODULEPARAM_H_ + +#include <linux/version.h> +#include_next <linux/moduleparam.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) + +#define __compat__module_param_call(p1, p2, p3, p4, p5, p6, p7) \ + __module_param_call(p1, p2, p3, p4, p5, p7) + +#else + +#define __compat__module_param_call(p1, p2, p3, p4, p5, p6, p7) \ + __module_param_call(p1, p2, p3, p4, p5, p6, p7) + +#endif /* < KERNEL_VERSION(2, 6, 31) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) + +struct kernel_param_ops { + /* Returns 0, or -errno. arg is in kp->arg. */ + int (*set)(const char *val, const struct kernel_param *kp); + /* Returns length written or -errno. Buffer is 4k (ie. be short!) */ + int (*get)(char *buffer, struct kernel_param *kp); + /* Optional function to free kp->arg when module unloaded. */ + void (*free)(void *arg); +}; + +#define module_param_cb(name, ops, arg, perm) \ + static int __compat_set_param_##name(const char *val, \ + struct kernel_param *kp) \ + { return (ops)->set(val, kp); } \ + static int __compat_get_param_##name(char *buffer, \ + struct kernel_param *kp) \ + { return (ops)->get(buffer, kp); } \ + __compat__module_param_call(MODULE_PARAM_PREFIX, name, \ + __compat_set_param_##name, \ + __compat_get_param_##name, arg, \ + __same_type((arg), bool *), perm) + +static inline int batadv_param_set_copystring(const char *val, + const struct kernel_param *kp) +{ + return param_set_copystring(val, (struct kernel_param *)kp); +} + +#define param_set_copystring batadv_param_set_copystring + +#endif /* < KERNEL_VERSION(2, 6, 36) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_MODULEPARAM_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/net.h similarity index 51% copy from icmp_socket.h copy to compat-include/linux/net.h index 0189910..fcd7873 100644 --- a/icmp_socket.h +++ b/compat-include/linux/net.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,27 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_NET_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_NET_H_
-#include <linux/types.h> +#include <linux/version.h> +#include_next <linux/net.h>
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
-#define BATADV_ICMP_SOCKET "socket" +#ifndef net_ratelimited_function +#define net_ratelimited_function(func, ...) \ + do { \ + if (net_ratelimit()) \ + func(__VA_ARGS__); \ + } while (0) +#endif /* ifndef net_ratelimited_function */
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 5, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NET_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/netdev_features.h similarity index 51% copy from icmp_socket.h copy to compat-include/linux/netdev_features.h index 0189910..36c9c2f 100644 --- a/icmp_socket.h +++ b/compat-include/linux/netdev_features.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,23 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_NETDEV_FEATURES_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_NETDEV_FEATURES_H_
-#include <linux/types.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) +#include_next <linux/netdev_features.h> +#endif /* >= KERNEL_VERSION(3, 3, 0) */
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
-#define BATADV_ICMP_SOCKET "socket" +#define NETIF_F_HW_VLAN_CTAG_FILTER NETIF_F_HW_VLAN_FILTER
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 10, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NETDEV_FEATURES_H_ */ diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h new file mode 100644 index 0000000..8d77bd8 --- /dev/null +++ b/compat-include/linux/netdevice.h @@ -0,0 +1,120 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_NETDEVICE_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_NETDEVICE_H_ + +#include <linux/version.h> +#include_next <linux/netdevice.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) + +#include <linux/netdev_features.h> + +#endif /* < KERNEL_VERSION(3, 3, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + +#define unregister_netdevice_queue(dev, head) unregister_netdevice(dev) + +#endif /* < KERNEL_VERSION(2, 6, 33) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) + +#include <linux/etherdevice.h> + +#undef netdev_for_each_mc_addr +#define netdev_for_each_mc_addr(mclist, dev) \ + for (mclist = (struct batadv_dev_addr_list *)dev->mc_list; mclist; \ + mclist = (struct batadv_dev_addr_list *)mclist->next) + +/* Note, that this breaks the usage of the normal 'struct netdev_hw_addr' + * for kernels < 2.6.35 in batman-adv! + */ +#define netdev_hw_addr batadv_dev_addr_list +struct batadv_dev_addr_list { + struct dev_addr_list *next; + u8 addr[MAX_ADDR_LEN]; + u8 da_addrlen; + u8 da_synced; + int da_users; + int da_gusers; +}; + +#endif /* < KERNEL_VERSION(2, 6, 35) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) + +#define NET_ADDR_RANDOM 0 + +#endif /* < KERNEL_VERSION(2, 6, 36) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) + +/* On older kernels net_dev->master is reserved for iface bonding. */ +static inline int batadv_netdev_set_master(struct net_device *slave, + struct net_device *master) +{ + return 0; +} + +#define netdev_set_master batadv_netdev_set_master + +#endif /* < KERNEL_VERSION(2, 6, 39) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) + +#define netdev_master_upper_dev_link netdev_set_master +#define netdev_upper_dev_unlink(slave, master) netdev_set_master(slave, NULL) +#define netdev_master_upper_dev_get(dev) \ +({\ + ASSERT_RTNL();\ + dev->master;\ +}) + +#endif /* < KERNEL_VERSION(3, 9, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) + +#define netdev_notifier_info_to_dev(ptr) ptr + +#endif /* < KERNEL_VERSION(3, 11, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) + +/* alloc_netdev() was defined differently before 2.6.38 */ +#undef alloc_netdev +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38) +#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \ + alloc_netdev_mq(sizeof_priv, name, setup, 1) +#else +#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \ + alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1) +#endif /* nested < KERNEL_VERSION(2, 6, 38) */ + +#endif /* < KERNEL_VERSION(3, 17, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0) + +#define dev_get_iflink(_net_dev) ((_net_dev)->iflink) + +#endif /* < KERNEL_VERSION(3, 19, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NETDEVICE_H_ */ diff --git a/compat-include/linux/percpu.h b/compat-include/linux/percpu.h new file mode 100644 index 0000000..82355e4 --- /dev/null +++ b/compat-include/linux/percpu.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_PERCPU_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_PERCPU_H_ + +#include <linux/version.h> +#include_next <linux/percpu.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + +#undef __alloc_percpu +#define __alloc_percpu(size, align) \ + percpu_alloc_mask((size), GFP_KERNEL, cpu_possible_map) + +#endif /* < KERNEL_VERSION(2, 6, 30) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + +#define this_cpu_add(x, c) batadv_this_cpu_add(&(x), c) + +static inline void batadv_this_cpu_add(uint64_t *count_ptr, size_t count) +{ + int cpu = get_cpu(); + *per_cpu_ptr(count_ptr, cpu) += count; + put_cpu(); +} + +#endif /* < KERNEL_VERSION(2, 6, 33) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_PERCPU_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/printk.h similarity index 55% copy from icmp_socket.h copy to compat-include/linux/printk.h index 0189910..c69c406 100644 --- a/icmp_socket.h +++ b/compat-include/linux/printk.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,27 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_PRINTK_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_PRINTK_H_
-#include "main.h" +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +#include_next <linux/printk.h> +#endif
-#include <linux/types.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
-struct batadv_icmp_header; -struct batadv_priv; +#define pr_warn pr_warning
-#define BATADV_ICMP_SOCKET "socket" +#endif
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_PRINTK_H_ */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif diff --git a/icmp_socket.h b/compat-include/linux/random.h similarity index 58% copy from icmp_socket.h copy to compat-include/linux/random.h index 0189910..ce12f1a 100644 --- a/icmp_socket.h +++ b/compat-include/linux/random.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_RANDOM_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_RANDOM_H_
-#include <linux/types.h> +#include <linux/version.h> +#include_next <linux/random.h>
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
-#define BATADV_ICMP_SOCKET "socket" +#define prandom_u32() random32()
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 9, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_RANDOM_H_ */ diff --git a/compat-include/linux/rculist.h b/compat-include/linux/rculist.h new file mode 100644 index 0000000..4736db1 --- /dev/null +++ b/compat-include/linux/rculist.h @@ -0,0 +1,49 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_RCULIST_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_RCULIST_H_ + +#include <linux/version.h> +#include_next <linux/rculist.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) + +#define hlist_first_rcu(head) \ + (*((struct hlist_node __rcu **)(&(head)->first))) + +#define hlist_next_rcu(node) \ + (*((struct hlist_node __rcu **)(&(node)->next))) + +#endif /* < KERNEL_VERSION(2, 6, 37) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) + +#undef hlist_for_each_entry_rcu +#define hlist_for_each_entry_rcu(pos, head, member) \ + for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),\ + typeof(*(pos)), member); \ + pos; \ + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\ + &(pos)->member)), typeof(*(pos)), member)) + +#endif + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_RCULIST_H_ */ diff --git a/compat-include/linux/rcupdate.h b/compat-include/linux/rcupdate.h new file mode 100644 index 0000000..12a1c2a --- /dev/null +++ b/compat-include/linux/rcupdate.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_RCUPDATE_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_RCUPDATE_H_ + +#include <linux/version.h> +#include_next <linux/rcupdate.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) + +#define rcu_dereference_protected(p, c) (p) + +#define rcu_dereference_raw(p) ({ \ + typeof(p) _________p1 = ACCESS_ONCE(p); \ + smp_read_barrier_depends(); \ + (_________p1); \ + }) + +#endif /* < KERNEL_VERSION(2, 6, 34) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) + +#define kfree_rcu(ptr, rcuhead_name) \ + do { \ + void batadv_free_rcu_##ptr(struct rcu_head *rcu) \ + { \ + void *container_ptr; \ + container_ptr = container_of(rcu, typeof(*(ptr)), rcuhead_name); \ + kfree(container_ptr); \ + } \ + call_rcu(&(ptr)->rcuhead_name, batadv_free_rcu_##ptr); \ + } while (0) + +#endif /* < KERNEL_VERSION(3, 0, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_RCUPDATE_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/seq_file.h similarity index 54% copy from icmp_socket.h copy to compat-include/linux/seq_file.h index 0189910..5eaaec8 100644 --- a/icmp_socket.h +++ b/compat-include/linux/seq_file.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,24 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_
-#include <linux/types.h> +#include <linux/version.h> +#include_next <linux/seq_file.h>
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
-#define BATADV_ICMP_SOCKET "socket" +static inline bool seq_has_overflowed(struct seq_file *m) +{ + return m->count == m->size; +}
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 19, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_ */ diff --git a/compat-include/linux/skbuff.h b/compat-include/linux/skbuff.h new file mode 100644 index 0000000..ed911ef --- /dev/null +++ b/compat-include/linux/skbuff.h @@ -0,0 +1,94 @@ +/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_SKBUFF_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_SKBUFF_H_ + +#include <linux/version.h> +#include_next <linux/skbuff.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) + +#define consume_skb(_skb) kfree_skb(_skb) + +#endif /* < KERNEL_VERSION(2, 6, 30) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) + +static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length) +{ + struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN); + + if (NET_IP_ALIGN && skb) + skb_reserve(skb, NET_IP_ALIGN); + return skb; +} + +#endif /* < KERNEL_VERSION(2, 6, 33) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) + +static inline void skb_reset_mac_len(struct sk_buff *skb) +{ + skb->mac_len = skb->network_header - skb->mac_header; +} + +#endif /* < KERNEL_VERSION(3, 0, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) + +/* hack for not correctly set mac_len. This may happen for some special + * configurations like batman-adv on VLANs. + * + * This is pretty dirty, but we only use skb_share_check() in main.c right + * before mac_len is checked, and the recomputation shouldn't hurt too much. + */ +#define skb_share_check(skb, b) \ + ({ \ + struct sk_buff *_t_skb; \ + _t_skb = skb_share_check(skb, b); \ + if (_t_skb) \ + skb_reset_mac_len(_t_skb); \ + _t_skb; \ + }) + +#endif /* < KERNEL_VERSION(3, 8, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) + +/* older kernels still need to call skb_abort_seq_read() */ +#define skb_seq_read(consumed, data, st) \ + ({ \ + int __len = skb_seq_read(consumed, data, st); \ + if (__len == 0) \ + skb_abort_seq_read(st); \ + __len; \ + }) + +#endif /* < KERNEL_VERSION(3, 11, 0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) + +#define pskb_copy_for_clone pskb_copy + +#endif /* < KERNEL_VERSION(3, 16, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SKBUFF_H_ */ diff --git a/icmp_socket.h b/compat-include/linux/slab.h similarity index 57% copy from icmp_socket.h copy to compat-include/linux/slab.h index 0189910..569c5aa 100644 --- a/icmp_socket.h +++ b/compat-include/linux/slab.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors: * - * Marek Lindner + * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -13,23 +13,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_SLAB_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_SLAB_H_
-#include <linux/types.h> +#include <linux/version.h> +#include_next <linux/slab.h>
-struct batadv_icmp_header; -struct batadv_priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
-#define BATADV_ICMP_SOCKET "socket" +#define kmalloc_array(n, size, flags) kmalloc(n * size, flags)
-void batadv_socket_init(void); -int batadv_socket_setup(struct batadv_priv *bat_priv); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); +#endif /* < KERNEL_VERSION(3, 4, 0) */
-#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SLAB_H_ */