diff options
| author | Patrick McHardy <kaber@trash.net> | 2013-10-10 03:21:55 -0400 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-10-14 05:29:31 -0400 |
| commit | 795aa6ef6a1aba99050735eadd0c2341b789b53b (patch) | |
| tree | ba3b0ee0dadcb55962b596342d5897b02db1d234 | |
| parent | ccdbb6e96beca362db876d820ac1e560ff6d9579 (diff) | |
netfilter: pass hook ops to hookfn
Pass the hook ops to the hookfn to allow for generic hook
functions. This change is required by nf_tables.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
26 files changed, 148 insertions, 122 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 61223c52414f..fef7e67f7101 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
| @@ -42,7 +42,8 @@ int netfilter_init(void); | |||
| 42 | 42 | ||
| 43 | struct sk_buff; | 43 | struct sk_buff; |
| 44 | 44 | ||
| 45 | typedef unsigned int nf_hookfn(unsigned int hooknum, | 45 | struct nf_hook_ops; |
| 46 | typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops, | ||
| 46 | struct sk_buff *skb, | 47 | struct sk_buff *skb, |
| 47 | const struct net_device *in, | 48 | const struct net_device *in, |
| 48 | const struct net_device *out, | 49 | const struct net_device *out, |
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index f87736270eaa..878f008afefa 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c | |||
| @@ -619,7 +619,7 @@ bad: | |||
| 619 | 619 | ||
| 620 | /* Replicate the checks that IPv6 does on packet reception and pass the packet | 620 | /* Replicate the checks that IPv6 does on packet reception and pass the packet |
| 621 | * to ip6tables, which doesn't support NAT, so things are fairly simple. */ | 621 | * to ip6tables, which doesn't support NAT, so things are fairly simple. */ |
| 622 | static unsigned int br_nf_pre_routing_ipv6(unsigned int hook, | 622 | static unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops, |
| 623 | struct sk_buff *skb, | 623 | struct sk_buff *skb, |
| 624 | const struct net_device *in, | 624 | const struct net_device *in, |
| 625 | const struct net_device *out, | 625 | const struct net_device *out, |
| @@ -669,7 +669,8 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook, | |||
| 669 | * receiving device) to make netfilter happy, the REDIRECT | 669 | * receiving device) to make netfilter happy, the REDIRECT |
| 670 | * target in particular. Save the original destination IP | 670 | * target in particular. Save the original destination IP |
| 671 | * address to be able to detect DNAT afterwards. */ | 671 | * address to be able to detect DNAT afterwards. */ |
| 672 | static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb, | 672 | static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops, |
| 673 | struct sk_buff *skb, | ||
| 673 | const struct net_device *in, | 674 | const struct net_device *in, |
| 674 | const struct net_device *out, | 675 | const struct net_device *out, |
| 675 | int (*okfn)(struct sk_buff *)) | 676 | int (*okfn)(struct sk_buff *)) |
| @@ -691,7 +692,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb, | |||
| 691 | return NF_ACCEPT; | 692 | return NF_ACCEPT; |
| 692 | 693 | ||
| 693 | nf_bridge_pull_encap_header_rcsum(skb); | 694 | nf_bridge_pull_encap_header_rcsum(skb); |
| 694 | return br_nf_pre_routing_ipv6(hook, skb, in, out, okfn); | 695 | return br_nf_pre_routing_ipv6(ops, skb, in, out, okfn); |
| 695 | } | 696 | } |
| 696 | 697 | ||
| 697 | if (!brnf_call_iptables && !br->nf_call_iptables) | 698 | if (!brnf_call_iptables && !br->nf_call_iptables) |
| @@ -727,7 +728,8 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb, | |||
| 727 | * took place when the packet entered the bridge), but we | 728 | * took place when the packet entered the bridge), but we |
| 728 | * register an IPv4 PRE_ROUTING 'sabotage' hook that will | 729 | * register an IPv4 PRE_ROUTING 'sabotage' hook that will |
| 729 | * prevent this from happening. */ | 730 | * prevent this from happening. */ |
| 730 | static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb, | 731 | static unsigned int br_nf_local_in(const struct nf_hook_ops *ops, |
| 732 | struct sk_buff *skb, | ||
| 731 | const struct net_device *in, | 733 | const struct net_device *in, |
| 732 | const struct net_device *out, | 734 | const struct net_device *out, |
| 733 | int (*okfn)(struct sk_buff *)) | 735 | int (*okfn)(struct sk_buff *)) |
| @@ -765,7 +767,8 @@ static int br_nf_forward_finish(struct sk_buff *skb) | |||
| 765 | * but we are still able to filter on the 'real' indev/outdev | 767 | * but we are still able to filter on the 'real' indev/outdev |
| 766 | * because of the physdev module. For ARP, indev and outdev are the | 768 | * because of the physdev module. For ARP, indev and outdev are the |
| 767 | * bridge ports. */ | 769 | * bridge ports. */ |
| 768 | static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb, | 770 | static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops, |
| 771 | struct sk_buff *skb, | ||
| 769 | const struct net_device *in, | 772 | const struct net_device *in, |
| 770 | const struct net_device *out, | 773 | const struct net_device *out, |
| 771 | int (*okfn)(struct sk_buff *)) | 774 | int (*okfn)(struct sk_buff *)) |
| @@ -818,7 +821,8 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb, | |||
| 818 | return NF_STOLEN; | 821 | return NF_STOLEN; |
| 819 | } | 822 | } |
| 820 | 823 | ||
| 821 | static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff *skb, | 824 | static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops, |
| 825 | struct sk_buff *skb, | ||
| 822 | const struct net_device *in, | 826 | const struct net_device *in, |
| 823 | const struct net_device *out, | 827 | const struct net_device *out, |
| 824 | int (*okfn)(struct sk_buff *)) | 828 | int (*okfn)(struct sk_buff *)) |
| @@ -878,7 +882,8 @@ static int br_nf_dev_queue_xmit(struct sk_buff *skb) | |||
| 878 | #endif | 882 | #endif |
| 879 | 883 | ||
| 880 | /* PF_BRIDGE/POST_ROUTING ********************************************/ | 884 | /* PF_BRIDGE/POST_ROUTING ********************************************/ |
| 881 | static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb, | 885 | static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops, |
| 886 | struct sk_buff *skb, | ||
| 882 | const struct net_device *in, | 887 | const struct net_device *in, |
| 883 | const struct net_device *out, | 888 | const struct net_device *out, |
| 884 | int (*okfn)(struct sk_buff *)) | 889 | int (*okfn)(struct sk_buff *)) |
| @@ -923,7 +928,8 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb, | |||
| 923 | /* IP/SABOTAGE *****************************************************/ | 928 | /* IP/SABOTAGE *****************************************************/ |
| 924 | /* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING | 929 | /* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING |
| 925 | * for the second time. */ | 930 | * for the second time. */ |
| 926 | static unsigned int ip_sabotage_in(unsigned int hook, struct sk_buff *skb, | 931 | static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops, |
| 932 | struct sk_buff *skb, | ||
| 927 | const struct net_device *in, | 933 | const struct net_device *in, |
| 928 | const struct net_device *out, | 934 | const struct net_device *out, |
| 929 | int (*okfn)(struct sk_buff *)) | 935 | int (*okfn)(struct sk_buff *)) |
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c index 94b2b700cff8..bb2da7b706e7 100644 --- a/net/bridge/netfilter/ebtable_filter.c +++ b/net/bridge/netfilter/ebtable_filter.c | |||
| @@ -60,17 +60,21 @@ static const struct ebt_table frame_filter = | |||
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | static unsigned int | 62 | static unsigned int |
| 63 | ebt_in_hook(unsigned int hook, struct sk_buff *skb, const struct net_device *in, | 63 | ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, |
| 64 | const struct net_device *out, int (*okfn)(struct sk_buff *)) | 64 | const struct net_device *in, const struct net_device *out, |
| 65 | int (*okfn)(struct sk_buff *)) | ||
| 65 | { | 66 | { |
| 66 | return ebt_do_table(hook, skb, in, out, dev_net(in)->xt.frame_filter); | 67 | return ebt_do_table(ops->hooknum, skb, in, out, |
| 68 | dev_net(in)->xt.frame_filter); | ||
| 67 | } | 69 | } |
| 68 | 70 | ||
| 69 | static unsigned int | 71 | static unsigned int |
| 70 | ebt_out_hook(unsigned int hook, struct sk_buff *skb, const struct net_device *in, | 72 | ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, |
| 71 | const struct net_device *out, int (*okfn)(struct sk_buff *)) | 73 | const struct net_device *in, const struct net_device *out, |
| 74 | int (*okfn)(struct sk_buff *)) | ||
| 72 | { | 75 | { |
| 73 | return ebt_do_table(hook, skb, in, out, dev_net(out)->xt.frame_filter); | 76 | return ebt_do_table(ops->hooknum, skb, in, out, |
| 77 | dev_net(out)->xt.frame_filter); | ||
| 74 | } | 78 | } |
