aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/exthdrs.c
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 /net/ipv6/exthdrs.c
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>
Diffstat (limited to 'net/ipv6/exthdrs.c')
-rw-r--r--net/ipv6/exthdrs.c64
1 files changed, 39 insertions, 25 deletions
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 **********************************/