[svn-commits] sruffell: linux/trunk r9610 - in /linux/trunk: README drivers/dahdi/dahdi-base.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jan 3 18:28:23 UTC 2011
Author: sruffell
Date: Mon Jan 3 12:28:19 2011
New Revision: 9610
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9610
Log:
dahdi: Add module parameter to limit number of pseudo channels.
Since there isn't a fixed array to hold all the channels, and also limit
the total number of channels that can be created, we'll add a module
parameter to allow the system administrator to specify the maximum
number of pseudo channels. This is to prevent a potentially
non-privledged process from consuming too much CPU (since all pseudos
are checked each "tick" for conferencing) and kernel memory.
By default the number of pseudo channels is limited to 512. Change the
default limit with:
]# modprobe dahdi max_pseudo_channels=<new limit>
or at runtime with:
]# echo <new limit> > /sys/module/dahdi/parameters/max_psuedo_channels
Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Kinsey Moore <kmoore at digium.com>
Modified:
linux/trunk/README
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/README
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/README?view=diff&rev=9610&r1=9609&r2=9610
==============================================================================
--- linux/trunk/README (original)
+++ linux/trunk/README Mon Jan 3 12:28:19 2011
@@ -437,6 +437,11 @@
different default size. So normally setting this doesn't change
anything.
+max_pseudo_channels (dahdi)::
+ The maximum number of pseudo channels that dahdi will allow userspace to
+ create. Pseudo channels are used when conferencing channels together.
+ The default is 512.
+
To get a list of parameters supported by a module, use
modinfo module_name
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9610&r1=9609&r2=9610
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Jan 3 12:28:19 2011
@@ -3003,7 +3003,10 @@
#endif
}
-static struct dahdi_chan *dahdi_alloc_pseudo(void)
+static unsigned int max_pseudo_channels = 512;
+static unsigned int num_pseudo_channels;
+
+static struct dahdi_chan *dahdi_alloc_pseudo(struct file *file)
{
struct pseudo_chan *pseudo;
unsigned long flags;
@@ -3014,6 +3017,9 @@
/* Don't allow /dev/dahdi/pseudo to open if there is not a timing
* source. */
if (!can_open_timer())
+ return NULL;
+
+ if (unlikely(num_pseudo_channels >= max_pseudo_channels))
return NULL;
pseudo = kzalloc(sizeof(*pseudo), GFP_KERNEL);
@@ -3059,9 +3065,12 @@
snprintf(pseudo->chan.name, sizeof(pseudo->chan.name)-1,
"Pseudo/%d", pseudo->chan.channo);
+ file->private_data = &pseudo->chan;
+
/* Once we place the pseudo chan on the list...it's registered and
* live. */
spin_lock_irqsave(&chan_lock, flags);
+ ++num_pseudo_channels;
list_add(&pseudo->node, pos);
spin_unlock_irqrestore(&chan_lock, flags);
@@ -3082,6 +3091,7 @@
spin_lock_irqsave(&chan_lock, flags);
list_del(&pseudo->node);
+ --num_pseudo_channels;
spin_unlock_irqrestore(&chan_lock, flags);
dahdi_chan_unreg(chan);
@@ -3127,13 +3137,10 @@
if (unit == DAHDI_CHANNEL)
return dahdi_chan_open(file);
if (unit == DAHDI_PSEUDO) {
- chan = dahdi_alloc_pseudo();
- if (chan) {
- file->private_data = chan;
- return dahdi_specchan_open(file);
- } else {
- return -ENXIO;
- }
+ chan = dahdi_alloc_pseudo(file);
+ if (unlikely(!chan))
+ return -ENOMEM;
+ return dahdi_specchan_open(file);
}
return dahdi_specchan_open(file);
}
@@ -9050,6 +9057,9 @@
" this to 32");
module_param(deftaps, int, 0644);
+module_param(max_pseudo_channels, int, 0644);
+MODULE_PARM_DESC(max_pseudo_channels, "Maximum number of pseudo channels.");
+
static const struct file_operations dahdi_fops = {
.owner = THIS_MODULE,
.open = dahdi_open,
More information about the svn-commits
mailing list