Skip to content

Commit

Permalink
Don't rate limit warnings on configuration parsing and starting
Browse files Browse the repository at this point in the history
  • Loading branch information
vankoven committed Mar 16, 2018
1 parent 3e09b4f commit 02a9715
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 67 deletions.
16 changes: 8 additions & 8 deletions tempesta_fw/apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,8 +1440,8 @@ bool
tfw_apm_check_hm(const char *name)
{
if (!tfw_hm_codes_cnt) {
TFW_ERR("No response codes specified for"
" server's health monitoring\n");
TFW_ERR_NL("No response codes specified for"
" server's health monitoring\n");
return false;
}

Expand Down Expand Up @@ -1561,15 +1561,15 @@ tfw_apm_cfgend(void)
if ((tfw_apm_jtmwindow < TFW_APM_MIN_TMWINDOW)
|| (tfw_apm_jtmwindow > TFW_APM_MAX_TMWINDOW))
{
TFW_ERR("apm_stats: window: value '%d' is out of limits.\n",
tfw_apm_jtmwindow);
TFW_ERR_NL("apm_stats: window: value '%d' is out of limits.\n",
tfw_apm_jtmwindow);
return -EINVAL;
}
if ((tfw_apm_tmwscale < TFW_APM_MIN_TMWSCALE)
|| (tfw_apm_tmwscale > TFW_APM_MAX_TMWSCALE))
{
TFW_ERR("apm_stats: scale: value '%d' is out of limits.\n",
tfw_apm_tmwscale);
TFW_ERR_NL("apm_stats: scale: value '%d' is out of limits.\n",
tfw_apm_tmwscale);
return -EINVAL;
}

Expand All @@ -1582,8 +1582,8 @@ tfw_apm_cfgend(void)
+ !!(jtmwindow % tfw_apm_tmwscale);

if (tfw_apm_jtmintrvl < TFW_APM_MIN_TMINTRVL) {
TFW_ERR("apm_stats window=%d scale=%d: scale is too long.\n",
tfw_apm_jtmwindow, tfw_apm_tmwscale);
TFW_ERR_NL("apm_stats window=%d scale=%d: scale is too long.\n",
tfw_apm_jtmwindow, tfw_apm_tmwscale);
return -EINVAL;
}
tfw_apm_jtmwindow = tfw_apm_jtmintrvl * tfw_apm_tmwscale;
Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ tfw_cache_start(void)
cache_mgr_thr = kthread_run(tfw_cache_mgr, NULL, "tfw_cache_mgr");
if (IS_ERR(cache_mgr_thr)) {
r = PTR_ERR(cache_mgr_thr);
TFW_ERR("Can't start cache manager, %d\n", r);
TFW_ERR_NL("Can't start cache manager, %d\n", r);
goto close_db;
}
#endif
Expand Down
27 changes: 14 additions & 13 deletions tempesta_fw/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ alloc_and_copy_literal(const char *src, size_t len)

dst = kmalloc(len + 1, GFP_KERNEL);
if (!dst) {
TFW_ERR("can't allocate memory\n");
TFW_ERR_NL("can't allocate memory\n");
return NULL;
}

Expand Down Expand Up @@ -160,22 +160,23 @@ check_identifier(const char *buf, size_t len)
size_t i;

if (!len) {
TFW_ERR("the string is empty\n");
TFW_ERR_NL("the string is empty\n");
return false;
}

if ((len == 1) && (buf[0] == '*'))
return true;

if (!isalpha(buf[0])) {
TFW_ERR("the first character is not a letter: '%c'\n", buf[0]);
TFW_ERR_NL("the first character is not a letter: '%c'\n",
buf[0]);
return false;
}

for (i = 0; i < len; ++i) {
if (!isalnum(buf[i]) && buf[i] != '_') {
TFW_ERR("invalid character: '%c' in '%.*s'\n",
buf[i], (int)len, buf);
TFW_ERR_NL("invalid character: '%c' in '%.*s'\n",
buf[i], (int)len, buf);
return false;
}
}
Expand Down Expand Up @@ -979,8 +980,8 @@ int
tfw_cfg_check_range(long value, long min, long max)
{
if (min != max && (value < min || value > max)) {
TFW_ERR("the value %ld is out of range: [%ld, %ld]\n",
value, min, max);
TFW_ERR_NL("the value %ld is out of range: [%ld, %ld]\n",
value, min, max);
return -EINVAL;
}
return 0;
Expand All @@ -995,8 +996,8 @@ int
tfw_cfg_check_multiple_of(long value, int divisor)
{
if (divisor && (value % divisor)) {
TFW_ERR("the value of %ld is not a multiple of %d\n",
value, divisor);
TFW_ERR_NL("the value of %ld is not a multiple of %d\n",
value, divisor);
return -EINVAL;
}
return 0;
Expand Down Expand Up @@ -1174,13 +1175,13 @@ tfw_cfg_handle_children(TfwCfgSpec *cs, TfwCfgEntry *e)
while (ps->t && (ps->t != TOKEN_RBRACE)) {
parse_cfg_entry(ps);
if (ps->err) {
TFW_ERR("parser error\n");
TFW_ERR_NL("parser error\n");
return ps->err;
}

matching_spec = spec_find(nested_specs, ps->e.name);
if (!matching_spec) {
TFW_ERR("don't know how to handle: %s\n", ps->e.name);
TFW_ERR_NL("don't know how to handle: %s\n", ps->e.name);
return -EINVAL;
}

Expand All @@ -1196,7 +1197,7 @@ tfw_cfg_handle_children(TfwCfgSpec *cs, TfwCfgEntry *e)
* Check that we have a '}' here.
*/
if (ps->t != TOKEN_RBRACE) {
TFW_ERR("%s: Missing closing brace.\n", cs->name);
TFW_ERR_NL("%s: Missing closing brace.\n", cs->name);
return -EINVAL;
}

Expand Down Expand Up @@ -1307,7 +1308,7 @@ tfw_cfg_set_int(TfwCfgSpec *cs, TfwCfgEntry *e)
return 0;

err:
TFW_ERR("can't parse integer");
TFW_ERR_NL("can't parse integer");
return -EINVAL;
}
EXPORT_SYMBOL(tfw_cfg_set_int);
Expand Down
10 changes: 5 additions & 5 deletions tempesta_fw/classifier/frang.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ frang_register_fsm_resp(void)
{
int r = tfw_gfsm_register_fsm(TFW_FSM_FRANG_RESP, frang_resp_handler);
if (r) {
TFW_ERR("\nfrang: can't register response fsm");
TFW_ERR_NL("\nfrang: can't register response fsm");
return r;
}

Expand All @@ -1140,7 +1140,7 @@ frang_register_fsm_resp(void)
TFW_FSM_FRANG_RESP,
TFW_FRANG_RESP_FSM_INIT);
if (fsm_hook_resp_prio < 0) {
TFW_ERR("\nfrang: can't register gfsm msg fwd hook");
TFW_ERR_NL("\nfrang: can't register gfsm msg fwd hook");
tfw_gfsm_unregister_fsm(TFW_FSM_FRANG_RESP);
return fsm_hook_resp_prio;
}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ frang_init(void)

r = tfw_gfsm_register_fsm(TFW_FSM_FRANG_REQ, frang_http_req_handler);
if (r) {
TFW_ERR("frang: can't register fsm\n");
TFW_ERR_NL("frang: can't register fsm\n");
goto err_fsm;
}

Expand All @@ -1390,7 +1390,7 @@ frang_init(void)
TFW_HTTP_FSM_REQ_MSG, TFW_FSM_FRANG_REQ,
TFW_FRANG_REQ_FSM_INIT);
if (prio0 < 0) {
TFW_ERR("frang: can't register gfsm msg hook\n");
TFW_ERR_NL("frang: can't register gfsm msg hook\n");
r = prio0;
goto err_hook;
}
Expand All @@ -1399,7 +1399,7 @@ frang_init(void)
TFW_HTTP_FSM_REQ_CHUNK, TFW_FSM_FRANG_REQ,
TFW_FRANG_REQ_FSM_INIT);
if (prio1 < 0) {
TFW_ERR("frang: can't register gfsm chunk hook\n");
TFW_ERR_NL("frang: can't register gfsm chunk hook\n");
r = prio1;
goto err_hook2;
}
Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ tfw_filter_start(void)
return -EINVAL;

if ((r = nf_register_hooks(tfw_nf_ops, ARRAY_SIZE(tfw_nf_ops)))) {
TFW_ERR("can't register netfilter hooks\n");
TFW_ERR_NL("can't register netfilter hooks\n");
tdb_close(ip_filter_db);
return r;
}
Expand Down
6 changes: 3 additions & 3 deletions tempesta_fw/gfsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ tfw_gfsm_register_hook(int fsm_id, int prio, int state,
if (!(fsm_hooks_bm[fsm_id][prio] & st_bit))
break;
if (prio == TFW_GFSM_HOOK_PRIORITY_NUM) {
TFW_ERR("All hook slots for FSM %d are acquired\n",
fsm_id);
TFW_ERR_NL("All hook slots for FSM %d are acquired\n",
fsm_id);
return -EBUSY;
}
}
Expand All @@ -306,7 +306,7 @@ tfw_gfsm_register_hook(int fsm_id, int prio, int state,
if (fsm_hooks[fsm_id][shift].fsm_id)
return -EBUSY;
if (!fsm_htbl[fsm_id]) {
TFW_ERR("gfsm: fsm %d is not registered\n", fsm_id);
TFW_ERR_NL("gfsm: fsm %d is not registered\n", fsm_id);
return -ENOENT;
}

Expand Down
6 changes: 3 additions & 3 deletions tempesta_fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,7 @@ tfw_http_set_common_body(int status_code, char *new_length, size_t l_size,
msg = &http_5xx_resp_body;
break;
default:
TFW_ERR("undefined HTTP status group: [%d]\n", status_code);
TFW_ERR_NL("undefined HTTP status group: [%d]\n", status_code);
return -EINVAL;
}

Expand Down Expand Up @@ -3504,7 +3504,7 @@ __tfw_http_msg_body_dup(const char *filename, TfwStr *c_len_hdr, size_t *len,
cl_buf->ptr = buff;
cl_buf->len = tfw_ultoa(b_sz, cl_buf->ptr, TFW_ULTOA_BUF_SIZ);
if (unlikely(!cl_buf->len)) {
TFW_ERR("Can't copy file %s: too big\n", filename);
TFW_ERR_NL("Can't copy file %s: too big\n", filename);
goto err;
}

Expand Down Expand Up @@ -3642,7 +3642,7 @@ tfw_cfgop_resp_body_restore_clen(TfwStr *hdr, int resp_num)
CLEN_STR_INIT(S_504_PART_02);
break;
default:
TFW_WARN("Bug in 'response_body' directive cleanup.");
TFW_WARN("Bug in 'response_body' directive cleanup.\n");
CLEN_STR_INIT(S_DEF_PART_02);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions tempesta_fw/http_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ tfw_http_match_rule_new(TfwHttpMatchList *mlst, size_t arg_len)

rule = tfw_pool_alloc(mlst->pool, size);
if (!rule) {
TFW_ERR("Can't allocate a rule for match list: %p\n", mlst);
TFW_ERR_NL("Can't allocate a rule for match list: %p\n", mlst);
return NULL;
}

Expand All @@ -429,7 +429,7 @@ tfw_http_match_list_alloc(void)

mlst = tfw_pool_new(TfwHttpMatchList, 0);
if (!mlst) {
TFW_ERR("Can't create a memory pool\n");
TFW_ERR_NL("Can't create a memory pool\n");
return NULL;
}

Expand Down
26 changes: 13 additions & 13 deletions tempesta_fw/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ tfw_mods_cfgstart(struct list_head *mod_list)
continue;
TFW_DBG2("mod_cfgstart(): %s\n", mod->name);
if ((ret = mod->cfgstart())) {
TFW_ERR("Unable to prepare for the configuration "
"of module '%s': %d\n", mod->name, ret);
TFW_ERR_NL("Unable to prepare for the configuration "
"of module '%s': %d\n", mod->name, ret);
return ret;
}
}
Expand All @@ -190,8 +190,8 @@ tfw_mods_start(struct list_head *mod_list)
continue;
TFW_DBG2("mod_start(): %s\n", mod->name);
if ((ret = mod->start())) {
TFW_ERR("Unable to start module '%s': %d\n",
mod->name, ret);
TFW_ERR_NL("Unable to start module '%s': %d\n",
mod->name, ret);
return ret;
}
}
Expand All @@ -212,8 +212,8 @@ tfw_mods_cfgend(struct list_head *mod_list)
continue;
TFW_DBG2("mod_cfgend(): %s\n", mod->name);
if ((ret = mod->cfgend())) {
TFW_ERR("Unable to complete the configuration "
"of module '%s': %d\n", mod->name, ret);
TFW_ERR_NL("Unable to complete the configuration "
"of module '%s': %d\n", mod->name, ret);
return ret;
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ tfw_start(struct list_head *mod_list)
WRITE_ONCE(tfw_reconfig, false);
tfw_mods_stop(mod_list);
cleanup:
TFW_WARN("Configuration parsing has failed. Clean up...\n");
TFW_WARN_NL("Configuration parsing has failed. Clean up...\n");
tfw_cleanup(mod_list);
return ret;
}
Expand Down Expand Up @@ -278,7 +278,7 @@ tfw_ctlfn_state_change(const char *old_state, const char *new_state)

if (!strcasecmp("stop", new_state)) {
if (!READ_ONCE(tfw_started)) {
TFW_WARN("Trying to stop an inactive system\n");
TFW_WARN_NL("Trying to stop an inactive system\n");
return -EINVAL;
}

Expand All @@ -288,8 +288,8 @@ tfw_ctlfn_state_change(const char *old_state, const char *new_state)
return 0;
}

TFW_ERR("invalid state: '%s'. Should be either 'start' or 'stop'\n",
new_state);
TFW_ERR_NL("invalid state: '%s'. Should be either 'start' or 'stop'\n",
new_state);

return -EINVAL;
}
Expand Down Expand Up @@ -351,8 +351,8 @@ do { \
TFW_DBG("init: %s\n", #mod); \
r = tfw_##mod##_init(); \
if (r) { \
TFW_ERR("can't initialize Tempesta FW module: '%s' (%d)\n", \
#mod, r); \
TFW_ERR_NL("can't initialize Tempesta FW module: '%s' (%d)\n", \
#mod, r); \
goto err; \
} \
exit_hooks[exit_hooks_n++] = tfw_##mod##_exit; \
Expand Down Expand Up @@ -385,7 +385,7 @@ tfw_init(void)
tfw_sysctl_hdr = register_net_sysctl(&init_net, "net/tempesta",
tfw_sysctl_tbl);
if (!tfw_sysctl_hdr) {
TFW_ERR("can't register sysctl table\n");
TFW_ERR_NL("can't register sysctl table\n");
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/sched/tfw_sched_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ tfw_sched_http_init(void)
tfw_mod_register(&tfw_sched_http_mod);

if ((ret = tfw_sched_register(&tfw_sched_http))) {
TFW_ERR("sched_http: Unable to register the module\n");
TFW_ERR_NL("sched_http: Unable to register the module\n");
tfw_mod_unregister(&tfw_sched_http_mod);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ tfw_sync_socket_init(void)
TfwRBQueue *wq = &per_cpu(si_wq, cpu);

if ((r = tfw_wq_init(wq, cpu_to_node(cpu)))) {
TFW_ERR("Cannot initialize softirq tx work queue\n");
TFW_ERR_NL("Cannot initialize softirq tx work queue\n");
kmem_cache_destroy(ss_cbacklog_cache);
return r;
}
Expand Down
9 changes: 5 additions & 4 deletions tempesta_fw/sock_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ tfw_listen_sock_start(TfwListenSock *ls)

r = ss_sock_create(addr->family, SOCK_STREAM, IPPROTO_TCP, &sk);
if (r) {
TFW_ERR("can't create listening socket (err: %d)\n", r);
TFW_ERR_NL("can't create listening socket (err: %d)\n", r);
return r;
}

Expand Down Expand Up @@ -410,7 +410,8 @@ tfw_listen_sock_start(TfwListenSock *ls)
TFW_DBG("start listening on socket: sk=%p\n", sk);
r = ss_listen(sk, TFW_LISTEN_SOCK_BACKLOG_LEN);
if (r) {
TFW_ERR("can't listen on front-end socket sk=%p (%d)\n", sk, r);
TFW_ERR_NL("can't listen on front-end socket sk=%p (%d)\n",
sk, r);
return r;
}

Expand Down Expand Up @@ -532,8 +533,8 @@ tfw_sock_clnt_cfgend(void)

TFW_DBG("Checking backends and listeners\n");
if ((r = tfw_sg_for_each_srv_reconfig(tfw_sock_check_lst))) {
TFW_ERR("One of the backends is Tempesta itself!"
" Please, fix the configuration.\n");
TFW_ERR_NL("One of the backends is Tempesta itself!"
" Please, fix the configuration.\n");
return r;
}

Expand Down
Loading

0 comments on commit 02a9715

Please sign in to comment.