diff options
-rw-r--r-- | include/net/netfilter/nf_conntrack_l4proto.h | 10 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 62 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 62 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto.c | 27 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto_dccp.c | 43 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto_gre.c | 23 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto_sctp.c | 43 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto_udplite.c | 40 |
8 files changed, 204 insertions, 106 deletions
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index c3be4aef6bf7..914d8d900798 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h | |||
@@ -121,12 +121,16 @@ extern struct nf_conntrack_l4proto * | |||
121 | nf_ct_l4proto_find_get(u_int16_t l3proto, u_int8_t l4proto); | 121 | nf_ct_l4proto_find_get(u_int16_t l3proto, u_int8_t l4proto); |
122 | extern void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p); | 122 | extern void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p); |
123 | 123 | ||
124 | /* Protocol registration. */ | 124 | /* Protocol pernet registration. */ |
125 | extern int nf_conntrack_l4proto_register(struct net *net, | 125 | extern int nf_ct_l4proto_pernet_register(struct net *net, |
126 | struct nf_conntrack_l4proto *proto); | 126 | struct nf_conntrack_l4proto *proto); |
127 | extern void nf_conntrack_l4proto_unregister(struct net *net, | 127 | extern void nf_ct_l4proto_pernet_unregister(struct net *net, |
128 | struct nf_conntrack_l4proto *proto); | 128 | struct nf_conntrack_l4proto *proto); |
129 | 129 | ||
130 | /* Protocol global registration. */ | ||
131 | extern int nf_ct_l4proto_register(struct nf_conntrack_l4proto *proto); | ||
132 | extern void nf_ct_l4proto_unregister(struct nf_conntrack_l4proto *proto); | ||
133 | |||
130 | static inline void nf_ct_kfree_compat_sysctl_table(struct nf_proto_net *pn) | 134 | static inline void nf_ct_kfree_compat_sysctl_table(struct nf_proto_net *pn) |
131 | { | 135 | { |
132 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) | 136 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index 76b84fc9acfc..48990ada0e1e 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
@@ -420,22 +420,19 @@ static int ipv4_net_init(struct net *net) | |||
420 | { | 420 | { |
421 | int ret = 0; | 421 | int ret = 0; |
422 | 422 | ||
423 | ret = nf_conntrack_l4proto_register(net, | 423 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_tcp4); |
424 | &nf_conntrack_l4proto_tcp4); | ||
425 | if (ret < 0) { | 424 | if (ret < 0) { |
426 | pr_err("nf_conntrack_l4proto_tcp4 :protocol register failed\n"); | 425 | pr_err("nf_conntrack_tcp4: pernet registration failed\n"); |
427 | goto out_tcp; | 426 | goto out_tcp; |
428 | } | 427 | } |
429 | ret = nf_conntrack_l4proto_register(net, | 428 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_udp4); |
430 | &nf_conntrack_l4proto_udp4); | ||
431 | if (ret < 0) { | 429 | if (ret < 0) { |
432 | pr_err("nf_conntrack_l4proto_udp4 :protocol register failed\n"); | 430 | pr_err("nf_conntrack_udp4: pernet registration failed\n"); |
433 | goto out_udp; | 431 | goto out_udp; |
434 | } | 432 | } |
435 | ret = nf_conntrack_l4proto_register(net, | 433 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_icmp); |
436 | &nf_conntrack_l4proto_icmp); | ||
437 | if (ret < 0) { | 434 | if (ret < 0) { |
438 | pr_err("nf_conntrack_l4proto_icmp4 :protocol register failed\n"); | 435 | pr_err("nf_conntrack_icmp4: pernet registration failed\n"); |
439 | goto out_icmp; | 436 | goto out_icmp; |
440 | } | 437 | } |
441 | ret = nf_ct_l3proto_pernet_register(net, &nf_conntrack_l3proto_ipv4); | 438 | ret = nf_ct_l3proto_pernet_register(net, &nf_conntrack_l3proto_ipv4); |
@@ -445,14 +442,11 @@ static int ipv4_net_init(struct net *net) | |||
445 | } | 442 | } |
446 | return 0; | 443 | return 0; |
447 | out_ipv4: | 444 | out_ipv4: |
448 | nf_conntrack_l4proto_unregister(net, | 445 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_icmp); |
449 | &nf_conntrack_l4proto_icmp); | ||
450 | out_icmp: | 446 | out_icmp: |
451 | nf_conntrack_l4proto_unregister(net, | 447 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udp4); |
452 | &nf_conntrack_l4proto_udp4); | ||
453 | out_udp: | 448 | out_udp: |
454 | nf_conntrack_l4proto_unregister(net, | 449 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_tcp4); |
455 | &nf_conntrack_l4proto_tcp4); | ||
456 | out_tcp: | 450 | out_tcp: |
457 | return ret; | 451 | return ret; |
458 | } | 452 | } |
@@ -460,12 +454,9 @@ out_tcp: | |||
460 | static void ipv4_net_exit(struct net *net) | 454 | static void ipv4_net_exit(struct net *net) |
461 | { | 455 | { |
462 | nf_ct_l3proto_pernet_unregister(net, &nf_conntrack_l3proto_ipv4); | 456 | nf_ct_l3proto_pernet_unregister(net, &nf_conntrack_l3proto_ipv4); |
463 | nf_conntrack_l4proto_unregister(net, | 457 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_icmp); |
464 | &nf_conntrack_l4proto_icmp); | 458 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udp4); |
465 | nf_conntrack_l4proto_unregister(net, | 459 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_tcp4); |
466 | &nf_conntrack_l4proto_udp4); | ||
467 | nf_conntrack_l4proto_unregister(net, | ||
468 | &nf_conntrack_l4proto_tcp4); | ||
469 | } | 460 | } |
470 | 461 | ||
471 | static struct pernet_operations ipv4_net_ops = { | 462 | static struct pernet_operations ipv4_net_ops = { |
@@ -499,10 +490,28 @@ static int __init nf_conntrack_l3proto_ipv4_init(void) | |||
499 | goto cleanup_pernet; | 490 | goto cleanup_pernet; |
500 | } | 491 | } |
501 | 492 | ||
493 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_tcp4); | ||
494 | if (ret < 0) { | ||
495 | pr_err("nf_conntrack_ipv4: can't register tcp4 proto.\n"); | ||
496 | goto cleanup_hooks; | ||
497 | } | ||
498 | |||
499 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udp4); | ||
500 | if (ret < 0) { | ||
501 | pr_err("nf_conntrack_ipv4: can't register udp4 proto.\n"); | ||
502 | goto cleanup_tcp4; | ||
503 | } | ||
504 | |||
505 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_icmp); | ||
506 | if (ret < 0) { | ||
507 | pr_err("nf_conntrack_ipv4: can't register icmpv4 proto.\n"); | ||
508 | goto cleanup_udp4; | ||
509 | } | ||
510 | |||
502 | ret = nf_ct_l3proto_register(&nf_conntrack_l3proto_ipv4); | 511 | ret = nf_ct_l3proto_register(&nf_conntrack_l3proto_ipv4); |
503 | if (ret < 0) { | 512 | if (ret < 0) { |
504 | pr_err("nf_conntrack_ipv4: can't register ipv4 proto.\n"); | 513 | pr_err("nf_conntrack_ipv4: can't register ipv4 proto.\n"); |
505 | goto cleanup_hooks; | 514 | goto cleanup_icmpv4; |
506 | } | 515 | } |
507 | 516 | ||
508 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) | 517 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) |
@@ -515,6 +524,12 @@ static int __init nf_conntrack_l3proto_ipv4_init(void) | |||
515 | cleanup_proto: | 524 | cleanup_proto: |
516 | nf_ct_l3proto_unregister(&nf_conntrack_l3proto_ipv4); | 525 | nf_ct_l3proto_unregister(&nf_conntrack_l3proto_ipv4); |
517 | #endif | 526 | #endif |
527 | cleanup_icmpv4: | ||
528 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_icmp); | ||
529 | cleanup_udp4: | ||
530 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udp4); | ||
531 | cleanup_tcp4: | ||
532 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_tcp4); | ||
518 | cleanup_hooks: | 533 | cleanup_hooks: |
519 | nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); | 534 | nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); |
520 | cleanup_pernet: | 535 | cleanup_pernet: |
@@ -531,6 +546,9 @@ static void __exit nf_conntrack_l3proto_ipv4_fini(void) | |||
531 | nf_conntrack_ipv4_compat_fini(); | 546 | nf_conntrack_ipv4_compat_fini(); |
532 | #endif | 547 | #endif |
533 | nf_ct_l3proto_unregister(&nf_conntrack_l3proto_ipv4); | 548 | nf_ct_l3proto_unregister(&nf_conntrack_l3proto_ipv4); |
549 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_icmp); | ||
550 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udp4); | ||
551 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_tcp4); | ||
534 | nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); | 552 | nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); |
535 | unregister_pernet_subsys(&ipv4_net_ops); | 553 | unregister_pernet_subsys(&ipv4_net_ops); |
536 | nf_unregister_sockopt(&so_getorigdst); | 554 | nf_unregister_sockopt(&so_getorigdst); |
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index 3eaf6baf8f61..8a45bb20bedb 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | |||
@@ -421,22 +421,19 @@ static int ipv6_net_init(struct net *net) | |||
421 | { | 421 | { |
422 | int ret = 0; | 422 | int ret = 0; |
423 | 423 | ||
424 | ret = nf_conntrack_l4proto_register(net, | 424 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_tcp6); |
425 | &nf_conntrack_l4proto_tcp6); | ||
426 | if (ret < 0) { | 425 | if (ret < 0) { |
427 | printk(KERN_ERR "nf_conntrack_l4proto_tcp6: protocol register failed\n"); | 426 | pr_err("nf_conntrack_tcp6: pernet registration failed\n"); |
428 | goto out; | 427 | goto out; |
429 | } | 428 | } |
430 | ret = nf_conntrack_l4proto_register(net, | 429 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_udp6); |
431 | &nf_conntrack_l4proto_udp6); | ||
432 | if (ret < 0) { | 430 | if (ret < 0) { |
433 | printk(KERN_ERR "nf_conntrack_l4proto_udp6: protocol register failed\n"); | 431 | pr_err("nf_conntrack_udp6: pernet registration failed\n"); |
434 | goto cleanup_tcp6; | 432 | goto cleanup_tcp6; |
435 | } | 433 | } |
436 | ret = nf_conntrack_l4proto_register(net, | 434 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_icmpv6); |
437 | &nf_conntrack_l4proto_icmpv6); | ||
438 | if (ret < 0) { | 435 | if (ret < 0) { |
439 | printk(KERN_ERR "nf_conntrack_l4proto_icmp6: protocol register failed\n"); | 436 | pr_err("nf_conntrack_icmp6: pernet registration failed\n"); |
440 | goto cleanup_udp6; | 437 | goto cleanup_udp6; |
441 | } | 438 | } |
442 | ret = nf_ct_l3proto_pernet_register(net, &nf_conntrack_l3proto_ipv6); | 439 | ret = nf_ct_l3proto_pernet_register(net, &nf_conntrack_l3proto_ipv6); |
@@ -446,14 +443,11 @@ static int ipv6_net_init(struct net *net) | |||
446 | } | 443 | } |
447 | return 0; | 444 | return 0; |
448 | cleanup_icmpv6: | 445 | cleanup_icmpv6: |
449 | nf_conntrack_l4proto_unregister(net, | 446 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_icmpv6); |
450 | &nf_conntrack_l4proto_icmpv6); | ||
451 | cleanup_udp6: | 447 | cleanup_udp6: |
452 | nf_conntrack_l4proto_unregister(net, | 448 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udp6); |
453 | &nf_conntrack_l4proto_udp6); | ||
454 | cleanup_tcp6: | 449 | cleanup_tcp6: |
455 | nf_conntrack_l4proto_unregister(net, | 450 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_tcp6); |
456 | &nf_conntrack_l4proto_tcp6); | ||
457 | out: | 451 | out: |
458 | return ret; | 452 | return ret; |
459 | } | 453 | } |
@@ -461,12 +455,9 @@ static int ipv6_net_init(struct net *net) | |||
461 | static void ipv6_net_exit(struct net *net) | 455 | static void ipv6_net_exit(struct net *net) |
462 | { | 456 | { |
463 | nf_ct_l3proto_pernet_unregister(net, &nf_conntrack_l3proto_ipv6); | 457 | nf_ct_l3proto_pernet_unregister(net, &nf_conntrack_l3proto_ipv6); |
464 | nf_conntrack_l4proto_unregister(net, | 458 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_icmpv6); |
465 | &nf_conntrack_l4proto_icmpv6); | 459 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udp6); |
466 | nf_conntrack_l4proto_unregister(net, | 460 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_tcp6); |
467 | &nf_conntrack_l4proto_udp6); | ||
468 | nf_conntrack_l4proto_unregister(net, | ||
469 | &nf_conntrack_l4proto_tcp6); | ||
470 | } | 461 | } |
471 | 462 | ||
472 | static struct pernet_operations ipv6_net_ops = { | 463 | static struct pernet_operations ipv6_net_ops = { |
@@ -499,13 +490,37 @@ static int __init nf_conntrack_l3proto_ipv6_init(void) | |||
499 | goto cleanup_pernet; | 490 | goto cleanup_pernet; |
500 | } | 491 | } |
501 | 492 | ||
493 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_tcp6); | ||
494 | if (ret < 0) { | ||
495 | pr_err("nf_conntrack_ipv6: can't register tcp6 proto.\n"); | ||
496 | goto cleanup_hooks; | ||
497 | } | ||
498 | |||
499 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udp6); | ||
500 | if (ret < 0) { | ||
501 | pr_err("nf_conntrack_ipv6: can't register udp6 proto.\n"); | ||
502 | goto cleanup_tcp6; | ||
503 | } | ||
504 | |||
505 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_icmpv6); | ||
506 | if (ret < 0) { | ||
507 | pr_err("nf_conntrack_ipv6: can't register icmpv6 proto.\n"); | ||
508 | goto cleanup_udp6; | ||
509 | } | ||
510 | |||
502 | ret = nf_ct_l3proto_register(&nf_conntrack_l3proto_ipv6); | 511 | ret = nf_ct_l3proto_register(&nf_conntrack_l3proto_ipv6); |
503 | if (ret < 0) { | 512 | if (ret < 0) { |
504 | pr_err("nf_conntrack_ipv6: can't register ipv6 proto.\n"); | 513 | pr_err("nf_conntrack_ipv6: can't register ipv6 proto.\n"); |
505 | goto cleanup_hooks; | 514 | goto cleanup_icmpv6; |
506 | } | 515 | } |
507 | return ret; | 516 | return ret; |
508 | 517 | ||
518 | cleanup_icmpv6: | ||
519 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_icmpv6); | ||
520 | cleanup_udp6: | ||
521 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udp6); | ||
522 | cleanup_tcp6: | ||
523 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_tcp6); | ||
509 | cleanup_hooks: | 524 | cleanup_hooks: |
510 | nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops)); | 525 | nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops)); |
511 | cleanup_pernet: | 526 | cleanup_pernet: |
@@ -519,6 +534,9 @@ static void __exit nf_conntrack_l3proto_ipv6_fini(void) | |||
519 | { | 534 | { |
520 | synchronize_net(); | 535 | synchronize_net(); |
521 | nf_ct_l3proto_unregister(&nf_conntrack_l3proto_ipv6); | 536 | nf_ct_l3proto_unregister(&nf_conntrack_l3proto_ipv6); |
537 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_tcp6); | ||
538 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udp6); | ||
539 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_icmpv6); | ||
522 | nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops)); | 540 | nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops)); |
523 | unregister_pernet_subsys(&ipv6_net_ops); | 541 | unregister_pernet_subsys(&ipv6_net_ops); |
524 | nf_unregister_sockopt(&so_getorigdst6); | 542 | nf_unregister_sockopt(&so_getorigdst6); |
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index 076d82707226..58ab4050830c 100644 --- a/net/netfilter/nf_conntrack_proto.c +++ b/net/netfilter/nf_conntrack_proto.c | |||
@@ -363,8 +363,7 @@ void nf_ct_l4proto_unregister_sysctl(struct net *net, | |||
363 | 363 | ||
364 | /* FIXME: Allow NULL functions and sub in pointers to generic for | 364 | /* FIXME: Allow NULL functions and sub in pointers to generic for |
365 | them. --RR */ | 365 | them. --RR */ |
366 | static int | 366 | int nf_ct_l4proto_register(struct nf_conntrack_l4proto *l4proto) |
367 | nf_conntrack_l4proto_register_net(struct nf_conntrack_l4proto *l4proto) | ||
368 | { | 367 | { |
369 | int ret = 0; | 368 | int ret = 0; |
370 | 369 | ||
@@ -418,8 +417,9 @@ out_unlock: | |||
418 | mutex_unlock(&nf_ct_proto_mutex); | 417 | mutex_unlock(&nf_ct_proto_mutex); |
419 | return ret; | 418 | return ret; |
420 | } | 419 | } |
420 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_register); | ||
421 | 421 | ||
422 | int nf_conntrack_l4proto_register(struct net *net, | 422 | int nf_ct_l4proto_pernet_register(struct net *net, |
423 | struct nf_conntrack_l4proto *l4proto) | 423 | struct nf_conntrack_l4proto *l4proto) |
424 | { | 424 | { |
425 | int ret = 0; | 425 | int ret = 0; |
@@ -439,22 +439,13 @@ int nf_conntrack_l4proto_register(struct net *net, | |||
439 | if (ret < 0) | 439 | if (ret < 0) |
440 | goto out; | 440 | goto out; |
441 | 441 | ||
442 | if (net == &init_net) { | ||
443 | ret = nf_conntrack_l4proto_register_net(l4proto); | ||
444 | if (ret < 0) { | ||
445 | nf_ct_l4proto_unregister_sysctl(net, pn, l4proto); | ||
446 | goto out; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | pn->users++; | 442 | pn->users++; |
451 | out: | 443 | out: |
452 | return ret; | 444 | return ret; |
453 | } | 445 | } |
454 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_register); | 446 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_pernet_register); |
455 | 447 | ||
456 | static void | 448 | void nf_ct_l4proto_unregister(struct nf_conntrack_l4proto *l4proto) |
457 | nf_conntrack_l4proto_unregister_net(struct nf_conntrack_l4proto *l4proto) | ||
458 | { | 449 | { |
459 | BUG_ON(l4proto->l3proto >= PF_MAX); | 450 | BUG_ON(l4proto->l3proto >= PF_MAX); |
460 | 451 | ||
@@ -469,15 +460,13 @@ nf_conntrack_l4proto_unregister_net(struct nf_conntrack_l4proto *l4proto) | |||
469 | 460 | ||
470 | synchronize_rcu(); | 461 | synchronize_rcu(); |
471 | } | 462 | } |
463 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_unregister); | ||
472 | 464 | ||
473 | void nf_conntrack_l4proto_unregister(struct net *net, | 465 | void nf_ct_l4proto_pernet_unregister(struct net *net, |
474 | struct nf_conntrack_l4proto *l4proto) | 466 | struct nf_conntrack_l4proto *l4proto) |
475 | { | 467 | { |
476 | struct nf_proto_net *pn = NULL; | 468 | struct nf_proto_net *pn = NULL; |
477 | 469 | ||
478 | if (net == &init_net) | ||
479 | nf_conntrack_l4proto_unregister_net(l4proto); | ||
480 | |||
481 | pn = nf_ct_l4proto_net(net, l4proto); | 470 | pn = nf_ct_l4proto_net(net, l4proto); |
482 | if (pn == NULL) | 471 | if (pn == NULL) |
483 | return; | 472 | return; |
@@ -488,7 +477,7 @@ void nf_conntrack_l4proto_unregister(struct net *net, | |||
488 | /* Remove all contrack entries for this protocol */ | 477 | /* Remove all contrack entries for this protocol */ |
489 | nf_ct_iterate_cleanup(net, kill_l4proto, l4proto); | 478 | nf_ct_iterate_cleanup(net, kill_l4proto, l4proto); |
490 | } | 479 | } |
491 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister); | 480 | EXPORT_SYMBOL_GPL(nf_ct_l4proto_pernet_unregister); |
492 | 481 | ||
493 | int nf_conntrack_proto_pernet_init(struct net *net) | 482 | int nf_conntrack_proto_pernet_init(struct net *net) |
494 | { | 483 | { |
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c index a8ae287bc7af..432f95780003 100644 --- a/net/netfilter/nf_conntrack_proto_dccp.c +++ b/net/netfilter/nf_conntrack_proto_dccp.c | |||
@@ -935,32 +935,27 @@ static struct nf_conntrack_l4proto dccp_proto6 __read_mostly = { | |||
935 | static __net_init int dccp_net_init(struct net *net) | 935 | static __net_init int dccp_net_init(struct net *net) |
936 | { | 936 | { |
937 | int ret = 0; | 937 | int ret = 0; |
938 | ret = nf_conntrack_l4proto_register(net, | 938 | ret = nf_ct_l4proto_pernet_register(net, &dccp_proto4); |
939 | &dccp_proto4); | ||
940 | if (ret < 0) { | 939 | if (ret < 0) { |
941 | pr_err("nf_conntrack_l4proto_dccp4 :protocol register failed.\n"); | 940 | pr_err("nf_conntrack_dccp4: pernet registration failed.\n"); |
942 | goto out; | 941 | goto out; |
943 | } | 942 | } |
944 | ret = nf_conntrack_l4proto_register(net, | 943 | ret = nf_ct_l4proto_pernet_register(net, &dccp_proto6); |
945 | &dccp_proto6); | ||
946 | if (ret < 0) { | 944 | if (ret < 0) { |
947 | pr_err("nf_conntrack_l4proto_dccp6 :protocol register failed.\n"); | 945 | pr_err("nf_conntrack_dccp6: pernet registration failed.\n"); |
948 | goto cleanup_dccp4; | 946 | goto cleanup_dccp4; |
949 | } | 947 | } |
950 | return 0; | 948 | return 0; |
951 | cleanup_dccp4: | 949 | cleanup_dccp4: |
952 | nf_conntrack_l4proto_unregister(net, | 950 | nf_ct_l4proto_pernet_unregister(net, &dccp_proto4); |
953 | &dccp_proto4); | ||
954 | out: | 951 | out: |
955 | return ret; | 952 | return ret; |
956 | } | 953 | } |
957 | 954 | ||
958 | static __net_exit void dccp_net_exit(struct net *net) | 955 | static __net_exit void dccp_net_exit(struct net *net) |
959 | { | 956 | { |
960 | nf_conntrack_l4proto_unregister(net, | 957 | nf_ct_l4proto_pernet_unregister(net, &dccp_proto6); |
961 | &dccp_proto6); | 958 | nf_ct_l4proto_pernet_unregister(net, &dccp_proto4); |
962 | nf_conntrack_l4proto_unregister(net, | ||
963 | &dccp_proto4); | ||
964 | } | 959 | } |
965 | 960 | ||
966 | static struct pernet_operations dccp_net_ops = { | 961 | static struct pernet_operations dccp_net_ops = { |
@@ -972,11 +967,33 @@ static struct pernet_operations dccp_net_ops = { | |||
972 | 967 | ||
973 | static int __init nf_conntrack_proto_dccp_init(void) | 968 | static int __init nf_conntrack_proto_dccp_init(void) |
974 | { | 969 | { |
975 | return register_pernet_subsys(&dccp_net_ops); | 970 | int ret; |
971 | |||
972 | ret = nf_ct_l4proto_register(&dccp_proto4); | ||
973 | if (ret < 0) | ||
974 | goto out_dccp4; | ||
975 | |||
976 | ret = nf_ct_l4proto_register(&dccp_proto6); | ||
977 | if (ret < 0) | ||
978 | goto out_dccp6; | ||
979 | |||
980 | ret = register_pernet_subsys(&dccp_net_ops); | ||
981 | if (ret < 0) | ||
982 | goto out_pernet; | ||
983 | |||
984 | return 0; | ||
985 | out_pernet: | ||
986 | nf_ct_l4proto_unregister(&dccp_proto6); | ||
987 | out_dccp6: | ||
988 | nf_ct_l4proto_unregister(&dccp_proto4); | ||
989 | out_dccp4: | ||
990 | return ret; | ||
976 | } | 991 | } |
977 | 992 | ||
978 | static void __exit nf_conntrack_proto_dccp_fini(void) | 993 | static void __exit nf_conntrack_proto_dccp_fini(void) |
979 | { | 994 | { |
995 | nf_ct_l4proto_unregister(&dccp_proto6); | ||
996 | nf_ct_l4proto_unregister(&dccp_proto4); | ||
980 | unregister_pernet_subsys(&dccp_net_ops); | 997 | unregister_pernet_subsys(&dccp_net_ops); |
981 | } | 998 | } |
982 | 999 | ||
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index b09b7af7f6f8..bd7d01d9c7e7 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c | |||
@@ -397,15 +397,15 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 __read_mostly = { | |||
397 | static int proto_gre_net_init(struct net *net) | 397 | static int proto_gre_net_init(struct net *net) |
398 | { | 398 | { |
399 | int ret = 0; | 399 | int ret = 0; |
400 | ret = nf_conntrack_l4proto_register(net, &nf_conntrack_l4proto_gre4); | 400 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_gre4); |
401 | if (ret < 0) | 401 | if (ret < 0) |
402 | pr_err("nf_conntrack_l4proto_gre4 :protocol register failed.\n"); | 402 | pr_err("nf_conntrack_gre4: pernet registration failed.\n"); |
403 | return ret; | 403 | return ret; |
404 | } | 404 | } |
405 | 405 | ||
406 | static void proto_gre_net_exit(struct net *net) | 406 | static void proto_gre_net_exit(struct net *net) |
407 | { | 407 | { |
408 | nf_conntrack_l4proto_unregister(net, &nf_conntrack_l4proto_gre4); | 408 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_gre4); |
409 | nf_ct_gre_keymap_flush(net); | 409 | nf_ct_gre_keymap_flush(net); |
410 | } | 410 | } |
411 | 411 | ||
@@ -418,11 +418,26 @@ static struct pernet_operations proto_gre_net_ops = { | |||
418 | 418 | ||
419 | static int __init nf_ct_proto_gre_init(void) | 419 | static int __init nf_ct_proto_gre_init(void) |
420 | { | 420 | { |
421 | return register_pernet_subsys(&proto_gre_net_ops); | 421 | int ret; |
422 | |||
423 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_gre4); | ||
424 | if (ret < 0) | ||
425 | goto out_gre4; | ||
426 | |||
427 | ret = register_pernet_subsys(&proto_gre_net_ops); | ||
428 | if (ret < 0) | ||
429 | goto out_pernet; | ||
430 | |||
431 | return 0; | ||
432 | out_pernet: | ||
433 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_gre4); | ||
434 | out_gre4: | ||
435 | return ret; | ||
422 | } | 436 | } |
423 | 437 | ||
424 | static void __exit nf_ct_proto_gre_fini(void) | 438 | static void __exit nf_ct_proto_gre_fini(void) |
425 | { | 439 | { |
440 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_gre4); | ||
426 | unregister_pernet_subsys(&proto_gre_net_ops); | 441 | unregister_pernet_subsys(&proto_gre_net_ops); |
427 | } | 442 | } |
428 | 443 | ||
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c index c746d61f83ed..480f616d5936 100644 --- a/net/netfilter/nf_conntrack_proto_sctp.c +++ b/net/netfilter/nf_conntrack_proto_sctp.c | |||
@@ -853,33 +853,28 @@ static int sctp_net_init(struct net *net) | |||
853 | { | 853 | { |
854 | int ret = 0; | 854 | int ret = 0; |
855 | 855 | ||
856 | ret = nf_conntrack_l4proto_register(net, | 856 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_sctp4); |
857 | &nf_conntrack_l4proto_sctp4); | ||
858 | if (ret < 0) { | 857 | if (ret < 0) { |
859 | pr_err("nf_conntrack_l4proto_sctp4 :protocol register failed.\n"); | 858 | pr_err("nf_conntrack_sctp4: pernet registration failed.\n"); |
860 | goto out; | 859 | goto out; |
861 | } | 860 | } |
862 | ret = nf_conntrack_l4proto_register(net, | 861 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_sctp6); |
863 | &nf_conntrack_l4proto_sctp6); | ||
864 | if (ret < 0) { | 862 | if (ret < 0) { |
865 | pr_err("nf_conntrack_l4proto_sctp6 :protocol register failed.\n"); | 863 | pr_err("nf_conntrack_sctp6: pernet registration failed.\n"); |
866 | goto cleanup_sctp4; | 864 | goto cleanup_sctp4; |
867 | } | 865 | } |
868 | return 0; | 866 | return 0; |
869 | 867 | ||
870 | cleanup_sctp4: | 868 | cleanup_sctp4: |
871 | nf_conntrack_l4proto_unregister(net, | 869 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_sctp4); |
872 | &nf_conntrack_l4proto_sctp4); | ||
873 | out: | 870 | out: |
874 | return ret; | 871 | return ret; |
875 | } | 872 | } |
876 | 873 | ||
877 | static void sctp_net_exit(struct net *net) | 874 | static void sctp_net_exit(struct net *net) |
878 | { | 875 | { |
879 | nf_conntrack_l4proto_unregister(net, | 876 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_sctp6); |
880 | &nf_conntrack_l4proto_sctp6); | 877 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_sctp4); |
881 | nf_conntrack_l4proto_unregister(net, | ||
882 | &nf_conntrack_l4proto_sctp4); | ||
883 | } | 878 | } |
884 | 879 | ||
885 | static struct pernet_operations sctp_net_ops = { | 880 | static struct pernet_operations sctp_net_ops = { |
@@ -891,11 +886,33 @@ static struct pernet_operations sctp_net_ops = { | |||
891 | 886 | ||
892 | static int __init nf_conntrack_proto_sctp_init(void) | 887 | static int __init nf_conntrack_proto_sctp_init(void) |
893 | { | 888 | { |
894 | return register_pernet_subsys(&sctp_net_ops); | 889 | int ret; |
890 | |||
891 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_sctp4); | ||
892 | if (ret < 0) | ||
893 | goto out_sctp4; | ||
894 | |||
895 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_sctp6); | ||
896 | if (ret < 0) | ||
897 | goto out_sctp6; | ||
898 | |||
899 | ret = register_pernet_subsys(&sctp_net_ops); | ||
900 | if (ret < 0) | ||
901 | goto out_pernet; | ||
902 | |||
903 | return 0; | ||
904 | out_pernet: | ||
905 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp6); | ||
906 | out_sctp6: | ||
907 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp4); | ||
908 | out_sctp4: | ||
909 | return ret; | ||
895 | } | 910 | } |
896 | 911 | ||
897 | static void __exit nf_conntrack_proto_sctp_fini(void) | 912 | static void __exit nf_conntrack_proto_sctp_fini(void) |
898 | { | 913 | { |
914 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp6); | ||
915 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp4); | ||
899 | unregister_pernet_subsys(&sctp_net_ops); | 916 | unregister_pernet_subsys(&sctp_net_ops); |
900 | } | 917 | } |
901 | 918 | ||
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c index 4b66df209286..157489581c31 100644 --- a/net/netfilter/nf_conntrack_proto_udplite.c +++ b/net/netfilter/nf_conntrack_proto_udplite.c | |||
@@ -336,30 +336,28 @@ static int udplite_net_init(struct net *net) | |||
336 | { | 336 | { |
337 | int ret = 0; | 337 | int ret = 0; |
338 | 338 | ||
339 | ret = nf_conntrack_l4proto_register(net, | 339 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_udplite4); |
340 | &nf_conntrack_l4proto_udplite4); | ||
341 | if (ret < 0) { | 340 | if (ret < 0) { |
342 | pr_err("nf_conntrack_l4proto_udplite4 :protocol register failed.\n"); | 341 | pr_err("nf_conntrack_udplite4: pernet registration failed.\n"); |
343 | goto out; | 342 | goto out; |
344 | } | 343 | } |
345 | ret = nf_conntrack_l4proto_register(net, | 344 | ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_udplite6); |
346 | &nf_conntrack_l4proto_udplite6); | ||
347 | if (ret < 0) { | 345 | if (ret < 0) { |
348 | pr_err("nf_conntrack_l4proto_udplite4 :protocol register failed.\n"); | 346 | pr_err("nf_conntrack_udplite6: pernet registration failed.\n"); |
349 | goto cleanup_udplite4; | 347 | goto cleanup_udplite4; |
350 | } | 348 | } |
351 | return 0; | 349 | return 0; |
352 | 350 | ||
353 | cleanup_udplite4: | 351 | cleanup_udplite4: |
354 | nf_conntrack_l4proto_unregister(net, &nf_conntrack_l4proto_udplite4); | 352 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udplite4); |
355 | out: | 353 | out: |
356 | return ret; | 354 | return ret; |
357 | } | 355 | } |
358 | 356 | ||
359 | static void udplite_net_exit(struct net *net) | 357 | static void udplite_net_exit(struct net *net) |
360 | { | 358 | { |
361 | nf_conntrack_l4proto_unregister(net, &nf_conntrack_l4proto_udplite6); | 359 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udplite6); |
362 | nf_conntrack_l4proto_unregister(net, &nf_conntrack_l4proto_udplite4); | 360 | nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udplite4); |
363 | } | 361 | } |
364 | 362 | ||
365 | static struct pernet_operations udplite_net_ops = { | 363 | static struct pernet_operations udplite_net_ops = { |
@@ -371,11 +369,33 @@ static struct pernet_operations udplite_net_ops = { | |||
371 | 369 | ||
372 | static int __init nf_conntrack_proto_udplite_init(void) | 370 | static int __init nf_conntrack_proto_udplite_init(void) |
373 | { | 371 | { |
374 | return register_pernet_subsys(&udplite_net_ops); | 372 | int ret; |
373 | |||
374 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udplite4); | ||
375 | if (ret < 0) | ||
376 | goto out_udplite4; | ||
377 | |||
378 | ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udplite6); | ||
379 | if (ret < 0) | ||
380 | goto out_udplite6; | ||
381 | |||
382 | ret = register_pernet_subsys(&udplite_net_ops); | ||
383 | if (ret < 0) | ||
384 | goto out_pernet; | ||
385 | |||
386 | return 0; | ||
387 | out_pernet: | ||
388 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite6); | ||
389 | out_udplite6: | ||
390 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite4); | ||
391 | out_udplite4: | ||
392 | return ret; | ||
375 | } | 393 | } |
376 | 394 | ||
377 | static void __exit nf_conntrack_proto_udplite_exit(void) | 395 | static void __exit nf_conntrack_proto_udplite_exit(void) |
378 | { | 396 | { |
397 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite6); | ||
398 | nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite4); | ||
379 | unregister_pernet_subsys(&udplite_net_ops); | 399 | unregister_pernet_subsys(&udplite_net_ops); |
380 | } | 400 | } |
381 | 401 | ||