* [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init
@ 2007-12-10 15:09 Daniel Lezcano
2007-12-10 15:09 ` [patch 1/5] ipv6: make flowlabel to return an error Daniel Lezcano
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:09 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, pekkas, netdev
This patchset continue the work to make the different af_inet6
subsystems initialization functions to return an error code and
to handle the error to fails safely.
It takes into account:
* flowlabel
* exthdrs
* frag
* udp
* udplite
* tcp
* raw
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 1/5] ipv6: make flowlabel to return an error
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
@ 2007-12-10 15:09 ` Daniel Lezcano
2007-12-11 10:23 ` David Miller
2007-12-10 15:09 ` [patch 2/5] ipv6: make extended headers to return an error at initialization Daniel Lezcano
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:09 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, pekkas, netdev
[-- Attachment #1: make-ip6-flowlabel-init-return-an-error-code.patch --]
[-- Type: text/plain, Size: 2837 bytes --]
This patch makes the flowlab subsystem to return an error code and makes
some cleanup with procfs ifdefs.
The af_inet6 will use the flowlabel init return code to check the initialization
was correct.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
include/net/ipv6.h | 2 +-
net/ipv6/af_inet6.c | 5 ++++-
net/ipv6/ip6_flowlabel.c | 30 +++++++++++++++++++++++-------
3 files changed, 28 insertions(+), 9 deletions(-)
Index: net-2.6.25/include/net/ipv6.h
===================================================================
--- net-2.6.25.orig/include/net/ipv6.h
+++ net-2.6.25/include/net/ipv6.h
@@ -219,7 +219,7 @@ extern struct ipv6_txoptions *fl6_merge_
struct ipv6_txoptions * fopt);
extern void fl6_free_socklist(struct sock *sk);
extern int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen);
-extern void ip6_flowlabel_init(void);
+extern int ip6_flowlabel_init(void);
extern void ip6_flowlabel_cleanup(void);
static inline void fl6_sock_release(struct ip6_flowlabel *fl)
Index: net-2.6.25/net/ipv6/af_inet6.c
===================================================================
--- net-2.6.25.orig/net/ipv6/af_inet6.c
+++ net-2.6.25/net/ipv6/af_inet6.c
@@ -851,7 +851,9 @@ static int __init inet6_init(void)
err = ip6_route_init();
if (err)
goto ip6_route_fail;
- ip6_flowlabel_init();
+ err = ip6_flowlabel_init();
+ if (err)
+ goto ip6_flowlabel_fail;
err = addrconf_init();
if (err)
goto addrconf_fail;
@@ -874,6 +876,7 @@ out:
addrconf_fail:
ip6_flowlabel_cleanup();
+ip6_flowlabel_fail:
ip6_route_cleanup();
ip6_route_fail:
#ifdef CONFIG_PROC_FS
Index: net-2.6.25/net/ipv6/ip6_flowlabel.c
===================================================================
--- net-2.6.25.orig/net/ipv6/ip6_flowlabel.c
+++ net-2.6.25/net/ipv6/ip6_flowlabel.c
@@ -692,20 +692,36 @@ static const struct file_operations ip6f
.llseek = seq_lseek,
.release = seq_release_private,
};
-#endif
+static int ip6_flowlabel_proc_init(struct net *net)
+{
+ if (!proc_net_fops_create(net, "ip6_flowlabel", S_IRUGO, &ip6fl_seq_fops))
+ return -ENOMEM;
+ return 0;
+}
-void ip6_flowlabel_init(void)
+static void ip6_flowlabel_proc_fini(struct net *net)
{
-#ifdef CONFIG_PROC_FS
- proc_net_fops_create(&init_net, "ip6_flowlabel", S_IRUGO, &ip6fl_seq_fops);
+ proc_net_remove(net, "ip6_flowlabel");
+}
+#else
+static inline int ip6_flowlabel_proc_init(struct net *net)
+{
+ return 0;
+}
+static inline void ip6_flowlabel_proc_fini(struct net *net)
+{
+ return ;
+}
#endif
+
+int ip6_flowlabel_init(void)
+{
+ return ip6_flowlabel_proc_init(&init_net);
}
void ip6_flowlabel_cleanup(void)
{
del_timer(&ip6_fl_gc_timer);
-#ifdef CONFIG_PROC_FS
- proc_net_remove(&init_net, "ip6_flowlabel");
-#endif
+ ip6_flowlabel_proc_fini(&init_net);
}
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 2/5] ipv6: make extended headers to return an error at initialization
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
2007-12-10 15:09 ` [patch 1/5] ipv6: make flowlabel to return an error Daniel Lezcano
@ 2007-12-10 15:09 ` Daniel Lezcano
2007-12-11 10:24 ` David Miller
2007-12-10 15:09 ` [patch 3/5] ipv6: make frag " Daniel Lezcano
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:09 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, pekkas, netdev
[-- Attachment #1: make-ip6-exthdrs-init-return-an-error.patch --]
[-- Type: text/plain, Size: 4320 bytes --]
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>
---
include/net/transp_v6.h | 5 +--
net/ipv6/af_inet6.c | 10 +++++--
net/ipv6/exthdrs.c | 64 +++++++++++++++++++++++++++++-------------------
3 files changed, 48 insertions(+), 31 deletions(-)
Index: net-2.6.25/include/net/transp_v6.h
===================================================================
--- net-2.6.25.orig/include/net/transp_v6.h
+++ net-2.6.25/include/net/transp_v6.h
@@ -17,10 +17,9 @@ extern struct proto tcpv6_prot;
struct flowi;
/* 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_nodata_init(void);
-extern void ipv6_destopt_init(void);
/* transport protocols */
extern void rawv6_init(void);
Index: net-2.6.25/net/ipv6/af_inet6.c
===================================================================
--- net-2.6.25.orig/net/ipv6/af_inet6.c
+++ net-2.6.25/net/ipv6/af_inet6.c
@@ -859,10 +859,11 @@ static int __init inet6_init(void)
goto addrconf_fail;
/* Init v6 extension headers. */
- ipv6_rthdr_init();
+ err = ipv6_exthdrs_init();
+ if (err)
+ goto ipv6_exthdrs_fail;
+
ipv6_frag_init();
- ipv6_nodata_init();
- ipv6_destopt_init();
/* Init v6 transport protocols. */
udpv6_init();
@@ -874,6 +875,8 @@ static int __init inet6_init(void)
out:
return err;
+ipv6_exthdrs_fail:
+ addrconf_cleanup();
addrconf_fail:
ip6_flowlabel_cleanup();
ip6_flowlabel_fail:
@@ -932,6 +935,7 @@ static void __exit inet6_exit(void)
/* Cleanup code parts. */
ipv6_packet_cleanup();
+ ipv6_exthdrs_exit();
addrconf_cleanup();
ip6_flowlabel_cleanup();
ip6_route_cleanup();
Index: net-2.6.25/net/ipv6/exthdrs.c
===================================================================
--- net-2.6.25.orig/net/ipv6/exthdrs.c
+++ net-2.6.25/net/ipv6/exthdrs.c
@@ -308,28 +308,6 @@ static int ipv6_destopt_rcv(struct sk_bu
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.
********************************/
@@ -527,12 +505,48 @@ static struct inet6_protocol rthdr_proto
.flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
};
-void __init ipv6_rthdr_init(void)
+static struct inet6_protocol destopt_protocol = {
+ .handler = ipv6_destopt_rcv,
+ .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
+};
+
+static struct inet6_protocol nodata_protocol = {
+ .handler = dst_discard,
+ .flags = INET6_PROTO_NOPOLICY,
+};
+
+int __init ipv6_exthdrs_init(void)
{
- if (inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING) < 0)
- printk(KERN_ERR "ipv6_rthdr_init: Could not register protocol\n");
+ 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.
**********************************/
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 3/5] ipv6: make frag to return an error at initialization
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
2007-12-10 15:09 ` [patch 1/5] ipv6: make flowlabel to return an error Daniel Lezcano
2007-12-10 15:09 ` [patch 2/5] ipv6: make extended headers to return an error at initialization Daniel Lezcano
@ 2007-12-10 15:09 ` Daniel Lezcano
2007-12-11 10:24 ` David Miller
2007-12-10 15:09 ` [patch 4/5] ipv6: make inet6_register_protosw to return an error code Daniel Lezcano
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:09 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, pekkas, netdev
[-- Attachment #1: make-ip6-frag-init-return-an-error.patch --]
[-- Type: text/plain, Size: 2649 bytes --]
This patch makes the frag_init to return an error code, so the af_inet6
module can handle the error.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
include/net/transp_v6.h | 3 ++-
net/ipv6/af_inet6.c | 8 ++++++--
net/ipv6/reassembly.c | 16 +++++++++++++---
3 files changed, 21 insertions(+), 6 deletions(-)
Index: net-2.6.25/include/net/transp_v6.h
===================================================================
--- net-2.6.25.orig/include/net/transp_v6.h
+++ net-2.6.25/include/net/transp_v6.h
@@ -19,7 +19,8 @@ struct flowi;
/* extention headers */
extern int ipv6_exthdrs_init(void);
extern void ipv6_exthdrs_exit(void);
-extern void ipv6_frag_init(void);
+extern int ipv6_frag_init(void);
+extern void ipv6_frag_exit(void);
/* transport protocols */
extern void rawv6_init(void);
Index: net-2.6.25/net/ipv6/af_inet6.c
===================================================================
--- net-2.6.25.orig/net/ipv6/af_inet6.c
+++ net-2.6.25/net/ipv6/af_inet6.c
@@ -863,7 +863,9 @@ static int __init inet6_init(void)
if (err)
goto ipv6_exthdrs_fail;
- ipv6_frag_init();
+ err = ipv6_frag_init();
+ if (err)
+ goto ipv6_frag_fail;
/* Init v6 transport protocols. */
udpv6_init();
@@ -875,6 +877,8 @@ static int __init inet6_init(void)
out:
return err;
+ipv6_frag_fail:
+ ipv6_exthdrs_exit();
ipv6_exthdrs_fail:
addrconf_cleanup();
addrconf_fail:
@@ -934,7 +938,7 @@ static void __exit inet6_exit(void)
/* Cleanup code parts. */
ipv6_packet_cleanup();
-
+ ipv6_frag_exit();
ipv6_exthdrs_exit();
addrconf_cleanup();
ip6_flowlabel_cleanup();
Index: net-2.6.25/net/ipv6/reassembly.c
===================================================================
--- net-2.6.25.orig/net/ipv6/reassembly.c
+++ net-2.6.25/net/ipv6/reassembly.c
@@ -632,11 +632,13 @@ static struct inet6_protocol frag_protoc
.flags = INET6_PROTO_NOPOLICY,
};
-void __init ipv6_frag_init(void)
+int __init ipv6_frag_init(void)
{
- if (inet6_add_protocol(&frag_protocol, IPPROTO_FRAGMENT) < 0)
- printk(KERN_ERR "ipv6_frag_init: Could not register protocol\n");
+ int ret;
+ ret = inet6_add_protocol(&frag_protocol, IPPROTO_FRAGMENT);
+ if (ret)
+ goto out;
ip6_frags.ctl = &ip6_frags_ctl;
ip6_frags.hashfn = ip6_hashfn;
ip6_frags.constructor = ip6_frag_init;
@@ -646,4 +648,12 @@ void __init ipv6_frag_init(void)
ip6_frags.match = ip6_frag_match;
ip6_frags.frag_expire = ip6_frag_expire;
inet_frags_init(&ip6_frags);
+out:
+ return ret;
+}
+
+void ipv6_frag_exit(void)
+{
+ inet_frags_fini(&ip6_frags);
+ inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
}
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 4/5] ipv6: make inet6_register_protosw to return an error code
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
` (2 preceding siblings ...)
2007-12-10 15:09 ` [patch 3/5] ipv6: make frag " Daniel Lezcano
@ 2007-12-10 15:09 ` Daniel Lezcano
2007-12-11 10:25 ` David Miller
2007-12-10 15:09 ` [patch 5/5] ipv6: make the protocol initialization " Daniel Lezcano
2007-12-10 15:32 ` [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
5 siblings, 1 reply; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:09 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, pekkas, netdev
[-- Attachment #1: make-inet6_register_protosw-return-an-error-code.patch --]
[-- Type: text/plain, Size: 2249 bytes --]
This patch makes the inet6_register_protosw to return an error code.
The different protocols can be aware the registration was successful or
not and can pass the error to the initial caller, af_inet6.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
include/net/protocol.h | 2 +-
net/ipv6/af_inet6.c | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
Index: net-2.6.25/include/net/protocol.h
===================================================================
--- net-2.6.25.orig/include/net/protocol.h
+++ net-2.6.25/include/net/protocol.h
@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(stru
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num);
extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num);
-extern void inet6_register_protosw(struct inet_protosw *p);
+extern int inet6_register_protosw(struct inet_protosw *p);
extern void inet6_unregister_protosw(struct inet_protosw *p);
#endif
Index: net-2.6.25/net/ipv6/af_inet6.c
===================================================================
--- net-2.6.25.orig/net/ipv6/af_inet6.c
+++ net-2.6.25/net/ipv6/af_inet6.c
@@ -565,21 +565,23 @@ static struct inet_protosw rawv6_protosw
.flags = INET_PROTOSW_REUSE,
};
-void
-inet6_register_protosw(struct inet_protosw *p)
+int inet6_register_protosw(struct inet_protosw *p)
{
struct list_head *lh;
struct inet_protosw *answer;
- int protocol = p->protocol;
struct list_head *last_perm;
+ int protocol = p->protocol;
+ int ret;
spin_lock_bh(&inetsw6_lock);
+ ret = -EINVAL;
if (p->type >= SOCK_MAX)
goto out_illegal;
/* If we are trying to override a permanent protocol, bail. */
answer = NULL;
+ ret = -EPERM;
last_perm = &inetsw6[p->type];
list_for_each(lh, &inetsw6[p->type]) {
answer = list_entry(lh, struct inet_protosw, list);
@@ -603,9 +605,10 @@ inet6_register_protosw(struct inet_proto
* system automatically returns to the old behavior.
*/
list_add_rcu(&p->list, last_perm);
+ ret = 0;
out:
spin_unlock_bh(&inetsw6_lock);
- return;
+ return ret;
out_permanent:
printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch 5/5] ipv6: make the protocol initialization to return an error code
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
` (3 preceding siblings ...)
2007-12-10 15:09 ` [patch 4/5] ipv6: make inet6_register_protosw to return an error code Daniel Lezcano
@ 2007-12-10 15:09 ` Daniel Lezcano
2007-12-11 10:25 ` David Miller
2007-12-10 15:32 ` [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
5 siblings, 1 reply; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:09 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, pekkas, netdev
[-- Attachment #1: make-protocol-init-to-return-an-error-code.patch --]
[-- Type: text/plain, Size: 11326 bytes --]
This patchset makes the different protocols to return an error code, so
the af_inet6 module can check the initialization was correct or not.
The raw6 was taken into account to be consistent with the rest of the
protocols, but the registration is at the same place.
Because the raw6 has its own init function, the proto and the ops structure
can be moved inside the raw6.c file.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
include/net/ipv6.h | 2 -
include/net/transp_v6.h | 12 ++++---
net/ipv6/af_inet6.c | 77 ++++++++++++++++++++---------------------------
net/ipv6/ipv6_sockglue.c | 3 +
net/ipv6/raw.c | 52 +++++++++++++++++++++++++++++++
net/ipv6/tcp_ipv6.c | 38 ++++++++++++++++++-----
net/ipv6/udp.c | 26 +++++++++++++--
net/ipv6/udplite.c | 25 ++++++++++++---
8 files changed, 169 insertions(+), 66 deletions(-)
Index: net-2.6.25/include/net/transp_v6.h
===================================================================
--- net-2.6.25.orig/include/net/transp_v6.h
+++ net-2.6.25/include/net/transp_v6.h
@@ -23,10 +23,14 @@ extern int ipv6_frag_init(void);
extern void ipv6_frag_exit(void);
/* transport protocols */
-extern void rawv6_init(void);
-extern void udpv6_init(void);
-extern void udplitev6_init(void);
-extern void tcpv6_init(void);
+extern int rawv6_init(void);
+extern void rawv6_exit(void);
+extern int udpv6_init(void);
+extern void udpv6_exit(void);
+extern int udplitev6_init(void);
+extern void udplitev6_exit(void);
+extern int tcpv6_init(void);
+extern void tcpv6_exit(void);
extern int udpv6_connect(struct sock *sk,
struct sockaddr *uaddr,
Index: net-2.6.25/net/ipv6/af_inet6.c
===================================================================
--- net-2.6.25.orig/net/ipv6/af_inet6.c
+++ net-2.6.25/net/ipv6/af_inet6.c
@@ -529,42 +529,6 @@ static struct net_proto_family inet6_fam
.owner = THIS_MODULE,
};
-/* Same as inet6_dgram_ops, sans udp_poll. */
-static const struct proto_ops inet6_sockraw_ops = {
- .family = PF_INET6,
- .owner = THIS_MODULE,
- .release = inet6_release,
- .bind = inet6_bind,
- .connect = inet_dgram_connect, /* ok */
- .socketpair = sock_no_socketpair, /* a do nothing */
- .accept = sock_no_accept, /* a do nothing */
- .getname = inet6_getname,
- .poll = datagram_poll, /* ok */
- .ioctl = inet6_ioctl, /* must change */
- .listen = sock_no_listen, /* ok */
- .shutdown = inet_shutdown, /* ok */
- .setsockopt = sock_common_setsockopt, /* ok */
- .getsockopt = sock_common_getsockopt, /* ok */
- .sendmsg = inet_sendmsg, /* ok */
- .recvmsg = sock_common_recvmsg, /* ok */
- .mmap = sock_no_mmap,
- .sendpage = sock_no_sendpage,
-#ifdef CONFIG_COMPAT
- .compat_setsockopt = compat_sock_common_setsockopt,
- .compat_getsockopt = compat_sock_common_getsockopt,
-#endif
-};
-
-static struct inet_protosw rawv6_protosw = {
- .type = SOCK_RAW,
- .protocol = IPPROTO_IP, /* wild card */
- .prot = &rawv6_prot,
- .ops = &inet6_sockraw_ops,
- .capability = CAP_NET_RAW,
- .no_check = UDP_CSUM_DEFAULT,
- .flags = INET_PROTOSW_REUSE,
-};
-
int inet6_register_protosw(struct inet_protosw *p)
{
struct list_head *lh;
@@ -771,7 +735,6 @@ static int __init inet6_init(void)
__this_module.can_unload = &ipv6_unload;
#endif
#endif
-
err = proto_register(&tcpv6_prot, 1);
if (err)
goto out;
@@ -796,14 +759,16 @@ static int __init inet6_init(void)
/* We MUST register RAW sockets before we create the ICMP6,
* IGMP6, or NDISC control sockets.
*/
- inet6_register_protosw(&rawv6_protosw);
+ err = rawv6_init();
+ if (err)
+ goto out_unregister_raw_proto;
/* Register the family here so that the init calls below will
* be able to create sockets. (?? is this dangerous ??)
*/
err = sock_register(&inet6_family_ops);
if (err)
- goto out_unregister_raw_proto;
+ goto out_sock_register_fail;
/* Initialise ipv6 mibs */
err = init_ipv6_mibs();
@@ -871,15 +836,32 @@ static int __init inet6_init(void)
goto ipv6_frag_fail;
/* Init v6 transport protocols. */
- udpv6_init();
- udplitev6_init();
- tcpv6_init();
+ err = udpv6_init();
+ if (err)
+ goto udpv6_fail;
+
+ err = udplitev6_init();
+ if (err)
+ goto udplitev6_fail;
+
+ err = tcpv6_init();
+ if (err)
+ goto tcpv6_fail;
- ipv6_packet_init();
- err = 0;
+ err = ipv6_packet_init();
+ if (err)
+ goto ipv6_packet_fail;
out:
return err;
+ipv6_packet_fail:
+ tcpv6_exit();
+tcpv6_fail:
+ udplitev6_exit();
+udplitev6_fail:
+ udpv6_exit();
+udpv6_fail:
+ ipv6_frag_exit();
ipv6_frag_fail:
ipv6_exthdrs_exit();
ipv6_exthdrs_fail:
@@ -920,6 +902,8 @@ icmp_fail:
out_unregister_sock:
sock_unregister(PF_INET6);
rtnl_unregister_all(PF_INET6);
+out_sock_register_fail:
+ rawv6_exit();
out_unregister_raw_proto:
proto_unregister(&rawv6_prot);
out_unregister_udplite_proto:
@@ -939,6 +923,10 @@ static void __exit inet6_exit(void)
/* Disallow any further netlink messages */
rtnl_unregister_all(PF_INET6);
+ udpv6_exit();
+ udplitev6_exit();
+ tcpv6_exit();
+
/* Cleanup code parts. */
ipv6_packet_cleanup();
ipv6_frag_exit();
@@ -961,6 +949,7 @@ static void __exit inet6_exit(void)
igmp6_cleanup();
ndisc_cleanup();
icmpv6_cleanup();
+ rawv6_exit();
#ifdef CONFIG_SYSCTL
ipv6_sysctl_unregister();
#endif
Index: net-2.6.25/net/ipv6/udp.c
===================================================================
--- net-2.6.25.orig/net/ipv6/udp.c
+++ net-2.6.25/net/ipv6/udp.c
@@ -1016,9 +1016,27 @@ static struct inet_protosw udpv6_protosw
};
-void __init udpv6_init(void)
+int __init udpv6_init(void)
{
- if (inet6_add_protocol(&udpv6_protocol, IPPROTO_UDP) < 0)
- printk(KERN_ERR "udpv6_init: Could not register protocol\n");
- inet6_register_protosw(&udpv6_protosw);
+ int ret;
+
+ ret = inet6_add_protocol(&udpv6_protocol, IPPROTO_UDP);
+ if (ret)
+ goto out;
+
+ ret = inet6_register_protosw(&udpv6_protosw);
+ if (ret)
+ goto out_udpv6_protocol;
+out:
+ return ret;
+
+out_udpv6_protocol:
+ inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
+ goto out;
+}
+
+void __exit udpv6_exit(void)
+{
+ inet6_unregister_protosw(&udpv6_protosw);
+ inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
}
Index: net-2.6.25/include/net/ipv6.h
===================================================================
--- net-2.6.25.orig/include/net/ipv6.h
+++ net-2.6.25/include/net/ipv6.h
@@ -545,7 +545,7 @@ extern int compat_ipv6_getsockopt(stru
char __user *optval,
int __user *optlen);
-extern void ipv6_packet_init(void);
+extern int ipv6_packet_init(void);
extern void ipv6_packet_cleanup(void);
Index: net-2.6.25/net/ipv6/ipv6_sockglue.c
===================================================================
--- net-2.6.25.orig/net/ipv6/ipv6_sockglue.c
+++ net-2.6.25/net/ipv6/ipv6_sockglue.c
@@ -1130,9 +1130,10 @@ int compat_ipv6_getsockopt(struct sock *
EXPORT_SYMBOL(compat_ipv6_getsockopt);
#endif
-void __init ipv6_packet_init(void)
+int __init ipv6_packet_init(void)
{
dev_add_pack(&ipv6_packet_type);
+ return 0;
}
void ipv6_packet_cleanup(void)
Index: net-2.6.25/net/ipv6/raw.c
===================================================================
--- net-2.6.25.orig/net/ipv6/raw.c
+++ net-2.6.25/net/ipv6/raw.c
@@ -1273,3 +1273,55 @@ void raw6_proc_exit(void)
proc_net_remove(&init_net, "raw6");
}
#endif /* CONFIG_PROC_FS */
+
+/* Same as inet6_dgram_ops, sans udp_poll. */
+static const struct proto_ops inet6_sockraw_ops = {
+ .family = PF_INET6,
+ .owner = THIS_MODULE,
+ .release = inet6_release,
+ .bind = inet6_bind,
+ .connect = inet_dgram_connect, /* ok */
+ .socketpair = sock_no_socketpair, /* a do nothing */
+ .accept = sock_no_accept, /* a do nothing */
+ .getname = inet6_getname,
+ .poll = datagram_poll, /* ok */
+ .ioctl = inet6_ioctl, /* must change */
+ .listen = sock_no_listen, /* ok */
+ .shutdown = inet_shutdown, /* ok */
+ .setsockopt = sock_common_setsockopt, /* ok */
+ .getsockopt = sock_common_getsockopt, /* ok */
+ .sendmsg = inet_sendmsg, /* ok */
+ .recvmsg = sock_common_recvmsg, /* ok */
+ .mmap = sock_no_mmap,
+ .sendpage = sock_no_sendpage,
+#ifdef CONFIG_COMPAT
+ .compat_setsockopt = compat_sock_common_setsockopt,
+ .compat_getsockopt = compat_sock_common_getsockopt,
+#endif
+};
+
+static struct inet_protosw rawv6_protosw = {
+ .type = SOCK_RAW,
+ .protocol = IPPROTO_IP, /* wild card */
+ .prot = &rawv6_prot,
+ .ops = &inet6_sockraw_ops,
+ .capability = CAP_NET_RAW,
+ .no_check = UDP_CSUM_DEFAULT,
+ .flags = INET_PROTOSW_REUSE,
+};
+
+int __init rawv6_init(void)
+{
+ int ret;
+
+ ret = inet6_register_protosw(&rawv6_protosw);
+ if (ret)
+ goto out;
+out:
+ return ret;
+}
+
+void __exit rawv6_exit(void)
+{
+ inet6_unregister_protosw(&rawv6_protosw);
+}
Index: net-2.6.25/net/ipv6/tcp_ipv6.c
===================================================================
--- net-2.6.25.orig/net/ipv6/tcp_ipv6.c
+++ net-2.6.25/net/ipv6/tcp_ipv6.c
@@ -2167,14 +2167,36 @@ static struct inet_protosw tcpv6_protosw
INET_PROTOSW_ICSK,
};
-void __init tcpv6_init(void)
+int __init tcpv6_init(void)
{
+ int ret;
+
+ ret = inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP);
+ if (ret)
+ goto out;
+
/* register inet6 protocol */
- if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0)
- printk(KERN_ERR "tcpv6_init: Could not register protocol\n");
- inet6_register_protosw(&tcpv6_protosw);
-
- if (inet_csk_ctl_sock_create(&tcp6_socket, PF_INET6, SOCK_RAW,
- IPPROTO_TCP) < 0)
- panic("Failed to create the TCPv6 control socket.\n");
+ ret = inet6_register_protosw(&tcpv6_protosw);
+ if (ret)
+ goto out_tcpv6_protocol;
+
+ ret = inet_csk_ctl_sock_create(&tcp6_socket, PF_INET6,
+ SOCK_RAW, IPPROTO_TCP);
+ if (ret)
+ goto out_tcpv6_protosw;
+out:
+ return ret;
+
+out_tcpv6_protocol:
+ inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
+out_tcpv6_protosw:
+ inet6_unregister_protosw(&tcpv6_protosw);
+ goto out;
+}
+
+void __exit tcpv6_exit(void)
+{
+ sock_release(tcp6_socket);
+ inet6_unregister_protosw(&tcpv6_protosw);
+ inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
}
Index: net-2.6.25/net/ipv6/udplite.c
===================================================================
--- net-2.6.25.orig/net/ipv6/udplite.c
+++ net-2.6.25/net/ipv6/udplite.c
@@ -77,12 +77,29 @@ static struct inet_protosw udplite6_prot
.flags = INET_PROTOSW_PERMANENT,
};
-void __init udplitev6_init(void)
+int __init udplitev6_init(void)
{
- if (inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE) < 0)
- printk(KERN_ERR "%s: Could not register.\n", __FUNCTION__);
+ int ret;
- inet6_register_protosw(&udplite6_protosw);
+ ret = inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
+ if (ret)
+ goto out;
+
+ ret = inet6_register_protosw(&udplite6_protosw);
+ if (ret)
+ goto out_udplitev6_protocol;
+out:
+ return ret;
+
+out_udplitev6_protocol:
+ inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
+ goto out;
+}
+
+void __exit udplitev6_exit(void)
+{
+ inet6_unregister_protosw(&udplite6_protosw);
+ inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
}
#ifdef CONFIG_PROC_FS
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
` (4 preceding siblings ...)
2007-12-10 15:09 ` [patch 5/5] ipv6: make the protocol initialization " Daniel Lezcano
@ 2007-12-10 15:32 ` Daniel Lezcano
2007-12-11 0:45 ` David Miller
5 siblings, 1 reply; 13+ messages in thread
From: Daniel Lezcano @ 2007-12-10 15:32 UTC (permalink / raw)
To: Daniel Lezcano; +Cc: davem, yoshfuji, pekkas, netdev
Daniel Lezcano wrote:
> This patchset continue the work to make the different af_inet6
> subsystems initialization functions to return an error code and
> to handle the error to fails safely.
>
> It takes into account:
> * flowlabel
> * exthdrs
> * frag
> * udp
> * udplite
> * tcp
> * raw
I just noticed that I forgot to put ipv6 under bracket.
Sorry for that :(
Should I resend the patchset ?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init
2007-12-10 15:32 ` [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
@ 2007-12-11 0:45 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-12-11 0:45 UTC (permalink / raw)
To: dlezcano; +Cc: yoshfuji, pekkas, netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Mon, 10 Dec 2007 16:32:50 +0100
> I just noticed that I forgot to put ipv6 under bracket.
> Sorry for that :(
>
> Should I resend the patchset ?
This is not necessary.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 1/5] ipv6: make flowlabel to return an error
2007-12-10 15:09 ` [patch 1/5] ipv6: make flowlabel to return an error Daniel Lezcano
@ 2007-12-11 10:23 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-12-11 10:23 UTC (permalink / raw)
To: dlezcano; +Cc: yoshfuji, pekkas, netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Mon, 10 Dec 2007 16:09:11 +0100
> This patch makes the flowlab subsystem to return an error code and makes
> some cleanup with procfs ifdefs.
> The af_inet6 will use the flowlabel init return code to check the initialization
> was correct.
>
> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 2/5] ipv6: make extended headers to return an error at initialization
2007-12-10 15:09 ` [patch 2/5] ipv6: make extended headers to return an error at initialization Daniel Lezcano
@ 2007-12-11 10:24 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-12-11 10:24 UTC (permalink / raw)
To: dlezcano; +Cc: yoshfuji, pekkas, netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Mon, 10 Dec 2007 16:09:12 +0100
> 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>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 3/5] ipv6: make frag to return an error at initialization
2007-12-10 15:09 ` [patch 3/5] ipv6: make frag " Daniel Lezcano
@ 2007-12-11 10:24 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-12-11 10:24 UTC (permalink / raw)
To: dlezcano; +Cc: yoshfuji, pekkas, netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Mon, 10 Dec 2007 16:09:13 +0100
> This patch makes the frag_init to return an error code, so the af_inet6
> module can handle the error.
>
> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 4/5] ipv6: make inet6_register_protosw to return an error code
2007-12-10 15:09 ` [patch 4/5] ipv6: make inet6_register_protosw to return an error code Daniel Lezcano
@ 2007-12-11 10:25 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-12-11 10:25 UTC (permalink / raw)
To: dlezcano; +Cc: yoshfuji, pekkas, netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Mon, 10 Dec 2007 16:09:14 +0100
> This patch makes the inet6_register_protosw to return an error code.
> The different protocols can be aware the registration was successful or
> not and can pass the error to the initial caller, af_inet6.
>
> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 5/5] ipv6: make the protocol initialization to return an error code
2007-12-10 15:09 ` [patch 5/5] ipv6: make the protocol initialization " Daniel Lezcano
@ 2007-12-11 10:25 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-12-11 10:25 UTC (permalink / raw)
To: dlezcano; +Cc: yoshfuji, pekkas, netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Mon, 10 Dec 2007 16:09:15 +0100
> This patchset makes the different protocols to return an error code, so
> the af_inet6 module can check the initialization was correct or not.
>
> The raw6 was taken into account to be consistent with the rest of the
> protocols, but the registration is at the same place.
> Because the raw6 has its own init function, the proto and the ops structure
> can be moved inside the raw6.c file.
>
> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Also applied, thanks Daniel.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-12-11 10:25 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-10 15:09 [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
2007-12-10 15:09 ` [patch 1/5] ipv6: make flowlabel to return an error Daniel Lezcano
2007-12-11 10:23 ` David Miller
2007-12-10 15:09 ` [patch 2/5] ipv6: make extended headers to return an error at initialization Daniel Lezcano
2007-12-11 10:24 ` David Miller
2007-12-10 15:09 ` [patch 3/5] ipv6: make frag " Daniel Lezcano
2007-12-11 10:24 ` David Miller
2007-12-10 15:09 ` [patch 4/5] ipv6: make inet6_register_protosw to return an error code Daniel Lezcano
2007-12-11 10:25 ` David Miller
2007-12-10 15:09 ` [patch 5/5] ipv6: make the protocol initialization " Daniel Lezcano
2007-12-11 10:25 ` David Miller
2007-12-10 15:32 ` [patch 0/5] ipv6: make af_inet6 subsystems to return an error at init Daniel Lezcano
2007-12-11 0:45 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).