From a7988ae4f73df84cbbe355568c0eabf3b1f67e68 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Sat, 6 Apr 2013 14:04:12 +0200 Subject: Add a compatibility header file for easier maintenance Unfortunately not everything could be moved there, there are still compatibility ifdefs in some other files. Signed-off-by: Jozsef Kadlecsik --- kernel/include/linux/netfilter/ipset/ip_set.h | 28 +------- .../include/linux/netfilter/ipset/ip_set_ahash.h | 3 - .../include/linux/netfilter/ipset/ip_set_compat.h | 82 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 kernel/include/linux/netfilter/ipset/ip_set_compat.h (limited to 'kernel/include') diff --git a/kernel/include/linux/netfilter/ipset/ip_set.h b/kernel/include/linux/netfilter/ipset/ip_set.h index 79c4f22..350178d 100644 --- a/kernel/include/linux/netfilter/ipset/ip_set.h +++ b/kernel/include/linux/netfilter/ipset/ip_set.h @@ -17,13 +17,9 @@ #include #include #include -#include #include #include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) -#define xt_action_param xt_match_param -#endif +#include #define _IP_SET_MODULE_DESC(a, b, c) \ MODULE_DESCRIPTION(a " type of IP sets, revisions " b "-" c) @@ -234,28 +230,6 @@ ip_set_get_h16(const struct nlattr *attr) #define ipset_nest_start(skb, attr) nla_nest_start(skb, attr | NLA_F_NESTED) #define ipset_nest_end(skb, start) nla_nest_end(skb, start) -#ifdef NLA_PUT_NET16 -static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) -{ - return nla_put(skb, attrtype, sizeof(__be16), &value); -} - -static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) -{ - return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, value); -} - -static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) -{ - return nla_put(skb, attrtype, sizeof(__be32), &value); -} - -static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) -{ - return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, value); -} -#endif - static inline int nla_put_ipaddr4(struct sk_buff *skb, int type, __be32 ipaddr) { struct nlattr *__nested = ipset_nest_start(skb, type); diff --git a/kernel/include/linux/netfilter/ipset/ip_set_ahash.h b/kernel/include/linux/netfilter/ipset/ip_set_ahash.h index 5d36453..0214c4c 100644 --- a/kernel/include/linux/netfilter/ipset/ip_set_ahash.h +++ b/kernel/include/linux/netfilter/ipset/ip_set_ahash.h @@ -4,9 +4,6 @@ #include #include #include -#ifndef rcu_dereference_bh -#define rcu_dereference_bh(p) rcu_dereference(p) -#endif #define CONCAT(a, b, c) a##b##c #define TOKEN(a, b, c) CONCAT(a, b, c) diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h b/kernel/include/linux/netfilter/ipset/ip_set_compat.h new file mode 100644 index 0000000..940a3c3 --- /dev/null +++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h @@ -0,0 +1,82 @@ +#ifndef __IP_SET_COMPAT_H +#define __IP_SET_COMPAT_H + +/* Not everything could be moved here. Compatibility stuffs can be found in + * xt_set.c, ip_set_core.c, ip_set_getport.c, pfxlen.c too. + */ + +#include +#include + +#ifndef rcu_dereference_bh +#define rcu_dereference_bh(p) rcu_dereference(p) +#endif + +#ifndef rcu_dereference_protected +#define rcu_dereference_protected(p, c) rcu_dereference(p) +#endif + +#ifndef __rcu +#define __rcu +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) +#define xt_action_param xt_match_param +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) +#define vzalloc(size) __vmalloc(size,\ + GFP_KERNEL|__GFP_ZERO|__GFP_HIGHMEM,\ + PAGE_KERNEL) +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0) +#include + +static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) +{ + return !compare_ether_addr(addr1, addr2); +} +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) +#define NETLINK_PORTID(skb) NETLINK_CB(skb).pid +#else +#define NETLINK_PORTID(skb) NETLINK_CB(skb).portid +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) +#define ns_capable(ns, cap) capable(cap) +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) +#define lock_nfnl() nfnl_lock() +#define unlock_nfnl() nfnl_unlock() +#else +#define lock_nfnl() nfnl_lock(NFNL_SUBSYS_IPSET) +#define unlock_nfnl() nfnl_unlock(NFNL_SUBSYS_IPSET) +#endif + +#ifdef NLA_PUT_NET16 +static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) +{ + return nla_put(skb, attrtype, sizeof(__be16), &value); +} + +static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) +{ + return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, value); +} + +static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) +{ + return nla_put(skb, attrtype, sizeof(__be32), &value); +} + +static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) +{ + return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, value); +} +#endif + +#endif /* __IP_SET_COMPAT_H */ -- cgit v1.2.3