Skip to content

Commit

Permalink
Rework NF_HOOK call, fixes #62.
Browse files Browse the repository at this point in the history
  • Loading branch information
aabc committed Sep 24, 2016
1 parent dde907b commit c40bcb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 0 additions & 9 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
14 changes: 10 additions & 4 deletions ipt_NETFLOW.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c40bcb9

Please sign in to comment.