|
Packit Service |
5956c7 |
/*
|
|
Packit Service |
5956c7 |
* Soft: Vrrpd is an implementation of VRRPv2 as specified in rfc2338.
|
|
Packit Service |
5956c7 |
* VRRP is a protocol which elect a master server on a LAN. If the
|
|
Packit Service |
5956c7 |
* master fails, a backup server takes over.
|
|
Packit Service |
5956c7 |
* The original implementation has been made by jerome etienne.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Part: vrrp.c program include file.
|
|
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 |
#ifndef _VRRP_H
|
|
Packit Service |
5956c7 |
#define _VRRP_H
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#include "config.h"
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* system include */
|
|
Packit Service |
5956c7 |
#include <stdint.h>
|
|
Packit Service |
5956c7 |
#include <stdbool.h>
|
|
Packit Service |
5956c7 |
#include <net/if.h>
|
|
Packit Service |
5956c7 |
#include <sys/types.h>
|
|
Packit Service |
5956c7 |
#include <sys/socket.h>
|
|
Packit Service |
5956c7 |
#include <arpa/inet.h>
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* local include */
|
|
Packit Service |
5956c7 |
#include "vector.h"
|
|
Packit Service |
5956c7 |
#include "list.h"
|
|
Packit Service |
5956c7 |
#include "timer.h"
|
|
Packit Service |
5956c7 |
#include "notify.h"
|
|
Packit Service |
5956c7 |
#if defined _WITH_VRRP_AUTH_
|
|
Packit Service |
5956c7 |
#include "vrrp_ipsecah.h"
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#include "vrrp_if.h"
|
|
Packit Service |
5956c7 |
#include "vrrp_sock.h"
|
|
Packit Service |
5956c7 |
#include "vrrp_track.h"
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Special value for parameters when we want to know they haven't been set */
|
|
Packit Service |
5956c7 |
#define PARAMETER_UNSET UINT_MAX
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _vrrphdr { /* rfc2338.5.1 */
|
|
Packit Service |
5956c7 |
uint8_t vers_type; /* 0-3=type, 4-7=version */
|
|
Packit Service |
5956c7 |
uint8_t vrid; /* virtual router id */
|
|
Packit Service |
5956c7 |
uint8_t priority; /* router priority */
|
|
Packit Service |
5956c7 |
uint8_t naddr; /* address counter */
|
|
Packit Service |
5956c7 |
union {
|
|
Packit Service |
5956c7 |
struct {
|
|
Packit Service |
5956c7 |
uint8_t auth_type; /* authentification type */
|
|
Packit Service |
5956c7 |
uint8_t adver_int; /* advertisement interval (in sec) */
|
|
Packit Service |
5956c7 |
} v2;
|
|
Packit Service |
5956c7 |
struct {
|
|
Packit Service |
5956c7 |
uint16_t adver_int; /* advertisement interval (in centi-sec (100ms)) */
|
|
Packit Service |
5956c7 |
} v3;
|
|
Packit Service |
5956c7 |
};
|
|
Packit Service |
5956c7 |
uint16_t chksum; /* checksum (ip-like one) */
|
|
Packit Service |
5956c7 |
/* here <naddr> ip addresses */
|
|
Packit Service |
5956c7 |
/* here authentification infos */
|
|
Packit Service |
5956c7 |
} vrrphdr_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct {
|
|
Packit Service |
5956c7 |
uint32_t src;
|
|
Packit Service |
5956c7 |
uint32_t dst;
|
|
Packit Service |
5956c7 |
uint8_t zero;
|
|
Packit Service |
5956c7 |
uint8_t proto;
|
|
Packit Service |
5956c7 |
uint16_t len;
|
|
Packit Service |
5956c7 |
} ipv4_phdr_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* protocol constants */
|
|
Packit Service |
5956c7 |
#define INADDR_VRRP_GROUP "224.0.0.18" /* multicast IPv4 addr - rfc2338.5.2.2 */
|
|
Packit Service |
5956c7 |
#define INADDR6_VRRP_GROUP "ff02::12" /* multicast IPv6 addr - rfc5798.5.1.2.2 */
|
|
Packit Service |
5956c7 |
#define VRRP_IP_TTL 255 /* in and out pkt ttl -- rfc2338.5.2.3 */
|
|
Packit Service |
5956c7 |
#define IPPROTO_VRRP 112 /* IP protocol number -- rfc2338.5.2.4 */
|
|
Packit Service |
5956c7 |
#define VRRP_VERSION_2 2 /* VRRP version 2 -- rfc2338.5.3.1 */
|
|
Packit Service |
5956c7 |
#define VRRP_VERSION_3 3 /* VRRP version 3 -- rfc5798.5.2.1 */
|
|
Packit Service |
5956c7 |
#define VRRP_PKT_ADVERT 1 /* packet type -- rfc2338.5.3.2 */
|
|
Packit Service |
5956c7 |
#define VRRP_PRIO_OWNER 255 /* priority of the ip owner -- rfc2338.5.3.4 */
|
|
Packit Service |
5956c7 |
#define VRRP_PRIO_DFL 100 /* default priority -- rfc2338.5.3.4 */
|
|
Packit Service |
5956c7 |
#define VRRP_PRIO_STOP 0 /* priority to stop -- rfc2338.5.3.4 */
|
|
Packit Service |
5956c7 |
#define VRRP_MAX_ADDR 0xFF /* count addr field is 8 bits wide */
|
|
Packit Service |
5956c7 |
#define VRRP_AUTH_NONE 0 /* no authentification -- rfc2338.5.3.6 */
|
|
Packit Service |
5956c7 |
#ifdef _WITH_VRRP_AUTH_
|
|
Packit Service |
5956c7 |
#define VRRP_AUTH_PASS 1 /* password authentification -- rfc2338.5.3.6 */
|
|
Packit Service |
5956c7 |
#define VRRP_AUTH_AH 2 /* AH(IPSec) authentification - rfc2338.5.3.6 */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#define VRRP_ADVER_DFL 1 /* advert. interval (in sec) -- rfc2338.5.3.7 */
|
|
Packit Service |
5956c7 |
#define VRRP_GARP_DELAY (5 * TIMER_HZ) /* Default delay to launch gratuitous arp */
|
|
Packit Service |
5956c7 |
#define VRRP_GARP_REP 5 /* Default repeat value for MASTER state gratuitous arp */
|
|
Packit Service |
5956c7 |
#define VRRP_GARP_REFRESH 0 /* Default interval for refresh gratuitous arp (0 = none) */
|
|
Packit Service |
5956c7 |
#define VRRP_GARP_REFRESH_REP 1 /* Default repeat value for refresh gratuitous arp */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/*
|
|
Packit Service |
5956c7 |
* parameters per vrrp sync group. A vrrp_sync_group is a set
|
|
Packit Service |
5956c7 |
* of VRRP instances that need to be state sync together.
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
typedef struct _vrrp_sgroup {
|
|
Packit Service |
5956c7 |
char *gname; /* Group name */
|
|
Packit Service |
5956c7 |
vector_t *iname; /* Set of VRRP instances in this group, only used during initialisation */
|
|
Packit Service |
5956c7 |
list vrrp_instances; /* List of VRRP instances */
|
|
Packit Service |
5956c7 |
unsigned num_member_fault; /* Number of members of group in fault state */
|
|
Packit Service |
5956c7 |
unsigned num_member_init; /* Number of members of group in pending state */
|
|
Packit Service |
5956c7 |
int state; /* current stable state */
|
|
Packit Service |
5956c7 |
bool sgroup_tracking_weight; /* Use floating priority and scripts
|
|
Packit Service |
5956c7 |
* Used if need different priorities needed on a track object in a sync group.
|
|
Packit Service |
5956c7 |
* It probably won't work properly. */
|
|
Packit Service |
5956c7 |
list track_ifp; /* Interface state we monitor */
|
|
Packit Service |
5956c7 |
list track_script; /* Script state we monitor */
|
|
Packit Service |
5956c7 |
list track_file; /* Files whose value we monitor (list of tracked_file_t) */
|
|
Packit Service |
5956c7 |
#ifdef _WITH_BFD_
|
|
Packit Service |
5956c7 |
list track_bfd; /* List of tracked_bfd_t */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* State transition notification */
|
|
Packit Service |
5956c7 |
bool notify_exec;
|
|
Packit Service |
5956c7 |
notify_script_t *script_backup;
|
|
Packit Service |
5956c7 |
notify_script_t *script_master;
|
|
Packit Service |
5956c7 |
notify_script_t *script_fault;
|
|
Packit Service |
5956c7 |
notify_script_t *script_stop;
|
|
Packit Service |
5956c7 |
notify_script_t *script;
|
|
Packit Service |
5956c7 |
int smtp_alert;
|
|
Packit Service |
5956c7 |
int last_email_state;
|
|
Packit Service |
5956c7 |
} vrrp_sgroup_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Statistics */
|
|
Packit Service |
5956c7 |
typedef struct _vrrp_stats {
|
|
Packit Service |
5956c7 |
uint64_t advert_rcvd;
|
|
Packit Service |
5956c7 |
uint32_t advert_sent;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
uint32_t become_master;
|
|
Packit Service |
5956c7 |
uint32_t release_master;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
uint64_t packet_len_err;
|
|
Packit Service |
5956c7 |
uint64_t advert_interval_err;
|
|
Packit Service |
5956c7 |
uint64_t ip_ttl_err;
|
|
Packit Service |
5956c7 |
uint64_t invalid_type_rcvd;
|
|
Packit Service |
5956c7 |
uint64_t addr_list_err;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
uint32_t invalid_authtype;
|
|
Packit Service |
5956c7 |
#ifdef _WITH_VRRP_AUTH_
|
|
Packit Service |
5956c7 |
uint32_t authtype_mismatch;
|
|
Packit Service |
5956c7 |
uint32_t auth_failure;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
uint64_t pri_zero_rcvd;
|
|
Packit Service |
5956c7 |
uint64_t pri_zero_sent;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#ifdef _WITH_SNMP_RFC_
|
|
Packit Service |
5956c7 |
uint32_t chk_err;
|
|
Packit Service |
5956c7 |
uint32_t vers_err;
|
|
Packit Service |
5956c7 |
uint32_t vrid_err;
|
|
Packit Service |
5956c7 |
timeval_t uptime;
|
|
Packit Service |
5956c7 |
#ifdef _WITH_SNMP_RFCV3_
|
|
Packit Service |
5956c7 |
uint32_t master_reason;
|
|
Packit Service |
5956c7 |
uint32_t next_master_reason;
|
|
Packit Service |
5956c7 |
uint32_t proto_err_reason;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
} vrrp_stats;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#ifdef _WITH_UNICAST_CHKSUM_COMPAT_
|
|
Packit Service |
5956c7 |
/* Whether we are using v1.3.6 and earlier VRRPv3 unicast checksums */
|
|
Packit Service |
5956c7 |
typedef enum chksum_compatibility {
|
|
Packit Service |
5956c7 |
CHKSUM_COMPATIBILITY_NONE, /* Default setting, will revert to old if receive advert with old */
|
|
Packit Service |
5956c7 |
CHKSUM_COMPATIBILITY_NEVER, /* Do not auto set old checksum mode */
|
|
Packit Service |
5956c7 |
CHKSUM_COMPATIBILITY_MIN_COMPAT, /* Values before this are new chksum, values after are old */
|
|
Packit Service |
5956c7 |
CHKSUM_COMPATIBILITY_CONFIG, /* Configuration specifies old chksum */
|
|
Packit Service |
5956c7 |
CHKSUM_COMPATIBILITY_AUTO, /* Use old chksum mode due to received advert with old mode */
|
|
Packit Service |
5956c7 |
} chksum_compatibility_t;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* parameters per virtual router -- rfc2338.6.1.2 */
|
|
Packit Service |
5956c7 |
typedef struct _vrrp_t {
|
|
Packit Service |
5956c7 |
sa_family_t family; /* AF_INET|AF_INET6 */
|
|
Packit Service |
5956c7 |
char *iname; /* Instance Name */
|
|
Packit Service |
5956c7 |
vrrp_sgroup_t *sync; /* Sync group we belong to */
|
|
Packit Service |
5956c7 |
vrrp_stats *stats; /* Statistics */
|
|
Packit Service |
5956c7 |
interface_t *ifp; /* Interface we belong to */
|
|
Packit Service |
5956c7 |
bool dont_track_primary; /* If set ignores ifp faults */
|
|
Packit Service |
5956c7 |
bool linkbeat_use_polling; /* Don't use netlink for interface status */
|
|
Packit Service |
5956c7 |
bool skip_check_adv_addr; /* If set, don't check the VIPs in subsequent
|
|
Packit Service |
5956c7 |
* adverts from the same master */
|
|
Packit Service |
5956c7 |
unsigned strict_mode; /* Enforces strict VRRP compliance */
|
|
Packit Service |
5956c7 |
#ifdef _HAVE_VRRP_VMAC_
|
|
Packit Service |
5956c7 |
unsigned long vmac_flags; /* VRRP VMAC flags */
|
|
Packit Service |
5956c7 |
char vmac_ifname[IFNAMSIZ]; /* Name of VRRP VMAC interface */
|
|
Packit Service |
5956c7 |
bool duplicate_vrid_fault; /* Set if we have a fault due to duplicate VRID */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
interface_t *configured_ifp; /* Interface the configuration says we are on */
|
|
Packit Service |
5956c7 |
list track_ifp; /* Interface state we monitor */
|
|
Packit Service |
5956c7 |
list track_script; /* Script state we monitor */
|
|
Packit Service |
5956c7 |
list track_file; /* list of tracked_file_t - Files whose value we monitor */
|
|
Packit Service |
5956c7 |
#ifdef _WITH_BFD_
|
|
Packit Service |
5956c7 |
list track_bfd; /* List of tracked_bfd_t */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
unsigned num_script_if_fault; /* Number of scripts and interfaces in fault state */
|
|
Packit Service |
5956c7 |
unsigned num_script_init; /* Number of scripts in init state */
|
|
Packit Service |
5956c7 |
struct sockaddr_storage saddr; /* Src IP address to use in VRRP IP header */
|
|
Packit Service |
5956c7 |
bool saddr_from_config; /* Set if the source address is from configuration */
|
|
Packit Service |
5956c7 |
bool track_saddr; /* Fault state if configured saddr is missing */
|
|
Packit Service |
5956c7 |
struct sockaddr_storage pkt_saddr; /* Src IP address received in VRRP IP header */
|
|
Packit Service |
5956c7 |
list unicast_peer; /* List of Unicast peer to send advert to */
|
|
Packit Service |
5956c7 |
#ifdef _WITH_UNICAST_CHKSUM_COMPAT_
|
|
Packit Service |
5956c7 |
chksum_compatibility_t unicast_chksum_compat; /* Whether v1.3.6 and earlier chksum is used */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
struct sockaddr_storage master_saddr; /* Store last heard Master address */
|
|
Packit Service |
5956c7 |
uint8_t master_priority; /* Store last heard priority */
|
|
Packit Service |
5956c7 |
timeval_t last_transition; /* Store transition time */
|
|
Packit Service |
5956c7 |
unsigned garp_delay; /* Delay to launch gratuitous ARP */
|
|
Packit Service |
5956c7 |
timeval_t garp_refresh; /* Next scheduled gratuitous ARP refresh */
|
|
Packit Service |
5956c7 |
timeval_t garp_refresh_timer; /* Next scheduled gratuitous ARP timer */
|
|
Packit Service |
5956c7 |
unsigned garp_rep; /* gratuitous ARP repeat value */
|
|
Packit Service |
5956c7 |
unsigned garp_refresh_rep; /* refresh gratuitous ARP repeat value */
|
|
Packit Service |
5956c7 |
unsigned garp_lower_prio_delay; /* Delay to second set or ARP messages */
|
|
Packit Service |
5956c7 |
bool garp_pending; /* Are there gratuitous ARP messages still to be sent */
|
|
Packit Service |
5956c7 |
bool gna_pending; /* Are there gratuitous NA messages still to be sent */
|
|
Packit Service |
5956c7 |
unsigned garp_lower_prio_rep; /* Number of ARP messages to send at a time */
|
|
Packit Service |
5956c7 |
unsigned lower_prio_no_advert; /* Don't send advert after lower prio advert received */
|
|
Packit Service |
5956c7 |
unsigned higher_prio_send_advert; /* Send advert after higher prio advert received */
|
|
Packit Service |
5956c7 |
uint8_t vrid; /* virtual id. from 1(!) to 255 */
|
|
Packit Service |
5956c7 |
uint8_t base_priority; /* configured priority value */
|
|
Packit Service |
5956c7 |
uint8_t effective_priority; /* effective priority value */
|
|
Packit Service |
5956c7 |
int total_priority; /* base_priority +/- track_script, track_interface and track_file weights.
|
|
Packit Service |
5956c7 |
effective_priority is this within the range [1,254]. */
|
|
Packit Service |
5956c7 |
bool vipset; /* All the vips are set ? */
|
|
Packit Service |
5956c7 |
list vip; /* list of virtual ip addresses */
|
|
Packit Service |
5956c7 |
list evip; /* list of protocol excluded VIPs.
|
|
Packit Service |
5956c7 |
* Those VIPs will not be presents into the
|
|
Packit Service |
5956c7 |
* VRRP adverts
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
bool promote_secondaries; /* Set promote_secondaries option on interface */
|
|
Packit Service |
5956c7 |
bool evip_add_ipv6; /* Enable IPv6 for eVIPs if this is an IPv4 instance */
|
|
Packit Service |
5956c7 |
list vroutes; /* list of virtual routes */
|
|
Packit Service |
5956c7 |
list vrules; /* list of virtual rules */
|
|
Packit Service |
5956c7 |
unsigned adver_int; /* locally configured delay between advertisements*/
|
|
Packit Service |
5956c7 |
unsigned master_adver_int; /* In v3, when we become BACKUP, we use the MASTER's
|
|
Packit Service |
5956c7 |
* adver_int. If we become MASTER again, we use the
|
|
Packit Service |
5956c7 |
* value we were originally configured with.
|
|
Packit Service |
5956c7 |
* In v2, this will always be the configured adver_int.
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
unsigned accept; /* Allow the non-master owner to process
|
|
Packit Service |
5956c7 |
* the packets destined to VIP.
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
size_t kernel_rx_buf_size; /* Socket receive buffer size */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
bool iptable_rules_set; /* Iptable drop rules set to VIP list ? */
|
|
Packit Service |
5956c7 |
bool nopreempt; /* true if higher prio does not preempt lower */
|
|
Packit Service |
5956c7 |
unsigned long preempt_delay; /* Seconds*TIMER_HZ after startup until
|
|
Packit Service |
5956c7 |
* preemption based on higher prio over lower
|
|
Packit Service |
5956c7 |
* prio is allowed. 0 means no delay.
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
timeval_t preempt_time; /* Time after which preemption can happen */
|
|
Packit Service |
5956c7 |
int state; /* internal state (init/backup/master/fault) */
|
|
Packit Service |
5956c7 |
#ifdef _WITH_SNMP_VRRP_
|
|
Packit Service |
5956c7 |
int configured_state; /* the configured state of the instance */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
int wantstate; /* user explicitly wants a state (back/mast) */
|
|
Packit Service |
5956c7 |
bool reload_master; /* set if the instance is a master being reloaded */
|
|
Packit Service |
5956c7 |
sock_t *sockets; /* In and out socket descriptors */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
int debug; /* Debug level 0-4 */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
int version; /* VRRP version (2 or 3) */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* State transition notification */
|
|
Packit Service |
5956c7 |
int smtp_alert;
|
|
Packit Service |
5956c7 |
int last_email_state;
|
|
Packit Service |
5956c7 |
bool notify_exec;
|
|
Packit Service |
5956c7 |
notify_script_t *script_backup;
|
|
Packit Service |
5956c7 |
notify_script_t *script_master;
|
|
Packit Service |
5956c7 |
notify_script_t *script_fault;
|
|
Packit Service |
5956c7 |
notify_script_t *script_stop;
|
|
Packit Service |
5956c7 |
notify_script_t *script_master_rx_lower_pri;
|
|
Packit Service |
5956c7 |
notify_script_t *script;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* rfc2338.6.2 */
|
|
Packit Service |
5956c7 |
uint32_t ms_down_timer;
|
|
Packit Service |
5956c7 |
timeval_t sands;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Sending buffer */
|
|
Packit Service |
5956c7 |
char *send_buffer; /* Allocated send buffer */
|
|
Packit Service |
5956c7 |
size_t send_buffer_size;
|
|
Packit Service |
5956c7 |
uint32_t ipv4_csum; /* Checksum ip IPv4 pseudo header for VRRPv3 */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#if defined _WITH_VRRP_AUTH_
|
|
Packit Service |
5956c7 |
/* Authentication data (only valid for VRRPv2) */
|
|
Packit Service |
5956c7 |
uint8_t auth_type; /* authentification type. VRRP_AUTH_* */
|
|
Packit Service |
5956c7 |
uint8_t auth_data[8]; /* authentification data */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* IPSEC AH counter def (only valid for VRRPv2) --rfc2402.3.3.2 */
|
|
Packit Service |
5956c7 |
seq_counter_t ipsecah_counter;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/*
|
|
Packit Service |
5956c7 |
* To have my own ip_id creates collision with kernel ip->id
|
|
Packit Service |
5956c7 |
* but it should be ok because the packets are unlikely to be
|
|
Packit Service |
5956c7 |
* fragmented (they are non routable and small)
|
|
Packit Service |
5956c7 |
* This packet isnt routed, i can check the outgoing MTU
|
|
Packit Service |
5956c7 |
* to warn the user only if the outoing mtu is too small
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
int ip_id;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* RB tree on a sock_t for receiving data */
|
|
Packit Service |
5956c7 |
rb_node_t rb_vrid;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* RB tree on a sock_t for vrrp sands */
|
|
Packit Service |
5956c7 |
rb_node_t rb_sands;
|
|
Packit Service |
5956c7 |
} vrrp_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* VRRP state machine -- rfc2338.6.4 */
|
|
Packit Service |
5956c7 |
#define VRRP_STATE_INIT 0 /* rfc2338.6.4.1 */
|
|
Packit Service |
5956c7 |
#define VRRP_STATE_BACK 1 /* rfc2338.6.4.2 */
|
|
Packit Service |
5956c7 |
#define VRRP_STATE_MAST 2 /* rfc2338.6.4.3 */
|
|
Packit Service |
5956c7 |
#define VRRP_STATE_FAULT 3 /* internal */
|
|
Packit Service |
5956c7 |
#define VRRP_STATE_STOP 98 /* internal */
|
|
Packit Service |
5956c7 |
#define VRRP_DISPATCHER 99 /* internal */
|
|
Packit Service |
5956c7 |
#define VRRP_EVENT_MASTER_RX_LOWER_PRI 1000 /* Dummy state for sending event notify */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* VRRP packet handling */
|
|
Packit Service |
5956c7 |
#define VRRP_PACKET_OK 0
|
|
Packit Service |
5956c7 |
#define VRRP_PACKET_KO 1
|
|
Packit Service |
5956c7 |
#define VRRP_PACKET_DROP 2
|
|
Packit Service |
5956c7 |
#define VRRP_PACKET_NULL 3
|
|
Packit Service |
5956c7 |
#define VRRP_PACKET_OTHER 4 /* Multiple VRRP on LAN, Identify "other" VRRP */
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* VRRP Packet fixed length */
|
|
Packit Service |
5956c7 |
#define VRRP_AUTH_LEN 8
|
|
Packit Service |
5956c7 |
#define VRRP_VIP_TYPE (1 << 0)
|
|
Packit Service |
5956c7 |
#define VRRP_EVIP_TYPE (1 << 1)
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* We have to do some reduction of the calculation for VRRPv3 in order not to overflow a uint32; 625 / 16 == TIMER_CENTI_HZ / 256 */
|
|
Packit Service |
5956c7 |
#define VRRP_TIMER_SKEW(svr) ((svr)->version == VRRP_VERSION_3 ? (((256U-(svr)->effective_priority) * ((svr)->master_adver_int / TIMER_CENTI_HZ) * 625U) / 16U) : ((256U-(svr)->effective_priority) * TIMER_HZ/256U))
|
|
Packit Service |
5956c7 |
#define VRRP_TIMER_SKEW_MIN(svr) ((svr)->version == VRRP_VERSION_3 ? ((((svr)->master_adver_int / TIMER_CENTI_HZ) * 625U) / 16U) : (TIMER_HZ/256U))
|
|
Packit Service |
5956c7 |
#define VRRP_VIP_ISSET(V) ((V)->vipset)
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#define VRRP_MIN(a, b) ((a) < (b)?(a):(b))
|
|
Packit Service |
5956c7 |
#define VRRP_MAX(a, b) ((a) > (b)?(a):(b))
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#ifdef _HAVE_VRRP_VMAC_
|
|
Packit Service |
5956c7 |
#define VRRP_CONFIGURED_IFP(V) ((V)->configured_ifp)
|
|
Packit Service |
5956c7 |
#else
|
|
Packit Service |
5956c7 |
#define VRRP_CONFIGURED_IFP(V) ((V)->ifp)
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#define VRRP_PKT_SADDR(V) (((V)->saddr.ss_family) ? ((struct sockaddr_in *) &(V)->saddr)->sin_addr.s_addr : IF_ADDR(VRRP_CONFIGURED_IFP(V)))
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#define VRRP_ISUP(V) (!(V)->num_script_if_fault)
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Global variables */
|
|
Packit Service |
5956c7 |
extern bool block_ipv4;
|
|
Packit Service |
5956c7 |
extern bool block_ipv6;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Configuration summary flags */
|
|
Packit Service |
5956c7 |
extern bool have_ipv4_instance;
|
|
Packit Service |
5956c7 |
extern bool have_ipv6_instance;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* prototypes */
|
|
Packit Service |
5956c7 |
extern void clear_summary_flags(void);
|
|
Packit Service |
5956c7 |
extern size_t vrrp_adv_len(vrrp_t *);
|
|
Packit Service |
5956c7 |
extern vrrphdr_t *vrrp_get_header(sa_family_t, char *, unsigned *);
|
|
Packit Service |
5956c7 |
extern int open_vrrp_send_socket(sa_family_t, int, interface_t *, bool);
|
|
Packit Service |
5956c7 |
extern int open_vrrp_read_socket(sa_family_t, int, interface_t *, bool, int);
|
|
Packit Service |
5956c7 |
extern int new_vrrp_socket(vrrp_t *);
|
|
Packit Service |
5956c7 |
extern void vrrp_send_adv(vrrp_t *, uint8_t);
|
|
Packit Service |
5956c7 |
extern void vrrp_send_link_update(vrrp_t *, unsigned);
|
|
Packit Service |
5956c7 |
extern void add_vrrp_to_interface(vrrp_t *, interface_t *, int, bool, track_t);
|
|
Packit Service |
5956c7 |
extern void del_vrrp_from_interface(vrrp_t *, interface_t *);
|
|
Packit Service |
5956c7 |
extern bool vrrp_state_fault_rx(vrrp_t *, char *, ssize_t);
|
|
Packit Service |
5956c7 |
extern bool vrrp_state_master_rx(vrrp_t *, char *, ssize_t);
|
|
Packit Service |
5956c7 |
extern void vrrp_state_master_tx(vrrp_t *);
|
|
Packit Service |
5956c7 |
extern void vrrp_state_backup(vrrp_t *, char *, ssize_t);
|
|
Packit Service |
5956c7 |
extern void vrrp_state_goto_master(vrrp_t *);
|
|
Packit Service |
5956c7 |
extern void vrrp_state_leave_master(vrrp_t *, bool);
|
|
Packit Service |
5956c7 |
extern void vrrp_state_leave_fault(vrrp_t *);
|
|
Packit Service |
5956c7 |
extern bool vrrp_complete_init(void);
|
|
Packit Service |
5956c7 |
extern void vrrp_restore_interfaces_startup(void);
|
|
Packit Service |
5956c7 |
extern void restore_vrrp_interfaces(void);
|
|
Packit Service |
5956c7 |
extern void shutdown_vrrp_instances(void);
|
|
Packit Service |
5956c7 |
extern void clear_diff_vrrp(void);
|
|
Packit Service |
5956c7 |
extern void clear_diff_script(void);
|
|
Packit Service |
5956c7 |
extern void clear_diff_bfd(void);
|
|
Packit Service |
5956c7 |
extern void vrrp_restore_interface(vrrp_t *, bool, bool);
|
|
Packit Service |
5956c7 |
#ifdef THREAD_DUMP
|
|
Packit Service |
5956c7 |
extern void register_vrrp_fifo_addresses(void);
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#endif
|