aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-05-11 12:59:21 -0400
committerPatrick McHardy <kaber@trash.net>2010-05-11 12:59:21 -0400
commitcba7a98a474a4f2a9316473734ba76829191a78a (patch)
tree28a0ab87dba93385353bedb76a26a1fc45b3a0c6 /net/ipv4
parentd250fe91ae129bff0968e685cc9c466d3a5e3482 (diff)
parent4538506be386f9736b83bf9892f829adbbb70fea (diff)
Merge branch 'master' of git://dev.medozas.de/linux
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/arp_tables.c65
-rw-r--r--net/ipv4/netfilter/arpt_mangle.c2
-rw-r--r--net/ipv4/netfilter/ip_tables.c128
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c2
-rw-r--r--net/ipv4/netfilter/ipt_ECN.c2
-rw-r--r--net/ipv4/netfilter/ipt_LOG.c2
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c2
-rw-r--r--net/ipv4/netfilter/ipt_NETMAP.c2
-rw-r--r--net/ipv4/netfilter/ipt_REDIRECT.c2
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c2
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c2
-rw-r--r--net/ipv4/netfilter/ipt_addrtype.c4
-rw-r--r--net/ipv4/netfilter/ipt_ah.c4
-rw-r--r--net/ipv4/netfilter/ipt_ecn.c4
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c4
15 files changed, 101 insertions, 126 deletions
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 07a699059390..03352fcba172 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -224,7 +224,7 @@ static inline int arp_checkentry(const struct arpt_arp *arp)
224} 224}
225 225
226static unsigned int 226static unsigned int
227arpt_error(struct sk_buff *skb, const struct xt_target_param *par) 227arpt_error(struct sk_buff *skb, const struct xt_action_param *par)
228{ 228{
229 if (net_ratelimit()) 229 if (net_ratelimit())
230 printk("arp_tables: error: '%s'\n", 230 printk("arp_tables: error: '%s'\n",
@@ -260,12 +260,11 @@ unsigned int arpt_do_table(struct sk_buff *skb,
260 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long)))); 260 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
261 unsigned int verdict = NF_DROP; 261 unsigned int verdict = NF_DROP;
262 const struct arphdr *arp; 262 const struct arphdr *arp;
263 bool hotdrop = false;
264 struct arpt_entry *e, *back; 263 struct arpt_entry *e, *back;
265 const char *indev, *outdev; 264 const char *indev, *outdev;
266 void *table_base; 265 void *table_base;
267 const struct xt_table_info *private; 266 const struct xt_table_info *private;
268 struct xt_target_param tgpar; 267 struct xt_action_param acpar;
269 268
270 if (!pskb_may_pull(skb, arp_hdr_len(skb->dev))) 269 if (!pskb_may_pull(skb, arp_hdr_len(skb->dev)))
271 return NF_DROP; 270 return NF_DROP;
@@ -280,10 +279,11 @@ unsigned int arpt_do_table(struct sk_buff *skb,
280 e = get_entry(table_base, private->hook_entry[hook]); 279 e = get_entry(table_base, private->hook_entry[hook]);
281 back = get_entry(table_base, private->underflow[hook]); 280 back = get_entry(table_base, private->underflow[hook]);
282 281
283 tgpar.in = in; 282 acpar.in = in;
284 tgpar.out = out; 283 acpar.out = out;
285 tgpar.hooknum = hook; 284 acpar.hooknum = hook;
286 tgpar.family = NFPROTO_ARP; 285 acpar.family = NFPROTO_ARP;
286 acpar.hotdrop = false;
287 287
288 arp = arp_hdr(skb); 288 arp = arp_hdr(skb);
289 do { 289 do {
@@ -333,9 +333,9 @@ unsigned int arpt_do_table(struct sk_buff *skb,
333 /* Targets which reenter must return 333 /* Targets which reenter must return
334 * abs. verdicts 334 * abs. verdicts
335 */ 335 */
336 tgpar.target = t->u.kernel.target; 336 acpar.target = t->u.kernel.target;
337 tgpar.targinfo = t->data; 337 acpar.targinfo = t->data;
338 verdict = t->u.kernel.target->target(skb, &tgpar); 338 verdict = t->u.kernel.target->target(skb, &acpar);
339 339
340 /* Target might have changed stuff. */ 340 /* Target might have changed stuff. */
341 arp = arp_hdr(skb); 341 arp = arp_hdr(skb);
@@ -345,10 +345,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
345 else 345 else
346 /* Verdict */ 346 /* Verdict */
347 break; 347 break;
348 } while (!hotdrop); 348 } while (!acpar.hotdrop);
349 xt_info_rdunlock_bh(); 349 xt_info_rdunlock_bh();
350 350
351 if (hotdrop) 351 if (acpar.hotdrop)
352 return NF_DROP; 352 return NF_DROP;
353 else 353 else
354 return verdict; 354 return verdict;
@@ -1828,22 +1828,23 @@ void arpt_unregister_table(struct xt_table *table)
1828} 1828}
1829 1829
1830/* The built-in targets: standard (NULL) and error. */ 1830/* The built-in targets: standard (NULL) and error. */
1831static struct xt_target arpt_standard_target __read_mostly = { 1831static struct xt_target arpt_builtin_tg[] __read_mostly = {
1832 .name = ARPT_STANDARD_TARGET, 1832 {
1833 .targetsize = sizeof(int), 1833 .name = ARPT_STANDARD_TARGET,
1834 .family = NFPROTO_ARP, 1834 .targetsize = sizeof(int),
1835 .family = NFPROTO_ARP,
1835#ifdef CONFIG_COMPAT 1836#ifdef CONFIG_COMPAT
1836 .compatsize = sizeof(compat_int_t), 1837 .compatsize = sizeof(compat_int_t),
1837 .compat_from_user = compat_standard_from_user, 1838 .compat_from_user = compat_standard_from_user,
1838 .compat_to_user = compat_standard_to_user, 1839 .compat_to_user = compat_standard_to_user,
1839#endif 1840#endif
1840}; 1841 },
1841 1842 {
1842static struct xt_target arpt_error_target __read_mostly = { 1843 .name = ARPT_ERROR_TARGET,
1843 .name = ARPT_ERROR_TARGET, 1844 .target = arpt_error,
1844 .target = arpt_error, 1845 .targetsize = ARPT_FUNCTION_MAXNAMELEN,
1845 .targetsize = ARPT_FUNCTION_MAXNAMELEN, 1846 .family = NFPROTO_ARP,
1846 .family = NFPROTO_ARP, 1847 },
1847}; 1848};
1848 1849
1849static struct nf_sockopt_ops arpt_sockopts = { 1850static struct nf_sockopt_ops arpt_sockopts = {
@@ -1887,12 +1888,9 @@ static int __init arp_tables_init(void)
1887 goto err1; 1888 goto err1;
1888 1889
1889 /* Noone else will be downing sem now, so we won't sleep */ 1890 /* Noone else will be downing sem now, so we won't sleep */
1890 ret = xt_register_target(&arpt_standard_target); 1891 ret = xt_register_targets(arpt_builtin_tg, ARRAY_SIZE(arpt_builtin_tg));
1891 if (ret < 0) 1892 if (ret < 0)
1892 goto err2; 1893 goto err2;
1893 ret = xt_register_target(&arpt_error_target);
1894 if (ret < 0)
1895 goto err3;
1896 1894
1897 /* Register setsockopt */ 1895 /* Register setsockopt */
1898 ret = nf_register_sockopt(&arpt_sockopts); 1896 ret = nf_register_sockopt(&arpt_sockopts);
@@ -1903,9 +1901,7 @@ static int __init arp_tables_init(void)
1903 return 0; 1901 return 0;
1904 1902
1905err4: 1903err4:
1906 xt_unregister_target(&arpt_error_target); 1904 xt_unregister_targets(arpt_builtin_tg, ARRAY_SIZE(arpt_builtin_tg));
1907err3:
1908 xt_unregister_target(&arpt_standard_target);
1909err2: 1905err2:
1910 unregister_pernet_subsys(&arp_tables_net_ops); 1906 unregister_pernet_subsys(&arp_tables_net_ops);
1911err1: 1907err1:
@@ -1915,8 +1911,7 @@ err1:
1915static void __exit arp_tables_fini(void) 1911static void __exit arp_tables_fini(void)
1916{ 1912{
1917 nf_unregister_sockopt(&arpt_sockopts); 1913 nf_unregister_sockopt(&arpt_sockopts);
1918 xt_unregister_target(&arpt_error_target); 1914 xt_unregister_targets(arpt_builtin_tg, ARRAY_SIZE(arpt_builtin_tg));
1919 xt_unregister_target(&arpt_standard_target);
1920 unregister_pernet_subsys(&arp_tables_net_ops); 1915 unregister_pernet_subsys(&arp_tables_net_ops);
1921} 1916}
1922 1917
diff --git a/net/ipv4/netfilter/arpt_mangle.c b/net/ipv4/netfilter/arpt_mangle.c
index 4b51a027f307..e1be7dd1171b 100644
--- a/net/ipv4/netfilter/arpt_mangle.c
+++ b/net/ipv4/netfilter/arpt_mangle.c
@@ -9,7 +9,7 @@ MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
9MODULE_DESCRIPTION("arptables arp payload mangle target"); 9MODULE_DESCRIPTION("arptables arp payload mangle target");
10 10
11static unsigned int 11static unsigned int
12target(struct sk_buff *skb, const struct xt_target_param *par) 12target(struct sk_buff *skb, const struct xt_action_param *par)
13{ 13{
14 const struct arpt_mangle *mangle = par->targinfo; 14 const struct arpt_mangle *mangle = par->targinfo;
15 const struct arphdr *arp; 15 const struct arphdr *arp;
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 3e6af1036fbc..49b9e4fb5460 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -165,7 +165,7 @@ ip_checkentry(const struct ipt_ip *ip)
165} 165}
166 166
167static unsigned int 167static unsigned int
168ipt_error(struct sk_buff *skb, const struct xt_target_param *par) 168ipt_error(struct sk_buff *skb, const struct xt_action_param *par)
169{ 169{
170 if (net_ratelimit()) 170 if (net_ratelimit())
171 pr_info("error: `%s'\n", (const char *)par->targinfo); 171 pr_info("error: `%s'\n", (const char *)par->targinfo);
@@ -173,21 +173,6 @@ ipt_error(struct sk_buff *skb, const struct xt_target_param *par)
173 return NF_DROP; 173 return NF_DROP;
174} 174}
175 175
176/* Performance critical - called for every packet */
177static inline bool
178do_match(const struct ipt_entry_match *m, const struct sk_buff *skb,
179 struct xt_match_param *par)
180{
181 par->match = m->u.kernel.match;
182 par->matchinfo = m->data;
183
184 /* Stop iteration if it doesn't match */
185 if (!m->u.kernel.match->match(skb, par))
186 return true;
187 else
188 return false;
189}
190
191/* Performance critical */ 176/* Performance critical */
192static inline struct ipt_entry * 177static inline struct ipt_entry *
193get_entry(const void *base, unsigned int offset) 178get_entry(const void *base, unsigned int offset)
@@ -323,7 +308,6 @@ ipt_do_table(struct sk_buff *skb,
323{ 308{
324 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long)))); 309 static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
325 const struct iphdr *ip; 310 const struct iphdr *ip;
326 bool hotdrop = false;
327 /* Initializing verdict to NF_DROP keeps gcc happy. */ 311 /* Initializing verdict to NF_DROP keeps gcc happy. */
328 unsigned int verdict = NF_DROP; 312 unsigned int verdict = NF_DROP;
329 const char *indev, *outdev; 313 const char *indev, *outdev;
@@ -331,8 +315,7 @@ ipt_do_table(struct sk_buff *skb,
331 struct ipt_entry *e, **jumpstack; 315 struct ipt_entry *e, **jumpstack;
332 unsigned int *stackptr, origptr, cpu; 316 unsigned int *stackptr, origptr, cpu;
333 const struct xt_table_info *private; 317 const struct xt_table_info *private;
334 struct xt_match_param mtpar; 318 struct xt_action_param acpar;
335 struct xt_target_param tgpar;
336 319
337 /* Initialization */ 320 /* Initialization */
338 ip = ip_hdr(skb); 321 ip = ip_hdr(skb);
@@ -344,13 +327,13 @@ ipt_do_table(struct sk_buff *skb,
344 * things we don't know, ie. tcp syn flag or ports). If the 327 * things we don't know, ie. tcp syn flag or ports). If the
345 * rule is also a fragment-specific rule, non-fragments won't 328 * rule is also a fragment-specific rule, non-fragments won't
346 * match it. */ 329 * match it. */
347 mtpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET; 330 acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET;
348 mtpar.thoff = ip_hdrlen(skb); 331 acpar.thoff = ip_hdrlen(skb);
349 mtpar.hotdrop = &hotdrop; 332 acpar.hotdrop = false;
350 mtpar.in = tgpar.in = in; 333 acpar.in = in;
351 mtpar.out = tgpar.out = out; 334 acpar.out = out;
352 mtpar.family = tgpar.family = NFPROTO_IPV4; 335 acpar.family = NFPROTO_IPV4;
353 mtpar.hooknum = tgpar.hooknum = hook; 336 acpar.hooknum = hook;
354 337
355 IP_NF_ASSERT(table->valid_hooks & (1 << hook)); 338 IP_NF_ASSERT(table->valid_hooks & (1 << hook));
356 xt_info_rdlock_bh(); 339 xt_info_rdlock_bh();
@@ -373,15 +356,18 @@ ipt_do_table(struct sk_buff *skb,
373 356
374 IP_NF_ASSERT(e); 357 IP_NF_ASSERT(e);
375 if (!ip_packet_match(ip, indev, outdev, 358 if (!ip_packet_match(ip, indev, outdev,
376 &e->ip, mtpar.fragoff)) { 359 &e->ip, acpar.fragoff)) {
377 no_match: 360 no_match:
378 e = ipt_next_entry(e); 361 e = ipt_next_entry(e);
379 continue; 362 continue;
380 } 363 }
381 364
382 xt_ematch_foreach(ematch, e) 365 xt_ematch_foreach(ematch, e) {
383 if (do_match(ematch, skb, &mtpar) != 0) 366 acpar.match = ematch->u.kernel.match;
367 acpar.matchinfo = ematch->data;
368 if (!acpar.match->match(skb, &acpar))
384 goto no_match; 369 goto no_match;
370 }
385 371
386 ADD_COUNTER(e->counters, ntohs(ip->tot_len), 1); 372 ADD_COUNTER(e->counters, ntohs(ip->tot_len), 1);
387 373
@@ -434,11 +420,10 @@ ipt_do_table(struct sk_buff *skb,
434 continue; 420 continue;
435 } 421 }
436 422
437 tgpar.target = t->u.kernel.target; 423 acpar.target = t->u.kernel.target;
438 tgpar.targinfo = t->data; 424 acpar.targinfo = t->data;
439
440 425
441 verdict = t->u.kernel.target->target(skb, &tgpar); 426 verdict = t->u.kernel.target->target(skb, &acpar);
442 /* Target might have changed stuff. */ 427 /* Target might have changed stuff. */
443 ip = ip_hdr(skb); 428 ip = ip_hdr(skb);
444 if (verdict == IPT_CONTINUE) 429 if (verdict == IPT_CONTINUE)
@@ -446,7 +431,7 @@ ipt_do_table(struct sk_buff *skb,
446 else 431 else
447 /* Verdict */ 432 /* Verdict */
448 break; 433 break;
449 } while (!hotdrop); 434 } while (!acpar.hotdrop);
450 xt_info_rdunlock_bh(); 435 xt_info_rdunlock_bh();
451 pr_debug("Exiting %s; resetting sp from %u to %u\n", 436 pr_debug("Exiting %s; resetting sp from %u to %u\n",
452 __func__, *stackptr, origptr); 437 __func__, *stackptr, origptr);
@@ -454,7 +439,7 @@ ipt_do_table(struct sk_buff *skb,
454#ifdef DEBUG_ALLOW_ALL 439#ifdef DEBUG_ALLOW_ALL
455 return NF_ACCEPT; 440 return NF_ACCEPT;
456#else 441#else
457 if (hotdrop) 442 if (acpar.hotdrop)
458 return NF_DROP; 443 return NF_DROP;
459 else return verdict; 444 else return verdict;
460#endif 445#endif
@@ -591,7 +576,7 @@ check_entry(const struct ipt_entry *e, const char *name)
591 const struct ipt_entry_target *t; 576 const struct ipt_entry_target *t;
592 577
593 if (!ip_checkentry(&e->ip)) { 578 if (!ip_checkentry(&e->ip)) {
594 duprintf("ip check failed %p %s.\n", e, name); 579 duprintf("ip check failed %p %s.\n", e, par->match->name);
595 return -EINVAL; 580 return -EINVAL;
596 } 581 }
597 582
@@ -618,7 +603,7 @@ check_match(struct ipt_entry_match *m, struct xt_mtchk_param *par)
618 ret = xt_check_match(par, m->u.match_size - sizeof(*m), 603 ret = xt_check_match(par, m->u.match_size - sizeof(*m),
619 ip->proto, ip->invflags & IPT_INV_PROTO); 604 ip->proto, ip->invflags & IPT_INV_PROTO);
620 if (ret < 0) { 605 if (ret < 0) {
621 duprintf("check failed for `%s'.\n", par.match->name); 606 duprintf("check failed for `%s'.\n", par->match->name);
622 return ret; 607 return ret;
623 } 608 }
624 return 0; 609 return 0;
@@ -2152,7 +2137,7 @@ icmp_type_code_match(u_int8_t test_type, u_int8_t min_code, u_int8_t max_code,
2152} 2137}
2153 2138
2154static bool 2139static bool
2155icmp_match(const struct sk_buff *skb, const struct xt_match_param *par) 2140icmp_match(const struct sk_buff *skb, struct xt_action_param *par)
2156{ 2141{
2157 const struct icmphdr *ic; 2142 const struct icmphdr *ic;
2158 struct icmphdr _icmph; 2143 struct icmphdr _icmph;
@@ -2168,7 +2153,7 @@ icmp_match(const struct sk_buff *skb, const struct xt_match_param *par)
2168 * can't. Hence, no choice but to drop. 2153 * can't. Hence, no choice but to drop.
2169 */ 2154 */
2170 duprintf("Dropping evil ICMP tinygram.\n"); 2155 duprintf("Dropping evil ICMP tinygram.\n");
2171 *par->hotdrop = true; 2156 par->hotdrop = true;
2172 return false; 2157 return false;
2173 } 2158 }
2174 2159
@@ -2187,23 +2172,23 @@ static int icmp_checkentry(const struct xt_mtchk_param *par)
2187 return (icmpinfo->invflags & ~IPT_ICMP_INV) ? -EINVAL : 0; 2172 return (icmpinfo->invflags & ~IPT_ICMP_INV) ? -EINVAL : 0;
2188} 2173}
2189 2174
2190/* The built-in targets: standard (NULL) and error. */ 2175static struct xt_target ipt_builtin_tg[] __read_mostly = {
2191static struct xt_target ipt_standard_target __read_mostly = { 2176 {
2192 .name = IPT_STANDARD_TARGET, 2177 .name = IPT_STANDARD_TARGET,
2193 .targetsize = sizeof(int), 2178 .targetsize = sizeof(int),
2194 .family = NFPROTO_IPV4, 2179 .family = NFPROTO_IPV4,
2195#ifdef CONFIG_COMPAT 2180#ifdef CONFIG_COMPAT
2196 .compatsize = sizeof(compat_int_t), 2181 .compatsize = sizeof(compat_int_t),
2197 .compat_from_user = compat_standard_from_user, 2182 .compat_from_user = compat_standard_from_user,
2198 .compat_to_user = compat_standard_to_user, 2183 .compat_to_user = compat_standard_to_user,
2199#endif 2184#endif
2200}; 2185 },
2201 2186 {
2202static struct xt_target ipt_error_target __read_mostly = { 2187 .name = IPT_ERROR_TARGET,
2203 .name = IPT_ERROR_TARGET, 2188 .target = ipt_error,
2204 .target = ipt_error, 2189 .targetsize = IPT_FUNCTION_MAXNAMELEN,
2205 .targetsize = IPT_FUNCTION_MAXNAMELEN, 2190 .family = NFPROTO_IPV4,
2206 .family = NFPROTO_IPV4, 2191 },
2207}; 2192};
2208 2193
2209static struct nf_sockopt_ops ipt_sockopts = { 2194static struct nf_sockopt_ops ipt_sockopts = {
@@ -2223,13 +2208,15 @@ static struct nf_sockopt_ops ipt_sockopts = {
2223 .owner = THIS_MODULE, 2208 .owner = THIS_MODULE,
2224}; 2209};
2225 2210
2226static struct xt_match icmp_matchstruct __read_mostly = { 2211static struct xt_match ipt_builtin_mt[] __read_mostly = {
2227 .name = "icmp", 2212 {
2228 .match = icmp_match, 2213 .name = "icmp",
2229 .matchsize = sizeof(struct ipt_icmp), 2214 .match = icmp_match,
2230 .checkentry = icmp_checkentry, 2215 .matchsize = sizeof(struct ipt_icmp),
2231 .proto = IPPROTO_ICMP, 2216 .checkentry = icmp_checkentry,
2232 .family = NFPROTO_IPV4, 2217 .proto = IPPROTO_ICMP,
2218 .family = NFPROTO_IPV4,
2219 },
2233}; 2220};
2234 2221
2235static int __net_init ip_tables_net_init(struct net *net) 2222static int __net_init ip_tables_net_init(struct net *net)
@@ -2256,13 +2243,10 @@ static int __init ip_tables_init(void)
2256 goto err1; 2243 goto err1;
2257 2244
2258 /* Noone else will be downing sem now, so we won't sleep */ 2245 /* Noone else will be downing sem now, so we won't sleep */
2259 ret = xt_register_target(&ipt_standard_target); 2246 ret = xt_register_targets(ipt_builtin_tg, ARRAY_SIZE(ipt_builtin_tg));
2260 if (ret < 0) 2247 if (ret < 0)
2261 goto err2; 2248 goto err2;
2262 ret = xt_register_target(&ipt_error_target); 2249 ret = xt_register_matches(ipt_builtin_mt, ARRAY_SIZE(ipt_builtin_mt));
2263 if (ret < 0)
2264 goto err3;
2265 ret = xt_register_match(&icmp_matchstruct);
2266 if (ret < 0) 2250 if (ret < 0)
2267 goto err4; 2251 goto err4;
2268 2252
@@ -2275,11 +2259,9 @@ static int __init ip_tables_init(void)
2275 return 0; 2259 return 0;
2276 2260
2277err5: 2261err5:
2278 xt_unregister_match(&icmp_matchstruct); 2262 xt_unregister_matches(ipt_builtin_mt, ARRAY_SIZE(ipt_builtin_mt));
2279err4: 2263err4:
2280 xt_unregister_target(&ipt_error_target); 2264 xt_unregister_targets(ipt_builtin_tg, ARRAY_SIZE(ipt_builtin_tg));
2281err3:
2282 xt_unregister_target(&ipt_standard_target);
2283err2: 2265err2:
2284 unregister_pernet_subsys(&ip_tables_net_ops); 2266 unregister_pernet_subsys(&ip_tables_net_ops);
2285err1: 2267err1:
@@ -2290,10 +2272,8 @@ static void __exit ip_tables_fini(void)
2290{ 2272{
2291 nf_unregister_sockopt(&ipt_sockopts); 2273 nf_unregister_sockopt(&ipt_sockopts);
2292 2274
2293 xt_unregister_match(&icmp_matchstruct); 2275 xt_unregister_matches(ipt_builtin_mt, ARRAY_SIZE(ipt_builtin_mt));
2294 xt_unregister_target(&ipt_error_target); 2276 xt_unregister_targets(ipt_builtin_tg, ARRAY_SIZE(ipt_builtin_tg));
2295 xt_unregister_target(&ipt_standard_target);
2296
2297 unregister_pernet_subsys(&ip_tables_net_ops); 2277 unregister_pernet_subsys(&ip_tables_net_ops);
2298} 2278}
2299 2279
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 8815d458de46..f91c94b9a790 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -282,7 +282,7 @@ clusterip_responsible(const struct clusterip_config *config, u_int32_t hash)
282 ***********************************************************************/ 282 ***********************************************************************/
283 283
284static unsigned int 284static unsigned int
285clusterip_tg(struct sk_buff *skb, const struct xt_target_param *par) 285clusterip_tg(struct sk_buff *skb, const struct xt_action_param *par)
286{ 286{
287 const struct ipt_clusterip_tgt_info *cipinfo = par->targinfo; 287 const struct ipt_clusterip_tgt_info *cipinfo = par->targinfo;
288 struct nf_conn *ct; 288 struct nf_conn *ct;
diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
index 563049f31aef..4bf3dc49ad1e 100644
--- a/net/ipv4/netfilter/ipt_ECN.c
+++ b/net/ipv4/netfilter/ipt_ECN.c
@@ -77,7 +77,7 @@ set_ect_tcp(struct sk_buff *skb, const struct ipt_ECN_info *einfo)
77} 77}
78 78
79static unsigned int 79static unsigned int
80ecn_tg(struct sk_buff *skb, const struct xt_target_param *par) 80ecn_tg(struct sk_buff *skb, const struct xt_action_param *par)
81{ 81{
82 const struct ipt_ECN_info *einfo = par->targinfo; 82 const struct ipt_ECN_info *einfo = par->targinfo;
83 83
diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
index 3bd35f370817..5234f4f3499a 100644
--- a/net/ipv4/netfilter/ipt_LOG.c
+++ b/net/ipv4/netfilter/ipt_LOG.c
@@ -425,7 +425,7 @@ ipt_log_packet(u_int8_t pf,
425} 425}
426 426
427static unsigned int 427static unsigned int
428log_tg(struct sk_buff *skb, const struct xt_target_param *par) 428log_tg(struct sk_buff *skb, const struct xt_action_param *par)
429{ 429{
430 const struct ipt_log_info *loginfo = par->targinfo; 430 const struct ipt_log_info *loginfo = par->targinfo;
431 struct nf_loginfo li; 431 struct nf_loginfo li;
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index 02b1bc477998..d2ed9dc74ebc 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -44,7 +44,7 @@ static int masquerade_tg_check(const struct xt_tgchk_param *par)
44} 44}
45 45
46static unsigned int 46static unsigned int
47masquerade_tg(struct sk_buff *skb, const struct xt_target_param *par) 47masquerade_tg(struct sk_buff *skb, const struct xt_action_param *par)
48{ 48{
49 struct nf_conn *ct; 49 struct nf_conn *ct;
50 struct nf_conn_nat *nat; 50 struct nf_conn_nat *nat;
diff --git a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c
index 708c7f8f7eea..f43867d1697f 100644
--- a/net/ipv4/netfilter/ipt_NETMAP.c
+++ b/net/ipv4/netfilter/ipt_NETMAP.c
@@ -38,7 +38,7 @@ static int netmap_tg_check(const struct xt_tgchk_param *par)
38} 38}
39 39
40static unsigned int 40static unsigned int
41netmap_tg(struct sk_buff *skb, const struct xt_target_param *par) 41netmap_tg(struct sk_buff *skb, const struct xt_action_param *par)
42{ 42{
43 struct nf_conn *ct; 43 struct nf_conn *ct;
44 enum ip_conntrack_info ctinfo; 44 enum ip_conntrack_info ctinfo;
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
index 3cf101916523..18a0656505a0 100644
--- a/net/ipv4/netfilter/ipt_REDIRECT.c
+++ b/net/ipv4/netfilter/ipt_REDIRECT.c
@@ -42,7 +42,7 @@ static int redirect_tg_check(const struct xt_tgchk_param *par)
42} 42}
43 43
44static unsigned int 44static unsigned int
45redirect_tg(struct sk_buff *skb, const struct xt_target_param *par) 45redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
46{ 46{
47 struct nf_conn *ct; 47 struct nf_conn *ct;
48 enum ip_conntrack_info ctinfo; 48 enum ip_conntrack_info ctinfo;
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index a86135a28058..f5f4a888e4ec 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -136,7 +136,7 @@ static inline void send_unreach(struct sk_buff *skb_in, int code)
136} 136}
137 137
138static unsigned int 138static unsigned int
139reject_tg(struct sk_buff *skb, const struct xt_target_param *par) 139reject_tg(struct sk_buff *skb, const struct xt_action_param *par)
140{ 140{
141 const struct ipt_reject_info *reject = par->targinfo; 141 const struct ipt_reject_info *reject = par->targinfo;
142 142
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index 8f60749e87a3..446e0f467a17 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -276,7 +276,7 @@ alloc_failure:
276} 276}
277 277
278static unsigned int 278static unsigned int
279ulog_tg(struct sk_buff *skb, const struct xt_target_param *par) 279ulog_tg(struct sk_buff *skb, const struct xt_action_param *par)
280{ 280{
281 ipt_ulog_packet(par->hooknum, skb, par->in, par->out, 281 ipt_ulog_packet(par->hooknum, skb, par->in, par->out,
282 par->targinfo, NULL); 282 par->targinfo, NULL);
diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c
index e4b8f2bf8aaa..db8bff0fb86d 100644
--- a/net/ipv4/netfilter/ipt_addrtype.c
+++ b/net/ipv4/netfilter/ipt_addrtype.c
@@ -30,7 +30,7 @@ static inline bool match_type(struct net *net, const struct net_device *dev,
30} 30}
31 31
32static bool 32static bool
33addrtype_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par) 33addrtype_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
34{ 34{
35 struct net *net = dev_net(par->in ? par->in : par->out); 35 struct net *net = dev_net(par->in ? par->in : par->out);
36 const struct ipt_addrtype_info *info = par->matchinfo; 36 const struct ipt_addrtype_info *info = par->matchinfo;
@@ -48,7 +48,7 @@ addrtype_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
48} 48}
49 49
50static bool 50static bool
51addrtype_mt_v1(const struct sk_buff *skb, const struct xt_match_param *par) 51addrtype_mt_v1(const struct sk_buff *skb, struct xt_action_param *par)
52{ 52{
53 struct net *net = dev_net(par->in ? par->in : par->out); 53 struct net *net = dev_net(par->in ? par->in : par->out);
54 const struct ipt_addrtype_info_v1 *info = par->matchinfo; 54 const struct ipt_addrtype_info_v1 *info = par->matchinfo;
diff --git a/net/ipv4/netfilter/ipt_ah.c b/net/ipv4/netfilter/ipt_ah.c
index 9f9810204892..14a2aa8b8a14 100644
--- a/net/ipv4/netfilter/ipt_ah.c
+++ b/net/ipv4/netfilter/ipt_ah.c
@@ -30,7 +30,7 @@ spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, bool invert)
30 return r; 30 return r;
31} 31}
32 32
33static bool ah_mt(const struct sk_buff *skb, const struct xt_match_param *par) 33static bool ah_mt(const struct sk_buff *skb, struct xt_action_param *par)
34{ 34{
35 struct ip_auth_hdr _ahdr; 35 struct ip_auth_hdr _ahdr;
36 const struct ip_auth_hdr *ah; 36 const struct ip_auth_hdr *ah;
@@ -46,7 +46,7 @@ static bool ah_mt(const struct sk_buff *skb, const struct xt_match_param *par)
46 * can't. Hence, no choice but to drop. 46 * can't. Hence, no choice but to drop.
47 */ 47 */
48 pr_debug("Dropping evil AH tinygram.\n"); 48 pr_debug("Dropping evil AH tinygram.\n");
49 *par->hotdrop = true; 49 par->hotdrop = true;
50 return 0; 50 return 0;
51 } 51 }
52 52
diff --git a/net/ipv4/netfilter/ipt_ecn.c b/net/ipv4/netfilter/ipt_ecn.c
index 32e24100d8d1..af6e9c778345 100644
--- a/net/ipv4/netfilter/ipt_ecn.c
+++ b/net/ipv4/netfilter/ipt_ecn.c
@@ -67,7 +67,7 @@ static inline bool match_tcp(const struct sk_buff *skb,
67 return true; 67 return true;
68} 68}
69 69
70static bool ecn_mt(const struct sk_buff *skb, const struct xt_match_param *par) 70static bool ecn_mt(const struct sk_buff *skb, struct xt_action_param *par)
71{ 71{
72 const struct ipt_ecn_info *info = par->matchinfo; 72 const struct ipt_ecn_info *info = par->matchinfo;
73 73
@@ -78,7 +78,7 @@ static bool ecn_mt(const struct sk_buff *skb, const struct xt_match_param *par)
78 if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)) { 78 if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)) {
79 if (ip_hdr(skb)->protocol != IPPROTO_TCP) 79 if (ip_hdr(skb)->protocol != IPPROTO_TCP)
80 return false; 80 return false;
81 if (!match_tcp(skb, info, par->hotdrop)) 81 if (!match_tcp(skb, info, &par->hotdrop))
82 return false; 82 return false;
83 } 83 }
84 84
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index b48a0fc3d9ed..98ed78281aee 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -39,7 +39,7 @@ static const struct xt_table nat_table = {
39 39
40/* Source NAT */ 40/* Source NAT */
41static unsigned int 41static unsigned int
42ipt_snat_target(struct sk_buff *skb, const struct xt_target_param *par) 42ipt_snat_target(struct sk_buff *skb, const struct xt_action_param *par)
43{ 43{
44 struct nf_conn *ct; 44 struct nf_conn *ct;
45 enum ip_conntrack_info ctinfo; 45 enum ip_conntrack_info ctinfo;
@@ -58,7 +58,7 @@ ipt_snat_target(struct sk_buff *skb, const struct xt_target_param *par)
58} 58}
59 59
60static unsigned int 60static unsigned int
61ipt_dnat_target(struct sk_buff *skb, const struct xt_target_param *par) 61ipt_dnat_target(struct sk_buff *skb, const struct xt_action_param *par)
62{ 62{
63 struct nf_conn *ct; 63 struct nf_conn *ct;
64 enum ip_conntrack_info ctinfo; 64 enum ip_conntrack_info ctinfo;