aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2013-10-10 03:21:55 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-10-14 05:29:31 -0400
commit795aa6ef6a1aba99050735eadd0c2341b789b53b (patch)
treeba3b0ee0dadcb55962b596342d5897b02db1d234 /net/ipv6
parentccdbb6e96beca362db876d820ac1e560ff6d9579 (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>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/netfilter/ip6t_SYNPROXY.c2
-rw-r--r--net/ipv6/netfilter/ip6table_filter.c5
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c10
-rw-r--r--net/ipv6/netfilter/ip6table_nat.c27
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c5
-rw-r--r--net/ipv6/netfilter/ip6table_security.c5
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c14
-rw-r--r--net/ipv6/netfilter/nf_defrag_ipv6_hooks.c6
8 files changed, 40 insertions, 34 deletions
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index 2748b042da72..bf9f612c1bc2 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -312,7 +312,7 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
312 return XT_CONTINUE; 312 return XT_CONTINUE;
313} 313}
314 314
315static unsigned int ipv6_synproxy_hook(unsigned int hooknum, 315static unsigned int ipv6_synproxy_hook(const struct nf_hook_ops *ops,
316 struct sk_buff *skb, 316 struct sk_buff *skb,
317 const struct net_device *in, 317 const struct net_device *in,
318 const struct net_device *out, 318 const struct net_device *out,
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index 29b44b14c5ea..ca7f6c128086 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -32,13 +32,14 @@ static const struct xt_table packet_filter = {
32 32
33/* The work comes in here from netfilter.c. */ 33/* The work comes in here from netfilter.c. */
34static unsigned int 34static unsigned int
35ip6table_filter_hook(unsigned int hook, struct sk_buff *skb, 35ip6table_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
36 const struct net_device *in, const struct net_device *out, 36 const struct net_device *in, const struct net_device *out,
37 int (*okfn)(struct sk_buff *)) 37 int (*okfn)(struct sk_buff *))
38{ 38{
39 const struct net *net = dev_net((in != NULL) ? in : out); 39 const struct net *net = dev_net((in != NULL) ? in : out);
40 40
41 return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_filter); 41 return ip6t_do_table(skb, ops->hooknum, in, out,
42 net->ipv6.ip6table_filter);
42} 43}
43 44
44static struct nf_hook_ops *filter_ops __read_mostly; 45static struct nf_hook_ops *filter_ops __read_mostly;
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index c705907ae6ab..307bbb782d14 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -76,17 +76,17 @@ ip6t_mangle_out(struct sk_buff *skb, const struct net_device *out)
76 76
77/* The work comes in here from netfilter.c. */ 77/* The work comes in here from netfilter.c. */
78static unsigned int 78static unsigned int
79ip6table_mangle_hook(unsigned int hook, struct sk_buff *skb, 79ip6table_mangle_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
80 const struct net_device *in, const struct net_device *out, 80 const struct net_device *in, const struct net_device *out,
81 int (*okfn)(struct sk_buff *)) 81 int (*okfn)(struct sk_buff *))
82{ 82{
83 if (hook == NF_INET_LOCAL_OUT) 83 if (ops->hooknum == NF_INET_LOCAL_OUT)
84 return ip6t_mangle_out(skb, out); 84 return ip6t_mangle_out(skb, out);
85 if (hook == NF_INET_POST_ROUTING) 85 if (ops->hooknum == NF_INET_POST_ROUTING)
86 return ip6t_do_table(skb, hook, in, out, 86 return ip6t_do_table(skb, ops->hooknum, in, out,
87 dev_net(out)->ipv6.ip6table_mangle); 87 dev_net(out)->ipv6.ip6table_mangle);
88 /* INPUT/FORWARD */ 88 /* INPUT/FORWARD */
89 return ip6t_do_table(skb, hook, in, out, 89 return ip6t_do_table(skb, ops->hooknum, in, out,
90 dev_net(in)->ipv6.ip6table_mangle); 90 dev_net(in)->ipv6.ip6table_mangle);
91} 91}
92 92
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c
index 9b076d2d3a7b..84c7f33d0cf8 100644
--- a/net/ipv6/netfilter/ip6table_nat.c
+++ b/net/ipv6/netfilter/ip6table_nat.c
@@ -63,7 +63,7 @@ static unsigned int nf_nat_rule_find(struct sk_buff *skb, unsigned int hooknum,
63} 63}
64 64
65static unsigned int 65static unsigned int
66nf_nat_ipv6_fn(unsigned int hooknum, 66nf_nat_ipv6_fn(const struct nf_hook_ops *ops,
67 struct sk_buff *skb, 67 struct sk_buff *skb,
68 const struct net_device *in, 68 const struct net_device *in,
69 const struct net_device *out, 69 const struct net_device *out,
@@ -72,7 +72,7 @@ nf_nat_ipv6_fn(unsigned int hooknum,
72 struct nf_conn *ct; 72 struct nf_conn *ct;
73 enum ip_conntrack_info ctinfo; 73 enum ip_conntrack_info ctinfo;
74 struct nf_conn_nat *nat; 74 struct nf_conn_nat *nat;
75 enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum); 75 enum nf_nat_manip_type maniptype = HOOK2MANIP(ops->hooknum);
76 __be16 frag_off; 76 __be16 frag_off;
77 int hdrlen; 77 int hdrlen;
78 u8 nexthdr; 78 u8 nexthdr;
@@ -111,7 +111,8 @@ nf_nat_ipv6_fn(unsigned int hooknum,
111 111
112 if (hdrlen >= 0 && nexthdr == IPPROTO_ICMPV6) { 112 if (hdrlen >= 0 && nexthdr == IPPROTO_ICMPV6) {
113 if (!nf_nat_icmpv6_reply_translation(skb, ct, ctinfo, 113 if (!nf_nat_icmpv6_reply_translation(skb, ct, ctinfo,
114 hooknum, hdrlen)) 114 ops->hooknum,
115 hdrlen))
115 return NF_DROP; 116 return NF_DROP;
116 else 117 else
117 return NF_ACCEPT; 118 return NF_ACCEPT;
@@ -124,14 +125,14 @@ nf_nat_ipv6_fn(unsigned int hooknum,
124 if (!nf_nat_initialized(ct, maniptype)) { 125 if (!nf_nat_initialized(ct, maniptype)) {
125 unsigned int ret; 126 unsigned int ret;
126 127
127 ret = nf_nat_rule_find(skb, hooknum, in, out, ct); 128 ret = nf_nat_rule_find(skb, ops->hooknum, in, out, ct);
128 if (ret != NF_ACCEPT) 129 if (ret != NF_ACCEPT)
129 return ret; 130 return ret;
130 } else { 131 } else {
131 pr_debug("Already setup manip %s for ct %p\n", 132 pr_debug("Already setup manip %s for ct %p\n",
132 maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST", 133 maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST",
133 ct); 134 ct);
134 if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) 135 if (nf_nat_oif_changed(ops->hooknum, ctinfo, nat, out))
135 goto oif_changed; 136 goto oif_changed;
136 } 137 }
137 break; 138 break;
@@ -140,11 +141,11 @@ nf_nat_ipv6_fn(unsigned int hooknum,
140 /* ESTABLISHED */ 141 /* ESTABLISHED */
141 NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED || 142 NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
142 ctinfo == IP_CT_ESTABLISHED_REPLY); 143 ctinfo == IP_CT_ESTABLISHED_REPLY);
143 if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) 144 if (nf_nat_oif_changed(ops->hooknum, ctinfo, nat, out))
144 goto oif_changed; 145 goto oif_changed;
145 } 146 }
146 147
147 return nf_nat_packet(ct, ctinfo, hooknum, skb); 148 return nf_nat_packet(ct, ctinfo, ops->hooknum, skb);
148 149
149oif_changed: 150oif_changed:
150 nf_ct_kill_acct(ct, ctinfo, skb); 151 nf_ct_kill_acct(ct, ctinfo, skb);
@@ -152,7 +153,7 @@ oif_changed:
152} 153}
153 154
154static unsigned int 155static unsigned int
155nf_nat_ipv6_in(unsigned int hooknum, 156nf_nat_ipv6_in(const struct nf_hook_ops *ops,
156 struct sk_buff *skb, 157 struct sk_buff *skb,
157 const struct net_device *in, 158 const struct net_device *in,
158 const struct net_device *out, 159 const struct net_device *out,
@@ -161,7 +162,7 @@ nf_nat_ipv6_in(unsigned int hooknum,
161 unsigned int ret; 162 unsigned int ret;
162 struct in6_addr daddr = ipv6_hdr(skb)->daddr; 163 struct in6_addr daddr = ipv6_hdr(skb)->daddr;
163 164
164 ret = nf_nat_ipv6_fn(hooknum, skb, in, out, okfn); 165 ret = nf_nat_ipv6_fn(ops, skb, in, out, okfn);
165 if (ret != NF_DROP && ret != NF_STOLEN && 166 if (ret != NF_DROP && ret != NF_STOLEN &&
166 ipv6_addr_cmp(&daddr, &ipv6_hdr(skb)->daddr)) 167 ipv6_addr_cmp(&daddr, &ipv6_hdr(skb)->daddr))
167 skb_dst_drop(skb); 168 skb_dst_drop(skb);
@@ -170,7 +171,7 @@ nf_nat_ipv6_in(unsigned int hooknum,
170} 171}
171 172
172static unsigned int 173static unsigned int
173nf_nat_ipv6_out(unsigned int hooknum, 174nf_nat_ipv6_out(const struct nf_hook_ops *ops,
174 struct sk_buff *skb, 175 struct sk_buff *skb,
175 const struct net_device *in, 176 const struct net_device *in,
176 const struct net_device *out, 177 const struct net_device *out,
@@ -187,7 +188,7 @@ nf_nat_ipv6_out(unsigned int hooknum,
187 if (skb->len < sizeof(struct ipv6hdr)) 188 if (skb->len < sizeof(struct ipv6hdr))
188 return NF_ACCEPT; 189 return NF_ACCEPT;
189 190
190 ret = nf_nat_ipv6_fn(hooknum, skb, in, out, okfn); 191 ret = nf_nat_ipv6_fn(ops, skb, in, out, okfn);
191#ifdef CONFIG_XFRM 192#ifdef CONFIG_XFRM
192 if (ret != NF_DROP && ret != NF_STOLEN && 193 if (ret != NF_DROP && ret != NF_STOLEN &&
193 !(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && 194 !(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
@@ -209,7 +210,7 @@ nf_nat_ipv6_out(unsigned int hooknum,
209} 210}
210 211
211static unsigned int 212static unsigned int
212nf_nat_ipv6_local_fn(unsigned int hooknum, 213nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
213 struct sk_buff *skb, 214 struct sk_buff *skb,
214 const struct net_device *in, 215 const struct net_device *in,
215 const struct net_device *out, 216 const struct net_device *out,
@@ -224,7 +225,7 @@ nf_nat_ipv6_local_fn(unsigned int hooknum,
224 if (skb->len < sizeof(struct ipv6hdr)) 225 if (skb->len < sizeof(struct ipv6hdr))
225 return NF_ACCEPT; 226 return NF_ACCEPT;
226 227
227 ret = nf_nat_ipv6_fn(hooknum, skb, in, out, okfn); 228 ret = nf_nat_ipv6_fn(ops, skb, in, out, okfn);
228 if (ret != NF_DROP && ret != NF_STOLEN && 229 if (ret != NF_DROP && ret != NF_STOLEN &&
229 (ct = nf_ct_get(skb, &ctinfo)) != NULL) { 230 (ct = nf_ct_get(skb, &ctinfo)) != NULL) {
230 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 231 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index 9a626d86720f..5274740acecc 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -19,13 +19,14 @@ static const struct xt_table packet_raw = {
19 19
20/* The work comes in here from netfilter.c. */ 20/* The work comes in here from netfilter.c. */
21static unsigned int 21static unsigned int
22ip6table_raw_hook(unsigned int hook, struct sk_buff *skb, 22ip6table_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
23 const struct net_device *in, const struct net_device *out, 23 const struct net_device *in, const struct net_device *out,
24 int (*okfn)(struct sk_buff *)) 24 int (*okfn)(struct sk_buff *))
25{ 25{
26 const struct net *net = dev_net((in != NULL) ? in : out); 26 const struct net *net = dev_net((in != NULL) ? in : out);
27 27
28 return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_raw); 28 return ip6t_do_table(skb, ops->hooknum, in, out,
29 net->ipv6.ip6table_raw);
29} 30}
30 31
31static struct nf_hook_ops *rawtable_ops __read_mostly; 32static struct nf_hook_ops *rawtable_ops __read_mostly;
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index ce88d1d7e525..ab3b0219ecfa 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -36,14 +36,15 @@ static const struct xt_table security_table = {
36}; 36};
37 37
38static unsigned int 38static unsigned int
39ip6table_security_hook(unsigned int hook, struct sk_buff *skb, 39ip6table_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
40 const struct net_device *in, 40 const struct net_device *in,
41 const struct net_device *out, 41 const struct net_device *out,
42 int (*okfn)(struct sk_buff *)) 42 int (*okfn)(struct sk_buff *))
43{ 43{
44 const struct net *net = dev_net((in != NULL) ? in : out); 44 const struct net *net = dev_net((in != NULL) ? in : out);
45 45
46 return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_security); 46 return ip6t_do_table(skb, ops->hooknum, in, out,
47 net->ipv6.ip6table_security);
47} 48}
48 49
49static struct nf_hook_ops *sectbl_ops __read_mostly; 50static struct nf_hook_ops *sectbl_ops __read_mostly;
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 54b75ead5a69..486545eb42ce 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -95,7 +95,7 @@ static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
95 return NF_ACCEPT; 95 return NF_ACCEPT;
96} 96}
97 97
98static unsigned int ipv6_helper(unsigned int hooknum, 98static unsigned int ipv6_helper(const struct nf_hook_ops *ops,
99 struct sk_buff *skb, 99 struct sk_buff *skb,
100 const struct net_device *in, 100 const struct net_device *in,
101 const struct net_device *out, 101 const struct net_device *out,
@@ -133,7 +133,7 @@ static unsigned int ipv6_helper(unsigned int hooknum,
133 return helper->help(skb, protoff, ct, ctinfo); 133 return helper->help(skb, protoff, ct, ctinfo);
134} 134}
135 135
136static unsigned int ipv6_confirm(unsigned int hooknum, 136static unsigned int ipv6_confirm(const struct nf_hook_ops *ops,
137 struct sk_buff *skb, 137 struct sk_buff *skb,
138 const struct net_device *in, 138 const struct net_device *in,
139 const struct net_device *out, 139 const struct net_device *out,
@@ -219,16 +219,17 @@ static unsigned int __ipv6_conntrack_in(struct net *net,
219 return nf_conntrack_in(net, PF_INET6, hooknum, skb); 219 return nf_conntrack_in(net, PF_INET6, hooknum, skb);
220} 220}
221 221
222static unsigned int ipv6_conntrack_in(unsigned int hooknum, 222static unsigned int ipv6_conntrack_in(const struct nf_hook_ops *ops,
223 struct sk_buff *skb, 223 struct sk_buff *skb,
224 const struct net_device *in, 224 const struct net_device *in,
225 const struct net_device *out, 225 const struct net_device *out,
226 int (*okfn)(struct sk_buff *)) 226 int (*okfn)(struct sk_buff *))
227{ 227{
228 return __ipv6_conntrack_in(dev_net(in), hooknum, skb, in, out, okfn); 228 return __ipv6_conntrack_in(dev_net(in), ops->hooknum, skb, in, out,
229 okfn);
229} 230}
230 231
231static unsigned int ipv6_conntrack_local(unsigned int hooknum, 232static unsigned int ipv6_conntrack_local(const struct nf_hook_ops *ops,
232 struct sk_buff *skb, 233 struct sk_buff *skb,
233 const struct net_device *in, 234 const struct net_device *in,
234 const struct net_device *out, 235 const struct net_device *out,
@@ -239,7 +240,8 @@ static unsigned int ipv6_conntrack_local(unsigned int hooknum,
239 net_notice_ratelimited("ipv6_conntrack_local: packet too short\n"); 240 net_notice_ratelimited("ipv6_conntrack_local: packet too short\n");
240 return NF_ACCEPT; 241 return NF_ACCEPT;
241 } 242 }
242 return __ipv6_conntrack_in(dev_net(out), hooknum, skb, in, out, okfn); 243 return __ipv6_conntrack_in(dev_net(out), ops->hooknum, skb, in, out,
244 okfn);
243} 245}
244 246
245static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = { 247static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = {
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index aacd121fe8c5..ec483aa3f60f 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -52,7 +52,7 @@ static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
52 52
53} 53}
54 54
55static unsigned int ipv6_defrag(unsigned int hooknum, 55static unsigned int ipv6_defrag(const struct nf_hook_ops *ops,
56 struct sk_buff *skb, 56 struct sk_buff *skb,
57 const struct net_device *in, 57 const struct net_device *in,
58 const struct net_device *out, 58 const struct net_device *out,
@@ -66,7 +66,7 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
66 return NF_ACCEPT; 66 return NF_ACCEPT;
67#endif 67#endif
68 68
69 reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(hooknum, skb)); 69 reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(ops->hooknum, skb));
70 /* queued */ 70 /* queued */
71 if (reasm == NULL) 71 if (reasm == NULL)
72 return NF_STOLEN; 72 return NF_STOLEN;
@@ -75,7 +75,7 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
75 if (reasm == skb) 75 if (reasm == skb)
76 return NF_ACCEPT; 76 return NF_ACCEPT;
77 77
78 nf_ct_frag6_output(hooknum, reasm, (struct net_device *)in, 78 nf_ct_frag6_output(ops->hooknum, reasm, (struct net_device *)in,
79 (struct net_device *)out, okfn); 79 (struct net_device *)out, okfn);
80 80
81 return NF_STOLEN; 81 return NF_STOLEN;