|
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: vrrp_iprule.c include file.
|
|
Packit |
c22fc9 |
*
|
|
Packit |
c22fc9 |
* Author: Chris Riley, <kernelchris@gmail.com>
|
|
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) 2015 Chris Riley, <kernelchris@gmail.com>
|
|
Packit |
c22fc9 |
* Copyright (C) 2016-2017 Alexandre Cassen, <acassen@gmail.com>
|
|
Packit |
c22fc9 |
*/
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#ifndef _VRRP_IPRULE_H
|
|
Packit |
c22fc9 |
#define _VRRP_IPRULE_H
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* global includes */
|
|
Packit |
c22fc9 |
#include <stdbool.h>
|
|
Packit |
c22fc9 |
#include <stdint.h>
|
|
Packit |
c22fc9 |
#include <stdio.h>
|
|
Packit |
c22fc9 |
#include <sys/types.h>
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_UID_RANGE
|
|
Packit |
c22fc9 |
#include <linux/fib_rules.h>
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* local includes */
|
|
Packit |
c22fc9 |
#include "vrrp_if.h"
|
|
Packit |
c22fc9 |
#include "vrrp_ipaddress.h"
|
|
Packit |
c22fc9 |
#include "vrrp_static_track.h"
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* print buffer sizes */
|
|
Packit |
c22fc9 |
#define RULE_BUF_SIZE 256
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
enum iprule_param_mask {
|
|
Packit |
c22fc9 |
IPRULE_BIT_PRIORITY = 0x01,
|
|
Packit |
c22fc9 |
IPRULE_BIT_FWMARK = 0x02,
|
|
Packit |
c22fc9 |
IPRULE_BIT_FWMASK = 0x04,
|
|
Packit |
c22fc9 |
IPRULE_BIT_SUP_GROUP = 0x08,
|
|
Packit |
c22fc9 |
IPRULE_BIT_UID_RANGE = 0x10,
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_PROTOCOL
|
|
Packit |
c22fc9 |
IPRULE_BIT_PROTOCOL = 0x20,
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_IP_PROTO
|
|
Packit |
c22fc9 |
IPRULE_BIT_IP_PROTO = 0x40,
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_SPORT_RANGE
|
|
Packit |
c22fc9 |
IPRULE_BIT_SPORT_RANGE = 0x80,
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_DPORT_RANGE
|
|
Packit |
c22fc9 |
IPRULE_BIT_DPORT_RANGE = 0x100,
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
} ;
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* types definition */
|
|
Packit |
c22fc9 |
typedef struct _ip_rule {
|
|
Packit |
c22fc9 |
uint32_t mask;
|
|
Packit |
c22fc9 |
bool invert;
|
|
Packit |
c22fc9 |
int family;
|
|
Packit |
c22fc9 |
ip_address_t *from_addr;
|
|
Packit |
c22fc9 |
ip_address_t *to_addr;
|
|
Packit |
c22fc9 |
uint32_t priority;
|
|
Packit |
c22fc9 |
uint8_t tos;
|
|
Packit |
c22fc9 |
uint32_t fwmark;
|
|
Packit |
c22fc9 |
uint32_t fwmask;
|
|
Packit |
c22fc9 |
uint32_t realms;
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_SUPPRESS_PREFIXLEN
|
|
Packit |
c22fc9 |
int32_t suppress_prefix_len;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_SUPPRESS_IFGROUP
|
|
Packit |
c22fc9 |
uint32_t suppress_group;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
interface_t *iif;
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_OIFNAME
|
|
Packit |
c22fc9 |
interface_t *oif;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
uint32_t goto_target;
|
|
Packit |
c22fc9 |
uint32_t table;
|
|
Packit |
c22fc9 |
uint8_t action;
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_TUN_ID
|
|
Packit |
c22fc9 |
uint64_t tunnel_id;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_UID_RANGE
|
|
Packit |
c22fc9 |
struct fib_rule_uid_range uid_range;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_L3MDEV
|
|
Packit |
c22fc9 |
bool l3mdev;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_PROTOCOL
|
|
Packit |
c22fc9 |
uint8_t protocol;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_IP_PROTO
|
|
Packit |
c22fc9 |
uint8_t ip_proto;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_SPORT_RANGE
|
|
Packit |
c22fc9 |
struct fib_rule_port_range src_port;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
#if HAVE_DECL_FRA_DPORT_RANGE
|
|
Packit |
c22fc9 |
struct fib_rule_port_range dst_port;
|
|
Packit |
c22fc9 |
#endif
|
|
Packit |
c22fc9 |
bool dont_track; /* used for virtual rules */
|
|
Packit |
c22fc9 |
static_track_group_t *track_group; /* used for static rules */
|
|
Packit |
c22fc9 |
bool set;
|
|
Packit |
c22fc9 |
} ip_rule_t;
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#define IPRULE_DEL 0
|
|
Packit |
c22fc9 |
#define IPRULE_ADD 1
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
/* prototypes */
|
|
Packit |
c22fc9 |
extern void reinstate_static_rule(ip_rule_t *);
|
|
Packit |
c22fc9 |
extern void netlink_rulelist(list, int, bool);
|
|
Packit |
c22fc9 |
extern void free_iprule(void *);
|
|
Packit |
c22fc9 |
extern void format_iprule(ip_rule_t *, char *, size_t);
|
|
Packit |
c22fc9 |
extern void dump_iprule(FILE *, void *);
|
|
Packit |
c22fc9 |
extern void alloc_rule(list, vector_t *, bool);
|
|
Packit |
c22fc9 |
extern void clear_diff_rules(list, list);
|
|
Packit |
c22fc9 |
extern void clear_diff_srules(void);
|
|
Packit |
c22fc9 |
extern void reset_next_rule_priority(void);
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
#endif
|