|
Packit |
c22fc9 |
/*
|
|
Packit |
c22fc9 |
* Soft: Keepalived is a failover program for the LVS project
|
|
Packit |
c22fc9 |
* <www.linuxvirtualserver.org>. It monitor & manipulate
|
|
Packit |
c22fc9 |
* a loadbalanced server pool using multi-layer checks.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Part: Dynamic data structure definition.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Author: Alexandre Cassen, <acassen@linux-vs.org>
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
c22fc9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
c22fc9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
c22fc9 |
* See the GNU General Public License for more details.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* This program is free software; you can redistribute it and/or
|
|
Packit |
c22fc9 |
* modify it under the terms of the GNU General Public License
|
|
Packit |
c22fc9 |
* as published by the Free Software Foundation; either version
|
|
Packit |
c22fc9 |
* 2 of the License, or (at your option) any later version.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>
|
|
Packit |
c22fc9 |
*/
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifndef _GLOBAL_DATA_H
|
|
Packit |
c22fc9 |
#define _GLOBAL_DATA_H
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#include "config.h"
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* system includes */
|
|
Packit |
c22fc9 |
#include <stdbool.h>
|
|
Packit |
c22fc9 |
#include <stdio.h>
|
|
Packit |
c22fc9 |
#include <sys/socket.h>
|
|
Packit Service |
dfccb1 |
#include <sched.h>
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifdef HAVE_LINUX_NETFILTER_X_TABLES_H
|
|
Packit |
c22fc9 |
#include <linux/netfilter/x_tables.h>
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifdef _HAVE_LIBIPSET_
|
|
Packit |
c22fc9 |
#include <linux/netfilter/ipset/ip_set.h>
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_NFTABLES_
|
|
Packit Service |
dfccb1 |
#include <linux/netfilter/nf_tables.h>
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
|
|
Packit |
c22fc9 |
#if HAVE_DECL_RLIMIT_RTTIME == 1
|
|
Packit |
c22fc9 |
#include <sys/resource.h>
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* local includes */
|
|
Packit Service |
dfccb1 |
#include "list_head.h"
|
|
Packit |
c22fc9 |
#include "vrrp_if.h"
|
|
Packit |
c22fc9 |
#include "timer.h"
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
#include "vrrp.h"
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
#include "ipvswrapper.h"
|
|
Packit Service |
dfccb1 |
#include "libipvs.h"
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#include "notify.h"
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* constants */
|
|
Packit |
c22fc9 |
#define DEFAULT_SMTP_CONNECTION_TIMEOUT (30 * TIMER_HZ)
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
#define RX_BUFS_POLICY_MTU 0x01
|
|
Packit |
c22fc9 |
#define RX_BUFS_POLICY_ADVERT 0x02
|
|
Packit |
c22fc9 |
#define RX_BUFS_SIZE 0x04
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_LVS_
|
|
Packit Service |
dfccb1 |
#define LVS_MAX_TIMEOUT (86400*31) /* 31 days */
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
|
|
Packit |
c22fc9 |
/* email link list */
|
|
Packit |
c22fc9 |
typedef struct _email {
|
|
Packit |
c22fc9 |
char *addr;
|
|
Packit Service |
dfccb1 |
|
|
Packit Service |
dfccb1 |
/* Linked list member */
|
|
Packit Service |
dfccb1 |
list_head_t e_list;
|
|
Packit |
c22fc9 |
} email_t;
|
|
Packit |
c22fc9 |
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_LVS_
|
|
Packit Service |
dfccb1 |
typedef enum {
|
|
Packit Service |
dfccb1 |
LVS_NO_FLUSH,
|
|
Packit Service |
dfccb1 |
LVS_FLUSH_FULL,
|
|
Packit Service |
dfccb1 |
LVS_FLUSH_VS
|
|
Packit Service |
dfccb1 |
} lvs_flush_t;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
|
|
Packit |
c22fc9 |
/* Configuration data root */
|
|
Packit |
c22fc9 |
typedef struct _data {
|
|
Packit Service |
dfccb1 |
const char *process_name;
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_VRRP_
|
|
Packit Service |
dfccb1 |
const char *vrrp_process_name;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_LVS_
|
|
Packit Service |
dfccb1 |
const char *lvs_process_name;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_BFD_
|
|
Packit Service |
dfccb1 |
const char *bfd_process_name;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_CLONE_NEWNET
|
|
Packit Service |
dfccb1 |
const char *network_namespace; /* network namespace name */
|
|
Packit Service |
dfccb1 |
const char *network_namespace_ipvs; /* network namespace name for ipvs */
|
|
Packit Service |
dfccb1 |
bool namespace_with_ipsets; /* override for namespaces with ipsets on Linux < 3.13 */
|
|
Packit |
c22fc9 |
#endif
|
|
Packit Service |
dfccb1 |
const char *local_name;
|
|
Packit Service |
dfccb1 |
const char *instance_name; /* keepalived instance name */
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_LINKBEAT_
|
|
Packit |
c22fc9 |
bool linkbeat_use_polling;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
const char *router_id;
|
|
Packit Service |
dfccb1 |
const char *email_from;
|
|
Packit |
c22fc9 |
struct sockaddr_storage smtp_server;
|
|
Packit Service |
dfccb1 |
const char *smtp_helo_name;
|
|
Packit |
c22fc9 |
unsigned long smtp_connection_to;
|
|
Packit Service |
dfccb1 |
list_head_t email;
|
|
Packit |
c22fc9 |
int smtp_alert;
|
|
Packit Service |
dfccb1 |
notify_script_t *startup_script;
|
|
Packit Service |
dfccb1 |
unsigned startup_script_timeout;
|
|
Packit Service |
dfccb1 |
notify_script_t *shutdown_script;
|
|
Packit Service |
dfccb1 |
unsigned shutdown_script_timeout;
|
|
Packit Service |
dfccb1 |
#ifndef _ONE_PROCESS_DEBUG_
|
|
Packit Service |
dfccb1 |
const char *reload_time_file;
|
|
Packit Service |
dfccb1 |
bool reload_repeat;
|
|
Packit Service |
dfccb1 |
time_t reload_time;
|
|
Packit Service |
dfccb1 |
bool reload_date_specified;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
bool dynamic_interfaces;
|
|
Packit |
c22fc9 |
bool allow_if_changes;
|
|
Packit |
c22fc9 |
bool no_email_faults;
|
|
Packit |
c22fc9 |
int smtp_alert_vrrp;
|
|
Packit Service |
dfccb1 |
const char *default_ifname; /* Name of default interface */
|
|
Packit |
c22fc9 |
interface_t *default_ifp; /* Default interface for static addresses */
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit Service |
dfccb1 |
ipvs_timeout_t lvs_timeouts;
|
|
Packit |
c22fc9 |
int smtp_alert_checker;
|
|
Packit Service |
dfccb1 |
bool checker_log_all_failures;
|
|
Packit |
c22fc9 |
struct lvs_syncd_config lvs_syncd;
|
|
Packit |
c22fc9 |
bool lvs_flush; /* flush any residual LVS config at startup */
|
|
Packit Service |
dfccb1 |
lvs_flush_t lvs_flush_onstop; /* flush any LVS config at shutdown */
|
|
Packit |
c22fc9 |
#endif
|
|
Packit Service |
dfccb1 |
int max_auto_priority;
|
|
Packit Service |
dfccb1 |
long min_auto_priority_delay;
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
struct sockaddr_in vrrp_mcast_group4;
|
|
Packit |
c22fc9 |
struct sockaddr_in6 vrrp_mcast_group6;
|
|
Packit |
c22fc9 |
unsigned vrrp_garp_delay;
|
|
Packit |
c22fc9 |
timeval_t vrrp_garp_refresh;
|
|
Packit |
c22fc9 |
unsigned vrrp_garp_rep;
|
|
Packit |
c22fc9 |
unsigned vrrp_garp_refresh_rep;
|
|
Packit |
c22fc9 |
unsigned vrrp_garp_lower_prio_delay;
|
|
Packit |
c22fc9 |
unsigned vrrp_garp_lower_prio_rep;
|
|
Packit |
c22fc9 |
unsigned vrrp_garp_interval;
|
|
Packit |
c22fc9 |
unsigned vrrp_gna_interval;
|
|
Packit |
c22fc9 |
bool vrrp_lower_prio_no_advert;
|
|
Packit |
c22fc9 |
bool vrrp_higher_prio_send_advert;
|
|
Packit Service |
dfccb1 |
int vrrp_version; /* VRRP version (2 or 3) */
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_IPTABLES_
|
|
Packit Service |
dfccb1 |
const char *vrrp_iptables_inchain;
|
|
Packit Service |
dfccb1 |
const char *vrrp_iptables_outchain;
|
|
Packit |
c22fc9 |
#ifdef _HAVE_LIBIPSET_
|
|
Packit Service |
dfccb1 |
unsigned using_ipsets;
|
|
Packit Service |
dfccb1 |
const char *vrrp_ipset_address;
|
|
Packit Service |
dfccb1 |
const char *vrrp_ipset_address6;
|
|
Packit Service |
dfccb1 |
const char *vrrp_ipset_address_iface6;
|
|
Packit Service |
dfccb1 |
#ifdef HAVE_IPSET_ATTR_IFACE
|
|
Packit Service |
dfccb1 |
const char *vrrp_ipset_igmp;
|
|
Packit Service |
dfccb1 |
const char *vrrp_ipset_mld;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_NFTABLES_
|
|
Packit Service |
dfccb1 |
const char *vrrp_nf_table_name;
|
|
Packit Service |
dfccb1 |
int vrrp_nf_chain_priority;
|
|
Packit Service |
dfccb1 |
bool vrrp_nf_counters;
|
|
Packit Service |
dfccb1 |
bool vrrp_nf_ifindex;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
bool vrrp_check_unicast_src;
|
|
Packit |
c22fc9 |
bool vrrp_skip_check_adv_addr;
|
|
Packit |
c22fc9 |
bool vrrp_strict;
|
|
Packit |
c22fc9 |
bool have_vrrp_config;
|
|
Packit |
c22fc9 |
char vrrp_process_priority;
|
|
Packit |
c22fc9 |
bool vrrp_no_swap;
|
|
Packit |
c22fc9 |
unsigned vrrp_realtime_priority;
|
|
Packit Service |
dfccb1 |
cpu_set_t vrrp_cpu_mask;
|
|
Packit |
c22fc9 |
#if HAVE_DECL_RLIMIT_RTTIME == 1
|
|
Packit |
c22fc9 |
rlim_t vrrp_rlimit_rt;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
bool have_checker_config;
|
|
Packit |
c22fc9 |
char checker_process_priority;
|
|
Packit |
c22fc9 |
bool checker_no_swap;
|
|
Packit |
c22fc9 |
unsigned checker_realtime_priority;
|
|
Packit Service |
dfccb1 |
cpu_set_t checker_cpu_mask;
|
|
Packit |
c22fc9 |
#if HAVE_DECL_RLIMIT_RTTIME == 1
|
|
Packit |
c22fc9 |
rlim_t checker_rlimit_rt;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_BFD_
|
|
Packit |
c22fc9 |
bool have_bfd_config;
|
|
Packit |
c22fc9 |
char bfd_process_priority;
|
|
Packit |
c22fc9 |
bool bfd_no_swap;
|
|
Packit |
c22fc9 |
unsigned bfd_realtime_priority;
|
|
Packit Service |
dfccb1 |
cpu_set_t bfd_cpu_mask;
|
|
Packit |
c22fc9 |
#if HAVE_DECL_RLIMIT_RTTIME == 1
|
|
Packit |
c22fc9 |
rlim_t bfd_rlimit_rt;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
notify_fifo_t notify_fifo;
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
notify_fifo_t vrrp_notify_fifo;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
notify_fifo_t lvs_notify_fifo;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_VRRP_
|
|
Packit Service |
dfccb1 |
int vrrp_notify_priority_changes;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_SNMP_
|
|
Packit |
c22fc9 |
bool enable_traps;
|
|
Packit Service |
dfccb1 |
const char *snmp_socket;
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
#ifdef _WITH_SNMP_VRRP_
|
|
Packit |
c22fc9 |
bool enable_snmp_vrrp;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_SNMP_RFCV2_
|
|
Packit |
c22fc9 |
bool enable_snmp_rfcv2;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_SNMP_RFCV3_
|
|
Packit |
c22fc9 |
bool enable_snmp_rfcv3;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
bool enable_snmp_checker;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_DBUS_
|
|
Packit |
c22fc9 |
bool enable_dbus;
|
|
Packit Service |
dfccb1 |
const char *dbus_service_name;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
unsigned vrrp_netlink_cmd_rcv_bufs;
|
|
Packit |
c22fc9 |
bool vrrp_netlink_cmd_rcv_bufs_force;
|
|
Packit |
c22fc9 |
unsigned vrrp_netlink_monitor_rcv_bufs;
|
|
Packit |
c22fc9 |
bool vrrp_netlink_monitor_rcv_bufs_force;
|
|
Packit Service |
dfccb1 |
#ifdef _WITH_CN_PROC_
|
|
Packit Service |
dfccb1 |
unsigned process_monitor_rcv_bufs;
|
|
Packit Service |
dfccb1 |
bool process_monitor_rcv_bufs_force;
|
|
Packit Service |
dfccb1 |
#endif
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
unsigned lvs_netlink_cmd_rcv_bufs;
|
|
Packit |
c22fc9 |
bool lvs_netlink_cmd_rcv_bufs_force;
|
|
Packit |
c22fc9 |
unsigned lvs_netlink_monitor_rcv_bufs;
|
|
Packit |
c22fc9 |
bool lvs_netlink_monitor_rcv_bufs_force;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_LVS_
|
|
Packit |
c22fc9 |
bool rs_init_notifies;
|
|
Packit |
c22fc9 |
bool no_checker_emails;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#ifdef _WITH_VRRP_
|
|
Packit |
c22fc9 |
int vrrp_rx_bufs_policy;
|
|
Packit |
c22fc9 |
size_t vrrp_rx_bufs_size;
|
|
Packit |
c22fc9 |
int vrrp_rx_bufs_multiples;
|
|
Packit Service |
dfccb1 |
unsigned vrrp_startup_delay;
|
|
Packit Service |
dfccb1 |
bool log_unknown_vrids;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
} data_t;
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* Global vars exported */
|
|
Packit |
c22fc9 |
extern data_t *global_data; /* Global configuration data */
|
|
Packit |
c22fc9 |
extern data_t *old_global_data; /* Old global configuration data - used during reload */
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* Prototypes */
|
|
Packit Service |
dfccb1 |
extern void alloc_email(const char *);
|
|
Packit |
c22fc9 |
extern data_t *alloc_global_data(void);
|
|
Packit Service |
dfccb1 |
extern void init_global_data(data_t *, data_t *, bool);
|
|
Packit |
c22fc9 |
extern void free_global_data(data_t *);
|
|
Packit |
c22fc9 |
extern void dump_global_data(FILE *, data_t *);
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#endif
|