From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, containers@lists.osdl.org,
"Denis V. Lunev" <den@openvz.org>
Subject: [PATCH 2/12 net-2.6.26] [ICMP]: Add return code to icmp_init.
Date: Fri, 29 Feb 2008 16:40:48 +0300 [thread overview]
Message-ID: <1204292458-11636-2-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1204292360.10368.11.camel@iris.sw.ru>
icmp_init could fail and this is normal for namespace other than initial.
So, the panic should be triggered only on init_net initialization path.
Additionally create rollback path for icmp_init as a separate function.
It will also be used later during namespace destruction.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
include/net/icmp.h | 2 +-
net/ipv4/af_inet.c | 3 ++-
net/ipv4/icmp.c | 26 ++++++++++++++++++++++----
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 7bf714d..faba64d 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -48,7 +48,7 @@ struct sk_buff;
extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info);
extern int icmp_rcv(struct sk_buff *skb);
extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
-extern void icmp_init(void);
+extern int icmp_init(void);
extern void icmp_out_count(unsigned char type);
/* Move into dst.h ? */
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index a7a99ac..4f539bd 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1430,7 +1430,8 @@ static int __init inet_init(void)
* Set the ICMP layer up
*/
- icmp_init();
+ if (icmp_init() < 0)
+ panic("Failed to create the ICMP control socket.\n");
/*
* Initialise the multicast router
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 98372db..b345b3d 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -1139,19 +1139,32 @@ static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
},
};
-void __init icmp_init(void)
+static void __exit icmp_exit(void)
{
- struct inet_sock *inet;
int i;
for_each_possible_cpu(i) {
- int err;
+ struct socket *sock;
+
+ sock = per_cpu(__icmp_socket, i);
+ if (sock == NULL)
+ continue;
+ per_cpu(__icmp_socket, i) = NULL;
+ sock_release(sock);
+ }
+}
+int __init icmp_init(void)
+{
+ struct inet_sock *inet;
+ int i, err;
+
+ for_each_possible_cpu(i) {
err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_ICMP,
&per_cpu(__icmp_socket, i));
if (err < 0)
- panic("Failed to create the ICMP control socket.\n");
+ goto fail;
per_cpu(__icmp_socket, i)->sk->sk_allocation = GFP_ATOMIC;
@@ -1171,6 +1184,11 @@ void __init icmp_init(void)
*/
per_cpu(__icmp_socket, i)->sk->sk_prot->unhash(per_cpu(__icmp_socket, i)->sk);
}
+ return 0;
+
+fail:
+ icmp_exit();
+ return err;
}
EXPORT_SYMBOL(icmp_err_convert);
--
1.5.3.rc5
next prev parent reply other threads:[~2008-02-29 13:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-29 13:39 [PATCH 0/12 net-2.6.26] icmp_socket namespacing Denis V. Lunev
2008-02-29 13:40 ` [PATCH 1/12 net-2.6.26] [INET]: Remove struct net_proto_family* from _init calls Denis V. Lunev
2008-02-29 13:40 ` Denis V. Lunev [this message]
2008-02-29 13:40 ` [PATCH 3/12 net-2.6.26] [ICMP]: Optimize icmp_socket usage Denis V. Lunev
2008-02-29 13:40 ` [PATCH 4/12 net-2.6.26] [ICMP]: Store sock rather than socket for ICMP flow control Denis V. Lunev
2008-02-29 13:40 ` [PATCH 5/12 net-2.6.26] [ICMP]: Pass proper ICMP socket into icmp(v6)_xmit_(un)lock Denis V. Lunev
2008-02-29 13:40 ` [PATCH 6/12 net-2.6.26] [ICMP]: Allocate data for __icmp(v6)_sk dynamically Denis V. Lunev
2008-02-29 13:40 ` [PATCH 7/12 net-2.6.26] No need for a separate __netlink_release call Denis V. Lunev
2008-02-29 13:40 ` [PATCH 8/12 net-2.6.26] Make netlink_kernel_release publically available as sk_release_kernel Denis V. Lunev
2008-02-29 13:40 ` [PATCH 9/12 net-2.6.26] [NETNS]: icmp(v6)_sk should not pin a namespace Denis V. Lunev
2008-02-29 19:35 ` David Miller
2008-02-29 13:40 ` [PATCH 10/12] [NETNS]: Make icmp_sk per namespace Denis V. Lunev
2008-02-29 13:40 ` [PATCH 11/12] [NETNS]: Make icmpv6_sk " Denis V. Lunev
2008-02-29 13:40 ` [PATCH 12/12 net-2.6.26] [ICMP6]: Consolidate fail path icmpv6_sk_init with icmpv6_sk_exit Denis V. Lunev
2008-02-29 19:23 ` David Miller
2008-02-29 20:12 ` Purpose of __net_exit & friends [Was: [ICMP6]: Consolidate fail ...] Sam Ravnborg
2008-02-29 20:23 ` Purpose of __net_exit & friends David Miller
2008-02-29 22:05 ` [PATCH 12/12 net-2.6.26] [ICMP6]: Consolidate fail path icmpv6_sk_init with icmpv6_sk_exit Denis V. Lunev
2008-02-29 22:15 ` David Miller
2008-02-29 19:23 ` [PATCH 0/12 net-2.6.26] icmp_socket namespacing David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1204292458-11636-2-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=containers@lists.osdl.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).