aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lezcano <dlezcano@fr.ibm.com>2007-12-11 05:23:54 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:57:10 -0500
commit248b238dc960a42aa235057ba0a51a98ae2b0f0d (patch)
tree0c655bde3e6a9ad24491fe3ec4edaba1bf9053f2
parent0a3e78ac2c555441f5bc00588070058533bc8d6b (diff)
[IPV6]: make extended headers to return an error at initialization
This patch factorize the code for the differents init functions for rthdr, nodata, destopt in a single function exthdrs_init. This function returns an error so the af_inet6 module can check correctly the initialization. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/transp_v6.h5
-rw-r--r--net/ipv6/af_inet6.c10
-rw-r--r--net/ipv6/exthdrs.c64
3 files changed, 48 insertions, 31 deletions
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h
index 409da3a9a455..610b1bb775c9 100644
--- a/include/net/transp_v6.h
+++ b/include/net/transp_v6.h
@@ -17,10 +17,9 @@ extern struct proto tcpv6_prot;
17struct flowi; 17struct flowi;
18 18
19/* extention headers */ 19/* extention headers */
20extern void ipv6_rthdr_init(void); 20extern int ipv6_exthdrs_init(void);
21extern void ipv6_exthdrs_exit(void);
21extern void ipv6_frag_init(void); 22extern void ipv6_frag_init(void);
22extern void ipv6_nodata_init(void);
23extern void ipv6_destopt_init(void);
24 23
25/* transport protocols */ 24/* transport protocols */
26extern void rawv6_init(void); 25extern void rawv6_init(void);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 614f3d905dd1..442c298c1d7c 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -859,10 +859,11 @@ static int __init inet6_init(void)
859 goto addrconf_fail; 859 goto addrconf_fail;
860 860
861 /* Init v6 extension headers. */ 861 /* Init v6 extension headers. */
862 ipv6_rthdr_init(); 862 err = ipv6_exthdrs_init();
863 if (err)
864 goto ipv6_exthdrs_fail;
865
863 ipv6_frag_init(); 866 ipv6_frag_init();
864 ipv6_nodata_init();
865 ipv6_destopt_init();
866 867
867 /* Init v6 transport protocols. */ 868 /* Init v6 transport protocols. */
868 udpv6_init(); 869 udpv6_init();
@@ -874,6 +875,8 @@ static int __init inet6_init(void)
874out: 875out:
875 return err; 876 return err;
876 877
878ipv6_exthdrs_fail:
879 addrconf_cleanup();
877addrconf_fail: 880addrconf_fail:
878 ip6_flowlabel_cleanup(); 881 ip6_flowlabel_cleanup();
879ip6_flowlabel_fail: 882ip6_flowlabel_fail:
@@ -932,6 +935,7 @@ static void __exit inet6_exit(void)
932 /* Cleanup code parts. */ 935 /* Cleanup code parts. */
933 ipv6_packet_cleanup(); 936 ipv6_packet_cleanup();
934 937
938 ipv6_exthdrs_exit();
935 addrconf_cleanup(); 939 addrconf_cleanup();
936 ip6_flowlabel_cleanup(); 940 ip6_flowlabel_cleanup();
937 ip6_route_cleanup(); 941 ip6_route_cleanup();
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index cee06b1655c1..2df34ed276f1 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -308,28 +308,6 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
308 return -1; 308 return -1;
309} 309}
310 310
311static struct inet6_protocol destopt_protocol = {
312 .handler = ipv6_destopt_rcv,
313 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
314};
315
316void __init ipv6_destopt_init(void)
317{
318 if (inet6_add_protocol(&destopt_protocol, IPPROTO_DSTOPTS) < 0)
319 printk(KERN_ERR "ipv6_destopt_init: Could not register protocol\n");
320}
321
322static struct inet6_protocol nodata_protocol = {
323 .handler = dst_discard,
324 .flags = INET6_PROTO_NOPOLICY,
325};
326
327void __init ipv6_nodata_init(void)
328{
329 if (inet6_add_protocol(&nodata_protocol, IPPROTO_NONE) < 0)
330 printk(KERN_ERR "ipv6_nodata_init: Could not register protocol\n");
331}
332
333/******************************** 311/********************************
334 Routing header. 312 Routing header.
335 ********************************/ 313 ********************************/
@@ -527,12 +505,48 @@ static struct inet6_protocol rthdr_protocol = {
527 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, 505 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
528}; 506};
529 507
530void __init ipv6_rthdr_init(void) 508static struct inet6_protocol destopt_protocol = {
509 .handler = ipv6_destopt_rcv,
510 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
511};
512
513static struct inet6_protocol nodata_protocol = {
514 .handler = dst_discard,
515 .flags = INET6_PROTO_NOPOLICY,
516};
517
518int __init ipv6_exthdrs_init(void)
531{ 519{
532 if (inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING) < 0) 520 int ret;
533 printk(KERN_ERR "ipv6_rthdr_init: Could not register protocol\n"); 521
522 ret = inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING);
523 if (ret)
524 goto out;
525
526 ret = inet6_add_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
527 if (ret)
528 goto out_rthdr;
529
530 ret = inet6_add_protocol(&nodata_protocol, IPPROTO_NONE);
531 if (ret)
532 goto out_destopt;
533
534out:
535 return ret;
536out_rthdr:
537 inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
538out_destopt:
539 inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
540 goto out;
534}; 541};
535 542
543void ipv6_exthdrs_exit(void)
544{
545 inet6_del_protocol(&nodata_protocol, IPPROTO_NONE);
546 inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
547 inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
548}
549
536/********************************** 550/**********************************
537 Hop-by-hop options. 551 Hop-by-hop options.
538 **********************************/ 552 **********************************/