diff options
Diffstat (limited to 'kernel/include/linux/netfilter/ipset/ip_set_compat.h.in')
-rw-r--r-- | kernel/include/linux/netfilter/ipset/ip_set_compat.h.in | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in new file mode 100644 index 0000000..b93c5d9 --- /dev/null +++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in @@ -0,0 +1,119 @@ +#ifndef __IP_SET_COMPAT_H +#define __IP_SET_COMPAT_H + +#@HAVE_STRUCT_XT_ACTION_PARAM@ HAVE_STRUCT_XT_ACTION_PARAM +#@HAVE_VZALLOC@ HAVE_VZALLOC +#@HAVE_ETHER_ADDR_EQUAL@ HAVE_ETHER_ADDR_EQUAL +#@HAVE_NLA_PUT_BE64@ HAVE_NLA_PUT_BE64 +#@HAVE_NL_INFO_PORTID@ HAVE_NL_INFO_PORTID +#define HAVE_NETLINK_DUMP_START_ARGS @HAVE_NETLINK_DUMP_START_ARGS@ +#@HAVE_NS_CAPABLE@ HAVE_NS_CAPABLE +#@HAVE_NFNL_LOCK_SUBSYS@ HAVE_NFNL_LOCK_SUBSYS +#@HAVE_EXPORT_H@ HAVE_EXPORT_H +#define HAVE_IPV6_SKIP_EXTHDR_ARGS @HAVE_IPV6_SKIP_EXTHDR_ARGS@ +#@HAVE_CHECKENTRY_BOOL@ HAVE_CHECKENTRY_BOOL +#@HAVE_XT_TARGET_PARAM@ HAVE_XT_TARGET_PARAM +#@HAVE_NET_OPS_ID@ HAVE_NET_OPS_ID + +/* 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 <linux/version.h> +#include <linux/netlink.h> + +#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 + +#ifdef CHECK_KCONFIG +#ifndef CONFIG_SPARSE_RCU_POINTER +#error "CONFIG_SPARSE_RCU_POINTER must be enabled" +#endif +#endif + +#if defined(CONFIG_NETFILTER_NETLINK) || defined(CONFIG_NETFILTER_NETLINK_MODULE) +#else +#error "NETFILTER_NETLINK must be enabled: select NFACCT/NFQUEUE/LOG over NFNETLINK" +#endif + +#ifndef HAVE_STRUCT_XT_ACTION_PARAM +#define xt_action_param xt_match_param +#endif + +#ifndef HAVE_VZALLOC +#define vzalloc(size) __vmalloc(size,\ + GFP_KERNEL|__GFP_ZERO|__GFP_HIGHMEM,\ + PAGE_KERNEL) +#endif + +#ifndef HAVE_ETHER_ADDR_EQUAL +#include <linux/etherdevice.h> + +static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) +{ + return !compare_ether_addr(addr1, addr2); +} +#endif + +#ifndef HAVE_NLA_PUT_BE64 +static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value) +{ + return nla_put(skb, attrtype, sizeof(__be64), &value); +} + +static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value) +{ + return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, value); +} +#endif + +#ifdef HAVE_NL_INFO_PORTID +#define NETLINK_PORTID(skb) NETLINK_CB(skb).portid +#else +#define NETLINK_PORTID(skb) NETLINK_CB(skb).pid +#endif + +#ifndef HAVE_NS_CAPABLE +#define ns_capable(ns, cap) capable(cap) +#endif + +#ifdef HAVE_NFNL_LOCK_SUBSYS +#define lock_nfnl() nfnl_lock(NFNL_SUBSYS_IPSET) +#define unlock_nfnl() nfnl_unlock(NFNL_SUBSYS_IPSET) +#else +#define lock_nfnl() nfnl_lock() +#define unlock_nfnl() nfnl_unlock() +#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 */ |