Module: sip-router Branch: master Commit: b76afe7c0699b936bec3d7bb1c3a740bf08fdb1c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b76afe7c...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Oct 17 09:40:33 2014 +0200
pipelimit: fix dynamic pipe limit check
- proper add and check at the same time
---
modules/pipelimit/doc/pipelimit_admin.xml | 18 +++++++++++++++++- modules/pipelimit/pipelimit.c | 6 +++--- modules/pipelimit/pl_ht.c | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/modules/pipelimit/doc/pipelimit_admin.xml b/modules/pipelimit/doc/pipelimit_admin.xml index d2ae537..0983f60 100644 --- a/modules/pipelimit/doc/pipelimit_admin.xml +++ b/modules/pipelimit/doc/pipelimit_admin.xml @@ -302,7 +302,15 @@ modparam("pipelimit", "reply_reason", "Limiting") <para>Meaning of the parameters is as follows:</para> <itemizedlist> <listitem><para> - <emphasis>name</emphasis> - the pseudovariable holding the pipe name. + <emphasis>name</emphasis> - the string or pseudovariable with the pipe name. + </para></listitem> + <listitem><para> + <emphasis>algorithm</emphasis> - the string or pseudovariable with the + algorithm. The values can be: taildrop, red, network or feedback - see + readme of ratelimit module for details on each algorithm. + </para></listitem> + <listitem><para> + <emphasis>limit</emphasis> - the integer or pseudovariable with the limit value. </para></listitem> </itemizedlist> <para> @@ -345,6 +353,14 @@ with unexpected retcode=$var(check_result)\n"); exit; } ... + # perform pipe match for authenticated user + $var(limit) = 20; + if (!pl_check("$au", "traildrop", "$var(limit)")) { + pl_drop(); + exit; + } +... + </programlisting> </example> </section> diff --git a/modules/pipelimit/pipelimit.c b/modules/pipelimit/pipelimit.c index b76ba0d..3e6b918 100644 --- a/modules/pipelimit/pipelimit.c +++ b/modules/pipelimit/pipelimit.c @@ -645,7 +645,7 @@ static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg, return -1; }
- pipe = pl_pipe_get(&pipeid, 1); + pipe = pl_pipe_get(&pipeid, 0); if(pipe==NULL) { LM_DBG("pipe not found [%.*s] - trying to add it\n", @@ -656,7 +656,7 @@ static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg, pipeid.len, pipeid.s); return -2; } - pipe = pl_pipe_get(&pipeid, 1); + pipe = pl_pipe_get(&pipeid, 0); if(pipe==NULL) { LM_ERR("failed to retrieve pipe [%.*s]\n", @@ -665,7 +665,7 @@ static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg, } }
- return 1; + return pl_check(msg, &pipeid); }
static int fixup_pl_check3(void** param, int param_no) diff --git a/modules/pipelimit/pl_ht.c b/modules/pipelimit/pl_ht.c index 3b4a3bd..6e48bb4 100644 --- a/modules/pipelimit/pl_ht.c +++ b/modules/pipelimit/pl_ht.c @@ -240,7 +240,7 @@ pl_pipe_t* pl_pipe_get(str *pipeid, int mode) if(pipeid->len==it->name.len && strncmp(pipeid->s, it->name.s, pipeid->len)==0) { - /* lock_release(&_pl_pipes_ht->slots[idx].lock);*/ + if(mode==0) lock_release(&_pl_pipes_ht->slots[idx].lock); return it; } it = it->next;