|
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: vrrp_iproute.c 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_IPROUTE_H
|
|
Packit Service |
5956c7 |
#define _VRRP_IPROUTE_H
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* global includes */
|
|
Packit Service |
5956c7 |
#include <stdbool.h>
|
|
Packit Service |
5956c7 |
#include <stdint.h>
|
|
Packit Service |
5956c7 |
#include <stdio.h>
|
|
Packit Service |
5956c7 |
#include <sys/types.h>
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_LWTUNNEL_ENCAP_MPLS
|
|
Packit Service |
5956c7 |
#include <linux/mpls.h>
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#ifdef RTNETLINK_H_NEEDS_SYS_SOCKET_H
|
|
Packit Service |
5956c7 |
#include <sys/socket.h>
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#include <linux/rtnetlink.h>
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* local includes */
|
|
Packit Service |
5956c7 |
#include "list.h"
|
|
Packit Service |
5956c7 |
#include "vector.h"
|
|
Packit Service |
5956c7 |
#include "vrrp_ipaddress.h"
|
|
Packit Service |
5956c7 |
#include "vrrp_if.h"
|
|
Packit Service |
5956c7 |
#include "vrrp_static_track.h"
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* We hope to get an official definion for this, but until then make a private one */
|
|
Packit Service |
5956c7 |
#ifndef RTPROT_KEEPALIVED
|
|
Packit Service |
5956c7 |
#define RTPROT_KEEPALIVED 112 /* Keepalived daemon */
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Buffer sizes for printing */
|
|
Packit Service |
5956c7 |
#define ROUTE_BUF_SIZE 1024
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* types definition */
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTA_ENCAP /* Since Linux 4.3 */
|
|
Packit Service |
5956c7 |
enum iproute_encap {
|
|
Packit Service |
5956c7 |
IPROUTE_ENCAP_ID,
|
|
Packit Service |
5956c7 |
IPROUTE_ENCAP_DSFIELD,
|
|
Packit Service |
5956c7 |
IPROUTE_ENCAP_HOPLIMIT,
|
|
Packit Service |
5956c7 |
IPROUTE_ENCAP_TTL = IPROUTE_ENCAP_HOPLIMIT,
|
|
Packit Service |
5956c7 |
IPROUTE_ENCAP_FLAGS,
|
|
Packit Service |
5956c7 |
};
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_ENCAP_ID (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_ENCAP_DSFIELD (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_ENCAP_HOPLIMIT (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_ENCAP_TTL (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_ENCAP_FLAGS (1<
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_LWTUNNEL_ENCAP_MPLS
|
|
Packit Service |
5956c7 |
#define MAX_MPLS_LABELS 2
|
|
Packit Service |
5956c7 |
typedef struct mpls_label mpls_labels[MAX_MPLS_LABELS];
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _encap_mpls {
|
|
Packit Service |
5956c7 |
mpls_labels addr;
|
|
Packit Service |
5956c7 |
size_t num_labels;
|
|
Packit Service |
5956c7 |
} encap_mpls_t;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _encap_ip {
|
|
Packit Service |
5956c7 |
uint64_t id;
|
|
Packit Service |
5956c7 |
ip_address_t *dst;
|
|
Packit Service |
5956c7 |
ip_address_t *src;
|
|
Packit Service |
5956c7 |
uint8_t tos;
|
|
Packit Service |
5956c7 |
uint16_t flags;
|
|
Packit Service |
5956c7 |
uint8_t ttl;
|
|
Packit Service |
5956c7 |
} encap_ip_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_LWTUNNEL_ENCAP_ILA
|
|
Packit Service |
5956c7 |
typedef struct _encap_ila {
|
|
Packit Service |
5956c7 |
uint64_t locator;
|
|
Packit Service |
5956c7 |
} encap_ila_t;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _encap_ip6 {
|
|
Packit Service |
5956c7 |
uint64_t id;
|
|
Packit Service |
5956c7 |
ip_address_t *dst;
|
|
Packit Service |
5956c7 |
ip_address_t *src;
|
|
Packit Service |
5956c7 |
uint8_t tc;
|
|
Packit Service |
5956c7 |
uint16_t flags;
|
|
Packit Service |
5956c7 |
uint8_t hoplimit;
|
|
Packit Service |
5956c7 |
} encap_ip6_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _encap {
|
|
Packit Service |
5956c7 |
uint16_t type;
|
|
Packit Service |
5956c7 |
uint32_t flags;
|
|
Packit Service |
5956c7 |
union {
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_LWTUNNEL_ENCAP_MPLS
|
|
Packit Service |
5956c7 |
encap_mpls_t mpls;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
encap_ip_t ip;
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_LWTUNNEL_ENCAP_ILA
|
|
Packit Service |
5956c7 |
encap_ila_t ila;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
encap_ip6_t ip6;
|
|
Packit Service |
5956c7 |
};
|
|
Packit Service |
5956c7 |
} encap_t;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _nexthop {
|
|
Packit Service |
5956c7 |
uint32_t mask;
|
|
Packit Service |
5956c7 |
ip_address_t *addr;
|
|
Packit Service |
5956c7 |
interface_t *ifp;
|
|
Packit Service |
5956c7 |
uint8_t weight;
|
|
Packit Service |
5956c7 |
uint8_t flags;
|
|
Packit Service |
5956c7 |
uint32_t realms;
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTA_ENCAP
|
|
Packit Service |
5956c7 |
encap_t encap;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
//#if HAVE_DECL_RTA_NEWDST
|
|
Packit Service |
5956c7 |
// ip_address_t *as_to;
|
|
Packit Service |
5956c7 |
//#endif
|
|
Packit Service |
5956c7 |
} nexthop_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
enum ip_route {
|
|
Packit Service |
5956c7 |
IPROUTE_DSFIELD = 0,
|
|
Packit Service |
5956c7 |
IPROUTE_TYPE,
|
|
Packit Service |
5956c7 |
IPROUTE_PROTOCOL,
|
|
Packit Service |
5956c7 |
IPROUTE_SCOPE,
|
|
Packit Service |
5956c7 |
IPROUTE_METRIC,
|
|
Packit Service |
5956c7 |
IPROUTE_WEIGHT,
|
|
Packit Service |
5956c7 |
IPROUTE_EXPIRES,
|
|
Packit Service |
5956c7 |
IPROUTE_MTU,
|
|
Packit Service |
5956c7 |
IPROUTE_HOPLIMIT,
|
|
Packit Service |
5956c7 |
IPROUTE_ADVMSS,
|
|
Packit Service |
5956c7 |
IPROUTE_RTT,
|
|
Packit Service |
5956c7 |
IPROUTE_RTTVAR,
|
|
Packit Service |
5956c7 |
IPROUTE_REORDERING,
|
|
Packit Service |
5956c7 |
IPROUTE_WINDOW,
|
|
Packit Service |
5956c7 |
IPROUTE_CWND,
|
|
Packit Service |
5956c7 |
IPROUTE_SSTHRESH,
|
|
Packit Service |
5956c7 |
IPROUTE_RTO_MIN,
|
|
Packit Service |
5956c7 |
IPROUTE_INITCWND,
|
|
Packit Service |
5956c7 |
IPROUTE_INITRWND,
|
|
Packit Service |
5956c7 |
IPROUTE_QUICKACK,
|
|
Packit Service |
5956c7 |
IPROUTE_PREF,
|
|
Packit Service |
5956c7 |
IPROUTE_FASTOPEN_NO_COOKIE,
|
|
Packit Service |
5956c7 |
IPROUTE_TTL_PROPAGATE,
|
|
Packit Service |
5956c7 |
};
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_DSFIELD (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_TYPE (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_PROTOCOL (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_SCOPE (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_METRIC (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_WEIGHT (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_EXPIRES (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_MTU (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_HOPLIMIT (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_ADVMSS (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_RTT (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_RTTVAR (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_REORDERING (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_WINDOW (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_CWND (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_SSTHRESH (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_RTO_MIN (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_INITCWND (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_INITRWND (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_QUICKACK (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_PREF (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_FASTOPEN_NO_COOKIE (1<
|
|
Packit Service |
5956c7 |
#define IPROUTE_BIT_TTL_PROPAGATE (1<
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
typedef struct _ip_route {
|
|
Packit Service |
5956c7 |
ip_address_t *dst;
|
|
Packit Service |
5956c7 |
ip_address_t *src;
|
|
Packit Service |
5956c7 |
ip_address_t *pref_src;
|
|
Packit Service |
5956c7 |
uint8_t family;
|
|
Packit Service |
5956c7 |
uint8_t tos;
|
|
Packit Service |
5956c7 |
uint32_t table;
|
|
Packit Service |
5956c7 |
uint8_t protocol;
|
|
Packit Service |
5956c7 |
uint8_t scope;
|
|
Packit Service |
5956c7 |
uint32_t metric;
|
|
Packit Service |
5956c7 |
ip_address_t *via;
|
|
Packit Service |
5956c7 |
interface_t *oif;
|
|
Packit Service |
5956c7 |
uint32_t flags;
|
|
Packit Service |
5956c7 |
uint32_t features;
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTAX_QUICKACK
|
|
Packit Service |
5956c7 |
bool quickack;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTA_EXPIRES
|
|
Packit Service |
5956c7 |
uint32_t expires;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
uint32_t lock;
|
|
Packit Service |
5956c7 |
uint32_t mtu;
|
|
Packit Service |
5956c7 |
uint8_t hoplimit;
|
|
Packit Service |
5956c7 |
uint32_t advmss;
|
|
Packit Service |
5956c7 |
//#if HAVE_DECL_RTA_NEWDST
|
|
Packit Service |
5956c7 |
// ip_address_t *as_to;
|
|
Packit Service |
5956c7 |
//#endif
|
|
Packit Service |
5956c7 |
uint32_t rtt;
|
|
Packit Service |
5956c7 |
uint32_t rttvar;
|
|
Packit Service |
5956c7 |
uint32_t reordering;
|
|
Packit Service |
5956c7 |
uint32_t window;
|
|
Packit Service |
5956c7 |
uint32_t cwnd;
|
|
Packit Service |
5956c7 |
uint32_t ssthresh;
|
|
Packit Service |
5956c7 |
uint32_t rto_min;
|
|
Packit Service |
5956c7 |
uint32_t initcwnd;
|
|
Packit Service |
5956c7 |
uint32_t initrwnd;
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTAX_CC_ALGO
|
|
Packit Service |
5956c7 |
char *congctl;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTA_PREF
|
|
Packit Service |
5956c7 |
uint8_t pref;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTAX_FASTOPEN_NO_COOKIE
|
|
Packit Service |
5956c7 |
bool fastopen_no_cookie;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTA_TTL_PROPAGATE
|
|
Packit Service |
5956c7 |
bool ttl_propagate;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
uint8_t type;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
uint32_t realms;
|
|
Packit Service |
5956c7 |
#if HAVE_DECL_RTA_ENCAP
|
|
Packit Service |
5956c7 |
encap_t encap;
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
list nhs;
|
|
Packit Service |
5956c7 |
uint32_t mask;
|
|
Packit Service |
5956c7 |
bool dont_track; /* used for virtual routes */
|
|
Packit Service |
5956c7 |
static_track_group_t *track_group; /* used for static routes */
|
|
Packit Service |
5956c7 |
bool set;
|
|
Packit Service |
5956c7 |
uint32_t configured_ifindex; /* Index of interface route is configured on */
|
|
Packit Service |
5956c7 |
} ip_route_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#define IPROUTE_DEL 0
|
|
Packit Service |
5956c7 |
#define IPROUTE_ADD 1
|
|
Packit Service |
5956c7 |
#define IPROUTE_REPLACE 2
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* prototypes */
|
|
Packit Service |
5956c7 |
extern unsigned short add_addr2req(struct nlmsghdr *, size_t, unsigned short, ip_address_t *);
|
|
Packit Service |
5956c7 |
extern void netlink_rtlist(list, int);
|
|
Packit Service |
5956c7 |
extern void free_iproute(void *);
|
|
Packit Service |
5956c7 |
extern void format_iproute(ip_route_t *, char *, size_t);
|
|
Packit Service |
5956c7 |
extern void dump_iproute(FILE *, void *);
|
|
Packit Service |
5956c7 |
extern void alloc_route(list, vector_t *, bool);
|
|
Packit Service |
5956c7 |
extern void clear_diff_routes(list, list);
|
|
Packit Service |
5956c7 |
extern void clear_diff_sroutes(void);
|
|
Packit Service |
5956c7 |
extern void reinstate_static_route(ip_route_t *);
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#endif
|