|
Packit Service |
5956c7 |
/*
|
|
Packit Service |
5956c7 |
* Soft: Keepalived is a failover program for the LVS project
|
|
Packit Service |
5956c7 |
* <www.linuxvirtualserver.org>. It monitor & manipulate
|
|
Packit Service |
5956c7 |
* a loadbalanced server pool using multi-layer checks.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Part: Configuration file parser/reader. Place into the dynamic
|
|
Packit Service |
5956c7 |
* data structure representation the conf file representing
|
|
Packit Service |
5956c7 |
* the loadbalanced server pool.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Author: Alexandre Cassen, <acassen@linux-vs.org>
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
5956c7 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
5956c7 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit Service |
5956c7 |
* See the GNU General Public License for more details.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
5956c7 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
5956c7 |
* as published by the Free Software Foundation; either version
|
|
Packit Service |
5956c7 |
* 2 of the License, or (at your option) any later version.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#include "config.h"
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#include <errno.h>
|
|
Packit Service |
5956c7 |
#include <stdint.h>
|
|
Packit Service |
5956c7 |
#include <arpa/inet.h>
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#include "check_parser.h"
|
|
Packit Service |
5956c7 |
#include "check_data.h"
|
|
Packit Service |
5956c7 |
#include "check_api.h"
|
|
Packit Service |
5956c7 |
#include "global_data.h"
|
|
Packit Service |
5956c7 |
#include "global_parser.h"
|
|
Packit Service |
5956c7 |
#include "main.h"
|
|
Packit Service |
5956c7 |
#include "logger.h"
|
|
Packit Service |
5956c7 |
#include "parser.h"
|
|
Packit Service |
5956c7 |
#include "utils.h"
|
|
Packit Service |
5956c7 |
#include "ipwrapper.h"
|
|
Packit Service |
5956c7 |
#if defined _WITH_VRRP_
|
|
Packit Service |
5956c7 |
#include "vrrp_parser.h"
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#if defined _WITH_BFD_
|
|
Packit Service |
5956c7 |
#include "bfd_parser.h"
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#include "libipvs.h"
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* List of valid schedulers */
|
|
Packit Service |
5956c7 |
char *lvs_schedulers[] =
|
|
Packit Service |
5956c7 |
{"rr", "wrr", "lc", "wlc", "lblc", "sh", "mh", "dh", "fo", "ovf", "lblcr", "sed", "nq", NULL};
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* SSL handlers */
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
ssl_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (!strvec)
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (check_data->ssl) {
|
|
Packit Service |
5956c7 |
free_ssl();
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "SSL context already specified - replacing");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
check_data->ssl = alloc_ssl();
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
sslpass_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (check_data->ssl->password) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "SSL password already specified - replacing");
|
|
Packit Service |
5956c7 |
FREE(check_data->ssl->password);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
check_data->ssl->password = set_value(strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
sslca_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (check_data->ssl->cafile) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "SSL cafile already specified - replacing");
|
|
Packit Service |
5956c7 |
FREE(check_data->ssl->cafile);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
check_data->ssl->cafile = set_value(strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
sslcert_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (check_data->ssl->certfile) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "SSL certfile already specified - replacing");
|
|
Packit Service |
5956c7 |
FREE(check_data->ssl->certfile);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
check_data->ssl->certfile = set_value(strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
sslkey_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (check_data->ssl->keyfile) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "SSL keyfile already specified - replacing");
|
|
Packit Service |
5956c7 |
FREE(check_data->ssl->keyfile);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
check_data->ssl->keyfile = set_value(strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Virtual Servers handlers */
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vsg_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_group_t *vsg;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!strvec)
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Fetch queued vsg */
|
|
Packit Service |
5956c7 |
alloc_vsg(strvec_slot(strvec, 1));
|
|
Packit Service |
5956c7 |
alloc_value_block(alloc_vsg_entry, strvec_slot(strvec, 0));
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Ensure the virtual server group has some configuration */
|
|
Packit Service |
5956c7 |
vsg = LIST_TAIL_DATA(check_data->vs_group);
|
|
Packit Service |
5956c7 |
if (LIST_ISEMPTY(vsg->vfwmark) && LIST_ISEMPTY(vsg->addr_range)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "virtual server group %s has no entries - removing", vsg->gname);
|
|
Packit Service |
5956c7 |
free_list_element(check_data->vs_group, check_data->vs_group->tail);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
global_data->have_checker_config = true;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* If we are not in the checker process, we don't want any more info */
|
|
Packit Service |
5956c7 |
if (!strvec)
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
alloc_vs(strvec_slot(strvec, 1), vector_size(strvec) >= 3 ? strvec_slot(strvec, 2) : NULL);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_end_handler(void)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs;
|
|
Packit Service |
5956c7 |
element e;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* If the real (sorry) server uses tunnel forwarding, the address family
|
|
Packit Service |
5956c7 |
* does not have to match the address family of the virtual server */
|
|
Packit Service |
5956c7 |
if (vs->s_svr
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_IPVS_DEST_ATTR_ADDR_FAMILY
|
|
Packit Service |
5956c7 |
&& vs->s_svr->forwarding_method != IP_VS_CONN_F_TUNNEL
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (vs->af == AF_UNSPEC)
|
|
Packit Service |
5956c7 |
vs->af = vs->s_svr->addr.ss_family;
|
|
Packit Service |
5956c7 |
else if (vs->af != vs->s_svr->addr.ss_family) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Address family of virtual server and sorry server %s don't match - skipping sorry server.", inet_sockaddrtos(&vs->s_svr->addr));
|
|
Packit Service |
5956c7 |
FREE(vs->s_svr);
|
|
Packit Service |
5956c7 |
vs->s_svr = NULL;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vs->af == AF_UNSPEC) {
|
|
Packit Service |
5956c7 |
/* This only occurs if the virtual server uses a fwmark, and all the
|
|
Packit Service |
5956c7 |
* real/sorry servers are tunnelled.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Maintain backward compatibility. Prior to the commit following 17fa4a3c
|
|
Packit Service |
5956c7 |
* the address family of the virtual server was set from any of its
|
|
Packit Service |
5956c7 |
* real or sorry servers, even if they were tunnelled. However, all the real
|
|
Packit Service |
5956c7 |
* and sorry servers had to be the same address family, even if tunnelled,
|
|
Packit Service |
5956c7 |
* so only set the address family from the tunnelled real/sorry servers
|
|
Packit Service |
5956c7 |
* if all the real/sorry servers are of the same address family. */
|
|
Packit Service |
5956c7 |
if (vs->s_svr)
|
|
Packit Service |
5956c7 |
vs->af = vs->s_svr->addr.ss_family;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!LIST_ISEMPTY(vs->rs)) {
|
|
Packit Service |
5956c7 |
for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
|
|
Packit Service |
5956c7 |
rs = ELEMENT_DATA(e);
|
|
Packit Service |
5956c7 |
if (vs->af == AF_UNSPEC)
|
|
Packit Service |
5956c7 |
vs->af = rs->addr.ss_family;
|
|
Packit Service |
5956c7 |
else if (vs->af != rs->addr.ss_family) {
|
|
Packit Service |
5956c7 |
vs->af = AF_UNSPEC;
|
|
Packit Service |
5956c7 |
break;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vs->af == AF_UNSPEC) {
|
|
Packit Service |
5956c7 |
/* We have a mixture of IPv4 and IPv6 tunnelled real/sorry servers.
|
|
Packit Service |
5956c7 |
* Default to IPv4. */
|
|
Packit Service |
5956c7 |
vs->af = AF_INET;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
ip_family_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
uint16_t af;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!strcmp(strvec_slot(strvec, 1), "inet"))
|
|
Packit Service |
5956c7 |
af = AF_INET;
|
|
Packit Service |
5956c7 |
else if (!strcmp(strvec_slot(strvec, 1), "inet6")) {
|
|
Packit Service |
5956c7 |
#ifndef LIBIPVS_USE_NL
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "IPVS with IPv6 is not supported by this build");
|
|
Packit Service |
5956c7 |
skip_block(false);
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
af = AF_INET6;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
else {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "unknown address family %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vs->af != AF_UNSPEC &&
|
|
Packit Service |
5956c7 |
af != vs->af) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Virtual server specified family %s conflicts with server family", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vs->af = af;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_delay_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned long delay;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (read_timer(strvec, 1, &delay, 1, 0, true))
|
|
Packit Service |
5956c7 |
vs->delay_loop = delay;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "virtual server delay loop '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_delay_before_retry_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned long delay;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (read_timer(strvec, 1, &delay, 0, 0, true))
|
|
Packit Service |
5956c7 |
vs->delay_before_retry = delay;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "virtual server delay before retry '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_retry_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned retry;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &retry, 1, UINT32_MAX, false)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "retry value invalid - %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
vs->retry = retry;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_warmup_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned long delay;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (read_timer(strvec, 1, &delay, 0, 0, true))
|
|
Packit Service |
5956c7 |
vs->warmup = delay;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "virtual server warmup '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
lbalgo_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
char *str = strvec_slot(strvec, 1);
|
|
Packit Service |
5956c7 |
int i;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Check valid scheduler name */
|
|
Packit Service |
5956c7 |
for (i = 0; lvs_schedulers[i] && strcmp(str, lvs_schedulers[i]); i++);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!lvs_schedulers[i] || strlen(str) >= sizeof(vs->sched)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid lvs_scheduler '%s' - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
strcpy(vs->sched, str);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
lbflags_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
char *str = strvec_slot(strvec, 0);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "hashed"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_HASHED;
|
|
Packit Service |
5956c7 |
#ifdef IP_VS_SVC_F_ONEPACKET
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "ops"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_ONEPACKET;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#ifdef IP_VS_SVC_F_SCHED1 /* From Linux 3.11 */
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "flag-1"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED1;
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "flag-2"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED2;
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "flag-3"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED3;
|
|
Packit Service |
5956c7 |
else if (!strcmp(vs->sched , "sh") )
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
/* sh-port and sh-fallback flags are relevant for sh scheduler only */
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "sh-port") )
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED_SH_PORT;
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "sh-fallback"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED_SH_FALLBACK;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
else if (!strcmp(vs->sched , "mh") )
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
/* mh-port and mh-fallback flags are relevant for mh scheduler only */
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "mh-port") )
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED_MH_PORT;
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "mh-fallback"))
|
|
Packit Service |
5956c7 |
vs->flags |= IP_VS_SVC_F_SCHED_MH_FALLBACK;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "%s only applies to sh scheduler - ignoring", str);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
forwarding_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
char *str = strvec_slot(strvec, 1);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "NAT"))
|
|
Packit Service |
5956c7 |
vs->forwarding_method = IP_VS_CONN_F_MASQ;
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "DR"))
|
|
Packit Service |
5956c7 |
vs->forwarding_method = IP_VS_CONN_F_DROUTE;
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "TUN"))
|
|
Packit Service |
5956c7 |
vs->forwarding_method = IP_VS_CONN_F_TUNNEL;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "PARSER : unknown [%s] routing method.", str);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
pto_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned timeout;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vector_size(strvec) < 2) {
|
|
Packit Service |
5956c7 |
vs->persistence_timeout = IPVS_SVC_PERSISTENT_TIMEOUT;
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &timeout, 1, UINT32_MAX, false)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "persistence_timeout invalid");
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vs->persistence_timeout = (uint32_t)timeout;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
#ifdef _HAVE_PE_NAME_
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
pengine_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
char *str = strvec_slot(strvec, 1);
|
|
Packit Service |
5956c7 |
size_t size = sizeof (vs->pe_name);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
strncpy(vs->pe_name, str, size - 1);
|
|
Packit Service |
5956c7 |
vs->pe_name[size - 1] = '\0';
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
pgr_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
struct in_addr addr;
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
uint16_t af = vs->af;
|
|
Packit Service |
5956c7 |
unsigned granularity;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (af == AF_UNSPEC)
|
|
Packit Service |
5956c7 |
af = strchr(strvec_slot(strvec, 1), '.') ? AF_INET : AF_INET6;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (af == AF_INET6) {
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &granularity, 1, 128, false)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid IPv6 persistence_granularity specified - %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
vs->persistence_granularity = granularity;
|
|
Packit Service |
5956c7 |
} else {
|
|
Packit Service |
5956c7 |
if (!inet_aton(strvec_slot(strvec, 1), &addr)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid IPv4 persistence_granularity specified - %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Ensure the netmask is solid */
|
|
Packit Service |
5956c7 |
uint32_t haddr = ntohl(addr.s_addr);
|
|
Packit Service |
5956c7 |
while (!(haddr & 1))
|
|
Packit Service |
5956c7 |
haddr = (haddr >> 1) | 0x80000000;
|
|
Packit Service |
5956c7 |
if (haddr != 0xffffffff) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "IPv4 persistence_granularity netmask is not solid - %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vs->persistence_granularity = addr.s_addr;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vs->af == AF_UNSPEC)
|
|
Packit Service |
5956c7 |
vs->af = af;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!vs->persistence_timeout)
|
|
Packit Service |
5956c7 |
vs->persistence_timeout = IPVS_SVC_PERSISTENT_TIMEOUT;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
proto_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
char *str = strvec_slot(strvec, 1);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!strcasecmp(str, "TCP"))
|
|
Packit Service |
5956c7 |
vs->service_type = IPPROTO_TCP;
|
|
Packit Service |
5956c7 |
else if (!strcasecmp(str, "SCTP"))
|
|
Packit Service |
5956c7 |
vs->service_type = IPPROTO_SCTP;
|
|
Packit Service |
5956c7 |
else if (!strcasecmp(str, "UDP"))
|
|
Packit Service |
5956c7 |
vs->service_type = IPPROTO_UDP;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Unknown protocol %s - ignoring", str);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
hasuspend_handler(__attribute__((unused)) vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
vs->ha_suspend = true;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_smtp_alert_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
int res = true;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vector_size(strvec) >= 2) {
|
|
Packit Service |
5956c7 |
res = check_true_false(strvec_slot(strvec, 1));
|
|
Packit Service |
5956c7 |
if (res == -1) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid virtual_server smtp_alert parameter %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
vs->smtp_alert = res;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_virtualhost_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
vs->virtualhost = set_value(strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
svr_forwarding_handler(real_server_t *rs, vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
char *str = strvec_slot(strvec, 1);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!strcmp(str, "NAT"))
|
|
Packit Service |
5956c7 |
rs->forwarding_method = IP_VS_CONN_F_MASQ;
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "DR"))
|
|
Packit Service |
5956c7 |
rs->forwarding_method = IP_VS_CONN_F_DROUTE;
|
|
Packit Service |
5956c7 |
else if (!strcmp(str, "TUN"))
|
|
Packit Service |
5956c7 |
rs->forwarding_method = IP_VS_CONN_F_TUNNEL;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "PARSER : unknown [%s] routing method for real server.", str);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
/* Sorry Servers handlers */
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
ssvr_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
alloc_ssvr(strvec_slot(strvec, 1), strvec_slot(strvec, 2));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
ssvri_handler(__attribute__((unused)) vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
if (vs->s_svr)
|
|
Packit Service |
5956c7 |
vs->s_svr->inhibit = true;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Ignoring sorry_server inhibit used before or without sorry_server");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
ss_forwarding_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vs->s_svr)
|
|
Packit Service |
5956c7 |
svr_forwarding_handler(vs->s_svr, strvec);
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "sorry_server forwarding used without sorry_server");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Real Servers handlers */
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
alloc_rs(strvec_slot(strvec, 1), strvec_slot(strvec, 2));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_end_handler(void)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs;
|
|
Packit Service |
5956c7 |
real_server_t *rs;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (LIST_ISEMPTY(check_data->vs))
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (LIST_ISEMPTY(vs->rs))
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* For tunnelled forwarding, the address families don't have to be the same, so
|
|
Packit Service |
5956c7 |
* long as the kernel supports IPVS_DEST_ATTR_ADDR_FAMILY */
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_IPVS_DEST_ATTR_ADDR_FAMILY
|
|
Packit Service |
5956c7 |
if (rs->forwarding_method != IP_VS_CONN_F_TUNNEL)
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
if (vs->af == AF_UNSPEC)
|
|
Packit Service |
5956c7 |
vs->af = rs->addr.ss_family;
|
|
Packit Service |
5956c7 |
else if (vs->af != rs->addr.ss_family) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Address family of virtual server and real server %s don't match - skipping real server.", inet_sockaddrtos(&rs->addr));
|
|
Packit Service |
5956c7 |
free_list_element(vs->rs, vs->rs->tail);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_weight_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned weight;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &weight, 1, 65535, true)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Real server weight %s is outside range 1-65535", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->weight = weight;
|
|
Packit Service |
5956c7 |
rs->iweight = weight;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_forwarding_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
svr_forwarding_handler(rs, strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
uthreshold_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned threshold;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &threshold, 0, UINT_MAX, true)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid real_server uthreshold '%s' - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->u_threshold = threshold;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
lthreshold_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned threshold;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &threshold, 0, UINT_MAX, true)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid real_server lthreshold '%s' - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->l_threshold = threshold;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_inhibit_handler(__attribute__((unused)) vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
vs->inhibit = true;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static inline notify_script_t*
|
|
Packit Service |
5956c7 |
set_check_notify_script(__attribute__((unused)) vector_t *strvec, const char *type)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
return notify_script_init(0, type);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
notify_up_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
if (rs->notify_up) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "(%s) notify_up script already specified - ignoring %s", vs->vsgname, FMT_STR_VSLOT(strvec,1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->notify_up = set_check_notify_script(strvec, "notify");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
notify_down_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
if (rs->notify_down) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "(%s) notify_down script already specified - ignoring %s", vs->vsgname, FMT_STR_VSLOT(strvec,1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->notify_down = set_check_notify_script(strvec, "notify");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_delay_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned long delay;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (read_timer(strvec, 1, &delay, 1, 0, true))
|
|
Packit Service |
5956c7 |
rs->delay_loop = delay;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "real server delay_loop '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_delay_before_retry_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned long delay;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (read_timer(strvec, 1, &delay, 0, 0, true))
|
|
Packit Service |
5956c7 |
rs->delay_before_retry = delay;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "real server delay_before_retry '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_retry_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned retry;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &retry, 1, UINT32_MAX, false)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "retry value invalid - %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->retry = (unsigned)retry;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_warmup_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
unsigned long delay;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (read_timer(strvec, 1, &delay, 0, 0, true))
|
|
Packit Service |
5956c7 |
rs->warmup = delay;
|
|
Packit Service |
5956c7 |
else
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "real server warmup '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_inhibit_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
int res = true;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vector_size(strvec) >= 2) {
|
|
Packit Service |
5956c7 |
res = check_true_false(strvec_slot(strvec, 1));
|
|
Packit Service |
5956c7 |
if (res == -1) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid inhibit_on_failure parameter %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->inhibit = res;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_alpha_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
int res = true;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vector_size(strvec) >= 2) {
|
|
Packit Service |
5956c7 |
res = check_true_false(strvec_slot(strvec, 1));
|
|
Packit Service |
5956c7 |
if (res == -1) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid alpha parameter %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->alpha = res;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_smtp_alert_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
int res = true;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (vector_size(strvec) >= 2) {
|
|
Packit Service |
5956c7 |
res = check_true_false(strvec_slot(strvec, 1));
|
|
Packit Service |
5956c7 |
if (res == -1) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Invalid real_server smtp_alert parameter %s", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
rs->smtp_alert = res;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
rs_virtualhost_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
|
|
Packit Service |
5956c7 |
rs->virtualhost = set_value(strvec);
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_alpha_handler(__attribute__((unused)) vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
vs->alpha = true;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
omega_handler(__attribute__((unused)) vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
vs->omega = true;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
quorum_up_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
if (vs->notify_quorum_up) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "(%s) quorum_up script already specified - ignoring %s", vs->vsgname, FMT_STR_VSLOT(strvec,1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
vs->notify_quorum_up = set_check_notify_script(strvec, "quorum");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
quorum_down_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
if (vs->notify_quorum_down) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "(%s) quorum_down script already specified - ignoring %s", vs->vsgname, FMT_STR_VSLOT(strvec,1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
vs->notify_quorum_down = set_check_notify_script(strvec, "quorum");
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
quorum_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned quorum;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &quorum, 1, UINT_MAX, true)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Quorum %s must be in [1, %u]. Setting to 1.", FMT_STR_VSLOT(strvec, 1), UINT_MAX);
|
|
Packit Service |
5956c7 |
quorum = 1;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vs->quorum = quorum;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
hysteresis_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned hysteresis;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &hysteresis, 0, UINT_MAX, true)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Hysteresis %s must be in [0, %u] - ignoring", FMT_STR_VSLOT(strvec, 1), UINT_MAX);
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vs->hysteresis = hysteresis;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
static void
|
|
Packit Service |
5956c7 |
vs_weight_handler(vector_t *strvec)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
|
|
Packit Service |
5956c7 |
unsigned weight;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
if (!read_unsigned_strvec(strvec, 1, &weight, 1, 65535, true)) {
|
|
Packit Service |
5956c7 |
report_config_error(CONFIG_GENERAL_ERROR, "Virtual server weight %s is outside range 1-65535", FMT_STR_VSLOT(strvec, 1));
|
|
Packit Service |
5956c7 |
return;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
vs->weight = weight;
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
void
|
|
Packit Service |
5956c7 |
init_check_keywords(bool active)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
/* SSL mapping */
|
|
Packit Service |
5956c7 |
install_keyword_root("SSL", &ssl_handler, active);
|
|
Packit Service |
5956c7 |
install_keyword("password", &sslpass_handler);
|
|
Packit Service |
5956c7 |
install_keyword("ca", &sslca_handler);
|
|
Packit Service |
5956c7 |
install_keyword("certificate", &sslcert_handler);
|
|
Packit Service |
5956c7 |
install_keyword("key", &sslkey_handler);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Virtual server mapping */
|
|
Packit Service |
5956c7 |
install_keyword_root("virtual_server_group", &vsg_handler, active);
|
|
Packit Service |
5956c7 |
install_keyword_root("virtual_server", &vs_handler, active);
|
|
Packit Service |
5956c7 |
install_root_end_handler(&vs_end_handler);
|
|
Packit Service |
5956c7 |
install_keyword("ip_family", &ip_family_handler);
|
|
Packit Service |
5956c7 |
install_keyword("retry", &vs_retry_handler);
|
|
Packit Service |
5956c7 |
install_keyword("delay_before_retry", &vs_delay_before_retry_handler);
|
|
Packit Service |
5956c7 |
install_keyword("warmup", &vs_warmup_handler);
|
|
Packit Service |
5956c7 |
install_keyword("delay_loop", &vs_delay_handler);
|
|
Packit Service |
5956c7 |
install_keyword("inhibit_on_failure", &vs_inhibit_handler);
|
|
Packit Service |
5956c7 |
install_keyword("lb_algo", &lbalgo_handler);
|
|
Packit Service |
5956c7 |
install_keyword("lvs_sched", &lbalgo_handler);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
install_keyword("hashed", &lbflags_handler);
|
|
Packit Service |
5956c7 |
#ifdef IP_VS_SVC_F_ONEPACKET
|
|
Packit Service |
5956c7 |
install_keyword("ops", &lbflags_handler);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#ifdef IP_VS_SVC_F_SCHED1
|
|
Packit Service |
5956c7 |
install_keyword("flag-1", &lbflags_handler);
|
|
Packit Service |
5956c7 |
install_keyword("flag-2", &lbflags_handler);
|
|
Packit Service |
5956c7 |
install_keyword("flag-3", &lbflags_handler);
|
|
Packit Service |
5956c7 |
install_keyword("sh-port", &lbflags_handler);
|
|
Packit Service |
5956c7 |
install_keyword("sh-fallback", &lbflags_handler);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
install_keyword("lb_kind", &forwarding_handler);
|
|
Packit Service |
5956c7 |
install_keyword("lvs_method", &forwarding_handler);
|
|
Packit Service |
5956c7 |
#ifdef _HAVE_PE_NAME_
|
|
Packit Service |
5956c7 |
install_keyword("persistence_engine", &pengine_handler);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
install_keyword("persistence_timeout", &pto_handler);
|
|
Packit Service |
5956c7 |
install_keyword("persistence_granularity", &pgr_handler);
|
|
Packit Service |
5956c7 |
install_keyword("protocol", &proto_handler);
|
|
Packit Service |
5956c7 |
install_keyword("ha_suspend", &hasuspend_handler);
|
|
Packit Service |
5956c7 |
install_keyword("smtp_alert", &vs_smtp_alert_handler);
|
|
Packit Service |
5956c7 |
install_keyword("virtualhost", &vs_virtualhost_handler);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Pool regression detection and handling. */
|
|
Packit Service |
5956c7 |
install_keyword("alpha", &vs_alpha_handler);
|
|
Packit Service |
5956c7 |
install_keyword("omega", &omega_handler);
|
|
Packit Service |
5956c7 |
install_keyword("quorum_up", &quorum_up_handler);
|
|
Packit Service |
5956c7 |
install_keyword("quorum_down", &quorum_down_handler);
|
|
Packit Service |
5956c7 |
install_keyword("quorum", &quorum_handler);
|
|
Packit Service |
5956c7 |
install_keyword("hysteresis", &hysteresis_handler);
|
|
Packit Service |
5956c7 |
install_keyword("weight", &vs_weight_handler);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Real server mapping */
|
|
Packit Service |
5956c7 |
install_keyword("sorry_server", &ssvr_handler);
|
|
Packit Service |
5956c7 |
install_keyword("sorry_server_inhibit", &ssvri_handler);
|
|
Packit Service |
5956c7 |
install_keyword("sorry_server_lvs_method", &ss_forwarding_handler);
|
|
Packit Service |
5956c7 |
install_keyword("real_server", &rs_handler);
|
|
Packit Service |
5956c7 |
install_sublevel();
|
|
Packit Service |
5956c7 |
install_keyword("weight", &rs_weight_handler);
|
|
Packit Service |
5956c7 |
install_keyword("lvs_method", &rs_forwarding_handler);
|
|
Packit Service |
5956c7 |
install_keyword("uthreshold", &uthreshold_handler);
|
|
Packit Service |
5956c7 |
install_keyword("lthreshold", <hreshold_handler);
|
|
Packit Service |
5956c7 |
install_keyword("inhibit_on_failure", &rs_inhibit_handler);
|
|
Packit Service |
5956c7 |
install_keyword("notify_up", ¬ify_up_handler);
|
|
Packit Service |
5956c7 |
install_keyword("notify_down", ¬ify_down_handler);
|
|
Packit Service |
5956c7 |
install_keyword("alpha", &rs_alpha_handler);
|
|
Packit Service |
5956c7 |
install_keyword("retry", &rs_retry_handler);
|
|
Packit Service |
5956c7 |
install_keyword("delay_before_retry", &rs_delay_before_retry_handler);
|
|
Packit Service |
5956c7 |
install_keyword("warmup", &rs_warmup_handler);
|
|
Packit Service |
5956c7 |
install_keyword("delay_loop", &rs_delay_handler);
|
|
Packit Service |
5956c7 |
install_keyword("smtp_alert", &rs_smtp_alert_handler);
|
|
Packit Service |
5956c7 |
install_keyword("virtualhost", &rs_virtualhost_handler);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
install_sublevel_end_handler(&rs_end_handler);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Checkers mapping */
|
|
Packit Service |
5956c7 |
install_checkers_keyword();
|
|
Packit Service |
5956c7 |
install_sublevel_end();
|
|
Packit Service |
5956c7 |
}
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
vector_t *
|
|
Packit Service |
5956c7 |
check_init_keywords(void)
|
|
Packit Service |
5956c7 |
{
|
|
Packit Service |
5956c7 |
/* global definitions mapping */
|
|
Packit Service |
5956c7 |
init_global_keywords(reload);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
init_check_keywords(true);
|
|
Packit Service |
5956c7 |
#ifdef _WITH_VRRP_
|
|
Packit Service |
5956c7 |
init_vrrp_keywords(false);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#ifdef _WITH_BFD_
|
|
Packit Service |
5956c7 |
init_bfd_keywords(true);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
return keywords;
|
|
Packit Service |
5956c7 |
}
|