sctp: Don't abort initialization when CONFIG_PROC_FS=n

This puts CONFIG_PROC_FS defines around the proc init/exit functions
and also avoids compiling proc.c if procfs is not supported.
Also make SCTP_DBG_OBJCNT depend on procfs.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Florian Westphal 2008-07-18 23:03:44 -07:00 committed by David S. Miller
parent c1e20f7c8b
commit c4e85f82ed
3 changed files with 14 additions and 5 deletions

View file

@ -47,11 +47,11 @@ config SCTP_DBG_MSG
config SCTP_DBG_OBJCNT config SCTP_DBG_OBJCNT
bool "SCTP: Debug object counts" bool "SCTP: Debug object counts"
depends on PROC_FS
help help
If you say Y, this will enable debugging support for counting the If you say Y, this will enable debugging support for counting the
type of objects that are currently allocated. This is useful for type of objects that are currently allocated. This is useful for
identifying memory leaks. If the /proc filesystem is enabled this identifying memory leaks. This debug information can be viewed by
debug information can be viewed by
'cat /proc/net/sctp/sctp_dbg_objcnt' 'cat /proc/net/sctp/sctp_dbg_objcnt'
If unsure, say N If unsure, say N

View file

@ -9,10 +9,10 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
transport.o chunk.o sm_make_chunk.o ulpevent.o \ transport.o chunk.o sm_make_chunk.o ulpevent.o \
inqueue.o outqueue.o ulpqueue.o command.o \ inqueue.o outqueue.o ulpqueue.o command.o \
tsnmap.o bind_addr.o socket.o primitive.o \ tsnmap.o bind_addr.o socket.o primitive.o \
output.o input.o debug.o ssnmap.o proc.o \ output.o input.o debug.o ssnmap.o auth.o
auth.o
sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o
sctp-$(CONFIG_PROC_FS) += proc.o
sctp-$(CONFIG_SYSCTL) += sysctl.o sctp-$(CONFIG_SYSCTL) += sysctl.o
sctp-$(subst m,y,$(CONFIG_IPV6)) += ipv6.o sctp-$(subst m,y,$(CONFIG_IPV6)) += ipv6.o

View file

@ -64,9 +64,12 @@
/* Global data structures. */ /* Global data structures. */
struct sctp_globals sctp_globals __read_mostly; struct sctp_globals sctp_globals __read_mostly;
struct proc_dir_entry *proc_net_sctp;
DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly; DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_net_sctp;
#endif
struct idr sctp_assocs_id; struct idr sctp_assocs_id;
DEFINE_SPINLOCK(sctp_assocs_id_lock); DEFINE_SPINLOCK(sctp_assocs_id_lock);
@ -97,6 +100,7 @@ struct sock *sctp_get_ctl_sock(void)
/* Set up the proc fs entry for the SCTP protocol. */ /* Set up the proc fs entry for the SCTP protocol. */
static __init int sctp_proc_init(void) static __init int sctp_proc_init(void)
{ {
#ifdef CONFIG_PROC_FS
if (!proc_net_sctp) { if (!proc_net_sctp) {
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
ent = proc_mkdir("sctp", init_net.proc_net); ent = proc_mkdir("sctp", init_net.proc_net);
@ -131,6 +135,9 @@ out_snmp_proc_init:
} }
out_nomem: out_nomem:
return -ENOMEM; return -ENOMEM;
#else
return 0;
#endif /* CONFIG_PROC_FS */
} }
/* Clean up the proc fs entry for the SCTP protocol. /* Clean up the proc fs entry for the SCTP protocol.
@ -139,6 +146,7 @@ out_nomem:
*/ */
static void sctp_proc_exit(void) static void sctp_proc_exit(void)
{ {
#ifdef CONFIG_PROC_FS
sctp_snmp_proc_exit(); sctp_snmp_proc_exit();
sctp_eps_proc_exit(); sctp_eps_proc_exit();
sctp_assocs_proc_exit(); sctp_assocs_proc_exit();
@ -148,6 +156,7 @@ static void sctp_proc_exit(void)
proc_net_sctp = NULL; proc_net_sctp = NULL;
remove_proc_entry("sctp", init_net.proc_net); remove_proc_entry("sctp", init_net.proc_net);
} }
#endif
} }
/* Private helper to extract ipv4 address and stash them in /* Private helper to extract ipv4 address and stash them in