diff options
Diffstat (limited to 'net/ipv6')
25 files changed, 244 insertions, 192 deletions
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig index e6f83b6a2b76..f8a107ab5592 100644 --- a/net/ipv6/Kconfig +++ b/net/ipv6/Kconfig | |||
@@ -88,7 +88,7 @@ config INET6_IPCOMP | |||
88 | tristate "IPv6: IPComp transformation" | 88 | tristate "IPv6: IPComp transformation" |
89 | depends on IPV6 | 89 | depends on IPV6 |
90 | select XFRM | 90 | select XFRM |
91 | select INET6_TUNNEL | 91 | select INET6_XFRM_TUNNEL |
92 | select CRYPTO | 92 | select CRYPTO |
93 | select CRYPTO_DEFLATE | 93 | select CRYPTO_DEFLATE |
94 | ---help--- | 94 | ---help--- |
@@ -97,19 +97,18 @@ config INET6_IPCOMP | |||
97 | 97 | ||
98 | If unsure, say Y. | 98 | If unsure, say Y. |
99 | 99 | ||
100 | config INET6_XFRM_TUNNEL | ||
101 | tristate | ||
102 | select INET6_TUNNEL | ||
103 | default n | ||
104 | |||
100 | config INET6_TUNNEL | 105 | config INET6_TUNNEL |
101 | tristate "IPv6: tunnel transformation" | 106 | tristate |
102 | depends on IPV6 | 107 | default n |
103 | select XFRM | ||
104 | ---help--- | ||
105 | Support for generic IPv6-in-IPv6 tunnel transformation, which is | ||
106 | required by the IPv6-in-IPv6 tunneling module as well as tunnel mode | ||
107 | IPComp. | ||
108 | |||
109 | If unsure, say Y. | ||
110 | 108 | ||
111 | config IPV6_TUNNEL | 109 | config IPV6_TUNNEL |
112 | tristate "IPv6: IPv6-in-IPv6 tunnel" | 110 | tristate "IPv6: IPv6-in-IPv6 tunnel" |
111 | select INET6_TUNNEL | ||
113 | depends on IPV6 | 112 | depends on IPV6 |
114 | ---help--- | 113 | ---help--- |
115 | Support for IPv6-in-IPv6 tunnels described in RFC 2473. | 114 | Support for IPv6-in-IPv6 tunnels described in RFC 2473. |
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile index 41877abd22e6..a760b0988fbb 100644 --- a/net/ipv6/Makefile +++ b/net/ipv6/Makefile | |||
@@ -18,7 +18,8 @@ ipv6-objs += $(ipv6-y) | |||
18 | obj-$(CONFIG_INET6_AH) += ah6.o | 18 | obj-$(CONFIG_INET6_AH) += ah6.o |
19 | obj-$(CONFIG_INET6_ESP) += esp6.o | 19 | obj-$(CONFIG_INET6_ESP) += esp6.o |
20 | obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o | 20 | obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o |
21 | obj-$(CONFIG_INET6_TUNNEL) += xfrm6_tunnel.o | 21 | obj-$(CONFIG_INET6_XFRM_TUNNEL) += xfrm6_tunnel.o |
22 | obj-$(CONFIG_INET6_TUNNEL) += tunnel6.o | ||
22 | obj-$(CONFIG_NETFILTER) += netfilter/ | 23 | obj-$(CONFIG_NETFILTER) += netfilter/ |
23 | 24 | ||
24 | obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o | 25 | obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 48597538db3f..ff9040c92556 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -44,7 +44,6 @@ | |||
44 | 44 | ||
45 | #include <net/ip.h> | 45 | #include <net/ip.h> |
46 | #include <net/ipv6.h> | 46 | #include <net/ipv6.h> |
47 | #include <net/protocol.h> | ||
48 | #include <net/ip6_route.h> | 47 | #include <net/ip6_route.h> |
49 | #include <net/addrconf.h> | 48 | #include <net/addrconf.h> |
50 | #include <net/ip6_tunnel.h> | 49 | #include <net/ip6_tunnel.h> |
@@ -391,7 +390,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *skb, __u8 * raw) | |||
391 | * to the specifications in RFC 2473. | 390 | * to the specifications in RFC 2473. |
392 | **/ | 391 | **/ |
393 | 392 | ||
394 | static void | 393 | static int |
395 | ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | 394 | ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, |
396 | int type, int code, int offset, __u32 info) | 395 | int type, int code, int offset, __u32 info) |
397 | { | 396 | { |
@@ -402,6 +401,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
402 | int rel_code = ICMPV6_ADDR_UNREACH; | 401 | int rel_code = ICMPV6_ADDR_UNREACH; |
403 | __u32 rel_info = 0; | 402 | __u32 rel_info = 0; |
404 | __u16 len; | 403 | __u16 len; |
404 | int err = -ENOENT; | ||
405 | 405 | ||
406 | /* If the packet doesn't contain the original IPv6 header we are | 406 | /* If the packet doesn't contain the original IPv6 header we are |
407 | in trouble since we might need the source address for further | 407 | in trouble since we might need the source address for further |
@@ -411,6 +411,8 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
411 | if ((t = ip6ip6_tnl_lookup(&ipv6h->daddr, &ipv6h->saddr)) == NULL) | 411 | if ((t = ip6ip6_tnl_lookup(&ipv6h->daddr, &ipv6h->saddr)) == NULL) |
412 | goto out; | 412 | goto out; |
413 | 413 | ||
414 | err = 0; | ||
415 | |||
414 | switch (type) { | 416 | switch (type) { |
415 | __u32 teli; | 417 | __u32 teli; |
416 | struct ipv6_tlv_tnl_enc_lim *tel; | 418 | struct ipv6_tlv_tnl_enc_lim *tel; |
@@ -492,6 +494,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
492 | } | 494 | } |
493 | out: | 495 | out: |
494 | read_unlock(&ip6ip6_lock); | 496 | read_unlock(&ip6ip6_lock); |
497 | return err; | ||
495 | } | 498 | } |
496 | 499 | ||
497 | static inline void ip6ip6_ecn_decapsulate(struct ipv6hdr *outer_iph, | 500 | static inline void ip6ip6_ecn_decapsulate(struct ipv6hdr *outer_iph, |
@@ -511,9 +514,8 @@ static inline void ip6ip6_ecn_decapsulate(struct ipv6hdr *outer_iph, | |||
511 | **/ | 514 | **/ |
512 | 515 | ||
513 | static int | 516 | static int |
514 | ip6ip6_rcv(struct sk_buff **pskb) | 517 | ip6ip6_rcv(struct sk_buff *skb) |
515 | { | 518 | { |
516 | struct sk_buff *skb = *pskb; | ||
517 | struct ipv6hdr *ipv6h; | 519 | struct ipv6hdr *ipv6h; |
518 | struct ip6_tnl *t; | 520 | struct ip6_tnl *t; |
519 | 521 | ||
@@ -1112,39 +1114,12 @@ ip6ip6_fb_tnl_dev_init(struct net_device *dev) | |||
1112 | return 0; | 1114 | return 0; |
1113 | } | 1115 | } |
1114 | 1116 | ||
1115 | #ifdef CONFIG_INET6_TUNNEL | ||
1116 | static struct xfrm6_tunnel ip6ip6_handler = { | 1117 | static struct xfrm6_tunnel ip6ip6_handler = { |
1117 | .handler = ip6ip6_rcv, | 1118 | .handler = ip6ip6_rcv, |
1118 | .err_handler = ip6ip6_err, | 1119 | .err_handler = ip6ip6_err, |
1120 | .priority = 1, | ||
1119 | }; | 1121 | }; |
1120 | 1122 | ||
1121 | static inline int ip6ip6_register(void) | ||
1122 | { | ||
1123 | return xfrm6_tunnel_register(&ip6ip6_handler); | ||
1124 | } | ||
1125 | |||
1126 | static inline int ip6ip6_unregister(void) | ||
1127 | { | ||
1128 | return xfrm6_tunnel_deregister(&ip6ip6_handler); | ||
1129 | } | ||
1130 | #else | ||
1131 | static struct inet6_protocol xfrm6_tunnel_protocol = { | ||
1132 | .handler = ip6ip6_rcv, | ||
1133 | .err_handler = ip6ip6_err, | ||
1134 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | ||
1135 | }; | ||
1136 | |||
1137 | static inline int ip6ip6_register(void) | ||
1138 | { | ||
1139 | return inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6); | ||
1140 | } | ||
1141 | |||
1142 | static inline int ip6ip6_unregister(void) | ||
1143 | { | ||
1144 | return inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6); | ||
1145 | } | ||
1146 | #endif | ||
1147 | |||
1148 | /** | 1123 | /** |
1149 | * ip6_tunnel_init - register protocol and reserve needed resources | 1124 | * ip6_tunnel_init - register protocol and reserve needed resources |
1150 | * | 1125 | * |
@@ -1155,7 +1130,7 @@ static int __init ip6_tunnel_init(void) | |||
1155 | { | 1130 | { |
1156 | int err; | 1131 | int err; |
1157 | 1132 | ||
1158 | if (ip6ip6_register() < 0) { | 1133 | if (xfrm6_tunnel_register(&ip6ip6_handler)) { |
1159 | printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); | 1134 | printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); |
1160 | return -EAGAIN; | 1135 | return -EAGAIN; |
1161 | } | 1136 | } |
@@ -1174,7 +1149,7 @@ static int __init ip6_tunnel_init(void) | |||
1174 | } | 1149 | } |
1175 | return 0; | 1150 | return 0; |
1176 | fail: | 1151 | fail: |
1177 | ip6ip6_unregister(); | 1152 | xfrm6_tunnel_deregister(&ip6ip6_handler); |
1178 | return err; | 1153 | return err; |
1179 | } | 1154 | } |
1180 | 1155 | ||
@@ -1184,7 +1159,7 @@ fail: | |||
1184 | 1159 | ||
1185 | static void __exit ip6_tunnel_cleanup(void) | 1160 | static void __exit ip6_tunnel_cleanup(void) |
1186 | { | 1161 | { |
1187 | if (ip6ip6_unregister() < 0) | 1162 | if (xfrm6_tunnel_deregister(&ip6ip6_handler)) |
1188 | printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); | 1163 | printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); |
1189 | 1164 | ||
1190 | unregister_netdev(ip6ip6_fb_tnl_dev); | 1165 | unregister_netdev(ip6ip6_fb_tnl_dev); |
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c index 344eab3b5da8..e81c6a9dab81 100644 --- a/net/ipv6/netfilter/ip6_queue.c +++ b/net/ipv6/netfilter/ip6_queue.c | |||
@@ -713,13 +713,13 @@ cleanup_netlink_notifier: | |||
713 | return status; | 713 | return status; |
714 | } | 714 | } |
715 | 715 | ||
716 | static int __init init(void) | 716 | static int __init ip6_queue_init(void) |
717 | { | 717 | { |
718 | 718 | ||
719 | return init_or_cleanup(1); | 719 | return init_or_cleanup(1); |
720 | } | 720 | } |
721 | 721 | ||
722 | static void __exit fini(void) | 722 | static void __exit ip6_queue_fini(void) |
723 | { | 723 | { |
724 | init_or_cleanup(0); | 724 | init_or_cleanup(0); |
725 | } | 725 | } |
@@ -727,5 +727,5 @@ static void __exit fini(void) | |||
727 | MODULE_DESCRIPTION("IPv6 packet queue handler"); | 727 | MODULE_DESCRIPTION("IPv6 packet queue handler"); |
728 | MODULE_LICENSE("GPL"); | 728 | MODULE_LICENSE("GPL"); |
729 | 729 | ||
730 | module_init(init); | 730 | module_init(ip6_queue_init); |
731 | module_exit(fini); | 731 | module_exit(ip6_queue_fini); |
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index db3c9ae98e95..3ecf2db841f8 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
@@ -1406,7 +1406,7 @@ static struct ip6t_match icmp6_matchstruct = { | |||
1406 | .family = AF_INET6, | 1406 | .family = AF_INET6, |
1407 | }; | 1407 | }; |
1408 | 1408 | ||
1409 | static int __init init(void) | 1409 | static int __init ip6_tables_init(void) |
1410 | { | 1410 | { |
1411 | int ret; | 1411 | int ret; |
1412 | 1412 | ||
@@ -1429,7 +1429,7 @@ static int __init init(void) | |||
1429 | return 0; | 1429 | return 0; |
1430 | } | 1430 | } |
1431 | 1431 | ||
1432 | static void __exit fini(void) | 1432 | static void __exit ip6_tables_fini(void) |
1433 | { | 1433 | { |
1434 | nf_unregister_sockopt(&ip6t_sockopts); | 1434 | nf_unregister_sockopt(&ip6t_sockopts); |
1435 | xt_unregister_match(&icmp6_matchstruct); | 1435 | xt_unregister_match(&icmp6_matchstruct); |
@@ -1517,5 +1517,5 @@ EXPORT_SYMBOL(ip6t_do_table); | |||
1517 | EXPORT_SYMBOL(ip6t_ext_hdr); | 1517 | EXPORT_SYMBOL(ip6t_ext_hdr); |
1518 | EXPORT_SYMBOL(ipv6_find_hdr); | 1518 | EXPORT_SYMBOL(ipv6_find_hdr); |
1519 | 1519 | ||
1520 | module_init(init); | 1520 | module_init(ip6_tables_init); |
1521 | module_exit(fini); | 1521 | module_exit(ip6_tables_fini); |
diff --git a/net/ipv6/netfilter/ip6t_HL.c b/net/ipv6/netfilter/ip6t_HL.c index da14c6d86bcc..b8eff8ee69b1 100644 --- a/net/ipv6/netfilter/ip6t_HL.c +++ b/net/ipv6/netfilter/ip6t_HL.c | |||
@@ -93,15 +93,15 @@ static struct ip6t_target ip6t_HL = { | |||
93 | .me = THIS_MODULE | 93 | .me = THIS_MODULE |
94 | }; | 94 | }; |
95 | 95 | ||
96 | static int __init init(void) | 96 | static int __init ip6t_hl_init(void) |
97 | { | 97 | { |
98 | return ip6t_register_target(&ip6t_HL); | 98 | return ip6t_register_target(&ip6t_HL); |
99 | } | 99 | } |
100 | 100 | ||
101 | static void __exit fini(void) | 101 | static void __exit ip6t_hl_fini(void) |
102 | { | 102 | { |
103 | ip6t_unregister_target(&ip6t_HL); | 103 | ip6t_unregister_target(&ip6t_HL); |
104 | } | 104 | } |
105 | 105 | ||
106 | module_init(init); | 106 | module_init(ip6t_hl_init); |
107 | module_exit(fini); | 107 | module_exit(ip6t_hl_fini); |
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c index 07c6bcbe4c5f..a96c0de14b00 100644 --- a/net/ipv6/netfilter/ip6t_LOG.c +++ b/net/ipv6/netfilter/ip6t_LOG.c | |||
@@ -483,7 +483,7 @@ static struct nf_logger ip6t_logger = { | |||
483 | .me = THIS_MODULE, | 483 | .me = THIS_MODULE, |
484 | }; | 484 | }; |
485 | 485 | ||
486 | static int __init init(void) | 486 | static int __init ip6t_log_init(void) |
487 | { | 487 | { |
488 | if (ip6t_register_target(&ip6t_log_reg)) | 488 | if (ip6t_register_target(&ip6t_log_reg)) |
489 | return -EINVAL; | 489 | return -EINVAL; |
@@ -497,11 +497,11 @@ static int __init init(void) | |||
497 | return 0; | 497 | return 0; |
498 | } | 498 | } |
499 | 499 | ||
500 | static void __exit fini(void) | 500 | static void __exit ip6t_log_fini(void) |
501 | { | 501 | { |
502 | nf_log_unregister_logger(&ip6t_logger); | 502 | nf_log_unregister_logger(&ip6t_logger); |
503 | ip6t_unregister_target(&ip6t_log_reg); | 503 | ip6t_unregister_target(&ip6t_log_reg); |
504 | } | 504 | } |
505 | 505 | ||
506 | module_init(init); | 506 | module_init(ip6t_log_init); |
507 | module_exit(fini); | 507 | module_exit(ip6t_log_fini); |
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index ddfa38575fe2..de1175c27f6d 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -255,17 +255,17 @@ static struct ip6t_target ip6t_reject_reg = { | |||
255 | .me = THIS_MODULE | 255 | .me = THIS_MODULE |
256 | }; | 256 | }; |
257 | 257 | ||
258 | static int __init init(void) | 258 | static int __init ip6t_reject_init(void) |
259 | { | 259 | { |
260 | if (ip6t_register_target(&ip6t_reject_reg)) | 260 | if (ip6t_register_target(&ip6t_reject_reg)) |
261 | return -EINVAL; | 261 | return -EINVAL; |
262 | return 0; | 262 | return 0; |
263 | } | 263 | } |
264 | 264 | ||
265 | static void __exit fini(void) | 265 | static void __exit ip6t_reject_fini(void) |
266 | { | 266 | { |
267 | ip6t_unregister_target(&ip6t_reject_reg); | 267 | ip6t_unregister_target(&ip6t_reject_reg); |
268 | } | 268 | } |
269 | 269 | ||
270 | module_init(init); | 270 | module_init(ip6t_reject_init); |
271 | module_exit(fini); | 271 | module_exit(ip6t_reject_fini); |
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c index 178f6fb1e53d..2f7bb20c758b 100644 --- a/net/ipv6/netfilter/ip6t_ah.c +++ b/net/ipv6/netfilter/ip6t_ah.c | |||
@@ -122,15 +122,15 @@ static struct ip6t_match ah_match = { | |||
122 | .me = THIS_MODULE, | 122 | .me = THIS_MODULE, |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static int __init init(void) | 125 | static int __init ip6t_ah_init(void) |
126 | { | 126 | { |
127 | return ip6t_register_match(&ah_match); | 127 | return ip6t_register_match(&ah_match); |
128 | } | 128 | } |
129 | 129 | ||
130 | static void __exit cleanup(void) | 130 | static void __exit ip6t_ah_fini(void) |
131 | { | 131 | { |
132 | ip6t_unregister_match(&ah_match); | 132 | ip6t_unregister_match(&ah_match); |
133 | } | 133 | } |
134 | 134 | ||
135 | module_init(init); | 135 | module_init(ip6t_ah_init); |
136 | module_exit(cleanup); | 136 | module_exit(ip6t_ah_fini); |
diff --git a/net/ipv6/netfilter/ip6t_dst.c b/net/ipv6/netfilter/ip6t_dst.c index e97a70226987..9422413d0571 100644 --- a/net/ipv6/netfilter/ip6t_dst.c +++ b/net/ipv6/netfilter/ip6t_dst.c | |||
@@ -206,15 +206,15 @@ static struct ip6t_match opts_match = { | |||
206 | .me = THIS_MODULE, | 206 | .me = THIS_MODULE, |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static int __init init(void) | 209 | static int __init ip6t_dst_init(void) |
210 | { | 210 | { |
211 | return ip6t_register_match(&opts_match); | 211 | return ip6t_register_match(&opts_match); |
212 | } | 212 | } |
213 | 213 | ||
214 | static void __exit cleanup(void) | 214 | static void __exit ip6t_dst_fini(void) |
215 | { | 215 | { |
216 | ip6t_unregister_match(&opts_match); | 216 | ip6t_unregister_match(&opts_match); |
217 | } | 217 | } |
218 | 218 | ||
219 | module_init(init); | 219 | module_init(ip6t_dst_init); |
220 | module_exit(cleanup); | 220 | module_exit(ip6t_dst_fini); |
diff --git a/net/ipv6/netfilter/ip6t_esp.c b/net/ipv6/netfilter/ip6t_esp.c index 540b8bfd5055..36bedad2c6f7 100644 --- a/net/ipv6/netfilter/ip6t_esp.c +++ b/net/ipv6/netfilter/ip6t_esp.c | |||
@@ -101,15 +101,15 @@ static struct ip6t_match esp_match = { | |||
101 | .me = THIS_MODULE, | 101 | .me = THIS_MODULE, |
102 | }; | 102 | }; |
103 | 103 | ||
104 | static int __init init(void) | 104 | static int __init ip6t_esp_init(void) |
105 | { | 105 | { |
106 | return ip6t_register_match(&esp_match); | 106 | return ip6t_register_match(&esp_match); |
107 | } | 107 | } |
108 | 108 | ||
109 | static void __exit cleanup(void) | 109 | static void __exit ip6t_esp_fini(void) |
110 | { | 110 | { |
111 | ip6t_unregister_match(&esp_match); | 111 | ip6t_unregister_match(&esp_match); |
112 | } | 112 | } |
113 | 113 | ||
114 | module_init(init); | 114 | module_init(ip6t_esp_init); |
115 | module_exit(cleanup); | 115 | module_exit(ip6t_esp_fini); |
diff --git a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c index d4b0bad52830..94dbdb8b458d 100644 --- a/net/ipv6/netfilter/ip6t_eui64.c +++ b/net/ipv6/netfilter/ip6t_eui64.c | |||
@@ -70,15 +70,15 @@ static struct ip6t_match eui64_match = { | |||
70 | .me = THIS_MODULE, | 70 | .me = THIS_MODULE, |
71 | }; | 71 | }; |
72 | 72 | ||
73 | static int __init init(void) | 73 | static int __init ip6t_eui64_init(void) |
74 | { | 74 | { |
75 | return ip6t_register_match(&eui64_match); | 75 | return ip6t_register_match(&eui64_match); |
76 | } | 76 | } |
77 | 77 | ||
78 | static void __exit fini(void) | 78 | static void __exit ip6t_eui64_fini(void) |
79 | { | 79 | { |
80 | ip6t_unregister_match(&eui64_match); | 80 | ip6t_unregister_match(&eui64_match); |
81 | } | 81 | } |
82 | 82 | ||
83 | module_init(init); | 83 | module_init(ip6t_eui64_init); |
84 | module_exit(fini); | 84 | module_exit(ip6t_eui64_fini); |
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c index 4c41e14823d5..06768c84bd31 100644 --- a/net/ipv6/netfilter/ip6t_frag.c +++ b/net/ipv6/netfilter/ip6t_frag.c | |||
@@ -139,15 +139,15 @@ static struct ip6t_match frag_match = { | |||
139 | .me = THIS_MODULE, | 139 | .me = THIS_MODULE, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static int __init init(void) | 142 | static int __init ip6t_frag_init(void) |
143 | { | 143 | { |
144 | return ip6t_register_match(&frag_match); | 144 | return ip6t_register_match(&frag_match); |
145 | } | 145 | } |
146 | 146 | ||
147 | static void __exit cleanup(void) | 147 | static void __exit ip6t_frag_fini(void) |
148 | { | 148 | { |
149 | ip6t_unregister_match(&frag_match); | 149 | ip6t_unregister_match(&frag_match); |
150 | } | 150 | } |
151 | 151 | ||
152 | module_init(init); | 152 | module_init(ip6t_frag_init); |
153 | module_exit(cleanup); | 153 | module_exit(ip6t_frag_fini); |
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c index b4a1fdfe6abc..374f1be85c0d 100644 --- a/net/ipv6/netfilter/ip6t_hbh.c +++ b/net/ipv6/netfilter/ip6t_hbh.c | |||
@@ -206,15 +206,15 @@ static struct ip6t_match opts_match = { | |||
206 | .me = THIS_MODULE, | 206 | .me = THIS_MODULE, |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static int __init init(void) | 209 | static int __init ip6t_hbh_init(void) |
210 | { | 210 | { |
211 | return ip6t_register_match(&opts_match); | 211 | return ip6t_register_match(&opts_match); |
212 | } | 212 | } |
213 | 213 | ||
214 | static void __exit cleanup(void) | 214 | static void __exit ip6t_hbh_fini(void) |
215 | { | 215 | { |
216 | ip6t_unregister_match(&opts_match); | 216 | ip6t_unregister_match(&opts_match); |
217 | } | 217 | } |
218 | 218 | ||
219 | module_init(init); | 219 | module_init(ip6t_hbh_init); |
220 | module_exit(cleanup); | 220 | module_exit(ip6t_hbh_fini); |
diff --git a/net/ipv6/netfilter/ip6t_hl.c b/net/ipv6/netfilter/ip6t_hl.c index 374055733b26..44a729e17c48 100644 --- a/net/ipv6/netfilter/ip6t_hl.c +++ b/net/ipv6/netfilter/ip6t_hl.c | |||
@@ -55,16 +55,16 @@ static struct ip6t_match hl_match = { | |||
55 | .me = THIS_MODULE, | 55 | .me = THIS_MODULE, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static int __init init(void) | 58 | static int __init ip6t_hl_init(void) |
59 | { | 59 | { |
60 | return ip6t_register_match(&hl_match); | 60 | return ip6t_register_match(&hl_match); |
61 | } | 61 | } |
62 | 62 | ||
63 | static void __exit fini(void) | 63 | static void __exit ip6t_hl_fini(void) |
64 | { | 64 | { |
65 | ip6t_unregister_match(&hl_match); | 65 | ip6t_unregister_match(&hl_match); |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | module_init(init); | 69 | module_init(ip6t_hl_init); |
70 | module_exit(fini); | 70 | module_exit(ip6t_hl_fini); |
diff --git a/net/ipv6/netfilter/ip6t_multiport.c b/net/ipv6/netfilter/ip6t_multiport.c index 752b65d21c72..10c48ba596d6 100644 --- a/net/ipv6/netfilter/ip6t_multiport.c +++ b/net/ipv6/netfilter/ip6t_multiport.c | |||
@@ -111,15 +111,15 @@ static struct ip6t_match multiport_match = { | |||
111 | .me = THIS_MODULE, | 111 | .me = THIS_MODULE, |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static int __init init(void) | 114 | static int __init ip6t_multiport_init(void) |
115 | { | 115 | { |
116 | return ip6t_register_match(&multiport_match); | 116 | return ip6t_register_match(&multiport_match); |
117 | } | 117 | } |
118 | 118 | ||
119 | static void __exit fini(void) | 119 | static void __exit ip6t_multiport_fini(void) |
120 | { | 120 | { |
121 | ip6t_unregister_match(&multiport_match); | 121 | ip6t_unregister_match(&multiport_match); |
122 | } | 122 | } |
123 | 123 | ||
124 | module_init(init); | 124 | module_init(ip6t_multiport_init); |
125 | module_exit(fini); | 125 | module_exit(ip6t_multiport_fini); |
diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c index e2cee3bcdef9..5d047990cd44 100644 --- a/net/ipv6/netfilter/ip6t_owner.c +++ b/net/ipv6/netfilter/ip6t_owner.c | |||
@@ -79,15 +79,15 @@ static struct ip6t_match owner_match = { | |||
79 | .me = THIS_MODULE, | 79 | .me = THIS_MODULE, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static int __init init(void) | 82 | static int __init ip6t_owner_init(void) |
83 | { | 83 | { |
84 | return ip6t_register_match(&owner_match); | 84 | return ip6t_register_match(&owner_match); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void __exit fini(void) | 87 | static void __exit ip6t_owner_fini(void) |
88 | { | 88 | { |
89 | ip6t_unregister_match(&owner_match); | 89 | ip6t_unregister_match(&owner_match); |
90 | } | 90 | } |
91 | 91 | ||
92 | module_init(init); | 92 | module_init(ip6t_owner_init); |
93 | module_exit(fini); | 93 | module_exit(ip6t_owner_fini); |
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c index 4c6b55bb225b..fbb0184a41d8 100644 --- a/net/ipv6/netfilter/ip6t_rt.c +++ b/net/ipv6/netfilter/ip6t_rt.c | |||
@@ -225,15 +225,15 @@ static struct ip6t_match rt_match = { | |||
225 | .me = THIS_MODULE, | 225 | .me = THIS_MODULE, |
226 | }; | 226 | }; |
227 | 227 | ||
228 | static int __init init(void) | 228 | static int __init ip6t_rt_init(void) |
229 | { | 229 | { |
230 | return ip6t_register_match(&rt_match); | 230 | return ip6t_register_match(&rt_match); |
231 | } | 231 | } |
232 | 232 | ||
233 | static void __exit cleanup(void) | 233 | static void __exit ip6t_rt_fini(void) |
234 | { | 234 | { |
235 | ip6t_unregister_match(&rt_match); | 235 | ip6t_unregister_match(&rt_match); |
236 | } | 236 | } |
237 | 237 | ||
238 | module_init(init); | 238 | module_init(ip6t_rt_init); |
239 | module_exit(cleanup); | 239 | module_exit(ip6t_rt_fini); |
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c index ce4a968e1f70..e5e724d9ee60 100644 --- a/net/ipv6/netfilter/ip6table_filter.c +++ b/net/ipv6/netfilter/ip6table_filter.c | |||
@@ -159,7 +159,7 @@ static struct nf_hook_ops ip6t_ops[] = { | |||
159 | static int forward = NF_ACCEPT; | 159 | static int forward = NF_ACCEPT; |
160 | module_param(forward, bool, 0000); | 160 | module_param(forward, bool, 0000); |
161 | 161 | ||
162 | static int __init init(void) | 162 | static int __init ip6table_filter_init(void) |
163 | { | 163 | { |
164 | int ret; | 164 | int ret; |
165 | 165 | ||
@@ -201,7 +201,7 @@ static int __init init(void) | |||
201 | return ret; | 201 | return ret; |
202 | } | 202 | } |
203 | 203 | ||
204 | static void __exit fini(void) | 204 | static void __exit ip6table_filter_fini(void) |
205 | { | 205 | { |
206 | unsigned int i; | 206 | unsigned int i; |
207 | 207 | ||
@@ -211,5 +211,5 @@ static void __exit fini(void) | |||
211 | ip6t_unregister_table(&packet_filter); | 211 | ip6t_unregister_table(&packet_filter); |
212 | } | 212 | } |
213 | 213 | ||
214 | module_init(init); | 214 | module_init(ip6table_filter_init); |
215 | module_exit(fini); | 215 | module_exit(ip6table_filter_fini); |
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c index 30a4627e000d..e1f0f6ae9841 100644 --- a/net/ipv6/netfilter/ip6table_mangle.c +++ b/net/ipv6/netfilter/ip6table_mangle.c | |||
@@ -228,7 +228,7 @@ static struct nf_hook_ops ip6t_ops[] = { | |||
228 | }, | 228 | }, |
229 | }; | 229 | }; |
230 | 230 | ||
231 | static int __init init(void) | 231 | static int __init ip6table_mangle_init(void) |
232 | { | 232 | { |
233 | int ret; | 233 | int ret; |
234 | 234 | ||
@@ -274,7 +274,7 @@ static int __init init(void) | |||
274 | return ret; | 274 | return ret; |
275 | } | 275 | } |
276 | 276 | ||
277 | static void __exit fini(void) | 277 | static void __exit ip6table_mangle_fini(void) |
278 | { | 278 | { |
279 | unsigned int i; | 279 | unsigned int i; |
280 | 280 | ||
@@ -284,5 +284,5 @@ static void __exit fini(void) | |||
284 | ip6t_unregister_table(&packet_mangler); | 284 | ip6t_unregister_table(&packet_mangler); |
285 | } | 285 | } |
286 | 286 | ||
287 | module_init(init); | 287 | module_init(ip6table_mangle_init); |
288 | module_exit(fini); | 288 | module_exit(ip6table_mangle_fini); |
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c index db28ba3855e2..54d1fffd62ba 100644 --- a/net/ipv6/netfilter/ip6table_raw.c +++ b/net/ipv6/netfilter/ip6table_raw.c | |||
@@ -142,7 +142,7 @@ static struct nf_hook_ops ip6t_ops[] = { | |||
142 | }, | 142 | }, |
143 | }; | 143 | }; |
144 | 144 | ||
145 | static int __init init(void) | 145 | static int __init ip6table_raw_init(void) |
146 | { | 146 | { |
147 | int ret; | 147 | int ret; |
148 | 148 | ||
@@ -170,7 +170,7 @@ static int __init init(void) | |||
170 | return ret; | 170 | return ret; |
171 | } | 171 | } |
172 | 172 | ||
173 | static void __exit fini(void) | 173 | static void __exit ip6table_raw_fini(void) |
174 | { | 174 | { |
175 | unsigned int i; | 175 | unsigned int i; |
176 | 176 | ||
@@ -180,6 +180,6 @@ static void __exit fini(void) | |||
180 | ip6t_unregister_table(&packet_raw); | 180 | ip6t_unregister_table(&packet_raw); |
181 | } | 181 | } |
182 | 182 | ||
183 | module_init(init); | 183 | module_init(ip6table_raw_init); |
184 | module_exit(fini); | 184 | module_exit(ip6table_raw_fini); |
185 | MODULE_LICENSE("GPL"); | 185 | MODULE_LICENSE("GPL"); |
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index c16f62934bd9..c8b5a96cbb0f 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | |||
@@ -588,16 +588,16 @@ MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6)); | |||
588 | MODULE_LICENSE("GPL"); | 588 | MODULE_LICENSE("GPL"); |
589 | MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>"); | 589 | MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>"); |
590 | 590 | ||
591 | static int __init init(void) | 591 | static int __init nf_conntrack_l3proto_ipv6_init(void) |
592 | { | 592 | { |
593 | need_conntrack(); | 593 | need_conntrack(); |
594 | return init_or_cleanup(1); | 594 | return init_or_cleanup(1); |
595 | } | 595 | } |
596 | 596 | ||
597 | static void __exit fini(void) | 597 | static void __exit nf_conntrack_l3proto_ipv6_fini(void) |
598 | { | 598 | { |
599 | init_or_cleanup(0); | 599 | init_or_cleanup(0); |
600 | } | 600 | } |
601 | 601 | ||
602 | module_init(init); | 602 | module_init(nf_conntrack_l3proto_ipv6_init); |
603 | module_exit(fini); | 603 | module_exit(nf_conntrack_l3proto_ipv6_fini); |
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c new file mode 100644 index 000000000000..5659b52284bd --- /dev/null +++ b/net/ipv6/tunnel6.c | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * Copyright (C)2003,2004 USAGI/WIDE Project | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | * | ||
18 | * Authors Mitsuru KANDA <mk@linux-ipv6.org> | ||
19 | * YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/mutex.h> | ||
25 | #include <linux/netdevice.h> | ||
26 | #include <linux/skbuff.h> | ||
27 | #include <net/protocol.h> | ||
28 | #include <net/xfrm.h> | ||
29 | |||
30 | static struct xfrm6_tunnel *tunnel6_handlers; | ||
31 | static DEFINE_MUTEX(tunnel6_mutex); | ||
32 | |||
33 | int xfrm6_tunnel_register(struct xfrm6_tunnel *handler) | ||
34 | { | ||
35 | struct xfrm6_tunnel **pprev; | ||
36 | int ret = -EEXIST; | ||
37 | int priority = handler->priority; | ||
38 | |||
39 | mutex_lock(&tunnel6_mutex); | ||
40 | |||
41 | for (pprev = &tunnel6_handlers; *pprev; pprev = &(*pprev)->next) { | ||
42 | if ((*pprev)->priority > priority) | ||
43 | break; | ||
44 | if ((*pprev)->priority == priority) | ||
45 | goto err; | ||
46 | } | ||
47 | |||
48 | handler->next = *pprev; | ||
49 | *pprev = handler; | ||
50 | |||
51 | ret = 0; | ||
52 | |||
53 | err: | ||
54 | mutex_unlock(&tunnel6_mutex); | ||
55 | |||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | EXPORT_SYMBOL(xfrm6_tunnel_register); | ||
60 | |||
61 | int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler) | ||
62 | { | ||
63 | struct xfrm6_tunnel **pprev; | ||
64 | int ret = -ENOENT; | ||
65 | |||
66 | mutex_lock(&tunnel6_mutex); | ||
67 | |||
68 | for (pprev = &tunnel6_handlers; *pprev; pprev = &(*pprev)->next) { | ||
69 | if (*pprev == handler) { | ||
70 | *pprev = handler->next; | ||
71 | ret = 0; | ||
72 | break; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | mutex_unlock(&tunnel6_mutex); | ||
77 | |||
78 | synchronize_net(); | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | EXPORT_SYMBOL(xfrm6_tunnel_deregister); | ||
84 | |||
85 | static int tunnel6_rcv(struct sk_buff **pskb) | ||
86 | { | ||
87 | struct sk_buff *skb = *pskb; | ||
88 | struct xfrm6_tunnel *handler; | ||
89 | |||
90 | for (handler = tunnel6_handlers; handler; handler = handler->next) | ||
91 | if (!handler->handler(skb)) | ||
92 | return 0; | ||
93 | |||
94 | kfree_skb(skb); | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | ||
99 | int type, int code, int offset, __u32 info) | ||
100 | { | ||
101 | struct xfrm6_tunnel *handler; | ||
102 | |||
103 | for (handler = tunnel6_handlers; handler; handler = handler->next) | ||
104 | if (!handler->err_handler(skb, opt, type, code, offset, info)) | ||
105 | break; | ||
106 | } | ||
107 | |||
108 | static struct inet6_protocol tunnel6_protocol = { | ||
109 | .handler = tunnel6_rcv, | ||
110 | .err_handler = tunnel6_err, | ||
111 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | ||
112 | }; | ||
113 | |||
114 | static int __init tunnel6_init(void) | ||
115 | { | ||
116 | if (inet6_add_protocol(&tunnel6_protocol, IPPROTO_IPV6)) { | ||
117 | printk(KERN_ERR "tunnel6 init(): can't add protocol\n"); | ||
118 | return -EAGAIN; | ||
119 | } | ||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | static void __exit tunnel6_fini(void) | ||
124 | { | ||
125 | if (inet6_del_protocol(&tunnel6_protocol, IPPROTO_IPV6)) | ||
126 | printk(KERN_ERR "tunnel6 close: can't remove protocol\n"); | ||
127 | } | ||
128 | |||
129 | module_init(tunnel6_init); | ||
130 | module_exit(tunnel6_fini); | ||
131 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c index 1ca2da68ef69..cccf8b76f046 100644 --- a/net/ipv6/xfrm6_input.c +++ b/net/ipv6/xfrm6_input.c | |||
@@ -28,9 +28,8 @@ static inline void ipip6_ecn_decapsulate(struct sk_buff *skb) | |||
28 | IP6_ECN_set_ce(inner_iph); | 28 | IP6_ECN_set_ce(inner_iph); |
29 | } | 29 | } |
30 | 30 | ||
31 | int xfrm6_rcv_spi(struct sk_buff **pskb, u32 spi) | 31 | int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi) |
32 | { | 32 | { |
33 | struct sk_buff *skb = *pskb; | ||
34 | int err; | 33 | int err; |
35 | u32 seq; | 34 | u32 seq; |
36 | struct sec_decap_state xfrm_vec[XFRM_MAX_DEPTH]; | 35 | struct sec_decap_state xfrm_vec[XFRM_MAX_DEPTH]; |
@@ -159,5 +158,5 @@ EXPORT_SYMBOL(xfrm6_rcv_spi); | |||
159 | 158 | ||
160 | int xfrm6_rcv(struct sk_buff **pskb) | 159 | int xfrm6_rcv(struct sk_buff **pskb) |
161 | { | 160 | { |
162 | return xfrm6_rcv_spi(pskb, 0); | 161 | return xfrm6_rcv_spi(*pskb, 0); |
163 | } | 162 | } |
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c index 08f9abbdf1d7..a8f6776c518d 100644 --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <net/ip.h> | 28 | #include <net/ip.h> |
29 | #include <net/xfrm.h> | 29 | #include <net/xfrm.h> |
30 | #include <net/ipv6.h> | 30 | #include <net/ipv6.h> |
31 | #include <net/protocol.h> | ||
32 | #include <linux/ipv6.h> | 31 | #include <linux/ipv6.h> |
33 | #include <linux/icmpv6.h> | 32 | #include <linux/icmpv6.h> |
34 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
@@ -357,71 +356,18 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct xfrm_decap_state *dec | |||
357 | return 0; | 356 | return 0; |
358 | } | 357 | } |
359 | 358 | ||
360 | static struct xfrm6_tunnel *xfrm6_tunnel_handler; | 359 | static int xfrm6_tunnel_rcv(struct sk_buff *skb) |
361 | static DEFINE_MUTEX(xfrm6_tunnel_mutex); | ||
362 | |||
363 | int xfrm6_tunnel_register(struct xfrm6_tunnel *handler) | ||
364 | { | 360 | { |
365 | int ret; | ||
366 | |||
367 | mutex_lock(&xfrm6_tunnel_mutex); | ||
368 | ret = 0; | ||
369 | if (xfrm6_tunnel_handler != NULL) | ||
370 | ret = -EINVAL; | ||
371 | if (!ret) | ||
372 | xfrm6_tunnel_handler = handler; | ||
373 | mutex_unlock(&xfrm6_tunnel_mutex); | ||
374 | |||
375 | return ret; | ||
376 | } | ||
377 | |||
378 | EXPORT_SYMBOL(xfrm6_tunnel_register); | ||
379 | |||
380 | int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler) | ||
381 | { | ||
382 | int ret; | ||
383 | |||
384 | mutex_lock(&xfrm6_tunnel_mutex); | ||
385 | ret = 0; | ||
386 | if (xfrm6_tunnel_handler != handler) | ||
387 | ret = -EINVAL; | ||
388 | if (!ret) | ||
389 | xfrm6_tunnel_handler = NULL; | ||
390 | mutex_unlock(&xfrm6_tunnel_mutex); | ||
391 | |||
392 | synchronize_net(); | ||
393 | |||
394 | return ret; | ||
395 | } | ||
396 | |||
397 | EXPORT_SYMBOL(xfrm6_tunnel_deregister); | ||
398 | |||
399 | static int xfrm6_tunnel_rcv(struct sk_buff **pskb) | ||
400 | { | ||
401 | struct sk_buff *skb = *pskb; | ||
402 | struct xfrm6_tunnel *handler = xfrm6_tunnel_handler; | ||
403 | struct ipv6hdr *iph = skb->nh.ipv6h; | 361 | struct ipv6hdr *iph = skb->nh.ipv6h; |
404 | u32 spi; | 362 | u32 spi; |
405 | 363 | ||
406 | /* device-like_ip6ip6_handler() */ | ||
407 | if (handler && handler->handler(pskb) == 0) | ||
408 | return 0; | ||
409 | |||
410 | spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&iph->saddr); | 364 | spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&iph->saddr); |
411 | return xfrm6_rcv_spi(pskb, spi); | 365 | return xfrm6_rcv_spi(skb, spi); |
412 | } | 366 | } |
413 | 367 | ||
414 | static void xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | 368 | static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt, |
415 | int type, int code, int offset, __u32 info) | 369 | int type, int code, int offset, __u32 info) |
416 | { | 370 | { |
417 | struct xfrm6_tunnel *handler = xfrm6_tunnel_handler; | ||
418 | |||
419 | /* call here first for device-like ip6ip6 err handling */ | ||
420 | if (handler) { | ||
421 | handler->err_handler(skb, opt, type, code, offset, info); | ||
422 | return; | ||
423 | } | ||
424 | |||
425 | /* xfrm6_tunnel native err handling */ | 371 | /* xfrm6_tunnel native err handling */ |
426 | switch (type) { | 372 | switch (type) { |
427 | case ICMPV6_DEST_UNREACH: | 373 | case ICMPV6_DEST_UNREACH: |
@@ -462,7 +408,8 @@ static void xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
462 | default: | 408 | default: |
463 | break; | 409 | break; |
464 | } | 410 | } |
465 | return; | 411 | |
412 | return 0; | ||
466 | } | 413 | } |
467 | 414 | ||
468 | static int xfrm6_tunnel_init_state(struct xfrm_state *x) | 415 | static int xfrm6_tunnel_init_state(struct xfrm_state *x) |
@@ -493,10 +440,10 @@ static struct xfrm_type xfrm6_tunnel_type = { | |||
493 | .output = xfrm6_tunnel_output, | 440 | .output = xfrm6_tunnel_output, |
494 | }; | 441 | }; |
495 | 442 | ||
496 | static struct inet6_protocol xfrm6_tunnel_protocol = { | 443 | static struct xfrm6_tunnel xfrm6_tunnel_handler = { |
497 | .handler = xfrm6_tunnel_rcv, | 444 | .handler = xfrm6_tunnel_rcv, |
498 | .err_handler = xfrm6_tunnel_err, | 445 | .err_handler = xfrm6_tunnel_err, |
499 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 446 | .priority = 2, |
500 | }; | 447 | }; |
501 | 448 | ||
502 | static int __init xfrm6_tunnel_init(void) | 449 | static int __init xfrm6_tunnel_init(void) |
@@ -508,16 +455,16 @@ static int __init xfrm6_tunnel_init(void) | |||
508 | "xfrm6_tunnel init: can't add xfrm type\n"); | 455 | "xfrm6_tunnel init: can't add xfrm type\n"); |
509 | return -EAGAIN; | 456 | return -EAGAIN; |
510 | } | 457 | } |
511 | if (inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6) < 0) { | 458 | if (xfrm6_tunnel_register(&xfrm6_tunnel_handler)) { |
512 | X6TPRINTK1(KERN_ERR | 459 | X6TPRINTK1(KERN_ERR |
513 | "xfrm6_tunnel init(): can't add protocol\n"); | 460 | "xfrm6_tunnel init(): can't add handler\n"); |
514 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); | 461 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); |
515 | return -EAGAIN; | 462 | return -EAGAIN; |
516 | } | 463 | } |
517 | if (xfrm6_tunnel_spi_init() < 0) { | 464 | if (xfrm6_tunnel_spi_init() < 0) { |
518 | X6TPRINTK1(KERN_ERR | 465 | X6TPRINTK1(KERN_ERR |
519 | "xfrm6_tunnel init: failed to initialize spi\n"); | 466 | "xfrm6_tunnel init: failed to initialize spi\n"); |
520 | inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6); | 467 | xfrm6_tunnel_deregister(&xfrm6_tunnel_handler); |
521 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); | 468 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); |
522 | return -EAGAIN; | 469 | return -EAGAIN; |
523 | } | 470 | } |
@@ -529,9 +476,9 @@ static void __exit xfrm6_tunnel_fini(void) | |||
529 | X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__); | 476 | X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__); |
530 | 477 | ||
531 | xfrm6_tunnel_spi_fini(); | 478 | xfrm6_tunnel_spi_fini(); |
532 | if (inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6) < 0) | 479 | if (xfrm6_tunnel_deregister(&xfrm6_tunnel_handler)) |
533 | X6TPRINTK1(KERN_ERR | 480 | X6TPRINTK1(KERN_ERR |
534 | "xfrm6_tunnel close: can't remove protocol\n"); | 481 | "xfrm6_tunnel close: can't remove handler\n"); |
535 | if (xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6) < 0) | 482 | if (xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6) < 0) |
536 | X6TPRINTK1(KERN_ERR | 483 | X6TPRINTK1(KERN_ERR |
537 | "xfrm6_tunnel close: can't remove xfrm type\n"); | 484 | "xfrm6_tunnel close: can't remove xfrm type\n"); |