diff mbox

[net-next,6/9] sctp: Move the percpu sockets counter out of sctp_proc_init

Message ID 87393zq2rb.fsf_-_@xmission.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric W. Biederman Aug. 6, 2012, 6:44 p.m. UTC
The percpu sctp socket counter has nothing at all to do with the sctp
proc files, and having it in the wrong initialization is confusing,
and makes network namespace support a pain.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 net/sctp/protocol.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

Comments

Vladislav Yasevich Aug. 15, 2012, 3:19 a.m. UTC | #1
On 08/06/2012 02:44 PM, Eric W. Biederman wrote:
>
> The percpu sctp socket counter has nothing at all to do with the sctp
> proc files, and having it in the wrong initialization is confusing,
> and makes network namespace support a pain.
>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Acked-by: Vlad Yasevich <vyasevich@gmail.com>

> ---
>   net/sctp/protocol.c |   13 +++++++------
>   1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 6193d20..976d765 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -93,8 +93,6 @@ int sysctl_sctp_wmem[3];
>   /* Set up the proc fs entry for the SCTP protocol. */
>   static __init int sctp_proc_init(void)
>   {
> -	if (percpu_counter_init(&sctp_sockets_allocated, 0))
> -		goto out_nomem;
>   #ifdef CONFIG_PROC_FS
>   	if (!proc_net_sctp) {
>   		proc_net_sctp = proc_mkdir("sctp", init_net.proc_net);
> @@ -125,12 +123,9 @@ out_snmp_proc_init:
>   		remove_proc_entry("sctp", init_net.proc_net);
>   	}
>   out_free_percpu:
> -	percpu_counter_destroy(&sctp_sockets_allocated);
>   #else
>   	return 0;
>   #endif /* CONFIG_PROC_FS */
> -
> -out_nomem:
>   	return -ENOMEM;
>   }
>
> @@ -151,7 +146,6 @@ static void sctp_proc_exit(void)
>   		remove_proc_entry("sctp", init_net.proc_net);
>   	}
>   #endif
> -	percpu_counter_destroy(&sctp_sockets_allocated);
>   }
>
>   /* Private helper to extract ipv4 address and stash them in
> @@ -1261,6 +1255,10 @@ SCTP_STATIC __init int sctp_init(void)
>   	if (status)
>   		goto err_init_mibs;
>
> +	status = percpu_counter_init(&sctp_sockets_allocated, 0);
> +	if (status)
> +		goto err_percpu_counter_init;
> +
>   	/* Initialize proc fs directory.  */
>   	status = sctp_proc_init();
>   	if (status)
> @@ -1481,6 +1479,8 @@ err_ahash_alloc:
>   	sctp_dbg_objcnt_exit();
>   	sctp_proc_exit();
>   err_init_proc:
> +	percpu_counter_destroy(&sctp_sockets_allocated);
> +err_percpu_counter_init:
>   	cleanup_sctp_mibs();
>   err_init_mibs:
>   	kmem_cache_destroy(sctp_chunk_cachep);
> @@ -1521,6 +1521,7 @@ SCTP_STATIC __exit void sctp_exit(void)
>   			     sizeof(struct sctp_bind_hashbucket)));
>
>   	sctp_dbg_objcnt_exit();
> +	percpu_counter_destroy(&sctp_sockets_allocated);
>   	sctp_proc_exit();
>   	cleanup_sctp_mibs();
>
>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 6193d20..976d765 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -93,8 +93,6 @@  int sysctl_sctp_wmem[3];
 /* Set up the proc fs entry for the SCTP protocol. */
 static __init int sctp_proc_init(void)
 {
-	if (percpu_counter_init(&sctp_sockets_allocated, 0))
-		goto out_nomem;
 #ifdef CONFIG_PROC_FS
 	if (!proc_net_sctp) {
 		proc_net_sctp = proc_mkdir("sctp", init_net.proc_net);
@@ -125,12 +123,9 @@  out_snmp_proc_init:
 		remove_proc_entry("sctp", init_net.proc_net);
 	}
 out_free_percpu:
-	percpu_counter_destroy(&sctp_sockets_allocated);
 #else
 	return 0;
 #endif /* CONFIG_PROC_FS */
-
-out_nomem:
 	return -ENOMEM;
 }
 
@@ -151,7 +146,6 @@  static void sctp_proc_exit(void)
 		remove_proc_entry("sctp", init_net.proc_net);
 	}
 #endif
-	percpu_counter_destroy(&sctp_sockets_allocated);
 }
 
 /* Private helper to extract ipv4 address and stash them in
@@ -1261,6 +1255,10 @@  SCTP_STATIC __init int sctp_init(void)
 	if (status)
 		goto err_init_mibs;
 
+	status = percpu_counter_init(&sctp_sockets_allocated, 0);
+	if (status)
+		goto err_percpu_counter_init;
+
 	/* Initialize proc fs directory.  */
 	status = sctp_proc_init();
 	if (status)
@@ -1481,6 +1479,8 @@  err_ahash_alloc:
 	sctp_dbg_objcnt_exit();
 	sctp_proc_exit();
 err_init_proc:
+	percpu_counter_destroy(&sctp_sockets_allocated);
+err_percpu_counter_init:
 	cleanup_sctp_mibs();
 err_init_mibs:
 	kmem_cache_destroy(sctp_chunk_cachep);
@@ -1521,6 +1521,7 @@  SCTP_STATIC __exit void sctp_exit(void)
 			     sizeof(struct sctp_bind_hashbucket)));
 
 	sctp_dbg_objcnt_exit();
+	percpu_counter_destroy(&sctp_sockets_allocated);
 	sctp_proc_exit();
 	cleanup_sctp_mibs();