diff --git a/doc/configuration.txt b/doc/configuration.txt index d94bdf2f1..7843e0440 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -12057,6 +12057,7 @@ tcp-request content [{if | unless} ] - set-dst - set-dst-port - set-log-level + - set-nice - set-src - set-src-port - set-var() @@ -12112,6 +12113,9 @@ tcp-request content [{if | unless} ] The "set-log-level" is used to set the log level of the current session. More information on how to use it at "http-request set-log-level". + The "set-nice" is used to set the "nice" factor of the current session. More + information on how to use it at "http-request set-nice". + The "set-src" and "set-src-port" are used to set respectively the source IP and port. More information on how to use it at "http-request set-src". @@ -12359,6 +12363,11 @@ tcp-response content [{if | unless} ] session. More information on how to use it at "http-response set-log-level". + - set-nice + The "set-nice" is used to set the "nice" factor of the current + session. More information on how to use it at "http-response + set-nice". + - set-var() Sets a variable. diff --git a/include/haproxy/action-t.h b/include/haproxy/action-t.h index 2e56848d8..4f0216372 100644 --- a/include/haproxy/action-t.h +++ b/include/haproxy/action-t.h @@ -81,7 +81,6 @@ enum act_name { /* common http actions .*/ ACT_HTTP_REDIR, - ACT_HTTP_SET_NICE, ACT_HTTP_SET_TOS, ACT_HTTP_SET_MARK, diff --git a/src/http_act.c b/src/http_act.c index 3bc72d794..9e49d3373 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -1315,32 +1315,6 @@ static enum act_parse_ret parse_http_auth(const char **args, int *orig_arg, stru return ACT_RET_PRS_OK; } -/* Parse a "set-nice" action. It takes the nice value as argument. It returns - * ACT_RET_PRS_OK on success, ACT_RET_PRS_ERR on error. - */ -static enum act_parse_ret parse_http_set_nice(const char **args, int *orig_arg, struct proxy *px, - struct act_rule *rule, char **err) -{ - int cur_arg; - - rule->action = ACT_HTTP_SET_NICE; - - cur_arg = *orig_arg; - if (!*args[cur_arg]) { - memprintf(err, "expects exactly 1 argument (integer value)"); - return ACT_RET_PRS_ERR; - } - rule->arg.http.i = atoi(args[cur_arg]); - if (rule->arg.http.i < -1024) - rule->arg.http.i = -1024; - else if (rule->arg.http.i > 1024) - rule->arg.http.i = 1024; - - LIST_INIT(&rule->arg.http.fmt); - *orig_arg = cur_arg + 1; - return ACT_RET_PRS_OK; -} - /* Parse a "set-tos" action. It takes the TOS value as argument. It returns * ACT_RET_PRS_OK on success, ACT_RET_PRS_ERR on error. */ @@ -2485,7 +2459,6 @@ static struct action_kw_list http_req_actions = { { "set-map", parse_http_set_map, KWF_MATCH_PREFIX }, { "set-method", parse_set_req_line, 0 }, { "set-mark", parse_http_set_mark, 0 }, - { "set-nice", parse_http_set_nice, 0 }, { "set-path", parse_set_req_line, 0 }, { "set-pathq", parse_set_req_line, 0 }, { "set-query", parse_set_req_line, 0 }, @@ -2519,7 +2492,6 @@ static struct action_kw_list http_res_actions = { { "set-header", parse_http_set_header, 0 }, { "set-map", parse_http_set_map, KWF_MATCH_PREFIX }, { "set-mark", parse_http_set_mark, 0 }, - { "set-nice", parse_http_set_nice, 0 }, { "set-status", parse_http_set_status, 0 }, { "set-tos", parse_http_set_tos, 0 }, { "strict-mode", parse_http_strict_mode, 0 }, diff --git a/src/http_ana.c b/src/http_ana.c index 29a9806b6..fc0b5bccc 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -2831,10 +2831,6 @@ static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct lis rule_ret = HTTP_RULE_RES_ERROR; goto end; - case ACT_HTTP_SET_NICE: - s->task->nice = rule->arg.http.i; - break; - case ACT_HTTP_SET_TOS: conn_set_tos(objt_conn(sess->origin), rule->arg.http.i); break; @@ -2962,10 +2958,6 @@ static enum rule_result http_res_get_intercept_rule(struct proxy *px, struct lis rule_ret = HTTP_RULE_RES_DENY; goto end; - case ACT_HTTP_SET_NICE: - s->task->nice = rule->arg.http.i; - break; - case ACT_HTTP_SET_TOS: conn_set_tos(objt_conn(sess->origin), rule->arg.http.i); break; diff --git a/src/stream.c b/src/stream.c index 3525bc42e..31913e08b 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2885,6 +2885,43 @@ static enum act_parse_ret stream_parse_set_log_level(const char **args, int *cur return ACT_RET_PRS_OK; } +static enum act_return stream_action_set_nice(struct act_rule *rule, struct proxy *px, + struct session *sess, struct stream *s, int flags) +{ + s->task->nice = (uintptr_t)rule->arg.act.p[0]; + return ACT_RET_CONT; +} + + +/* Parse a "set-nice" action. It takes the nice value as argument. It returns + * ACT_RET_PRS_OK on success, ACT_RET_PRS_ERR on error. + */ +static enum act_parse_ret stream_parse_set_nice(const char **args, int *cur_arg, struct proxy *px, + struct act_rule *rule, char **err) +{ + int nice; + + if (!*args[*cur_arg]) { + bad_log_level: + memprintf(err, "expects exactly 1 argument (integer value)"); + return ACT_RET_PRS_ERR; + } + + nice = atoi(args[*cur_arg]); + if (nice < -1024) + nice = -1024; + else if (nice > 1024) + nice = 1024; + + (*cur_arg)++; + + /* Register processing function. */ + rule->action_ptr = stream_action_set_nice; + rule->action = ACT_CUSTOM; + rule->arg.act.p[0] = (void *)(uintptr_t)nice; + return ACT_RET_PRS_OK; +} + static enum act_return tcp_action_switch_stream_mode(struct act_rule *rule, struct proxy *px, struct session *sess, struct stream *s, int flags) @@ -3743,6 +3780,7 @@ INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); /* main configuration keyword registration. */ static struct action_kw_list stream_tcp_req_keywords = { ILH, { { "set-log-level", stream_parse_set_log_level }, + { "set-nice", stream_parse_set_nice }, { "switch-mode", stream_parse_switch_mode }, { "use-service", stream_parse_use_service }, { /* END */ } @@ -3753,6 +3791,7 @@ INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &stream_tcp_req_keywords /* main configuration keyword registration. */ static struct action_kw_list stream_tcp_res_keywords = { ILH, { { "set-log-level", stream_parse_set_log_level }, + { "set-nice", stream_parse_set_nice }, { /* END */ } }}; @@ -3760,6 +3799,7 @@ INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &stream_tcp_res_keywords static struct action_kw_list stream_http_req_keywords = { ILH, { { "set-log-level", stream_parse_set_log_level }, + { "set-nice", stream_parse_set_nice }, { "use-service", stream_parse_use_service }, { /* END */ } }}; @@ -3768,6 +3808,7 @@ INITCALL1(STG_REGISTER, http_req_keywords_register, &stream_http_req_keywords); static struct action_kw_list stream_http_res_keywords = { ILH, { { "set-log-level", stream_parse_set_log_level }, + { "set-nice", stream_parse_set_nice }, { /* END */ } }};