Skip to content

Commit

Permalink
Fixed port param for lb_is_destination().
Browse files Browse the repository at this point in the history
It must accept integer values also, not only variables.
Reported by @telephone-man on GITHUB
Closes #808.
  • Loading branch information
bogdan-iancu committed Mar 20, 2016
1 parent e49e2e8 commit 143328f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
9 changes: 2 additions & 7 deletions modules/load_balancer/lb_data.c
Expand Up @@ -952,7 +952,7 @@ int do_lb_disable_dst(struct sip_msg *req, struct lb_data *data, unsigned int ve
/* Checks, if the IP PORT is a LB destination
*/
int lb_is_dst(struct lb_data *data, struct sip_msg *_m,
pv_spec_t *pv_ip, pv_spec_t *pv_port, int group, int active)
pv_spec_t *pv_ip, gparam_t *pv_port, int group, int active)
{
pv_value_t val;
struct ip_addr *ip;
Expand All @@ -976,15 +976,10 @@ int lb_is_dst(struct lb_data *data, struct sip_msg *_m,

/* get the port to test */
if (pv_port) {
if (pv_get_spec_value( _m, pv_port, &val)!=0) {
if (fixup_get_ivalue(_m, (gparam_p)pv_port, &port) != 0) {
LM_ERR("failed to get PORT value from PV\n");
return -1;
}
if ( (val.flags&PV_VAL_INT)==0 ) {
LM_ERR("PORT PV val is not integer\n");
return -1;
}
port = val.ri;
} else {
port = 0;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/load_balancer/lb_data.h
Expand Up @@ -29,6 +29,7 @@
#ifndef LB_LB_DATA_H_
#define LB_LB_DATA_H_

#include "../../mod_fix.h"
#include "../../str.h"
#include "../../locking.h"
#include "../../parser/msg_parser.h"
Expand Down Expand Up @@ -102,7 +103,7 @@ int do_lb_is_started(struct sip_msg *req);
int do_lb_disable_dst(struct sip_msg *req, struct lb_data *data, unsigned int verbose);

int lb_is_dst(struct lb_data *data, struct sip_msg *_m,
pv_spec_t *pv_ip, pv_spec_t *pv_port, int group, int active);
pv_spec_t *pv_ip, gparam_t *pv_port, int group, int active);

int lb_count_call(struct lb_data *data, struct sip_msg *req,
struct ip_addr *ip, int port, int group, struct lb_res_str_list *rl, int dir);
Expand Down
6 changes: 3 additions & 3 deletions modules/load_balancer/load_balancer.c
Expand Up @@ -310,7 +310,7 @@ static int fixup_is_dst(void** param, int param_no)
*param = NULL;
return 0;
}
return fixup_pvar(param);
return fixup_igp(param);
} else if (param_no==3) {
/* the group to check in */
return fixup_igp(param);
Expand Down Expand Up @@ -685,7 +685,7 @@ static int w_lb_is_dst2(struct sip_msg *msg, char *ip, char *port)

lock_start_read( ref_lock );

ret = lb_is_dst(*curr_data, msg, (pv_spec_t*)ip, (pv_spec_t*)port, -1, 0);
ret = lb_is_dst(*curr_data, msg, (pv_spec_t*)ip, (gparam_t*)port, -1, 0);

lock_stop_read( ref_lock );

Expand Down Expand Up @@ -713,7 +713,7 @@ static int w_lb_is_dst4(struct sip_msg *msg,char *ip,char *port,char *grp,

lock_start_read( ref_lock );

ret = lb_is_dst(*curr_data, msg, (pv_spec_t*)ip, (pv_spec_t*)port,
ret = lb_is_dst(*curr_data, msg, (pv_spec_t*)ip, (gparam_t*)port,
group, (int)(long)active);

lock_stop_read( ref_lock );
Expand Down

0 comments on commit 143328f

Please sign in to comment.