blob: 98ac2cd106f560b1c38ea7b93e2e120c10ad5855 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Server management functions.
3 *
Willy Tarreau21faa912012-10-10 08:27:36 +02004 * Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01005 * Copyright 2007-2008 Krzysztof Piotr Oledzki <ole@ans.pl>
Willy Tarreaubaaee002006-06-26 02:48:02 +02006 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 */
13
Willy Tarreau272adea2014-03-31 10:39:59 +020014#include <ctype.h>
15
16#include <common/cfgparse.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020017#include <common/config.h>
Willy Tarreaudff55432012-10-10 17:51:05 +020018#include <common/errors.h>
Krzysztof Oledzki85130942007-10-22 16:21:10 +020019#include <common/time.h>
20
Willy Tarreau272adea2014-03-31 10:39:59 +020021#include <types/global.h>
22
23#include <proto/port_range.h>
24#include <proto/protocol.h>
Willy Tarreau4aac7db2014-05-16 11:48:10 +020025#include <proto/queue.h>
Willy Tarreau272adea2014-03-31 10:39:59 +020026#include <proto/raw_sock.h>
Willy Tarreauec6c5df2008-07-15 00:22:45 +020027#include <proto/server.h>
Willy Tarreau4aac7db2014-05-16 11:48:10 +020028#include <proto/session.h>
29#include <proto/task.h>
30
Willy Tarreaubaaee002006-06-26 02:48:02 +020031
Willy Tarreau21faa912012-10-10 08:27:36 +020032/* List head of all known server keywords */
33static struct srv_kw_list srv_keywords = {
34 .list = LIST_HEAD_INIT(srv_keywords.list)
35};
Krzysztof Oledzki85130942007-10-22 16:21:10 +020036
Simon Hormana3608442013-11-01 16:46:15 +090037int srv_downtime(const struct server *s)
Willy Tarreau21faa912012-10-10 08:27:36 +020038{
Willy Tarreau892337c2014-05-13 23:41:20 +020039 if ((s->state != SRV_ST_STOPPED) && s->last_change < now.tv_sec) // ignore negative time
Krzysztof Oledzki85130942007-10-22 16:21:10 +020040 return s->down_time;
41
42 return now.tv_sec - s->last_change + s->down_time;
43}
Willy Tarreaubaaee002006-06-26 02:48:02 +020044
Bhaskar Maddalaa20cb852014-02-03 16:26:46 -050045int srv_lastsession(const struct server *s)
46{
47 if (s->counters.last_sess)
48 return now.tv_sec - s->counters.last_sess;
49
50 return -1;
51}
52
Simon Horman4a741432013-02-23 15:35:38 +090053int srv_getinter(const struct check *check)
Willy Tarreau21faa912012-10-10 08:27:36 +020054{
Simon Horman4a741432013-02-23 15:35:38 +090055 const struct server *s = check->server;
56
Willy Tarreauff5ae352013-12-11 20:36:34 +010057 if ((check->state & CHK_ST_CONFIGURED) && (check->health == check->rise + check->fall - 1))
Simon Horman4a741432013-02-23 15:35:38 +090058 return check->inter;
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +010059
Willy Tarreau892337c2014-05-13 23:41:20 +020060 if ((s->state == SRV_ST_STOPPED) && check->health == 0)
Simon Horman4a741432013-02-23 15:35:38 +090061 return (check->downinter)?(check->downinter):(check->inter);
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +010062
Simon Horman4a741432013-02-23 15:35:38 +090063 return (check->fastinter)?(check->fastinter):(check->inter);
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +010064}
65
Willy Tarreau21faa912012-10-10 08:27:36 +020066/*
67 * Registers the server keyword list <kwl> as a list of valid keywords for next
68 * parsing sessions.
69 */
70void srv_register_keywords(struct srv_kw_list *kwl)
71{
72 LIST_ADDQ(&srv_keywords.list, &kwl->list);
73}
74
75/* Return a pointer to the server keyword <kw>, or NULL if not found. If the
76 * keyword is found with a NULL ->parse() function, then an attempt is made to
77 * find one with a valid ->parse() function. This way it is possible to declare
78 * platform-dependant, known keywords as NULL, then only declare them as valid
79 * if some options are met. Note that if the requested keyword contains an
80 * opening parenthesis, everything from this point is ignored.
81 */
82struct srv_kw *srv_find_kw(const char *kw)
83{
84 int index;
85 const char *kwend;
86 struct srv_kw_list *kwl;
87 struct srv_kw *ret = NULL;
88
89 kwend = strchr(kw, '(');
90 if (!kwend)
91 kwend = kw + strlen(kw);
92
93 list_for_each_entry(kwl, &srv_keywords.list, list) {
94 for (index = 0; kwl->kw[index].kw != NULL; index++) {
95 if ((strncmp(kwl->kw[index].kw, kw, kwend - kw) == 0) &&
96 kwl->kw[index].kw[kwend-kw] == 0) {
97 if (kwl->kw[index].parse)
98 return &kwl->kw[index]; /* found it !*/
99 else
100 ret = &kwl->kw[index]; /* may be OK */
101 }
102 }
103 }
104 return ret;
105}
106
107/* Dumps all registered "server" keywords to the <out> string pointer. The
108 * unsupported keywords are only dumped if their supported form was not
109 * found.
110 */
111void srv_dump_kws(char **out)
112{
113 struct srv_kw_list *kwl;
114 int index;
115
116 *out = NULL;
117 list_for_each_entry(kwl, &srv_keywords.list, list) {
118 for (index = 0; kwl->kw[index].kw != NULL; index++) {
119 if (kwl->kw[index].parse ||
120 srv_find_kw(kwl->kw[index].kw) == &kwl->kw[index]) {
121 memprintf(out, "%s[%4s] %s%s%s%s\n", *out ? *out : "",
122 kwl->scope,
123 kwl->kw[index].kw,
124 kwl->kw[index].skip ? " <arg>" : "",
125 kwl->kw[index].default_ok ? " [dflt_ok]" : "",
126 kwl->kw[index].parse ? "" : " (not supported)");
127 }
128 }
129 }
130}
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +0100131
Willy Tarreaudff55432012-10-10 17:51:05 +0200132/* parse the "id" server keyword */
133static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err)
134{
135 struct eb32_node *node;
136
137 if (!*args[*cur_arg + 1]) {
138 memprintf(err, "'%s' : expects an integer argument", args[*cur_arg]);
139 return ERR_ALERT | ERR_FATAL;
140 }
141
142 newsrv->puid = atol(args[*cur_arg + 1]);
143 newsrv->conf.id.key = newsrv->puid;
144
145 if (newsrv->puid <= 0) {
146 memprintf(err, "'%s' : custom id has to be > 0", args[*cur_arg]);
147 return ERR_ALERT | ERR_FATAL;
148 }
149
150 node = eb32_lookup(&curproxy->conf.used_server_id, newsrv->puid);
151 if (node) {
152 struct server *target = container_of(node, struct server, conf.id);
153 memprintf(err, "'%s' : custom id %d already used at %s:%d ('server %s')",
154 args[*cur_arg], newsrv->puid, target->conf.file, target->conf.line,
155 target->id);
156 return ERR_ALERT | ERR_FATAL;
157 }
158
159 eb32_insert(&curproxy->conf.used_server_id, &newsrv->conf.id);
160 return 0;
161}
162
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200163/* Shutdown all connections of a server. The caller must pass a termination
164 * code in <why>, which must be one of SN_ERR_* indicating the reason for the
165 * shutdown.
166 */
167void srv_shutdown_sessions(struct server *srv, int why)
168{
169 struct session *session, *session_bck;
170
171 list_for_each_entry_safe(session, session_bck, &srv->actconns, by_srv)
172 if (session->srv_conn == srv)
173 session_shutdown(session, why);
174}
175
176/* Shutdown all connections of all backup servers of a proxy. The caller must
177 * pass a termination code in <why>, which must be one of SN_ERR_* indicating
178 * the reason for the shutdown.
179 */
180void srv_shutdown_backup_sessions(struct proxy *px, int why)
181{
182 struct server *srv;
183
184 for (srv = px->srv; srv != NULL; srv = srv->next)
185 if (srv->flags & SRV_F_BACKUP)
186 srv_shutdown_sessions(srv, why);
187}
188
Willy Tarreaubda92272014-05-20 21:55:30 +0200189/* Appends some information to a message string related to a server going UP or
190 * DOWN. If both <forced> and <reason> are null and the server tracks another
191 * one, a "via" information will be provided to know where the status came from.
192 * If <reason> is non-null, the entire string will be appended after a comma and
193 * a space (eg: to report some information from the check that changed the state).
194 * If <xferred> is non-negative, some information about requeued sessions are
195 * provided.
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200196 */
Willy Tarreaubda92272014-05-20 21:55:30 +0200197void srv_append_status(struct chunk *msg, struct server *s, const char *reason, int xferred, int forced)
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200198{
Willy Tarreaubda92272014-05-20 21:55:30 +0200199 if (reason)
200 chunk_appendf(msg, ", %s", reason);
201 else if (!forced && s->track)
202 chunk_appendf(msg, " via %s/%s", s->track->proxy->id, s->track->id);
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200203
204 if (xferred >= 0) {
205 if (s->state == SRV_ST_STOPPED)
206 chunk_appendf(msg, ". %d active and %d backup servers left.%s"
207 " %d sessions active, %d requeued, %d remaining in queue",
208 s->proxy->srv_act, s->proxy->srv_bck,
209 (s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
210 s->cur_sess, xferred, s->nbpend);
211 else
212 chunk_appendf(msg, ". %d active and %d backup servers online.%s"
213 " %d sessions requeued, %d total in queue",
214 s->proxy->srv_act, s->proxy->srv_bck,
215 (s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
216 xferred, s->nbpend);
217 }
218}
219
Willy Tarreaue7d1ef12014-05-20 22:25:12 +0200220/* Marks server <s> down, regardless of its checks' statuses, notifies by all
221 * available means, recounts the remaining servers on the proxy and transfers
222 * queued sessions whenever possible to other servers. It automatically
223 * recomputes the number of servers, but not the map. Maintenance servers are
224 * ignored. It reports <reason> if non-null as the reason for going down. Note
225 * that it makes use of the trash to build the log strings, so <reason> must
226 * not be placed there.
227 */
228void srv_set_stopped(struct server *s, const char *reason)
229{
230 struct server *srv;
231 int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
232 int srv_was_stopping = (s->state == SRV_ST_STOPPING);
233 int xferred;
234
235 if ((s->admin & SRV_ADMF_MAINT) || s->state == SRV_ST_STOPPED)
236 return;
237
238 s->last_change = now.tv_sec;
239 s->state = SRV_ST_STOPPED;
240 if (s->proxy->lbprm.set_server_status_down)
241 s->proxy->lbprm.set_server_status_down(s);
242
243 if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS)
244 srv_shutdown_sessions(s, SN_ERR_DOWN);
245
246 /* we might have sessions queued on this server and waiting for
247 * a connection. Those which are redispatchable will be queued
248 * to another server or to the proxy itself.
249 */
250 xferred = pendconn_redistribute(s);
251
252 chunk_printf(&trash,
253 "%sServer %s/%s is DOWN", s->flags & SRV_F_BACKUP ? "Backup " : "",
254 s->proxy->id, s->id);
255
256 srv_append_status(&trash, s, reason, xferred, 0);
257 Warning("%s.\n", trash.str);
258
259 /* we don't send an alert if the server was previously paused */
260 send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n", trash.str);
261
262 if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
263 set_backend_down(s->proxy);
264
265 s->counters.down_trans++;
266
267 for (srv = s->trackers; srv; srv = srv->tracknext)
268 srv_set_stopped(srv, NULL);
269}
270
Willy Tarreaudbd5e782014-05-20 22:46:35 +0200271/* Marks server <s> up regardless of its checks' statuses and provided it isn't
272 * in maintenance. Notifies by all available means, recounts the remaining
273 * servers on the proxy and tries to grab requests from the proxy. It
274 * automatically recomputes the number of servers, but not the map. Maintenance
275 * servers are ignored. It reports <reason> if non-null as the reason for going
276 * up. Note that it makes use of the trash to build the log strings, so <reason>
277 * must not be placed there.
278 */
279void srv_set_running(struct server *s, const char *reason)
280{
281 struct server *srv;
282 int xferred;
283
284 if (s->admin & SRV_ADMF_MAINT)
285 return;
286
287 if (s->state == SRV_ST_STARTING || s->state == SRV_ST_RUNNING)
288 return;
289
290 if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
291 if (s->proxy->last_change < now.tv_sec) // ignore negative times
292 s->proxy->down_time += now.tv_sec - s->proxy->last_change;
293 s->proxy->last_change = now.tv_sec;
294 }
295
296 if (s->state == SRV_ST_STOPPED && s->last_change < now.tv_sec) // ignore negative times
297 s->down_time += now.tv_sec - s->last_change;
298
299 s->last_change = now.tv_sec;
300
301 s->state = SRV_ST_STARTING;
302 if (s->slowstart > 0)
303 task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20))));
304 else
305 s->state = SRV_ST_RUNNING;
306
307 server_recalc_eweight(s);
308
309 /* If the server is set with "on-marked-up shutdown-backup-sessions",
310 * and it's not a backup server and its effective weight is > 0,
311 * then it can accept new connections, so we shut down all sessions
312 * on all backup servers.
313 */
314 if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
315 !(s->flags & SRV_F_BACKUP) && s->eweight)
316 srv_shutdown_backup_sessions(s->proxy, SN_ERR_UP);
317
318 /* check if we can handle some connections queued at the proxy. We
319 * will take as many as we can handle.
320 */
321 xferred = pendconn_grab_from_px(s);
322
323 chunk_printf(&trash,
324 "%sServer %s/%s is UP", s->flags & SRV_F_BACKUP ? "Backup " : "",
325 s->proxy->id, s->id);
326
327 srv_append_status(&trash, s, reason, xferred, 0);
328 Warning("%s.\n", trash.str);
329 send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
330
331 for (srv = s->trackers; srv; srv = srv->tracknext)
332 srv_set_running(srv, NULL);
333}
334
Willy Tarreau8eb77842014-05-21 13:54:57 +0200335/* Marks server <s> stopping regardless of its checks' statuses and provided it
336 * isn't in maintenance. Notifies by all available means, recounts the remaining
337 * servers on the proxy and tries to grab requests from the proxy. It
338 * automatically recomputes the number of servers, but not the map. Maintenance
339 * servers are ignored. It reports <reason> if non-null as the reason for going
340 * up. Note that it makes use of the trash to build the log strings, so <reason>
341 * must not be placed there.
342 */
343void srv_set_stopping(struct server *s, const char *reason)
344{
345 struct server *srv;
346 int xferred;
347
348 if (s->admin & SRV_ADMF_MAINT)
349 return;
350
351 if (s->state == SRV_ST_STOPPING)
352 return;
353
354 s->last_change = now.tv_sec;
355 s->state = SRV_ST_STOPPING;
356 if (s->proxy->lbprm.set_server_status_down)
357 s->proxy->lbprm.set_server_status_down(s);
358
359 /* we might have sessions queued on this server and waiting for
360 * a connection. Those which are redispatchable will be queued
361 * to another server or to the proxy itself.
362 */
363 xferred = pendconn_redistribute(s);
364
365 chunk_printf(&trash,
366 "%sServer %s/%s is stopping", s->flags & SRV_F_BACKUP ? "Backup " : "",
367 s->proxy->id, s->id);
368
369 srv_append_status(&trash, s, reason, xferred, 0);
370
371 Warning("%s.\n", trash.str);
372 send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
373
374 if (!s->proxy->srv_bck && !s->proxy->srv_act)
375 set_backend_down(s->proxy);
376
377 for (srv = s->trackers; srv; srv = srv->tracknext)
378 srv_set_stopping(srv, NULL);
379}
Willy Tarreaudbd5e782014-05-20 22:46:35 +0200380
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200381/* Puts server <s> into maintenance mode, and propagate that status down to all
382 * tracking servers. This does the same action as the CLI's "disable server x".
383 * A log is emitted for all servers that were not yet in maintenance mode.
384 * Health checks are disabled but not agent checks. The server is marked as
385 * being either forced into maintenance by having <mode> set to SRV_ADMF_FMAINT,
386 * or as inheriting the maintenance status by having <mode> set to
387 * SRV_ADMF_IMAINT. Nothing is done if neither flag is set.
388 */
389void srv_adm_set_maint(struct server *s, enum srv_admin mode)
390{
391 struct check *check = &s->check;
392 struct server *srv;
393 int xferred;
394
395 if (!mode)
396 return;
397
398 /* stop going down as soon as we meet a server already in the same state */
399 if (s->admin & mode)
400 return;
401
402 s->admin |= mode;
403
404 if (s->check.state & CHK_ST_ENABLED) {
405 s->check.state |= CHK_ST_PAUSED;
406 check->health = 0;
407 }
408
409 if (s->state == SRV_ST_STOPPED) { /* server was already down */
410 if (!(s->admin & ~mode & SRV_ADMF_MAINT)) {
411 chunk_printf(&trash,
412 "%sServer %s/%s was DOWN and now enters maintenance",
413 s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id);
414
Willy Tarreaubda92272014-05-20 21:55:30 +0200415 srv_append_status(&trash, s, NULL, -1, (mode & SRV_ADMF_FMAINT));
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200416
417 Warning("%s.\n", trash.str);
418 send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
419 }
420 }
421 else { /* server was still running */
422 int srv_was_stopping = (s->state == SRV_ST_STOPPING);
423 int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
424
425 check->health = 0; /* failure */
426 s->last_change = now.tv_sec;
427 s->state = SRV_ST_STOPPED;
428 if (s->proxy->lbprm.set_server_status_down)
429 s->proxy->lbprm.set_server_status_down(s);
430
431 if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS)
432 srv_shutdown_sessions(s, SN_ERR_DOWN);
433
434 /* we might have sessions queued on this server and waiting for
435 * a connection. Those which are redispatchable will be queued
436 * to another server or to the proxy itself.
437 */
438 xferred = pendconn_redistribute(s);
439
440 chunk_printf(&trash,
441 "%sServer %s/%s is going DOWN for maintenance",
442 s->flags & SRV_F_BACKUP ? "Backup " : "",
443 s->proxy->id, s->id);
444
Willy Tarreaubda92272014-05-20 21:55:30 +0200445 srv_append_status(&trash, s, NULL, xferred, (mode & SRV_ADMF_FMAINT));
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200446
447 Warning("%s.\n", trash.str);
448 send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n", trash.str);
449
450 if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
451 set_backend_down(s->proxy);
452
453 s->counters.down_trans++;
454 }
455
456 for (srv = s->trackers; srv; srv = srv->tracknext)
457 srv_adm_set_maint(srv, SRV_ADMF_IMAINT);
458}
459
460/* Gets server <s> out of maintenance mode, and propagate that status down to
461 * all tracking servers. This does the same action as the CLI's "enable server x".
462 * A log is emitted for all servers that leave maintenance mode. Health checks
463 * are possibly enabled again. The server is marked as leaving forced maintenance
464 * when <mode> is set to SRV_ADMF_FMAINT, or as leaving inherited maintenance
465 * when <mode> set to SRV_ADMF_IMAINT. Nothing is done if neither flag is set.
466 */
467void srv_adm_set_ready(struct server *s, enum srv_admin mode)
468{
469 struct check *check = &s->check;
470 struct server *srv;
471 int xferred = -1;
472
473 if (!mode)
474 return;
475
476 /* stop going down as soon as we see the flag is not there anymore */
477 if (!(s->admin & mode))
478 return;
479
480 s->admin &= ~mode;
481
482 if (s->admin & SRV_ADMF_MAINT) {
483 /* remaining in maintenance mode, let's inform precisely about the
484 * situation.
485 */
486
487 if (s->admin & SRV_ADMF_FMAINT) {
488 chunk_printf(&trash,
489 "%sServer %s/%s remains in forced maintenance",
490 s->flags & SRV_F_BACKUP ? "Backup " : "",
491 s->proxy->id, s->id);
492 }
493 else {
494 chunk_printf(&trash,
495 "%sServer %s/%s is leaving forced maintenance but remains in maintenance",
496 s->flags & SRV_F_BACKUP ? "Backup " : "",
497 s->proxy->id, s->id);
498
499 if (s->track) /* normally it's mandatory here */
500 chunk_appendf(&trash, " via %s/%s",
501 s->track->proxy->id, s->track->id);
502 }
503
504 Warning("%s.\n", trash.str);
505 send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
506 return;
507 }
508
509 /* OK here we're leaving maintenance, we have many things to check,
510 * because the server might possibly be coming back up depending on
511 * its state. In practice, leaving maintenance means that we should
512 * immediately turn to UP (more or less the slowstart) under the
513 * following conditions :
514 * - server is neither checked nor tracked
515 * - server tracks another server which is not checked
516 * - server tracks another server which is already up
517 * Which sums up as something simpler :
518 * "either the server's or the tracked server's checks are disabled or up".
519 * Otherwise we only re-enable health checks.
520 */
521
522 if (s->check.state & CHK_ST_ENABLED) {
523 s->check.state &= ~CHK_ST_PAUSED;
524 check->health = check->rise; /* start OK but check immediately */
525 }
526
Willy Tarreau32091232014-05-16 13:52:00 +0200527 srv = s;
528 while (srv->track)
529 srv = srv->track;
530
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200531 if ((!s->track &&
532 (!(s->agent.state & CHK_ST_ENABLED) || (s->agent.health >= s->agent.rise)) &&
533 (!(s->check.state & CHK_ST_ENABLED) || (s->check.health >= s->check.rise))) ||
534 (s->track &&
Willy Tarreau32091232014-05-16 13:52:00 +0200535 (!(srv->agent.state & CHK_ST_ENABLED) || (srv->agent.health >= srv->agent.rise)) &&
536 (!(srv->check.state & CHK_ST_ENABLED) || (srv->check.health >= srv->check.rise)))) {
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200537
538 if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
539 if (s->proxy->last_change < now.tv_sec) // ignore negative times
540 s->proxy->down_time += now.tv_sec - s->proxy->last_change;
541 s->proxy->last_change = now.tv_sec;
542 }
543
544 if (s->last_change < now.tv_sec) // ignore negative times
545 s->down_time += now.tv_sec - s->last_change;
546 s->last_change = now.tv_sec;
547
548 s->state = SRV_ST_STARTING;
549 if (s->slowstart > 0)
550 task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20))));
551 else
552 s->state = SRV_ST_RUNNING;
553
554 server_recalc_eweight(s);
555
556 /* If the server is set with "on-marked-up shutdown-backup-sessions",
557 * and it's not a backup server and its effective weight is > 0,
558 * then it can accept new connections, so we shut down all sessions
559 * on all backup servers.
560 */
561 if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
562 !(s->flags & SRV_F_BACKUP) && s->eweight)
563 srv_shutdown_backup_sessions(s->proxy, SN_ERR_UP);
564
565 /* check if we can handle some connections queued at the proxy. We
566 * will take as many as we can handle.
567 */
568 xferred = pendconn_grab_from_px(s);
569 }
570
571 if (mode & SRV_ADMF_FMAINT) {
572 chunk_printf(&trash,
573 "%sServer %s/%s is %s (leaving forced maintenance)",
574 s->flags & SRV_F_BACKUP ? "Backup " : "",
575 s->proxy->id, s->id,
576 (s->state == SRV_ST_STOPPED) ? "DOWN" : "UP");
577 }
578 else {
579 chunk_printf(&trash,
580 "%sServer %s/%s is %s (leaving maintenance)",
581 s->flags & SRV_F_BACKUP ? "Backup " : "",
582 s->proxy->id, s->id,
583 (s->state == SRV_ST_STOPPED) ? "DOWN" : "UP");
Willy Tarreaubda92272014-05-20 21:55:30 +0200584 srv_append_status(&trash, s, NULL, xferred, 0);
Willy Tarreaua0066dd2014-05-16 11:25:16 +0200585 }
586
587 Warning("%s.\n", trash.str);
588 send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
589
590 for (srv = s->trackers; srv; srv = srv->tracknext)
591 srv_adm_set_ready(srv, SRV_ADMF_IMAINT);
592}
593
Willy Tarreaudff55432012-10-10 17:51:05 +0200594/* Note: must not be declared <const> as its list will be overwritten.
595 * Please take care of keeping this list alphabetically sorted, doing so helps
596 * all code contributors.
597 * Optional keywords are also declared with a NULL ->parse() function so that
598 * the config parser can report an appropriate error when a known keyword was
599 * not enabled.
600 */
601static struct srv_kw_list srv_kws = { "ALL", { }, {
602 { "id", srv_parse_id, 1, 0 }, /* set id# of server */
603 { NULL, NULL, 0 },
604}};
605
606__attribute__((constructor))
607static void __listener_init(void)
608{
609 srv_register_keywords(&srv_kws);
610}
611
Willy Tarreau004e0452013-11-21 11:22:01 +0100612/* Recomputes the server's eweight based on its state, uweight, the current time,
613 * and the proxy's algorihtm. To be used after updating sv->uweight. The warmup
614 * state is automatically disabled if the time is elapsed.
615 */
616void server_recalc_eweight(struct server *sv)
617{
618 struct proxy *px = sv->proxy;
619 unsigned w;
620
621 if (now.tv_sec < sv->last_change || now.tv_sec >= sv->last_change + sv->slowstart) {
622 /* go to full throttle if the slowstart interval is reached */
Willy Tarreau892337c2014-05-13 23:41:20 +0200623 if (sv->state == SRV_ST_STARTING)
624 sv->state = SRV_ST_RUNNING;
Willy Tarreau004e0452013-11-21 11:22:01 +0100625 }
626
627 /* We must take care of not pushing the server to full throttle during slow starts.
628 * It must also start immediately, at least at the minimal step when leaving maintenance.
629 */
Willy Tarreau892337c2014-05-13 23:41:20 +0200630 if ((sv->state == SRV_ST_STARTING) && (px->lbprm.algo & BE_LB_PROP_DYN))
Willy Tarreau004e0452013-11-21 11:22:01 +0100631 w = (px->lbprm.wdiv * (now.tv_sec - sv->last_change) + sv->slowstart) / sv->slowstart;
632 else
633 w = px->lbprm.wdiv;
634
635 sv->eweight = (sv->uweight * w + px->lbprm.wmult - 1) / px->lbprm.wmult;
636
637 /* now propagate the status change to any LB algorithms */
638 if (px->lbprm.update_server_eweight)
639 px->lbprm.update_server_eweight(sv);
640 else if (sv->eweight) {
641 if (px->lbprm.set_server_status_up)
642 px->lbprm.set_server_status_up(sv);
643 }
644 else {
645 if (px->lbprm.set_server_status_down)
646 px->lbprm.set_server_status_down(sv);
647 }
648}
649
Willy Tarreaubaaee002006-06-26 02:48:02 +0200650/*
Simon Horman7d09b9a2013-02-12 10:45:51 +0900651 * Parses weight_str and configures sv accordingly.
652 * Returns NULL on success, error message string otherwise.
653 */
654const char *server_parse_weight_change_request(struct server *sv,
655 const char *weight_str)
656{
657 struct proxy *px;
Simon Hormanb796afa2013-02-12 10:45:53 +0900658 long int w;
659 char *end;
Simon Horman7d09b9a2013-02-12 10:45:51 +0900660
661 px = sv->proxy;
662
663 /* if the weight is terminated with '%', it is set relative to
664 * the initial weight, otherwise it is absolute.
665 */
666 if (!*weight_str)
667 return "Require <weight> or <weight%>.\n";
668
Simon Hormanb796afa2013-02-12 10:45:53 +0900669 w = strtol(weight_str, &end, 10);
670 if (end == weight_str)
671 return "Empty weight string empty or preceded by garbage";
672 else if (end[0] == '%' && end[1] == '\0') {
Simon Horman58b5d292013-02-12 10:45:52 +0900673 if (w < 0)
Simon Horman7d09b9a2013-02-12 10:45:51 +0900674 return "Relative weight must be positive.\n";
Simon Horman58b5d292013-02-12 10:45:52 +0900675 /* Avoid integer overflow */
676 if (w > 25600)
677 w = 25600;
Simon Horman7d09b9a2013-02-12 10:45:51 +0900678 w = sv->iweight * w / 100;
Simon Horman58b5d292013-02-12 10:45:52 +0900679 if (w > 256)
680 w = 256;
Simon Horman7d09b9a2013-02-12 10:45:51 +0900681 }
682 else if (w < 0 || w > 256)
683 return "Absolute weight can only be between 0 and 256 inclusive.\n";
Simon Hormanb796afa2013-02-12 10:45:53 +0900684 else if (end[0] != '\0')
685 return "Trailing garbage in weight string";
Simon Horman7d09b9a2013-02-12 10:45:51 +0900686
687 if (w && w != sv->iweight && !(px->lbprm.algo & BE_LB_PROP_DYN))
688 return "Backend is using a static LB algorithm and only accepts weights '0%' and '100%'.\n";
689
690 sv->uweight = w;
Willy Tarreau004e0452013-11-21 11:22:01 +0100691 server_recalc_eweight(sv);
Simon Horman7d09b9a2013-02-12 10:45:51 +0900692
693 return NULL;
694}
695
Willy Tarreau272adea2014-03-31 10:39:59 +0200696static int init_check(struct check *check, int type, const char * file, int linenum)
697{
698 check->type = type;
699
700 /* Allocate buffer for requests... */
701 if ((check->bi = calloc(sizeof(struct buffer) + global.tune.chksize, sizeof(char))) == NULL) {
702 Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
703 return ERR_ALERT | ERR_ABORT;
704 }
705 check->bi->size = global.tune.chksize;
706
707 /* Allocate buffer for responses... */
708 if ((check->bo = calloc(sizeof(struct buffer) + global.tune.chksize, sizeof(char))) == NULL) {
709 Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
710 return ERR_ALERT | ERR_ABORT;
711 }
712 check->bo->size = global.tune.chksize;
713
714 /* Allocate buffer for partial results... */
715 if ((check->conn = calloc(1, sizeof(struct connection))) == NULL) {
716 Alert("parsing [%s:%d] : out of memory while allocating check connection.\n", file, linenum);
717 return ERR_ALERT | ERR_ABORT;
718 }
719
720 check->conn->t.sock.fd = -1; /* no agent in progress yet */
721
722 return 0;
723}
724
725int parse_server(const char *file, int linenum, char **args, struct proxy *curproxy, struct proxy *defproxy)
726{
727 struct server *newsrv = NULL;
728 const char *err;
729 char *errmsg = NULL;
730 int err_code = 0;
731 unsigned val;
732
733 if (!strcmp(args[0], "server") || !strcmp(args[0], "default-server")) { /* server address */
734 int cur_arg;
735 short realport = 0;
736 int do_agent = 0, do_check = 0, defsrv = (*args[0] == 'd');
737
738 if (!defsrv && curproxy == defproxy) {
739 Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
740 err_code |= ERR_ALERT | ERR_FATAL;
741 goto out;
742 }
743 else if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
744 err_code |= ERR_ALERT | ERR_FATAL;
745
746 if (!*args[2]) {
747 Alert("parsing [%s:%d] : '%s' expects <name> and <addr>[:<port>] as arguments.\n",
748 file, linenum, args[0]);
749 err_code |= ERR_ALERT | ERR_FATAL;
750 goto out;
751 }
752
753 err = invalid_char(args[1]);
754 if (err && !defsrv) {
755 Alert("parsing [%s:%d] : character '%c' is not permitted in server name '%s'.\n",
756 file, linenum, *err, args[1]);
757 err_code |= ERR_ALERT | ERR_FATAL;
758 goto out;
759 }
760
761 if (!defsrv) {
762 struct sockaddr_storage *sk;
763 int port1, port2;
764 struct protocol *proto;
765
766 if ((newsrv = (struct server *)calloc(1, sizeof(struct server))) == NULL) {
767 Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
768 err_code |= ERR_ALERT | ERR_ABORT;
769 goto out;
770 }
771
772 /* the servers are linked backwards first */
773 newsrv->next = curproxy->srv;
774 curproxy->srv = newsrv;
775 newsrv->proxy = curproxy;
776 newsrv->conf.file = strdup(file);
777 newsrv->conf.line = linenum;
778
779 newsrv->obj_type = OBJ_TYPE_SERVER;
780 LIST_INIT(&newsrv->actconns);
781 LIST_INIT(&newsrv->pendconns);
782 do_check = 0;
783 do_agent = 0;
Willy Tarreauc93cd162014-05-13 15:54:22 +0200784 newsrv->flags = 0;
Willy Tarreau20125212014-05-13 19:44:56 +0200785 newsrv->admin = 0;
Willy Tarreau892337c2014-05-13 23:41:20 +0200786 newsrv->state = SRV_ST_RUNNING; /* early server setup */
Willy Tarreau272adea2014-03-31 10:39:59 +0200787 newsrv->last_change = now.tv_sec;
788 newsrv->id = strdup(args[1]);
789
790 /* several ways to check the port component :
791 * - IP => port=+0, relative (IPv4 only)
792 * - IP: => port=+0, relative
793 * - IP:N => port=N, absolute
794 * - IP:+N => port=+N, relative
795 * - IP:-N => port=-N, relative
796 */
797 sk = str2sa_range(args[2], &port1, &port2, &errmsg, NULL);
798 if (!sk) {
799 Alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg);
800 err_code |= ERR_ALERT | ERR_FATAL;
801 goto out;
802 }
803
804 proto = protocol_by_family(sk->ss_family);
805 if (!proto || !proto->connect) {
806 Alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
807 file, linenum, args[0], args[1]);
808 err_code |= ERR_ALERT | ERR_FATAL;
809 goto out;
810 }
811
812 if (!port1 || !port2) {
813 /* no port specified, +offset, -offset */
Willy Tarreauc93cd162014-05-13 15:54:22 +0200814 newsrv->flags |= SRV_F_MAPPORTS;
Willy Tarreau272adea2014-03-31 10:39:59 +0200815 }
816 else if (port1 != port2) {
817 /* port range */
818 Alert("parsing [%s:%d] : '%s %s' : port ranges are not allowed in '%s'\n",
819 file, linenum, args[0], args[1], args[2]);
820 err_code |= ERR_ALERT | ERR_FATAL;
821 goto out;
822 }
823 else {
824 /* used by checks */
825 realport = port1;
826 }
827
828 newsrv->addr = *sk;
829 newsrv->proto = newsrv->check_common.proto = protocol_by_family(newsrv->addr.ss_family);
830 newsrv->xprt = newsrv->check_common.xprt = &raw_sock;
831
832 if (!newsrv->proto) {
833 Alert("parsing [%s:%d] : Unknown protocol family %d '%s'\n",
834 file, linenum, newsrv->addr.ss_family, args[2]);
835 err_code |= ERR_ALERT | ERR_FATAL;
836 goto out;
837 }
838
839 newsrv->check.use_ssl = curproxy->defsrv.check.use_ssl;
840 newsrv->check.port = curproxy->defsrv.check.port;
841 newsrv->check.inter = curproxy->defsrv.check.inter;
842 newsrv->check.fastinter = curproxy->defsrv.check.fastinter;
843 newsrv->check.downinter = curproxy->defsrv.check.downinter;
844 newsrv->agent.use_ssl = curproxy->defsrv.agent.use_ssl;
845 newsrv->agent.port = curproxy->defsrv.agent.port;
846 newsrv->agent.inter = curproxy->defsrv.agent.inter;
847 newsrv->agent.fastinter = curproxy->defsrv.agent.fastinter;
848 newsrv->agent.downinter = curproxy->defsrv.agent.downinter;
849 newsrv->maxqueue = curproxy->defsrv.maxqueue;
850 newsrv->minconn = curproxy->defsrv.minconn;
851 newsrv->maxconn = curproxy->defsrv.maxconn;
852 newsrv->slowstart = curproxy->defsrv.slowstart;
853 newsrv->onerror = curproxy->defsrv.onerror;
854 newsrv->onmarkeddown = curproxy->defsrv.onmarkeddown;
855 newsrv->onmarkedup = curproxy->defsrv.onmarkedup;
856 newsrv->consecutive_errors_limit
857 = curproxy->defsrv.consecutive_errors_limit;
858#ifdef OPENSSL
859 newsrv->use_ssl = curproxy->defsrv.use_ssl;
860#endif
861 newsrv->uweight = newsrv->iweight
862 = curproxy->defsrv.iweight;
863
864 newsrv->check.status = HCHK_STATUS_INI;
865 newsrv->check.rise = curproxy->defsrv.check.rise;
866 newsrv->check.fall = curproxy->defsrv.check.fall;
867 newsrv->check.health = newsrv->check.rise; /* up, but will fall down at first failure */
868 newsrv->check.server = newsrv;
869
870 newsrv->agent.status = HCHK_STATUS_INI;
871 newsrv->agent.rise = curproxy->defsrv.agent.rise;
872 newsrv->agent.fall = curproxy->defsrv.agent.fall;
873 newsrv->agent.health = newsrv->agent.rise; /* up, but will fall down at first failure */
874 newsrv->agent.server = newsrv;
875
876 cur_arg = 3;
877 } else {
878 newsrv = &curproxy->defsrv;
879 cur_arg = 1;
880 }
881
882 while (*args[cur_arg]) {
883 if (!strcmp(args[cur_arg], "agent-check")) {
884 global.maxsock++;
885 do_agent = 1;
886 cur_arg += 1;
887 } else if (!strcmp(args[cur_arg], "agent-inter")) {
888 const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
889 if (err) {
890 Alert("parsing [%s:%d] : unexpected character '%c' in 'agent-inter' argument of server %s.\n",
891 file, linenum, *err, newsrv->id);
892 err_code |= ERR_ALERT | ERR_FATAL;
893 goto out;
894 }
895 if (val <= 0) {
896 Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
897 file, linenum, val, args[cur_arg], newsrv->id);
898 err_code |= ERR_ALERT | ERR_FATAL;
899 goto out;
900 }
901 newsrv->agent.inter = val;
902 cur_arg += 2;
903 }
904 else if (!strcmp(args[cur_arg], "agent-port")) {
905 global.maxsock++;
906 newsrv->agent.port = atol(args[cur_arg + 1]);
907 cur_arg += 2;
908 }
909 else if (!defsrv && !strcmp(args[cur_arg], "cookie")) {
910 newsrv->cookie = strdup(args[cur_arg + 1]);
911 newsrv->cklen = strlen(args[cur_arg + 1]);
912 cur_arg += 2;
913 }
914 else if (!defsrv && !strcmp(args[cur_arg], "redir")) {
915 newsrv->rdr_pfx = strdup(args[cur_arg + 1]);
916 newsrv->rdr_len = strlen(args[cur_arg + 1]);
917 cur_arg += 2;
918 }
919 else if (!strcmp(args[cur_arg], "rise")) {
920 if (!*args[cur_arg + 1]) {
921 Alert("parsing [%s:%d]: '%s' expects an integer argument.\n",
922 file, linenum, args[cur_arg]);
923 err_code |= ERR_ALERT | ERR_FATAL;
924 goto out;
925 }
926
927 newsrv->check.rise = atol(args[cur_arg + 1]);
928 if (newsrv->check.rise <= 0) {
929 Alert("parsing [%s:%d]: '%s' has to be > 0.\n",
930 file, linenum, args[cur_arg]);
931 err_code |= ERR_ALERT | ERR_FATAL;
932 goto out;
933 }
934
935 if (newsrv->check.health)
936 newsrv->check.health = newsrv->check.rise;
937 cur_arg += 2;
938 }
939 else if (!strcmp(args[cur_arg], "fall")) {
940 newsrv->check.fall = atol(args[cur_arg + 1]);
941
942 if (!*args[cur_arg + 1]) {
943 Alert("parsing [%s:%d]: '%s' expects an integer argument.\n",
944 file, linenum, args[cur_arg]);
945 err_code |= ERR_ALERT | ERR_FATAL;
946 goto out;
947 }
948
949 if (newsrv->check.fall <= 0) {
950 Alert("parsing [%s:%d]: '%s' has to be > 0.\n",
951 file, linenum, args[cur_arg]);
952 err_code |= ERR_ALERT | ERR_FATAL;
953 goto out;
954 }
955
956 cur_arg += 2;
957 }
958 else if (!strcmp(args[cur_arg], "inter")) {
959 const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
960 if (err) {
961 Alert("parsing [%s:%d] : unexpected character '%c' in 'inter' argument of server %s.\n",
962 file, linenum, *err, newsrv->id);
963 err_code |= ERR_ALERT | ERR_FATAL;
964 goto out;
965 }
966 if (val <= 0) {
967 Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
968 file, linenum, val, args[cur_arg], newsrv->id);
969 err_code |= ERR_ALERT | ERR_FATAL;
970 goto out;
971 }
972 newsrv->check.inter = val;
973 cur_arg += 2;
974 }
975 else if (!strcmp(args[cur_arg], "fastinter")) {
976 const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
977 if (err) {
978 Alert("parsing [%s:%d]: unexpected character '%c' in 'fastinter' argument of server %s.\n",
979 file, linenum, *err, newsrv->id);
980 err_code |= ERR_ALERT | ERR_FATAL;
981 goto out;
982 }
983 if (val <= 0) {
984 Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
985 file, linenum, val, args[cur_arg], newsrv->id);
986 err_code |= ERR_ALERT | ERR_FATAL;
987 goto out;
988 }
989 newsrv->check.fastinter = val;
990 cur_arg += 2;
991 }
992 else if (!strcmp(args[cur_arg], "downinter")) {
993 const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
994 if (err) {
995 Alert("parsing [%s:%d]: unexpected character '%c' in 'downinter' argument of server %s.\n",
996 file, linenum, *err, newsrv->id);
997 err_code |= ERR_ALERT | ERR_FATAL;
998 goto out;
999 }
1000 if (val <= 0) {
1001 Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
1002 file, linenum, val, args[cur_arg], newsrv->id);
1003 err_code |= ERR_ALERT | ERR_FATAL;
1004 goto out;
1005 }
1006 newsrv->check.downinter = val;
1007 cur_arg += 2;
1008 }
1009 else if (!defsrv && !strcmp(args[cur_arg], "addr")) {
1010 struct sockaddr_storage *sk;
1011 int port1, port2;
1012 struct protocol *proto;
1013
1014 sk = str2sa_range(args[cur_arg + 1], &port1, &port2, &errmsg, NULL);
1015 if (!sk) {
1016 Alert("parsing [%s:%d] : '%s' : %s\n",
1017 file, linenum, args[cur_arg], errmsg);
1018 err_code |= ERR_ALERT | ERR_FATAL;
1019 goto out;
1020 }
1021
1022 proto = protocol_by_family(sk->ss_family);
1023 if (!proto || !proto->connect) {
1024 Alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
1025 file, linenum, args[cur_arg], args[cur_arg + 1]);
1026 err_code |= ERR_ALERT | ERR_FATAL;
1027 goto out;
1028 }
1029
1030 if (port1 != port2) {
1031 Alert("parsing [%s:%d] : '%s' : port ranges and offsets are not allowed in '%s'\n",
1032 file, linenum, args[cur_arg], args[cur_arg + 1]);
1033 err_code |= ERR_ALERT | ERR_FATAL;
1034 goto out;
1035 }
1036
1037 newsrv->check_common.addr = *sk;
Willy Tarreau640556c2014-05-09 23:38:15 +02001038 newsrv->check_common.proto = protocol_by_family(sk->ss_family);
Willy Tarreau272adea2014-03-31 10:39:59 +02001039 cur_arg += 2;
1040 }
1041 else if (!strcmp(args[cur_arg], "port")) {
1042 newsrv->check.port = atol(args[cur_arg + 1]);
1043 cur_arg += 2;
1044 }
1045 else if (!defsrv && !strcmp(args[cur_arg], "backup")) {
Willy Tarreauc93cd162014-05-13 15:54:22 +02001046 newsrv->flags |= SRV_F_BACKUP;
Willy Tarreau272adea2014-03-31 10:39:59 +02001047 cur_arg ++;
1048 }
1049 else if (!defsrv && !strcmp(args[cur_arg], "non-stick")) {
Willy Tarreauc93cd162014-05-13 15:54:22 +02001050 newsrv->flags |= SRV_F_NON_STICK;
Willy Tarreau272adea2014-03-31 10:39:59 +02001051 cur_arg ++;
1052 }
1053 else if (!defsrv && !strcmp(args[cur_arg], "send-proxy")) {
David Safb76832014-05-08 23:42:08 -04001054 newsrv->pp_opts |= SRV_PP_V1;
Willy Tarreau272adea2014-03-31 10:39:59 +02001055 cur_arg ++;
1056 }
David Safb76832014-05-08 23:42:08 -04001057 else if (!defsrv && !strcmp(args[cur_arg], "send-proxy-v2")) {
1058 newsrv->pp_opts |= SRV_PP_V2;
1059 cur_arg ++;
1060 }
Willy Tarreau272adea2014-03-31 10:39:59 +02001061 else if (!defsrv && !strcmp(args[cur_arg], "check-send-proxy")) {
1062 newsrv->check.send_proxy = 1;
1063 cur_arg ++;
1064 }
1065 else if (!strcmp(args[cur_arg], "weight")) {
1066 int w;
1067 w = atol(args[cur_arg + 1]);
1068 if (w < 0 || w > SRV_UWGHT_MAX) {
1069 Alert("parsing [%s:%d] : weight of server %s is not within 0 and %d (%d).\n",
1070 file, linenum, newsrv->id, SRV_UWGHT_MAX, w);
1071 err_code |= ERR_ALERT | ERR_FATAL;
1072 goto out;
1073 }
1074 newsrv->uweight = newsrv->iweight = w;
1075 cur_arg += 2;
1076 }
1077 else if (!strcmp(args[cur_arg], "minconn")) {
1078 newsrv->minconn = atol(args[cur_arg + 1]);
1079 cur_arg += 2;
1080 }
1081 else if (!strcmp(args[cur_arg], "maxconn")) {
1082 newsrv->maxconn = atol(args[cur_arg + 1]);
1083 cur_arg += 2;
1084 }
1085 else if (!strcmp(args[cur_arg], "maxqueue")) {
1086 newsrv->maxqueue = atol(args[cur_arg + 1]);
1087 cur_arg += 2;
1088 }
1089 else if (!strcmp(args[cur_arg], "slowstart")) {
1090 /* slowstart is stored in seconds */
1091 const char *err = parse_time_err(args[cur_arg + 1], &val, TIME_UNIT_MS);
1092 if (err) {
1093 Alert("parsing [%s:%d] : unexpected character '%c' in 'slowstart' argument of server %s.\n",
1094 file, linenum, *err, newsrv->id);
1095 err_code |= ERR_ALERT | ERR_FATAL;
1096 goto out;
1097 }
1098 newsrv->slowstart = (val + 999) / 1000;
1099 cur_arg += 2;
1100 }
1101 else if (!defsrv && !strcmp(args[cur_arg], "track")) {
1102
1103 if (!*args[cur_arg + 1]) {
1104 Alert("parsing [%s:%d]: 'track' expects [<proxy>/]<server> as argument.\n",
1105 file, linenum);
1106 err_code |= ERR_ALERT | ERR_FATAL;
1107 goto out;
1108 }
1109
1110 newsrv->trackit = strdup(args[cur_arg + 1]);
1111
1112 cur_arg += 2;
1113 }
1114 else if (!defsrv && !strcmp(args[cur_arg], "check")) {
1115 global.maxsock++;
1116 do_check = 1;
1117 cur_arg += 1;
1118 }
1119 else if (!defsrv && !strcmp(args[cur_arg], "disabled")) {
Willy Tarreau20125212014-05-13 19:44:56 +02001120 newsrv->admin |= SRV_ADMF_FMAINT;
Willy Tarreau892337c2014-05-13 23:41:20 +02001121 newsrv->state = SRV_ST_STOPPED;
Willy Tarreau272adea2014-03-31 10:39:59 +02001122 newsrv->check.state |= CHK_ST_PAUSED;
1123 newsrv->check.health = 0;
1124 newsrv->agent.health = 0;
1125 cur_arg += 1;
1126 }
1127 else if (!defsrv && !strcmp(args[cur_arg], "observe")) {
1128 if (!strcmp(args[cur_arg + 1], "none"))
1129 newsrv->observe = HANA_OBS_NONE;
1130 else if (!strcmp(args[cur_arg + 1], "layer4"))
1131 newsrv->observe = HANA_OBS_LAYER4;
1132 else if (!strcmp(args[cur_arg + 1], "layer7")) {
1133 if (curproxy->mode != PR_MODE_HTTP) {
1134 Alert("parsing [%s:%d]: '%s' can only be used in http proxies.\n",
1135 file, linenum, args[cur_arg + 1]);
1136 err_code |= ERR_ALERT;
1137 }
1138 newsrv->observe = HANA_OBS_LAYER7;
1139 }
1140 else {
1141 Alert("parsing [%s:%d]: '%s' expects one of 'none', "
1142 "'layer4', 'layer7' but got '%s'\n",
1143 file, linenum, args[cur_arg], args[cur_arg + 1]);
1144 err_code |= ERR_ALERT | ERR_FATAL;
1145 goto out;
1146 }
1147
1148 cur_arg += 2;
1149 }
1150 else if (!strcmp(args[cur_arg], "on-error")) {
1151 if (!strcmp(args[cur_arg + 1], "fastinter"))
1152 newsrv->onerror = HANA_ONERR_FASTINTER;
1153 else if (!strcmp(args[cur_arg + 1], "fail-check"))
1154 newsrv->onerror = HANA_ONERR_FAILCHK;
1155 else if (!strcmp(args[cur_arg + 1], "sudden-death"))
1156 newsrv->onerror = HANA_ONERR_SUDDTH;
1157 else if (!strcmp(args[cur_arg + 1], "mark-down"))
1158 newsrv->onerror = HANA_ONERR_MARKDWN;
1159 else {
1160 Alert("parsing [%s:%d]: '%s' expects one of 'fastinter', "
1161 "'fail-check', 'sudden-death' or 'mark-down' but got '%s'\n",
1162 file, linenum, args[cur_arg], args[cur_arg + 1]);
1163 err_code |= ERR_ALERT | ERR_FATAL;
1164 goto out;
1165 }
1166
1167 cur_arg += 2;
1168 }
1169 else if (!strcmp(args[cur_arg], "on-marked-down")) {
1170 if (!strcmp(args[cur_arg + 1], "shutdown-sessions"))
1171 newsrv->onmarkeddown = HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS;
1172 else {
1173 Alert("parsing [%s:%d]: '%s' expects 'shutdown-sessions' but got '%s'\n",
1174 file, linenum, args[cur_arg], args[cur_arg + 1]);
1175 err_code |= ERR_ALERT | ERR_FATAL;
1176 goto out;
1177 }
1178
1179 cur_arg += 2;
1180 }
1181 else if (!strcmp(args[cur_arg], "on-marked-up")) {
1182 if (!strcmp(args[cur_arg + 1], "shutdown-backup-sessions"))
1183 newsrv->onmarkedup = HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS;
1184 else {
1185 Alert("parsing [%s:%d]: '%s' expects 'shutdown-backup-sessions' but got '%s'\n",
1186 file, linenum, args[cur_arg], args[cur_arg + 1]);
1187 err_code |= ERR_ALERT | ERR_FATAL;
1188 goto out;
1189 }
1190
1191 cur_arg += 2;
1192 }
1193 else if (!strcmp(args[cur_arg], "error-limit")) {
1194 if (!*args[cur_arg + 1]) {
1195 Alert("parsing [%s:%d]: '%s' expects an integer argument.\n",
1196 file, linenum, args[cur_arg]);
1197 err_code |= ERR_ALERT | ERR_FATAL;
1198 goto out;
1199 }
1200
1201 newsrv->consecutive_errors_limit = atoi(args[cur_arg + 1]);
1202
1203 if (newsrv->consecutive_errors_limit <= 0) {
1204 Alert("parsing [%s:%d]: %s has to be > 0.\n",
1205 file, linenum, args[cur_arg]);
1206 err_code |= ERR_ALERT | ERR_FATAL;
1207 goto out;
1208 }
1209 cur_arg += 2;
1210 }
1211 else if (!defsrv && !strcmp(args[cur_arg], "source")) { /* address to which we bind when connecting */
1212 int port_low, port_high;
1213 struct sockaddr_storage *sk;
1214 struct protocol *proto;
1215
1216 if (!*args[cur_arg + 1]) {
1217 Alert("parsing [%s:%d] : '%s' expects <addr>[:<port>[-<port>]], and optionally '%s' <addr>, and '%s' <name> as argument.\n",
1218 file, linenum, "source", "usesrc", "interface");
1219 err_code |= ERR_ALERT | ERR_FATAL;
1220 goto out;
1221 }
1222
1223 newsrv->conn_src.opts |= CO_SRC_BIND;
1224 sk = str2sa_range(args[cur_arg + 1], &port_low, &port_high, &errmsg, NULL);
1225 if (!sk) {
1226 Alert("parsing [%s:%d] : '%s %s' : %s\n",
1227 file, linenum, args[cur_arg], args[cur_arg+1], errmsg);
1228 err_code |= ERR_ALERT | ERR_FATAL;
1229 goto out;
1230 }
1231
1232 proto = protocol_by_family(sk->ss_family);
1233 if (!proto || !proto->connect) {
1234 Alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
1235 file, linenum, args[cur_arg], args[cur_arg+1]);
1236 err_code |= ERR_ALERT | ERR_FATAL;
1237 goto out;
1238 }
1239
1240 newsrv->conn_src.source_addr = *sk;
1241
1242 if (port_low != port_high) {
1243 int i;
1244
1245 if (!port_low || !port_high) {
1246 Alert("parsing [%s:%d] : %s does not support port offsets (found '%s').\n",
1247 file, linenum, args[cur_arg], args[cur_arg + 1]);
1248 err_code |= ERR_ALERT | ERR_FATAL;
1249 goto out;
1250 }
1251
1252 if (port_low <= 0 || port_low > 65535 ||
1253 port_high <= 0 || port_high > 65535 ||
1254 port_low > port_high) {
1255 Alert("parsing [%s:%d] : invalid source port range %d-%d.\n",
1256 file, linenum, port_low, port_high);
1257 err_code |= ERR_ALERT | ERR_FATAL;
1258 goto out;
1259 }
1260 newsrv->conn_src.sport_range = port_range_alloc_range(port_high - port_low + 1);
1261 for (i = 0; i < newsrv->conn_src.sport_range->size; i++)
1262 newsrv->conn_src.sport_range->ports[i] = port_low + i;
1263 }
1264
1265 cur_arg += 2;
1266 while (*(args[cur_arg])) {
1267 if (!strcmp(args[cur_arg], "usesrc")) { /* address to use outside */
1268#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT)
1269#if !defined(CONFIG_HAP_TRANSPARENT)
Willy Tarreau9cf8d3f2014-05-09 22:56:10 +02001270 if (!is_inet_addr(&newsrv->conn_src.source_addr)) {
Willy Tarreau272adea2014-03-31 10:39:59 +02001271 Alert("parsing [%s:%d] : '%s' requires an explicit '%s' address.\n",
1272 file, linenum, "usesrc", "source");
1273 err_code |= ERR_ALERT | ERR_FATAL;
1274 goto out;
1275 }
1276#endif
1277 if (!*args[cur_arg + 1]) {
1278 Alert("parsing [%s:%d] : '%s' expects <addr>[:<port>], 'client', 'clientip', or 'hdr_ip(name,#)' as argument.\n",
1279 file, linenum, "usesrc");
1280 err_code |= ERR_ALERT | ERR_FATAL;
1281 goto out;
1282 }
1283 if (!strcmp(args[cur_arg + 1], "client")) {
1284 newsrv->conn_src.opts &= ~CO_SRC_TPROXY_MASK;
1285 newsrv->conn_src.opts |= CO_SRC_TPROXY_CLI;
1286 } else if (!strcmp(args[cur_arg + 1], "clientip")) {
1287 newsrv->conn_src.opts &= ~CO_SRC_TPROXY_MASK;
1288 newsrv->conn_src.opts |= CO_SRC_TPROXY_CIP;
1289 } else if (!strncmp(args[cur_arg + 1], "hdr_ip(", 7)) {
1290 char *name, *end;
1291
1292 name = args[cur_arg+1] + 7;
1293 while (isspace(*name))
1294 name++;
1295
1296 end = name;
1297 while (*end && !isspace(*end) && *end != ',' && *end != ')')
1298 end++;
1299
1300 newsrv->conn_src.opts &= ~CO_SRC_TPROXY_MASK;
1301 newsrv->conn_src.opts |= CO_SRC_TPROXY_DYN;
1302 newsrv->conn_src.bind_hdr_name = calloc(1, end - name + 1);
1303 newsrv->conn_src.bind_hdr_len = end - name;
1304 memcpy(newsrv->conn_src.bind_hdr_name, name, end - name);
1305 newsrv->conn_src.bind_hdr_name[end-name] = '\0';
1306 newsrv->conn_src.bind_hdr_occ = -1;
1307
1308 /* now look for an occurrence number */
1309 while (isspace(*end))
1310 end++;
1311 if (*end == ',') {
1312 end++;
1313 name = end;
1314 if (*end == '-')
1315 end++;
1316 while (isdigit((int)*end))
1317 end++;
1318 newsrv->conn_src.bind_hdr_occ = strl2ic(name, end-name);
1319 }
1320
1321 if (newsrv->conn_src.bind_hdr_occ < -MAX_HDR_HISTORY) {
1322 Alert("parsing [%s:%d] : usesrc hdr_ip(name,num) does not support negative"
1323 " occurrences values smaller than %d.\n",
1324 file, linenum, MAX_HDR_HISTORY);
1325 err_code |= ERR_ALERT | ERR_FATAL;
1326 goto out;
1327 }
1328 } else {
1329 struct sockaddr_storage *sk;
1330 int port1, port2;
1331
1332 sk = str2sa_range(args[cur_arg + 1], &port1, &port2, &errmsg, NULL);
1333 if (!sk) {
1334 Alert("parsing [%s:%d] : '%s %s' : %s\n",
1335 file, linenum, args[cur_arg], args[cur_arg+1], errmsg);
1336 err_code |= ERR_ALERT | ERR_FATAL;
1337 goto out;
1338 }
1339
1340 proto = protocol_by_family(sk->ss_family);
1341 if (!proto || !proto->connect) {
1342 Alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
1343 file, linenum, args[cur_arg], args[cur_arg+1]);
1344 err_code |= ERR_ALERT | ERR_FATAL;
1345 goto out;
1346 }
1347
1348 if (port1 != port2) {
1349 Alert("parsing [%s:%d] : '%s' : port ranges and offsets are not allowed in '%s'\n",
1350 file, linenum, args[cur_arg], args[cur_arg + 1]);
1351 err_code |= ERR_ALERT | ERR_FATAL;
1352 goto out;
1353 }
1354 newsrv->conn_src.tproxy_addr = *sk;
1355 newsrv->conn_src.opts |= CO_SRC_TPROXY_ADDR;
1356 }
1357 global.last_checks |= LSTCHK_NETADM;
1358#if !defined(CONFIG_HAP_TRANSPARENT)
1359 global.last_checks |= LSTCHK_CTTPROXY;
1360#endif
1361 cur_arg += 2;
1362 continue;
1363#else /* no TPROXY support */
1364 Alert("parsing [%s:%d] : '%s' not allowed here because support for TPROXY was not compiled in.\n",
1365 file, linenum, "usesrc");
1366 err_code |= ERR_ALERT | ERR_FATAL;
1367 goto out;
1368#endif /* defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT) */
1369 } /* "usesrc" */
1370
1371 if (!strcmp(args[cur_arg], "interface")) { /* specifically bind to this interface */
1372#ifdef SO_BINDTODEVICE
1373 if (!*args[cur_arg + 1]) {
1374 Alert("parsing [%s:%d] : '%s' : missing interface name.\n",
1375 file, linenum, args[0]);
1376 err_code |= ERR_ALERT | ERR_FATAL;
1377 goto out;
1378 }
1379 free(newsrv->conn_src.iface_name);
1380 newsrv->conn_src.iface_name = strdup(args[cur_arg + 1]);
1381 newsrv->conn_src.iface_len = strlen(newsrv->conn_src.iface_name);
1382 global.last_checks |= LSTCHK_NETADM;
1383#else
1384 Alert("parsing [%s:%d] : '%s' : '%s' option not implemented.\n",
1385 file, linenum, args[0], args[cur_arg]);
1386 err_code |= ERR_ALERT | ERR_FATAL;
1387 goto out;
1388#endif
1389 cur_arg += 2;
1390 continue;
1391 }
1392 /* this keyword in not an option of "source" */
1393 break;
1394 } /* while */
1395 }
1396 else if (!defsrv && !strcmp(args[cur_arg], "usesrc")) { /* address to use outside: needs "source" first */
1397 Alert("parsing [%s:%d] : '%s' only allowed after a '%s' statement.\n",
1398 file, linenum, "usesrc", "source");
1399 err_code |= ERR_ALERT | ERR_FATAL;
1400 goto out;
1401 }
1402 else {
1403 static int srv_dumped;
1404 struct srv_kw *kw;
1405 char *err;
1406
1407 kw = srv_find_kw(args[cur_arg]);
1408 if (kw) {
1409 char *err = NULL;
1410 int code;
1411
1412 if (!kw->parse) {
1413 Alert("parsing [%s:%d] : '%s %s' : '%s' option is not implemented in this version (check build options).\n",
1414 file, linenum, args[0], args[1], args[cur_arg]);
1415 cur_arg += 1 + kw->skip ;
1416 err_code |= ERR_ALERT | ERR_FATAL;
1417 goto out;
1418 }
1419
1420 if (defsrv && !kw->default_ok) {
1421 Alert("parsing [%s:%d] : '%s %s' : '%s' option is not accepted in default-server sections.\n",
1422 file, linenum, args[0], args[1], args[cur_arg]);
1423 cur_arg += 1 + kw->skip ;
1424 err_code |= ERR_ALERT;
1425 continue;
1426 }
1427
1428 code = kw->parse(args, &cur_arg, curproxy, newsrv, &err);
1429 err_code |= code;
1430
1431 if (code) {
1432 if (err && *err) {
1433 indent_msg(&err, 2);
1434 Alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], err);
1435 }
1436 else
1437 Alert("parsing [%s:%d] : '%s %s' : error encountered while processing '%s'.\n",
1438 file, linenum, args[0], args[1], args[cur_arg]);
1439 if (code & ERR_FATAL) {
1440 free(err);
1441 cur_arg += 1 + kw->skip;
1442 goto out;
1443 }
1444 }
1445 free(err);
1446 cur_arg += 1 + kw->skip;
1447 continue;
1448 }
1449
1450 err = NULL;
1451 if (!srv_dumped) {
1452 srv_dump_kws(&err);
1453 indent_msg(&err, 4);
1454 srv_dumped = 1;
1455 }
1456
1457 Alert("parsing [%s:%d] : '%s %s' unknown keyword '%s'.%s%s\n",
1458 file, linenum, args[0], args[1], args[cur_arg],
1459 err ? " Registered keywords :" : "", err ? err : "");
1460 free(err);
1461
1462 err_code |= ERR_ALERT | ERR_FATAL;
1463 goto out;
1464 }
1465 }
1466
Willy Tarreau272adea2014-03-31 10:39:59 +02001467 if (do_check) {
1468 int ret;
1469
1470 if (newsrv->trackit) {
1471 Alert("parsing [%s:%d]: unable to enable checks and tracking at the same time!\n",
1472 file, linenum);
1473 err_code |= ERR_ALERT | ERR_FATAL;
1474 goto out;
1475 }
1476
1477 /* If neither a port nor an addr was specified and no check transport
1478 * layer is forced, then the transport layer used by the checks is the
1479 * same as for the production traffic. Otherwise we use raw_sock by
1480 * default, unless one is specified.
1481 */
1482 if (!newsrv->check.port && !is_addr(&newsrv->check_common.addr)) {
1483#ifdef USE_OPENSSL
1484 newsrv->check.use_ssl |= (newsrv->use_ssl || (newsrv->proxy->options & PR_O_TCPCHK_SSL));
1485#endif
David Safb76832014-05-08 23:42:08 -04001486 newsrv->check.send_proxy |= (newsrv->pp_opts);
Willy Tarreau272adea2014-03-31 10:39:59 +02001487 }
1488 /* try to get the port from check_core.addr if check.port not set */
1489 if (!newsrv->check.port)
1490 newsrv->check.port = get_host_port(&newsrv->check_common.addr);
1491
1492 if (!newsrv->check.port)
1493 newsrv->check.port = realport; /* by default */
1494
1495 if (!newsrv->check.port) {
1496 /* not yet valid, because no port was set on
1497 * the server either. We'll check if we have
1498 * a known port on the first listener.
1499 */
1500 struct listener *l;
1501
1502 list_for_each_entry(l, &curproxy->conf.listeners, by_fe) {
1503 newsrv->check.port = get_host_port(&l->addr);
1504 if (newsrv->check.port)
1505 break;
1506 }
1507 }
1508 /*
1509 * We need at least a service port, a check port or the first tcp-check rule must
Willy Tarreau5cf0b522014-05-09 23:59:19 +02001510 * be a 'connect' one when checking an IPv4/IPv6 server.
Willy Tarreau272adea2014-03-31 10:39:59 +02001511 */
Willy Tarreau5cf0b522014-05-09 23:59:19 +02001512 if (!newsrv->check.port &&
1513 (is_inet_addr(&newsrv->check_common.addr) ||
1514 (!is_addr(&newsrv->check_common.addr) && is_inet_addr(&newsrv->addr)))) {
Willy Tarreau272adea2014-03-31 10:39:59 +02001515 struct tcpcheck_rule *n = NULL, *r = NULL;
1516 struct list *l;
1517
1518 r = (struct tcpcheck_rule *)newsrv->proxy->tcpcheck_rules.n;
1519 if (!r) {
1520 Alert("parsing [%s:%d] : server %s has neither service port nor check port. Check has been disabled.\n",
1521 file, linenum, newsrv->id);
1522 err_code |= ERR_ALERT | ERR_FATAL;
1523 goto out;
1524 }
1525 if ((r->action != TCPCHK_ACT_CONNECT) || !r->port) {
1526 Alert("parsing [%s:%d] : server %s has neither service port nor check port nor tcp_check rule 'connect' with port information. Check has been disabled.\n",
1527 file, linenum, newsrv->id);
1528 err_code |= ERR_ALERT | ERR_FATAL;
1529 goto out;
1530 }
1531 else {
1532 /* scan the tcp-check ruleset to ensure a port has been configured */
1533 l = &newsrv->proxy->tcpcheck_rules;
1534 list_for_each_entry(n, l, list) {
1535 r = (struct tcpcheck_rule *)n->list.p;
1536 if ((r->action == TCPCHK_ACT_CONNECT) && (!r->port)) {
1537 Alert("parsing [%s:%d] : server %s has neither service port nor check port, and a tcp_check rule 'connect' with no port information. Check has been disabled.\n",
1538 file, linenum, newsrv->id);
1539 err_code |= ERR_ALERT | ERR_FATAL;
1540 goto out;
1541 }
1542 }
1543 }
1544 }
1545
1546 /* note: check type will be set during the config review phase */
1547 ret = init_check(&newsrv->check, 0, file, linenum);
1548 if (ret) {
1549 err_code |= ret;
1550 goto out;
1551 }
1552
1553 newsrv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
1554 }
1555
1556 if (do_agent) {
1557 int ret;
1558
1559 if (!newsrv->agent.port) {
1560 Alert("parsing [%s:%d] : server %s does not have agent port. Agent check has been disabled.\n",
1561 file, linenum, newsrv->id);
1562 err_code |= ERR_ALERT | ERR_FATAL;
1563 goto out;
1564 }
1565
1566 if (!newsrv->agent.inter)
1567 newsrv->agent.inter = newsrv->check.inter;
1568
1569 ret = init_check(&newsrv->agent, PR_O2_LB_AGENT_CHK, file, linenum);
1570 if (ret) {
1571 err_code |= ret;
1572 goto out;
1573 }
1574
1575 newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_AGENT;
1576 }
1577
1578 if (!defsrv) {
Willy Tarreauc93cd162014-05-13 15:54:22 +02001579 if (newsrv->flags & SRV_F_BACKUP)
Willy Tarreau272adea2014-03-31 10:39:59 +02001580 curproxy->srv_bck++;
1581 else
1582 curproxy->srv_act++;
1583
Willy Tarreauc5150da2014-05-13 19:27:31 +02001584 srv_lb_commit_status(newsrv);
Willy Tarreau272adea2014-03-31 10:39:59 +02001585 }
1586 }
1587 return 0;
1588
1589 out:
1590 free(errmsg);
1591 return err_code;
1592}
1593
Simon Horman7d09b9a2013-02-12 10:45:51 +09001594/*
Willy Tarreaubaaee002006-06-26 02:48:02 +02001595 * Local variables:
1596 * c-indent-level: 8
1597 * c-basic-offset: 8
1598 * End:
1599 */