[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>
This commit is contained in:
parent
0a3e78ac2c
commit
248b238dc9
|
@ -17,10 +17,9 @@ extern struct proto tcpv6_prot;
|
||||||
struct flowi;
|
struct flowi;
|
||||||
|
|
||||||
/* extention headers */
|
/* extention headers */
|
||||||
extern void ipv6_rthdr_init(void);
|
extern int ipv6_exthdrs_init(void);
|
||||||
|
extern void ipv6_exthdrs_exit(void);
|
||||||
extern void ipv6_frag_init(void);
|
extern void ipv6_frag_init(void);
|
||||||
extern void ipv6_nodata_init(void);
|
|
||||||
extern void ipv6_destopt_init(void);
|
|
||||||
|
|
||||||
/* transport protocols */
|
/* transport protocols */
|
||||||
extern void rawv6_init(void);
|
extern void rawv6_init(void);
|
||||||
|
|
|
@ -859,10 +859,11 @@ static int __init inet6_init(void)
|
||||||
goto addrconf_fail;
|
goto addrconf_fail;
|
||||||
|
|
||||||
/* Init v6 extension headers. */
|
/* Init v6 extension headers. */
|
||||||
ipv6_rthdr_init();
|
err = ipv6_exthdrs_init();
|
||||||
|
if (err)
|
||||||
|
goto ipv6_exthdrs_fail;
|
||||||
|
|
||||||
ipv6_frag_init();
|
ipv6_frag_init();
|
||||||
ipv6_nodata_init();
|
|
||||||
ipv6_destopt_init();
|
|
||||||
|
|
||||||
/* Init v6 transport protocols. */
|
/* Init v6 transport protocols. */
|
||||||
udpv6_init();
|
udpv6_init();
|
||||||
|
@ -874,6 +875,8 @@ static int __init inet6_init(void)
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
ipv6_exthdrs_fail:
|
||||||
|
addrconf_cleanup();
|
||||||
addrconf_fail:
|
addrconf_fail:
|
||||||
ip6_flowlabel_cleanup();
|
ip6_flowlabel_cleanup();
|
||||||
ip6_flowlabel_fail:
|
ip6_flowlabel_fail:
|
||||||
|
@ -932,6 +935,7 @@ static void __exit inet6_exit(void)
|
||||||
/* Cleanup code parts. */
|
/* Cleanup code parts. */
|
||||||
ipv6_packet_cleanup();
|
ipv6_packet_cleanup();
|
||||||
|
|
||||||
|
ipv6_exthdrs_exit();
|
||||||
addrconf_cleanup();
|
addrconf_cleanup();
|
||||||
ip6_flowlabel_cleanup();
|
ip6_flowlabel_cleanup();
|
||||||
ip6_route_cleanup();
|
ip6_route_cleanup();
|
||||||
|
|
|
@ -308,28 +308,6 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct inet6_protocol destopt_protocol = {
|
|
||||||
.handler = ipv6_destopt_rcv,
|
|
||||||
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
|
|
||||||
};
|
|
||||||
|
|
||||||
void __init ipv6_destopt_init(void)
|
|
||||||
{
|
|
||||||
if (inet6_add_protocol(&destopt_protocol, IPPROTO_DSTOPTS) < 0)
|
|
||||||
printk(KERN_ERR "ipv6_destopt_init: Could not register protocol\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct inet6_protocol nodata_protocol = {
|
|
||||||
.handler = dst_discard,
|
|
||||||
.flags = INET6_PROTO_NOPOLICY,
|
|
||||||
};
|
|
||||||
|
|
||||||
void __init ipv6_nodata_init(void)
|
|
||||||
{
|
|
||||||
if (inet6_add_protocol(&nodata_protocol, IPPROTO_NONE) < 0)
|
|
||||||
printk(KERN_ERR "ipv6_nodata_init: Could not register protocol\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
Routing header.
|
Routing header.
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -527,12 +505,48 @@ static struct inet6_protocol rthdr_protocol = {
|
||||||
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
|
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
|
||||||
};
|
};
|
||||||
|
|
||||||
void __init ipv6_rthdr_init(void)
|
static struct inet6_protocol destopt_protocol = {
|
||||||
{
|
.handler = ipv6_destopt_rcv,
|
||||||
if (inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING) < 0)
|
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
|
||||||
printk(KERN_ERR "ipv6_rthdr_init: Could not register protocol\n");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct inet6_protocol nodata_protocol = {
|
||||||
|
.handler = dst_discard,
|
||||||
|
.flags = INET6_PROTO_NOPOLICY,
|
||||||
|
};
|
||||||
|
|
||||||
|
int __init ipv6_exthdrs_init(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = inet6_add_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
|
||||||
|
if (ret)
|
||||||
|
goto out_rthdr;
|
||||||
|
|
||||||
|
ret = inet6_add_protocol(&nodata_protocol, IPPROTO_NONE);
|
||||||
|
if (ret)
|
||||||
|
goto out_destopt;
|
||||||
|
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
out_rthdr:
|
||||||
|
inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
|
||||||
|
out_destopt:
|
||||||
|
inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
|
||||||
|
goto out;
|
||||||
|
};
|
||||||
|
|
||||||
|
void ipv6_exthdrs_exit(void)
|
||||||
|
{
|
||||||
|
inet6_del_protocol(&nodata_protocol, IPPROTO_NONE);
|
||||||
|
inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
|
||||||
|
inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
Hop-by-hop options.
|
Hop-by-hop options.
|
||||||
**********************************/
|
**********************************/
|
||||||
|
|
Loading…
Reference in New Issue