From c40bcb96674b42d98f6cfe4529717e2b793b843f Mon Sep 17 00:00:00 2001 From: ABC Date: Sat, 24 Sep 2016 21:45:06 +0400 Subject: [PATCH] Rework NF_HOOK call, fixes #62. --- compat.h | 9 --------- ipt_NETFLOW.c | 14 ++++++++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/compat.h b/compat.h index d0b9475..9743f40 100644 --- a/compat.h +++ b/compat.h @@ -589,13 +589,4 @@ int in6_pton(const char *src, int srclen, # define vlan_tx_tag_present skb_vlan_tag_present #endif -/* NF_HOOK is 'define' in old code, but it's function in new code, - * also, it's function in, supposedly older, kernel version of Centos 7.[01], - * due to backporing. */ -#if defined(NF_HOOK) || (defined(RHEL_MAJOR) && RHEL_MAJOR == 7 && RHEL_MINOR < 2) -# define NF_HOOK_COMPAT(a,b,c,d,e,f,g) NF_HOOK(a,b, d,e,f,g) -#else /* new kernels */ -# define NF_HOOK_COMPAT NF_HOOK -#endif - #endif /* COMPAT_NETFLOW_H */ diff --git a/ipt_NETFLOW.c b/ipt_NETFLOW.c index d7e807c..ac7fcd6 100644 --- a/ipt_NETFLOW.c +++ b/ipt_NETFLOW.c @@ -1219,11 +1219,14 @@ static int promisc4_rcv(struct sk_buff *skb, struct net_device *dev, struct pack memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); skb_orphan(skb); - return NF_HOOK_COMPAT(NFPROTO_IPV4, NF_INET_PRE_ROUTING, + return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0) dev_net(dev), #endif - NULL, skb, dev, NULL, promisc_finish); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) || (defined(RHEL_MAJOR) && RHEL_MAJOR == 7 && RHEL_MINOR > 1) + NULL, +#endif + skb, dev, NULL, promisc_finish); drop: NETFLOW_STAT_INC(pkt_promisc_drop); kfree_skb(skb); @@ -1291,11 +1294,14 @@ static int promisc6_rcv(struct sk_buff *skb, struct net_device *dev, struct pack rcu_read_unlock(); skb_orphan(skb); - return NF_HOOK_COMPAT(NFPROTO_IPV6, NF_INET_PRE_ROUTING, + return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0) dev_net(dev), #endif - NULL, skb, dev, NULL, promisc_finish); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) || (defined(RHEL_MAJOR) && RHEL_MAJOR == 7 && RHEL_MINOR > 1) + NULL, +#endif + skb, dev, NULL, promisc_finish); drop: rcu_read_unlock(); NETFLOW_STAT_INC(pkt_promisc_drop);