diff --git a/src/backend.c b/src/backend.c index 6ec85ae1f..0a7875cdf 100644 --- a/src/backend.c +++ b/src/backend.c @@ -2669,11 +2669,15 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy) static int smp_fetch_nbsrv(const struct arg *args, struct sample *smp, const char *kw, void *private) { - struct proxy *px; + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - px = args->data.prx; smp->data.u.sint = be_usable_srv(px); @@ -2708,12 +2712,18 @@ static int smp_fetch_connslots(const struct arg *args, struct sample *smp, const char *kw, void *private) { struct server *iterator; + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; smp->data.u.sint = 0; - for (iterator = args->data.prx->srv; iterator; iterator = iterator->next) { + for (iterator = px->srv; iterator; iterator = iterator->next) { if (iterator->cur_state == SRV_ST_STOPPED) continue; @@ -2822,9 +2832,16 @@ smp_fetch_srv_name(const struct arg *args, struct sample *smp, const char *kw, v static int smp_fetch_be_sess_rate(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.u.sint = read_freq_ctr(&args->data.prx->be_sess_per_sec); + smp->data.u.sint = read_freq_ctr(&px->be_sess_per_sec); return 1; } @@ -2835,9 +2852,16 @@ smp_fetch_be_sess_rate(const struct arg *args, struct sample *smp, const char *k static int smp_fetch_be_conn(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.u.sint = args->data.prx->beconn; + smp->data.u.sint = px->beconn; return 1; } @@ -2850,14 +2874,19 @@ static int smp_fetch_be_conn_free(const struct arg *args, struct sample *smp, const char *kw, void *private) { struct server *iterator; - struct proxy *px; + struct proxy *px = args->data.prx; unsigned int maxconn; + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; smp->data.u.sint = 0; - for (iterator = args->data.prx->srv; iterator; iterator = iterator->next) { + for (iterator = px->srv; iterator; iterator = iterator->next) { if (iterator->cur_state == SRV_ST_STOPPED) continue; @@ -2888,9 +2917,16 @@ smp_fetch_be_conn_free(const struct arg *args, struct sample *smp, const char *k static int smp_fetch_queue_size(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.u.sint = args->data.prx->totpend; + smp->data.u.sint = px->totpend; return 1; } @@ -2905,12 +2941,16 @@ smp_fetch_queue_size(const struct arg *args, struct sample *smp, const char *kw, static int smp_fetch_avg_queue_size(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; int nbsrv; - struct proxy *px; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - px = args->data.prx; nbsrv = be_usable_srv(px); diff --git a/src/frontend.c b/src/frontend.c index 6aa102701..f976cc831 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -211,9 +211,16 @@ smp_fetch_fe_defbe(const struct arg *args, struct sample *smp, const char *kw, v static int smp_fetch_fe_req_rate(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.u.sint = read_freq_ctr(&args->data.prx->fe_req_per_sec); + smp->data.u.sint = read_freq_ctr(&px->fe_req_per_sec); return 1; } @@ -224,9 +231,16 @@ smp_fetch_fe_req_rate(const struct arg *args, struct sample *smp, const char *kw static int smp_fetch_fe_sess_rate(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.u.sint = read_freq_ctr(&args->data.prx->fe_sess_per_sec); + smp->data.u.sint = read_freq_ctr(&px->fe_sess_per_sec); return 1; } @@ -237,9 +251,16 @@ smp_fetch_fe_sess_rate(const struct arg *args, struct sample *smp, const char *k static int smp_fetch_fe_conn(const struct arg *args, struct sample *smp, const char *kw, void *private) { + struct proxy *px = args->data.prx; + + if (px == NULL) + return 0; + if (px->cap & PR_CAP_DEF) + px = smp->px; + smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.u.sint = args->data.prx->feconn; + smp->data.u.sint = px->feconn; return 1; } diff --git a/src/sample.c b/src/sample.c index d5ce8ad6c..9200ca303 100644 --- a/src/sample.c +++ b/src/sample.c @@ -1217,8 +1217,16 @@ int smp_resolve_args(struct proxy *p, char **err) break; } } - else + else { + if (px->cap & PR_CAP_DEF) { + memprintf(err, "%sparsing [%s:%d]: backend name must be set in arg %d of %s%s%s%s '%s' %s proxy '%s'.\n", + *err ? *err : "", cur->file, cur->line, + cur->arg_pos + 1, conv_pre, conv_ctx, conv_pos, ctx, cur->kw, where, p->id); + cfgerr++; + break; + } sname = arg->data.str.area; + } srv = findserver(px, sname); if (!srv) { @@ -1293,8 +1301,16 @@ int smp_resolve_args(struct proxy *p, char **err) case ARGT_TAB: if (arg->data.str.data) stktname = arg->data.str.area; - else + else { + if (px->cap & PR_CAP_DEF) { + memprintf(err, "%sparsing [%s:%d]: table name must be set in arg %d of %s%s%s%s '%s' %s proxy '%s'.\n", + *err ? *err : "", cur->file, cur->line, + cur->arg_pos + 1, conv_pre, conv_ctx, conv_pos, ctx, cur->kw, where, p->id); + cfgerr++; + break; + } stktname = px->id; + } t = stktable_find_by_name(stktname); if (!t) {