2018-09-08 08:25:27 -07:00
|
|
|
/* $OpenBSD: bgpd.h,v 1.337 2018/09/08 15:25:27 benno Exp $ */
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
/*
|
2004-01-05 19:43:50 -08:00
|
|
|
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
2003-12-17 03:46:54 -08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef __BGPD_H__
|
2003-12-25 09:07:24 -08:00
|
|
|
#define __BGPD_H__
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
2004-01-17 10:27:19 -08:00
|
|
|
#include <sys/socket.h>
|
2003-12-17 03:46:54 -08:00
|
|
|
#include <sys/queue.h>
|
2010-05-19 05:44:14 -07:00
|
|
|
#include <sys/tree.h>
|
2005-06-13 14:16:18 -07:00
|
|
|
#include <net/route.h>
|
2003-12-17 03:46:54 -08:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
2004-01-17 10:27:19 -08:00
|
|
|
#include <net/if.h>
|
2004-04-25 18:59:26 -07:00
|
|
|
#include <net/pfkeyv2.h>
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2004-01-01 15:46:47 -08:00
|
|
|
#include <poll.h>
|
2003-12-17 03:46:54 -08:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2009-06-06 11:31:42 -07:00
|
|
|
#include <imsg.h>
|
2009-06-05 23:33:15 -07:00
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
#define BGP_VERSION 4
|
|
|
|
#define BGP_PORT 179
|
2003-12-25 09:07:24 -08:00
|
|
|
#define CONFFILE "/etc/bgpd.conf"
|
2003-12-17 03:46:54 -08:00
|
|
|
#define BGPD_USER "_bgpd"
|
2003-12-25 09:07:24 -08:00
|
|
|
#define PEER_DESCR_LEN 32
|
2017-01-13 10:59:12 -08:00
|
|
|
#define SHUT_COMM_LEN 129
|
2013-01-09 00:04:25 -08:00
|
|
|
#define PFTABLE_LEN 32
|
2004-01-28 15:31:28 -08:00
|
|
|
#define TCP_MD5_KEY_LEN 80
|
2004-04-25 18:59:26 -07:00
|
|
|
#define IPSEC_ENC_KEY_LEN 32
|
2004-07-05 09:54:53 -07:00
|
|
|
#define IPSEC_AUTH_KEY_LEN 20
|
2018-09-06 22:43:33 -07:00
|
|
|
#define SET_NAME_LEN 64
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
#define MAX_PKTSIZE 4096
|
|
|
|
#define MIN_HOLDTIME 3
|
2003-12-24 15:14:23 -08:00
|
|
|
#define READ_BUF_SIZE 65535
|
2003-12-25 09:07:24 -08:00
|
|
|
#define RT_BUF_SIZE 16384
|
2018-02-07 16:16:18 -08:00
|
|
|
#define MAX_RTSOCK_BUF (2 * 1024 * 1024)
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2003-12-25 09:07:24 -08:00
|
|
|
#define BGPD_OPT_VERBOSE 0x0001
|
|
|
|
#define BGPD_OPT_VERBOSE2 0x0002
|
|
|
|
#define BGPD_OPT_NOACTION 0x0004
|
2006-06-17 07:06:09 -07:00
|
|
|
#define BGPD_OPT_FORCE_DEMOTE 0x0008
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2004-03-01 08:02:01 -08:00
|
|
|
#define BGPD_FLAG_NO_EVALUATE 0x0002
|
2004-05-21 08:36:40 -07:00
|
|
|
#define BGPD_FLAG_REFLECTOR 0x0004
|
2006-03-22 05:30:35 -08:00
|
|
|
#define BGPD_FLAG_NEXTHOP_BGP 0x0080
|
|
|
|
#define BGPD_FLAG_NEXTHOP_DEFAULT 0x1000
|
2004-11-11 02:35:15 -08:00
|
|
|
#define BGPD_FLAG_DECISION_MASK 0x0f00
|
|
|
|
#define BGPD_FLAG_DECISION_ROUTEAGE 0x0100
|
2005-03-11 04:54:19 -08:00
|
|
|
#define BGPD_FLAG_DECISION_TRANS_AS 0x0200
|
2005-08-09 13:27:25 -07:00
|
|
|
#define BGPD_FLAG_DECISION_MED_ALWAYS 0x0400
|
2003-12-24 05:49:21 -08:00
|
|
|
|
2004-07-05 09:54:53 -07:00
|
|
|
#define BGPD_LOG_UPDATES 0x0001
|
2003-12-26 12:52:14 -08:00
|
|
|
|
2004-01-01 18:27:57 -08:00
|
|
|
#define SOCKET_NAME "/var/run/bgpd.sock"
|
|
|
|
|
2004-07-05 09:54:53 -07:00
|
|
|
#define F_BGPD_INSERTED 0x0001
|
|
|
|
#define F_KERNEL 0x0002
|
|
|
|
#define F_CONNECTED 0x0004
|
|
|
|
#define F_NEXTHOP 0x0008
|
|
|
|
#define F_DOWN 0x0010
|
|
|
|
#define F_STATIC 0x0020
|
2005-06-24 07:01:52 -07:00
|
|
|
#define F_DYNAMIC 0x0040
|
2004-07-05 09:54:53 -07:00
|
|
|
#define F_REJECT 0x0080
|
|
|
|
#define F_BLACKHOLE 0x0100
|
2005-06-24 07:01:52 -07:00
|
|
|
#define F_LONGER 0x0200
|
2010-05-17 08:49:29 -07:00
|
|
|
#define F_MPLS 0x0400
|
|
|
|
#define F_REDISTRIBUTED 0x0800
|
2006-03-22 02:18:49 -08:00
|
|
|
#define F_CTL_DETAIL 0x1000 /* only used by bgpctl */
|
2006-08-23 01:13:04 -07:00
|
|
|
#define F_CTL_ADJ_IN 0x2000
|
|
|
|
#define F_CTL_ADJ_OUT 0x4000
|
2012-03-27 11:22:07 -07:00
|
|
|
#define F_CTL_ACTIVE 0x8000
|
2016-10-05 00:38:06 -07:00
|
|
|
#define F_RTLABEL 0x10000
|
2017-10-15 13:44:21 -07:00
|
|
|
#define F_CTL_SSV 0x20000 /* only used by bgpctl */
|
2018-08-29 12:47:47 -07:00
|
|
|
#define F_CTL_INVALID 0x40000 /* only used by bgpctl */
|
2004-01-09 05:47:07 -08:00
|
|
|
|
2007-01-26 09:40:48 -08:00
|
|
|
/*
|
2017-05-28 05:21:36 -07:00
|
|
|
* Limit the number of messages queued in the session engine.
|
|
|
|
* The SE will send an IMSG_XOFF messages to the RDE if the high water mark
|
|
|
|
* is reached. The RDE should then throttle this peer or control connection.
|
|
|
|
* Once the message queue in the SE drops below the low water mark an
|
|
|
|
* IMSG_XON message will be sent and the RDE will produce more messages again.
|
2007-01-26 09:40:48 -08:00
|
|
|
*/
|
|
|
|
#define RDE_RUNNER_ROUNDS 100
|
2017-05-28 05:21:36 -07:00
|
|
|
#define SESS_MSG_HIGH_MARK 300
|
|
|
|
#define SESS_MSG_LOW_MARK 50
|
|
|
|
#define CTL_MSG_HIGH_MARK 500
|
|
|
|
#define CTL_MSG_LOW_MARK 100
|
2007-01-26 09:40:48 -08:00
|
|
|
|
2015-07-20 09:10:37 -07:00
|
|
|
enum bgpd_process {
|
2003-12-20 10:32:22 -08:00
|
|
|
PROC_MAIN,
|
|
|
|
PROC_SE,
|
|
|
|
PROC_RDE
|
|
|
|
} bgpd_process;
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
enum reconf_action {
|
|
|
|
RECONF_NONE,
|
|
|
|
RECONF_KEEP,
|
|
|
|
RECONF_REINIT,
|
2013-08-14 13:34:25 -07:00
|
|
|
RECONF_RELOAD,
|
2003-12-17 03:46:54 -08:00
|
|
|
RECONF_DELETE
|
|
|
|
};
|
|
|
|
|
2009-12-08 06:03:40 -08:00
|
|
|
/* Address Family Numbers as per RFC 1700 */
|
|
|
|
#define AFI_UNSPEC 0
|
|
|
|
#define AFI_IPv4 1
|
|
|
|
#define AFI_IPv6 2
|
|
|
|
|
|
|
|
/* Subsequent Address Family Identifier as per RFC 4760 */
|
2010-01-12 22:02:37 -08:00
|
|
|
#define SAFI_NONE 0
|
|
|
|
#define SAFI_UNICAST 1
|
|
|
|
#define SAFI_MULTICAST 2
|
|
|
|
#define SAFI_MPLS 4
|
|
|
|
#define SAFI_MPLSVPN 128
|
2009-12-08 06:03:40 -08:00
|
|
|
|
|
|
|
struct aid {
|
|
|
|
u_int16_t afi;
|
|
|
|
sa_family_t af;
|
|
|
|
u_int8_t safi;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct aid aid_vals[];
|
|
|
|
|
|
|
|
#define AID_UNSPEC 0
|
|
|
|
#define AID_INET 1
|
|
|
|
#define AID_INET6 2
|
2010-01-12 22:02:37 -08:00
|
|
|
#define AID_VPN_IPv4 3
|
|
|
|
#define AID_MAX 4
|
2012-09-11 22:56:22 -07:00
|
|
|
#define AID_MIN 1 /* skip AID_UNSPEC since that is a dummy */
|
2009-12-08 06:03:40 -08:00
|
|
|
|
|
|
|
#define AID_VALS { \
|
|
|
|
/* afi, af, safii, name */ \
|
|
|
|
{ AFI_UNSPEC, AF_UNSPEC, SAFI_NONE, "unspec"}, \
|
|
|
|
{ AFI_IPv4, AF_INET, SAFI_UNICAST, "IPv4 unicast" }, \
|
2010-01-12 22:02:37 -08:00
|
|
|
{ AFI_IPv6, AF_INET6, SAFI_UNICAST, "IPv6 unicast" }, \
|
|
|
|
{ AFI_IPv4, AF_INET, SAFI_MPLSVPN, "IPv4 vpn" } \
|
2009-12-08 06:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define AID_PTSIZE { \
|
|
|
|
0, \
|
2018-07-10 06:06:28 -07:00
|
|
|
sizeof(struct pt_entry4), \
|
2010-01-12 22:02:37 -08:00
|
|
|
sizeof(struct pt_entry6), \
|
|
|
|
sizeof(struct pt_entry_vpn4) \
|
2009-12-08 06:03:40 -08:00
|
|
|
}
|
|
|
|
|
2010-01-12 22:02:37 -08:00
|
|
|
struct vpn4_addr {
|
|
|
|
u_int64_t rd;
|
|
|
|
struct in_addr addr;
|
|
|
|
u_int8_t labelstack[21]; /* max that makes sense */
|
|
|
|
u_int8_t labellen;
|
|
|
|
u_int8_t pad1;
|
|
|
|
u_int8_t pad2;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BGP_MPLS_BOS 0x01
|
|
|
|
|
2004-01-04 10:51:23 -08:00
|
|
|
struct bgpd_addr {
|
|
|
|
union {
|
|
|
|
struct in_addr v4;
|
|
|
|
struct in6_addr v6;
|
2010-01-12 22:02:37 -08:00
|
|
|
struct vpn4_addr vpn4;
|
|
|
|
/* maximum size for a prefix is 256 bits */
|
|
|
|
u_int8_t addr8[32];
|
|
|
|
u_int16_t addr16[16];
|
|
|
|
u_int32_t addr32[8];
|
2004-01-04 10:51:23 -08:00
|
|
|
} ba; /* 128-bit address */
|
2004-02-16 09:24:04 -08:00
|
|
|
u_int32_t scope_id; /* iface scope id for v6 */
|
2010-01-12 22:02:37 -08:00
|
|
|
u_int8_t aid;
|
2004-07-05 09:54:53 -07:00
|
|
|
#define v4 ba.v4
|
|
|
|
#define v6 ba.v6
|
2010-01-12 22:02:37 -08:00
|
|
|
#define vpn4 ba.vpn4
|
2004-07-05 09:54:53 -07:00
|
|
|
#define addr8 ba.addr8
|
|
|
|
#define addr16 ba.addr16
|
|
|
|
#define addr32 ba.addr32
|
2004-01-04 10:51:23 -08:00
|
|
|
};
|
|
|
|
|
2004-07-05 09:54:53 -07:00
|
|
|
#define DEFAULT_LISTENER 0x01
|
|
|
|
#define LISTENER_LISTENING 0x02
|
2004-06-06 10:38:10 -07:00
|
|
|
|
|
|
|
struct listen_addr {
|
|
|
|
TAILQ_ENTRY(listen_addr) entry;
|
|
|
|
struct sockaddr_storage sa;
|
|
|
|
int fd;
|
|
|
|
enum reconf_action reconf;
|
|
|
|
u_int8_t flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
TAILQ_HEAD(listen_addrs, listen_addr);
|
2005-07-01 06:38:14 -07:00
|
|
|
TAILQ_HEAD(filter_set_head, filter_set);
|
2004-06-06 10:38:10 -07:00
|
|
|
|
2015-07-16 11:26:04 -07:00
|
|
|
struct rdomain;
|
|
|
|
SIMPLEQ_HEAD(rdomain_head, rdomain);
|
|
|
|
|
|
|
|
struct network;
|
|
|
|
TAILQ_HEAD(network_head, network);
|
|
|
|
|
2018-02-09 17:24:28 -08:00
|
|
|
struct prefixset;
|
|
|
|
SIMPLEQ_HEAD(prefixset_head, prefixset);
|
2018-09-07 03:49:22 -07:00
|
|
|
struct rde_prefixset_head;
|
|
|
|
struct rde_prefixset;
|
2018-02-09 17:24:28 -08:00
|
|
|
|
2018-09-06 22:43:33 -07:00
|
|
|
struct as_set;
|
|
|
|
SIMPLEQ_HEAD(as_set_head, as_set);
|
|
|
|
|
2015-07-16 11:26:04 -07:00
|
|
|
struct filter_rule;
|
|
|
|
TAILQ_HEAD(filter_head, filter_rule);
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
struct bgpd_config {
|
2015-07-16 11:26:04 -07:00
|
|
|
struct rdomain_head rdomains;
|
|
|
|
struct network_head networks;
|
|
|
|
struct filter_head *filters;
|
2004-12-23 07:08:43 -08:00
|
|
|
struct listen_addrs *listen_addrs;
|
2015-07-16 11:26:04 -07:00
|
|
|
struct mrt_head *mrt;
|
2018-02-09 17:24:28 -08:00
|
|
|
struct prefixset_head *prefixsets;
|
2018-09-07 03:49:22 -07:00
|
|
|
struct rde_prefixset_head *rde_prefixsets;
|
2018-09-06 22:43:33 -07:00
|
|
|
struct as_set_head *as_sets;
|
2006-03-15 03:33:42 -08:00
|
|
|
char *csock;
|
2006-01-24 02:03:44 -08:00
|
|
|
char *rcsock;
|
2004-12-23 07:08:43 -08:00
|
|
|
int flags;
|
|
|
|
int log;
|
2017-05-28 08:16:33 -07:00
|
|
|
u_int default_tableid;
|
2004-06-06 10:38:10 -07:00
|
|
|
u_int32_t bgpid;
|
|
|
|
u_int32_t clusterid;
|
2007-04-23 06:04:24 -07:00
|
|
|
u_int32_t as;
|
|
|
|
u_int16_t short_as;
|
2004-06-06 10:38:10 -07:00
|
|
|
u_int16_t holdtime;
|
|
|
|
u_int16_t min_holdtime;
|
2009-05-26 21:18:21 -07:00
|
|
|
u_int16_t connectretry;
|
2013-11-13 01:14:48 -08:00
|
|
|
u_int8_t fib_priority;
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2015-03-13 19:43:02 -07:00
|
|
|
extern int cmd_opts;
|
|
|
|
|
2018-06-13 02:33:51 -07:00
|
|
|
enum export_type {
|
|
|
|
EXPORT_UNSET,
|
|
|
|
EXPORT_NONE,
|
|
|
|
EXPORT_DEFAULT_ROUTE
|
2004-01-13 05:45:49 -08:00
|
|
|
};
|
|
|
|
|
2004-02-26 06:00:33 -08:00
|
|
|
enum enforce_as {
|
|
|
|
ENFORCE_AS_UNDEF,
|
|
|
|
ENFORCE_AS_OFF,
|
|
|
|
ENFORCE_AS_ON
|
|
|
|
};
|
|
|
|
|
2004-04-27 15:06:54 -07:00
|
|
|
enum auth_method {
|
2004-05-06 04:57:55 -07:00
|
|
|
AUTH_NONE,
|
|
|
|
AUTH_MD5SIG,
|
2004-04-27 17:38:39 -07:00
|
|
|
AUTH_IPSEC_MANUAL_ESP,
|
|
|
|
AUTH_IPSEC_MANUAL_AH,
|
2004-04-27 21:34:46 -07:00
|
|
|
AUTH_IPSEC_IKE_ESP,
|
|
|
|
AUTH_IPSEC_IKE_AH
|
2004-04-27 15:06:54 -07:00
|
|
|
};
|
2004-04-27 18:08:38 -07:00
|
|
|
|
2004-04-27 15:42:13 -07:00
|
|
|
struct peer_auth {
|
|
|
|
char md5key[TCP_MD5_KEY_LEN];
|
2004-12-23 07:08:43 -08:00
|
|
|
char auth_key_in[IPSEC_AUTH_KEY_LEN];
|
|
|
|
char auth_key_out[IPSEC_AUTH_KEY_LEN];
|
|
|
|
char enc_key_in[IPSEC_ENC_KEY_LEN];
|
|
|
|
char enc_key_out[IPSEC_ENC_KEY_LEN];
|
2004-04-27 15:06:54 -07:00
|
|
|
u_int32_t spi_in;
|
|
|
|
u_int32_t spi_out;
|
2004-12-23 07:08:43 -08:00
|
|
|
enum auth_method method;
|
|
|
|
u_int8_t md5key_len;
|
2004-04-27 15:06:54 -07:00
|
|
|
u_int8_t auth_alg_in;
|
|
|
|
u_int8_t auth_alg_out;
|
|
|
|
u_int8_t auth_keylen_in;
|
|
|
|
u_int8_t auth_keylen_out;
|
|
|
|
u_int8_t enc_alg_in;
|
|
|
|
u_int8_t enc_alg_out;
|
|
|
|
u_int8_t enc_keylen_in;
|
|
|
|
u_int8_t enc_keylen_out;
|
2004-04-25 18:59:26 -07:00
|
|
|
};
|
|
|
|
|
2004-11-18 09:07:38 -08:00
|
|
|
struct capabilities {
|
2012-09-11 22:56:22 -07:00
|
|
|
struct {
|
|
|
|
int16_t timeout; /* graceful restart timeout */
|
|
|
|
int8_t flags[AID_MAX]; /* graceful restart per AID flags */
|
|
|
|
int8_t restart; /* graceful restart, RFC 4724 */
|
|
|
|
} grestart;
|
|
|
|
int8_t mp[AID_MAX]; /* multiprotocol extensions, RFC 4760 */
|
|
|
|
int8_t refresh; /* route refresh, RFC 2918 */
|
|
|
|
int8_t as4byte; /* 4-byte ASnum, RFC 4893 */
|
2004-11-18 09:07:38 -08:00
|
|
|
};
|
|
|
|
|
2012-09-11 22:56:22 -07:00
|
|
|
#define CAPA_GR_PRESENT 0x01
|
|
|
|
#define CAPA_GR_RESTART 0x02
|
|
|
|
#define CAPA_GR_FORWARD 0x04
|
|
|
|
#define CAPA_GR_RESTARTING 0x08
|
|
|
|
|
|
|
|
#define CAPA_GR_TIMEMASK 0x0fff
|
|
|
|
#define CAPA_GR_R_FLAG 0x8000
|
|
|
|
#define CAPA_GR_F_FLAG 0x80
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
struct peer_config {
|
2004-01-27 08:49:53 -08:00
|
|
|
struct bgpd_addr remote_addr;
|
|
|
|
struct bgpd_addr local_addr;
|
2004-12-23 07:08:43 -08:00
|
|
|
struct peer_auth auth;
|
|
|
|
struct capabilities capabilities;
|
|
|
|
char group[PEER_DESCR_LEN];
|
|
|
|
char descr[PEER_DESCR_LEN];
|
2017-01-13 10:59:12 -08:00
|
|
|
char shutcomm[SHUT_COMM_LEN];
|
2009-06-05 12:52:32 -07:00
|
|
|
char rib[PEER_DESCR_LEN];
|
2004-12-23 07:08:43 -08:00
|
|
|
char if_depend[IFNAMSIZ];
|
2006-06-17 07:06:09 -07:00
|
|
|
char demote_group[IFNAMSIZ];
|
2004-12-23 07:08:43 -08:00
|
|
|
u_int32_t id;
|
|
|
|
u_int32_t groupid;
|
2007-04-23 06:04:24 -07:00
|
|
|
u_int32_t remote_as;
|
2009-03-18 12:41:41 -07:00
|
|
|
u_int32_t local_as;
|
2004-02-08 17:46:34 -08:00
|
|
|
u_int32_t max_prefix;
|
2018-06-13 02:33:51 -07:00
|
|
|
enum export_type export_type;
|
2004-02-26 06:00:33 -08:00
|
|
|
enum enforce_as enforce_as;
|
2017-05-27 11:12:23 -07:00
|
|
|
enum enforce_as enforce_local_as;
|
2004-12-23 07:08:43 -08:00
|
|
|
enum reconf_action reconf_action;
|
2006-08-04 05:01:48 -07:00
|
|
|
u_int16_t max_prefix_restart;
|
2004-12-23 07:39:22 -08:00
|
|
|
u_int16_t holdtime;
|
|
|
|
u_int16_t min_holdtime;
|
2009-03-18 12:41:41 -07:00
|
|
|
u_int16_t local_short_as;
|
2004-12-23 07:08:43 -08:00
|
|
|
u_int8_t template;
|
|
|
|
u_int8_t remote_masklen;
|
2012-04-12 10:31:05 -07:00
|
|
|
u_int8_t ebgp; /* 0 = ibgp else ebgp */
|
2004-12-23 07:08:43 -08:00
|
|
|
u_int8_t distance; /* 1 = direct, >1 = multihop */
|
|
|
|
u_int8_t passive;
|
2005-10-19 03:42:06 -07:00
|
|
|
u_int8_t down;
|
2004-11-18 09:07:38 -08:00
|
|
|
u_int8_t announce_capa;
|
2004-05-21 08:36:40 -07:00
|
|
|
u_int8_t reflector_client;
|
2006-12-05 04:08:13 -08:00
|
|
|
u_int8_t ttlsec; /* TTL security hack */
|
2009-03-22 15:34:59 -07:00
|
|
|
u_int8_t flags;
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2009-03-26 06:59:30 -07:00
|
|
|
#define PEERFLAG_TRANS_AS 0x01
|
2015-09-21 02:47:15 -07:00
|
|
|
#define PEERFLAG_LOG_UPDATES 0x02
|
2009-03-26 06:59:30 -07:00
|
|
|
|
2010-05-17 08:49:29 -07:00
|
|
|
enum network_type {
|
2018-07-10 05:40:41 -07:00
|
|
|
NETWORK_DEFAULT, /* from network statements */
|
2010-05-17 08:49:29 -07:00
|
|
|
NETWORK_STATIC,
|
2012-05-27 11:52:07 -07:00
|
|
|
NETWORK_CONNECTED,
|
2016-10-05 00:38:06 -07:00
|
|
|
NETWORK_RTLABEL,
|
2018-07-11 07:08:46 -07:00
|
|
|
NETWORK_MRTCLONE,
|
2018-09-08 08:25:27 -07:00
|
|
|
NETWORK_PRIORITY,
|
2010-05-17 08:49:29 -07:00
|
|
|
};
|
|
|
|
|
2004-01-17 11:35:35 -08:00
|
|
|
struct network_config {
|
2012-05-27 11:52:07 -07:00
|
|
|
struct bgpd_addr prefix;
|
|
|
|
struct filter_set_head attrset;
|
|
|
|
struct rde_aspath *asp;
|
|
|
|
u_int rtableid;
|
2016-10-05 00:38:06 -07:00
|
|
|
u_int16_t rtlabel;
|
2012-05-27 11:52:07 -07:00
|
|
|
enum network_type type;
|
|
|
|
u_int8_t prefixlen;
|
2018-07-11 07:08:46 -07:00
|
|
|
u_int8_t priority;
|
2012-05-27 11:52:07 -07:00
|
|
|
u_int8_t old; /* used for reloading */
|
2004-01-17 11:35:35 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct network {
|
2010-05-17 08:49:29 -07:00
|
|
|
struct network_config net;
|
|
|
|
TAILQ_ENTRY(network) entry;
|
2004-01-17 11:35:35 -08:00
|
|
|
};
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
enum imsg_type {
|
|
|
|
IMSG_NONE,
|
2004-01-04 11:39:46 -08:00
|
|
|
IMSG_CTL_END,
|
2004-01-05 08:21:14 -08:00
|
|
|
IMSG_CTL_RELOAD,
|
|
|
|
IMSG_CTL_FIB_COUPLE,
|
2004-01-06 15:14:58 -08:00
|
|
|
IMSG_CTL_FIB_DECOUPLE,
|
|
|
|
IMSG_CTL_NEIGHBOR_UP,
|
2004-01-09 05:47:07 -08:00
|
|
|
IMSG_CTL_NEIGHBOR_DOWN,
|
2004-08-20 08:49:02 -07:00
|
|
|
IMSG_CTL_NEIGHBOR_CLEAR,
|
2006-05-23 05:11:38 -07:00
|
|
|
IMSG_CTL_NEIGHBOR_RREFRESH,
|
2013-03-07 13:26:28 -08:00
|
|
|
IMSG_CTL_NEIGHBOR_DESTROY,
|
2004-01-09 11:08:50 -08:00
|
|
|
IMSG_CTL_KROUTE,
|
2004-01-10 18:35:13 -08:00
|
|
|
IMSG_CTL_KROUTE_ADDR,
|
2005-10-19 05:32:16 -07:00
|
|
|
IMSG_CTL_RESULT,
|
|
|
|
IMSG_CTL_SHOW_NEIGHBOR,
|
2004-01-17 10:05:46 -08:00
|
|
|
IMSG_CTL_SHOW_NEXTHOP,
|
2004-02-26 08:16:41 -08:00
|
|
|
IMSG_CTL_SHOW_INTERFACE,
|
|
|
|
IMSG_CTL_SHOW_RIB,
|
|
|
|
IMSG_CTL_SHOW_RIB_AS,
|
2004-04-26 20:53:42 -07:00
|
|
|
IMSG_CTL_SHOW_RIB_PREFIX,
|
2006-03-22 02:18:49 -08:00
|
|
|
IMSG_CTL_SHOW_RIB_ATTR,
|
2007-03-28 05:33:32 -07:00
|
|
|
IMSG_CTL_SHOW_RIB_COMMUNITY,
|
2017-08-10 07:12:34 -07:00
|
|
|
IMSG_CTL_SHOW_RIB_EXTCOMMUNITY,
|
2016-10-14 09:05:35 -07:00
|
|
|
IMSG_CTL_SHOW_RIB_LARGECOMMUNITY,
|
2004-05-21 04:48:56 -07:00
|
|
|
IMSG_CTL_SHOW_NETWORK,
|
2006-01-03 14:49:17 -08:00
|
|
|
IMSG_CTL_SHOW_RIB_MEM,
|
2018-07-11 09:34:36 -07:00
|
|
|
IMSG_CTL_SHOW_RIB_HASH,
|
2006-01-24 07:28:02 -08:00
|
|
|
IMSG_CTL_SHOW_TERSE,
|
2007-12-23 10:26:13 -08:00
|
|
|
IMSG_CTL_SHOW_TIMER,
|
2009-11-02 12:38:15 -08:00
|
|
|
IMSG_CTL_LOG_VERBOSE,
|
2010-05-03 06:09:38 -07:00
|
|
|
IMSG_CTL_SHOW_FIB_TABLES,
|
2009-06-06 14:35:32 -07:00
|
|
|
IMSG_NETWORK_ADD,
|
2012-05-27 11:52:07 -07:00
|
|
|
IMSG_NETWORK_ASPATH,
|
|
|
|
IMSG_NETWORK_ATTR,
|
2009-06-06 14:35:32 -07:00
|
|
|
IMSG_NETWORK_REMOVE,
|
|
|
|
IMSG_NETWORK_FLUSH,
|
|
|
|
IMSG_NETWORK_DONE,
|
|
|
|
IMSG_FILTER_SET,
|
2015-07-20 09:10:37 -07:00
|
|
|
IMSG_SOCKET_CONN,
|
|
|
|
IMSG_SOCKET_CONN_CTL,
|
2009-06-06 14:35:32 -07:00
|
|
|
IMSG_RECONF_CONF,
|
2009-06-06 17:30:23 -07:00
|
|
|
IMSG_RECONF_RIB,
|
2009-06-06 14:35:32 -07:00
|
|
|
IMSG_RECONF_PEER,
|
|
|
|
IMSG_RECONF_FILTER,
|
|
|
|
IMSG_RECONF_LISTENER,
|
2010-06-27 12:53:34 -07:00
|
|
|
IMSG_RECONF_CTRL,
|
2010-05-17 08:49:29 -07:00
|
|
|
IMSG_RECONF_RDOMAIN,
|
|
|
|
IMSG_RECONF_RDOMAIN_EXPORT,
|
|
|
|
IMSG_RECONF_RDOMAIN_IMPORT,
|
|
|
|
IMSG_RECONF_RDOMAIN_DONE,
|
2018-09-06 22:43:33 -07:00
|
|
|
IMSG_RECONF_PREFIXSET,
|
|
|
|
IMSG_RECONF_PREFIXSETITEM,
|
|
|
|
IMSG_RECONF_AS_SET,
|
|
|
|
IMSG_RECONF_AS_SET_ITEMS,
|
|
|
|
IMSG_RECONF_AS_SET_DONE,
|
2009-06-06 14:35:32 -07:00
|
|
|
IMSG_RECONF_DONE,
|
|
|
|
IMSG_UPDATE,
|
|
|
|
IMSG_UPDATE_ERR,
|
|
|
|
IMSG_SESSION_ADD,
|
|
|
|
IMSG_SESSION_UP,
|
|
|
|
IMSG_SESSION_DOWN,
|
2012-09-11 22:56:22 -07:00
|
|
|
IMSG_SESSION_STALE,
|
|
|
|
IMSG_SESSION_FLUSH,
|
|
|
|
IMSG_SESSION_RESTARTED,
|
2009-06-06 14:35:32 -07:00
|
|
|
IMSG_MRT_OPEN,
|
|
|
|
IMSG_MRT_REOPEN,
|
|
|
|
IMSG_MRT_CLOSE,
|
|
|
|
IMSG_KROUTE_CHANGE,
|
|
|
|
IMSG_KROUTE_DELETE,
|
|
|
|
IMSG_NEXTHOP_ADD,
|
|
|
|
IMSG_NEXTHOP_REMOVE,
|
|
|
|
IMSG_NEXTHOP_UPDATE,
|
|
|
|
IMSG_PFTABLE_ADD,
|
|
|
|
IMSG_PFTABLE_REMOVE,
|
|
|
|
IMSG_PFTABLE_COMMIT,
|
2004-10-19 05:02:49 -07:00
|
|
|
IMSG_REFRESH,
|
2006-06-17 07:06:09 -07:00
|
|
|
IMSG_IFINFO,
|
2017-05-28 05:21:36 -07:00
|
|
|
IMSG_DEMOTE,
|
|
|
|
IMSG_XON,
|
|
|
|
IMSG_XOFF
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2006-06-17 07:06:09 -07:00
|
|
|
struct demote_msg {
|
|
|
|
char demote_group[IFNAMSIZ];
|
|
|
|
int level;
|
|
|
|
};
|
|
|
|
|
2005-10-19 05:32:16 -07:00
|
|
|
enum ctl_results {
|
|
|
|
CTL_RES_OK,
|
2006-01-24 02:03:44 -08:00
|
|
|
CTL_RES_NOSUCHPEER,
|
2006-05-23 05:11:38 -07:00
|
|
|
CTL_RES_DENIED,
|
2006-05-27 14:24:36 -07:00
|
|
|
CTL_RES_NOCAP,
|
2007-01-26 09:40:48 -08:00
|
|
|
CTL_RES_PARSE_ERROR,
|
2012-09-18 02:45:50 -07:00
|
|
|
CTL_RES_PENDING,
|
2013-03-07 13:26:28 -08:00
|
|
|
CTL_RES_NOMEM,
|
|
|
|
CTL_RES_BADPEER,
|
|
|
|
CTL_RES_BADSTATE
|
2005-10-19 05:32:16 -07:00
|
|
|
};
|
|
|
|
|
2004-01-05 14:57:58 -08:00
|
|
|
/* needed for session.h parse prototype */
|
|
|
|
LIST_HEAD(mrt_head, mrt);
|
|
|
|
|
2004-02-16 04:53:15 -08:00
|
|
|
/* error codes and subcodes needed in SE and RDE */
|
|
|
|
enum err_codes {
|
|
|
|
ERR_HEADER = 1,
|
|
|
|
ERR_OPEN,
|
|
|
|
ERR_UPDATE,
|
|
|
|
ERR_HOLDTIMEREXPIRED,
|
|
|
|
ERR_FSM,
|
|
|
|
ERR_CEASE
|
|
|
|
};
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
enum suberr_update {
|
2004-01-13 05:34:56 -08:00
|
|
|
ERR_UPD_UNSPECIFIC,
|
|
|
|
ERR_UPD_ATTRLIST,
|
2003-12-17 03:46:54 -08:00
|
|
|
ERR_UPD_UNKNWN_WK_ATTR,
|
|
|
|
ERR_UPD_MISSNG_WK_ATTR,
|
|
|
|
ERR_UPD_ATTRFLAGS,
|
|
|
|
ERR_UPD_ATTRLEN,
|
|
|
|
ERR_UPD_ORIGIN,
|
|
|
|
ERR_UPD_LOOP,
|
|
|
|
ERR_UPD_NEXTHOP,
|
|
|
|
ERR_UPD_OPTATTR,
|
|
|
|
ERR_UPD_NETWORK,
|
|
|
|
ERR_UPD_ASPATH
|
|
|
|
};
|
|
|
|
|
2004-02-16 04:53:15 -08:00
|
|
|
enum suberr_cease {
|
|
|
|
ERR_CEASE_MAX_PREFIX = 1,
|
|
|
|
ERR_CEASE_ADMIN_DOWN,
|
|
|
|
ERR_CEASE_PEER_UNCONF,
|
|
|
|
ERR_CEASE_ADMIN_RESET,
|
|
|
|
ERR_CEASE_CONN_REJECT,
|
|
|
|
ERR_CEASE_OTHER_CHANGE,
|
|
|
|
ERR_CEASE_COLLISION,
|
|
|
|
ERR_CEASE_RSRC_EXHAUST
|
|
|
|
};
|
|
|
|
|
2010-05-03 06:09:38 -07:00
|
|
|
struct kroute_node;
|
|
|
|
struct kroute6_node;
|
|
|
|
struct knexthop_node;
|
|
|
|
RB_HEAD(kroute_tree, kroute_node);
|
|
|
|
RB_HEAD(kroute6_tree, kroute6_node);
|
|
|
|
RB_HEAD(knexthop_tree, knexthop_node);
|
|
|
|
|
|
|
|
struct ktable {
|
|
|
|
char descr[PEER_DESCR_LEN];
|
|
|
|
char ifmpe[IFNAMSIZ];
|
|
|
|
struct kroute_tree krt;
|
|
|
|
struct kroute6_tree krt6;
|
|
|
|
struct knexthop_tree knt;
|
|
|
|
struct network_head krn;
|
|
|
|
u_int rtableid;
|
|
|
|
u_int nhtableid; /* rdomain id for nexthop lookup */
|
|
|
|
u_int ifindex; /* ifindex of ifmpe */
|
|
|
|
int nhrefcnt; /* refcnt for nexthop table */
|
|
|
|
enum reconf_action state;
|
|
|
|
u_int8_t fib_conf; /* configured FIB sync flag */
|
|
|
|
u_int8_t fib_sync; /* is FIB synced with kernel? */
|
|
|
|
};
|
|
|
|
|
2010-04-13 02:09:48 -07:00
|
|
|
struct kroute_full {
|
|
|
|
struct bgpd_addr prefix;
|
|
|
|
struct bgpd_addr nexthop;
|
|
|
|
char label[RTLABEL_LEN];
|
2016-10-05 00:38:06 -07:00
|
|
|
u_int16_t labelid;
|
2010-04-13 02:09:48 -07:00
|
|
|
u_int16_t flags;
|
|
|
|
u_short ifindex;
|
|
|
|
u_int8_t prefixlen;
|
|
|
|
u_int8_t priority;
|
|
|
|
};
|
|
|
|
|
2003-12-22 07:22:13 -08:00
|
|
|
struct kroute {
|
2004-01-27 13:56:21 -08:00
|
|
|
struct in_addr prefix;
|
|
|
|
struct in_addr nexthop;
|
2010-05-17 08:49:29 -07:00
|
|
|
u_int32_t mplslabel;
|
2004-07-05 09:54:53 -07:00
|
|
|
u_int16_t flags;
|
2005-06-13 14:16:18 -07:00
|
|
|
u_int16_t labelid;
|
2004-01-09 05:47:07 -08:00
|
|
|
u_short ifindex;
|
2004-12-23 07:39:22 -08:00
|
|
|
u_int8_t prefixlen;
|
2008-12-12 15:15:12 -08:00
|
|
|
u_int8_t priority;
|
2003-12-22 07:22:13 -08:00
|
|
|
};
|
|
|
|
|
2004-06-22 00:22:31 -07:00
|
|
|
struct kroute6 {
|
|
|
|
struct in6_addr prefix;
|
|
|
|
struct in6_addr nexthop;
|
2004-07-05 09:54:53 -07:00
|
|
|
u_int16_t flags;
|
2005-06-13 14:16:18 -07:00
|
|
|
u_int16_t labelid;
|
2004-06-22 00:22:31 -07:00
|
|
|
u_short ifindex;
|
2004-12-23 07:39:22 -08:00
|
|
|
u_int8_t prefixlen;
|
2008-12-12 15:15:12 -08:00
|
|
|
u_int8_t priority;
|
2004-06-22 00:22:31 -07:00
|
|
|
};
|
|
|
|
|
2003-12-25 15:15:58 -08:00
|
|
|
struct kroute_nexthop {
|
2004-12-23 07:08:43 -08:00
|
|
|
struct bgpd_addr nexthop;
|
|
|
|
struct bgpd_addr gateway;
|
2010-04-06 06:25:08 -07:00
|
|
|
struct bgpd_addr net;
|
2004-12-23 07:08:43 -08:00
|
|
|
u_int8_t valid;
|
|
|
|
u_int8_t connected;
|
2010-04-06 06:25:08 -07:00
|
|
|
u_int8_t netlen;
|
2003-12-25 15:15:58 -08:00
|
|
|
};
|
|
|
|
|
2004-01-17 10:05:46 -08:00
|
|
|
struct kif {
|
2004-01-17 10:27:19 -08:00
|
|
|
char ifname[IFNAMSIZ];
|
2007-09-11 10:07:59 -07:00
|
|
|
u_int64_t baudrate;
|
2018-07-12 14:45:37 -07:00
|
|
|
u_int rdomain;
|
2004-12-23 07:08:43 -08:00
|
|
|
int flags;
|
|
|
|
u_short ifindex;
|
2015-09-16 13:25:41 -07:00
|
|
|
u_int8_t if_type;
|
2004-01-17 13:06:55 -08:00
|
|
|
u_int8_t link_state;
|
2004-01-21 19:07:51 -08:00
|
|
|
u_int8_t nh_reachable; /* for nexthop verification */
|
2004-01-17 10:05:46 -08:00
|
|
|
};
|
|
|
|
|
2004-01-11 12:13:00 -08:00
|
|
|
struct session_up {
|
|
|
|
struct bgpd_addr local_addr;
|
|
|
|
struct bgpd_addr remote_addr;
|
2009-12-08 06:03:40 -08:00
|
|
|
struct capabilities capa;
|
2004-12-23 07:39:22 -08:00
|
|
|
u_int32_t remote_bgpid;
|
2007-04-23 06:04:24 -07:00
|
|
|
u_int16_t short_as;
|
2004-01-11 12:13:00 -08:00
|
|
|
};
|
|
|
|
|
2004-05-07 03:06:15 -07:00
|
|
|
struct pftable_msg {
|
|
|
|
struct bgpd_addr addr;
|
2004-12-23 07:08:43 -08:00
|
|
|
char pftable[PFTABLE_LEN];
|
2004-05-07 03:06:15 -07:00
|
|
|
u_int8_t len;
|
|
|
|
};
|
|
|
|
|
2004-01-10 18:35:13 -08:00
|
|
|
struct ctl_show_nexthop {
|
|
|
|
struct bgpd_addr addr;
|
2005-03-14 04:25:50 -08:00
|
|
|
struct kif kif;
|
2009-07-23 07:53:18 -07:00
|
|
|
union {
|
|
|
|
struct kroute kr4;
|
|
|
|
struct kroute6 kr6;
|
|
|
|
} kr;
|
2009-07-20 08:03:16 -07:00
|
|
|
u_int8_t valid;
|
2010-10-24 10:20:08 -07:00
|
|
|
u_int8_t krvalid;
|
2004-01-10 18:35:13 -08:00
|
|
|
};
|
|
|
|
|
2004-12-23 09:26:51 -08:00
|
|
|
struct ctl_neighbor {
|
|
|
|
struct bgpd_addr addr;
|
|
|
|
char descr[PEER_DESCR_LEN];
|
2017-01-13 10:59:12 -08:00
|
|
|
char shutcomm[SHUT_COMM_LEN];
|
2007-12-23 10:26:13 -08:00
|
|
|
int show_timers;
|
2004-12-23 09:26:51 -08:00
|
|
|
};
|
|
|
|
|
2010-05-03 06:09:38 -07:00
|
|
|
#define F_PREF_ELIGIBLE 0x01
|
|
|
|
#define F_PREF_ACTIVE 0x02
|
|
|
|
#define F_PREF_INTERNAL 0x04
|
|
|
|
#define F_PREF_ANNOUNCE 0x08
|
2012-09-11 22:56:22 -07:00
|
|
|
#define F_PREF_STALE 0x10
|
2018-08-29 12:47:47 -07:00
|
|
|
#define F_PREF_INVALID 0x20
|
2004-02-26 08:16:41 -08:00
|
|
|
|
|
|
|
struct ctl_show_rib {
|
2006-06-14 10:08:56 -07:00
|
|
|
struct bgpd_addr true_nexthop;
|
|
|
|
struct bgpd_addr exit_nexthop;
|
2004-12-23 07:08:43 -08:00
|
|
|
struct bgpd_addr prefix;
|
2006-03-22 02:18:49 -08:00
|
|
|
struct bgpd_addr remote_addr;
|
|
|
|
char descr[PEER_DESCR_LEN];
|
2004-02-26 08:16:41 -08:00
|
|
|
time_t lastchange;
|
2006-03-22 02:18:49 -08:00
|
|
|
u_int32_t remote_id;
|
2004-02-26 08:16:41 -08:00
|
|
|
u_int32_t local_pref;
|
|
|
|
u_int32_t med;
|
2012-09-18 03:10:00 -07:00
|
|
|
u_int32_t weight;
|
2017-05-27 05:09:27 -07:00
|
|
|
u_int32_t flags;
|
2004-12-23 07:08:43 -08:00
|
|
|
u_int16_t aspath_len;
|
2004-02-26 08:16:41 -08:00
|
|
|
u_int8_t prefixlen;
|
|
|
|
u_int8_t origin;
|
|
|
|
/* plus a aspath_len bytes long aspath */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum as_spec {
|
|
|
|
AS_NONE,
|
|
|
|
AS_ALL,
|
|
|
|
AS_SOURCE,
|
|
|
|
AS_TRANSIT,
|
2007-03-06 08:52:48 -08:00
|
|
|
AS_PEER,
|
2004-02-26 08:16:41 -08:00
|
|
|
AS_EMPTY
|
|
|
|
};
|
|
|
|
|
2010-05-17 09:08:20 -07:00
|
|
|
enum aslen_spec {
|
|
|
|
ASLEN_NONE,
|
|
|
|
ASLEN_MAX,
|
|
|
|
ASLEN_SEQ
|
|
|
|
};
|
|
|
|
|
2018-09-06 22:43:33 -07:00
|
|
|
#define AS_FLAG_NEIGHBORAS 0x01
|
|
|
|
#define AS_FLAG_AS_SET_NAME 0x02
|
|
|
|
#define AS_FLAG_AS_SET 0x04
|
|
|
|
|
2004-11-19 06:43:56 -08:00
|
|
|
struct filter_as {
|
2018-09-06 22:43:33 -07:00
|
|
|
char name[SET_NAME_LEN];
|
|
|
|
struct as_set *aset;
|
|
|
|
u_int32_t as_min;
|
|
|
|
u_int32_t as_max;
|
|
|
|
enum as_spec type;
|
|
|
|
u_int8_t flags;
|
|
|
|
u_int8_t op;
|
2004-02-26 08:16:41 -08:00
|
|
|
};
|
|
|
|
|
2010-05-17 09:08:20 -07:00
|
|
|
struct filter_aslen {
|
|
|
|
u_int aslen;
|
|
|
|
enum aslen_spec type;
|
|
|
|
};
|
|
|
|
|
2018-02-09 17:24:28 -08:00
|
|
|
#define PREFIXSET_FLAG_FILTER 0x01
|
|
|
|
#define PREFIXSET_FLAG_DIRTY 0x02 /* prefix-set changed at reload */
|
2018-09-08 08:25:27 -07:00
|
|
|
#define PREFIXSET_FLAG_OPS 0x04 /* indiv. prefixes have prefixlenops */
|
|
|
|
#define PREFIXSET_FLAG_LONGER 0x08 /* filter all prefixes with or-longer */
|
2018-02-09 17:24:28 -08:00
|
|
|
|
|
|
|
struct filter_prefixset {
|
|
|
|
int flags;
|
2018-09-06 22:43:33 -07:00
|
|
|
char name[SET_NAME_LEN];
|
2018-09-07 03:49:22 -07:00
|
|
|
struct rde_prefixset *ps;
|
2018-02-09 17:24:28 -08:00
|
|
|
};
|
|
|
|
|
2007-03-28 05:33:32 -07:00
|
|
|
struct filter_community {
|
2010-05-17 09:08:20 -07:00
|
|
|
int as;
|
|
|
|
int type;
|
2007-03-28 05:33:32 -07:00
|
|
|
};
|
|
|
|
|
2016-10-14 09:05:35 -07:00
|
|
|
struct filter_largecommunity {
|
|
|
|
int64_t as;
|
|
|
|
int64_t ld1;
|
|
|
|
int64_t ld2;
|
|
|
|
};
|
|
|
|
|
2009-12-16 07:40:55 -08:00
|
|
|
struct filter_extcommunity {
|
2010-03-05 07:25:00 -08:00
|
|
|
u_int16_t flags;
|
2009-12-16 07:40:55 -08:00
|
|
|
u_int8_t type;
|
|
|
|
u_int8_t subtype; /* if extended type */
|
|
|
|
union {
|
|
|
|
struct ext_as {
|
|
|
|
u_int16_t as;
|
|
|
|
u_int32_t val;
|
|
|
|
} ext_as;
|
|
|
|
struct ext_as4 {
|
|
|
|
u_int32_t as4;
|
|
|
|
u_int16_t val;
|
|
|
|
} ext_as4;
|
|
|
|
struct ext_ip {
|
|
|
|
struct in_addr addr;
|
|
|
|
u_int16_t val;
|
|
|
|
} ext_ip;
|
|
|
|
u_int64_t ext_opaq; /* only 48 bits */
|
|
|
|
} data;
|
|
|
|
};
|
|
|
|
|
2006-06-15 03:04:40 -07:00
|
|
|
struct ctl_show_rib_request {
|
2009-06-05 23:04:10 -07:00
|
|
|
char rib[PEER_DESCR_LEN];
|
2006-08-23 01:13:04 -07:00
|
|
|
struct ctl_neighbor neighbor;
|
2006-06-15 03:04:40 -07:00
|
|
|
struct bgpd_addr prefix;
|
|
|
|
struct filter_as as;
|
2007-03-28 05:33:32 -07:00
|
|
|
struct filter_community community;
|
2017-08-10 07:12:34 -07:00
|
|
|
struct filter_extcommunity extcommunity;
|
2016-10-14 09:05:35 -07:00
|
|
|
struct filter_largecommunity large_community;
|
2006-08-23 01:13:04 -07:00
|
|
|
u_int32_t peerid;
|
2018-08-29 12:47:47 -07:00
|
|
|
u_int32_t flags;
|
2006-06-15 03:04:40 -07:00
|
|
|
pid_t pid;
|
2007-01-26 09:40:48 -08:00
|
|
|
enum imsg_type type;
|
2006-06-15 03:04:40 -07:00
|
|
|
u_int8_t prefixlen;
|
2010-01-09 16:15:09 -08:00
|
|
|
u_int8_t aid;
|
2006-06-15 03:04:40 -07:00
|
|
|
};
|
|
|
|
|
2004-02-06 12:18:18 -08:00
|
|
|
enum filter_actions {
|
|
|
|
ACTION_NONE,
|
|
|
|
ACTION_ALLOW,
|
|
|
|
ACTION_DENY
|
|
|
|
};
|
|
|
|
|
|
|
|
enum directions {
|
2004-12-23 07:39:22 -08:00
|
|
|
DIR_IN = 1,
|
2005-11-01 02:58:29 -08:00
|
|
|
DIR_OUT
|
2004-02-06 12:18:18 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum from_spec {
|
|
|
|
FROM_ALL,
|
|
|
|
FROM_ADDRESS,
|
|
|
|
FROM_DESCR,
|
|
|
|
FROM_GROUP
|
|
|
|
};
|
|
|
|
|
|
|
|
enum comp_ops {
|
|
|
|
OP_NONE,
|
|
|
|
OP_RANGE,
|
2004-02-24 07:43:03 -08:00
|
|
|
OP_XRANGE,
|
2004-02-06 12:18:18 -08:00
|
|
|
OP_EQ,
|
|
|
|
OP_NE,
|
|
|
|
OP_LE,
|
|
|
|
OP_LT,
|
|
|
|
OP_GE,
|
|
|
|
OP_GT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct filter_peers {
|
|
|
|
u_int32_t peerid;
|
|
|
|
u_int32_t groupid;
|
2015-04-25 08:28:18 -07:00
|
|
|
u_int32_t remote_as;
|
2009-06-05 18:10:29 -07:00
|
|
|
u_int16_t ribid;
|
2017-08-12 09:47:50 -07:00
|
|
|
u_int8_t ebgp;
|
|
|
|
u_int8_t ibgp;
|
2004-02-06 12:18:18 -08:00
|
|
|
};
|
|
|
|
|
2004-03-11 09:12:51 -08:00
|
|
|
/* special community type */
|
2004-07-05 09:54:53 -07:00
|
|
|
#define COMMUNITY_ERROR -1
|
|
|
|
#define COMMUNITY_ANY -2
|
2006-02-02 06:06:05 -08:00
|
|
|
#define COMMUNITY_NEIGHBOR_AS -3
|
2017-05-27 03:24:44 -07:00
|
|
|
#define COMMUNITY_LOCAL_AS -4
|
|
|
|
#define COMMUNITY_UNSET -5
|
2004-07-05 09:54:53 -07:00
|
|
|
#define COMMUNITY_WELLKNOWN 0xffff
|
2017-06-26 03:05:57 -07:00
|
|
|
#define COMMUNITY_GRACEFUL_SHUTDOWN 0x0000 /* draft-ietf-grow-bgp-gshut */
|
2017-05-27 02:26:42 -07:00
|
|
|
#define COMMUNITY_BLACKHOLE 0x029A /* RFC 7999 */
|
2004-07-05 09:54:53 -07:00
|
|
|
#define COMMUNITY_NO_EXPORT 0xff01
|
|
|
|
#define COMMUNITY_NO_ADVERTISE 0xff02
|
|
|
|
#define COMMUNITY_NO_EXPSUBCONFED 0xff03
|
2007-03-16 07:06:57 -07:00
|
|
|
#define COMMUNITY_NO_PEER 0xff04 /* RFC 3765 */
|
2004-03-11 09:12:51 -08:00
|
|
|
|
2008-01-23 00:11:32 -08:00
|
|
|
/* extended community definitions */
|
|
|
|
#define EXT_COMMUNITY_IANA 0x80
|
|
|
|
#define EXT_COMMUNITY_TRANSITIVE 0x40
|
|
|
|
#define EXT_COMMUNITY_VALUE 0x3f
|
2017-05-31 03:44:00 -07:00
|
|
|
/* extended types transitive */
|
|
|
|
#define EXT_COMMUNITY_TRANS_TWO_AS 0x00 /* 2 octet AS specific */
|
|
|
|
#define EXT_COMMUNITY_TRANS_IPV4 0x01 /* IPv4 specific */
|
|
|
|
#define EXT_COMMUNITY_TRANS_FOUR_AS 0x02 /* 4 octet AS specific */
|
|
|
|
#define EXT_COMMUNITY_TRANS_OPAQUE 0x03 /* opaque ext community */
|
|
|
|
#define EXT_COMMUNITY_TRANS_EVPN 0x06 /* EVPN RFC7432 */
|
|
|
|
/* extended types non-transitive */
|
|
|
|
#define EXT_COMMUNITY_NON_TRANS_TWO_AS 0x40 /* 2 octet AS specific */
|
|
|
|
#define EXT_COMMUNITY_NON_TRANS_IPV4 0x41 /* IPv4 specific */
|
|
|
|
#define EXT_COMMUNITY_NON_TRANS_FOUR_AS 0x42 /* 4 octet AS specific */
|
|
|
|
#define EXT_COMMUNITY_NON_TRANS_OPAQUE 0x43 /* opaque ext community */
|
|
|
|
|
|
|
|
/* BGP Origin Validation State Extended Community RFC8097 */
|
|
|
|
#define EXT_COMMUNITY_OVS_VALID 0
|
|
|
|
#define EXT_COMMUNITY_OVS_NOTFOUND 1
|
|
|
|
#define EXT_COMMUNITY_OVS_INVALID 2
|
|
|
|
|
2009-12-16 07:40:55 -08:00
|
|
|
/* other handy defines */
|
|
|
|
#define EXT_COMMUNITY_OPAQUE_MAX 0xffffffffffffULL
|
2010-03-05 07:25:00 -08:00
|
|
|
#define EXT_COMMUNITY_FLAG_VALID 0x01
|
2009-12-16 07:40:55 -08:00
|
|
|
|
|
|
|
struct ext_comm_pairs {
|
|
|
|
u_int8_t type;
|
|
|
|
u_int8_t subtype;
|
2017-05-31 03:44:00 -07:00
|
|
|
const char *subname;
|
2009-12-16 07:40:55 -08:00
|
|
|
};
|
|
|
|
|
2017-05-31 03:44:00 -07:00
|
|
|
#define IANA_EXT_COMMUNITIES { \
|
|
|
|
{ EXT_COMMUNITY_TRANS_TWO_AS, 0x02, "rt" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_TWO_AS, 0x03, "soo" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_TWO_AS, 0x05, "odi" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_TWO_AS, 0x08, "bdc" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_TWO_AS, 0x09, "srcas" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_TWO_AS, 0x0a, "l2vid" }, \
|
|
|
|
\
|
|
|
|
{ EXT_COMMUNITY_TRANS_FOUR_AS, 0x02, "rt" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_FOUR_AS, 0x03, "soo" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_FOUR_AS, 0x05, "odi" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_FOUR_AS, 0x08, "bdc" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_FOUR_AS, 0x09, "srcas" }, \
|
|
|
|
\
|
|
|
|
{ EXT_COMMUNITY_TRANS_IPV4, 0x02, "rt" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_IPV4, 0x03, "soo" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_IPV4, 0x05, "odi" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_IPV4, 0x07, "ori" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_IPV4, 0x0a, "l2vid" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_IPV4, 0x0b, "vrfri" }, \
|
|
|
|
\
|
|
|
|
{ EXT_COMMUNITY_TRANS_OPAQUE, 0x06, "ort" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_OPAQUE, 0x0d, "defgw" }, \
|
|
|
|
\
|
|
|
|
{ EXT_COMMUNITY_NON_TRANS_OPAQUE, 0x00, "ovs" }, \
|
|
|
|
\
|
|
|
|
{ EXT_COMMUNITY_TRANS_EVPN, 0x00, "mac-mob" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_EVPN, 0x01, "esi-lab" }, \
|
|
|
|
{ EXT_COMMUNITY_TRANS_EVPN, 0x02, "esi-rt" }, \
|
2017-08-06 05:28:31 -07:00
|
|
|
\
|
2017-08-06 06:23:12 -07:00
|
|
|
{ 0 } \
|
2009-12-16 07:40:55 -08:00
|
|
|
}
|
2008-01-23 00:11:32 -08:00
|
|
|
|
2017-05-31 03:44:00 -07:00
|
|
|
extern const struct ext_comm_pairs iana_ext_comms[];
|
2008-01-23 00:11:32 -08:00
|
|
|
|
2004-07-27 08:26:45 -07:00
|
|
|
struct filter_prefix {
|
|
|
|
struct bgpd_addr addr;
|
2013-10-19 08:04:25 -07:00
|
|
|
u_int8_t op;
|
2004-07-27 08:26:45 -07:00
|
|
|
u_int8_t len;
|
2013-10-19 08:04:25 -07:00
|
|
|
u_int8_t len_min;
|
|
|
|
u_int8_t len_max;
|
2004-07-27 08:26:45 -07:00
|
|
|
};
|
|
|
|
|
2012-11-13 01:47:20 -08:00
|
|
|
struct filter_nexthop {
|
|
|
|
struct bgpd_addr addr;
|
|
|
|
u_int8_t flags;
|
|
|
|
#define FILTER_NEXTHOP_ADDR 1
|
|
|
|
#define FILTER_NEXTHOP_NEIGHBOR 2
|
|
|
|
};
|
|
|
|
|
2004-02-06 12:18:18 -08:00
|
|
|
struct filter_match {
|
2010-03-05 07:25:00 -08:00
|
|
|
struct filter_prefix prefix;
|
2012-11-13 01:47:20 -08:00
|
|
|
struct filter_nexthop nexthop;
|
2010-03-05 07:25:00 -08:00
|
|
|
struct filter_as as;
|
2010-05-17 09:08:20 -07:00
|
|
|
struct filter_aslen aslen;
|
2010-03-05 07:25:00 -08:00
|
|
|
struct filter_community community;
|
2016-10-14 09:05:35 -07:00
|
|
|
struct filter_largecommunity large_community;
|
2010-03-05 07:25:00 -08:00
|
|
|
struct filter_extcommunity ext_community;
|
2018-02-09 17:24:28 -08:00
|
|
|
struct filter_prefixset prefixset;
|
2004-02-06 12:18:18 -08:00
|
|
|
};
|
|
|
|
|
2015-11-06 08:23:26 -08:00
|
|
|
union filter_rule_ptr {
|
|
|
|
struct filter_rule *ptr;
|
|
|
|
u_int32_t nr;
|
|
|
|
};
|
|
|
|
|
2004-02-06 12:18:18 -08:00
|
|
|
struct filter_rule {
|
2004-06-20 11:35:11 -07:00
|
|
|
TAILQ_ENTRY(filter_rule) entry;
|
2009-06-05 18:10:29 -07:00
|
|
|
char rib[PEER_DESCR_LEN];
|
2004-02-06 12:18:18 -08:00
|
|
|
struct filter_peers peer;
|
|
|
|
struct filter_match match;
|
2004-11-23 05:07:01 -08:00
|
|
|
struct filter_set_head set;
|
2015-11-06 08:23:26 -08:00
|
|
|
#define RDE_FILTER_SKIP_DIR 0
|
|
|
|
#define RDE_FILTER_SKIP_GROUPID 1
|
|
|
|
#define RDE_FILTER_SKIP_REMOTE_AS 2
|
|
|
|
#define RDE_FILTER_SKIP_PEERID 3
|
|
|
|
#define RDE_FILTER_SKIP_COUNT 4
|
|
|
|
union filter_rule_ptr skip[RDE_FILTER_SKIP_COUNT];
|
2004-12-23 07:08:43 -08:00
|
|
|
enum filter_actions action;
|
|
|
|
enum directions dir;
|
|
|
|
u_int8_t quick;
|
2004-11-23 05:07:01 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum action_types {
|
|
|
|
ACTION_SET_LOCALPREF,
|
2005-03-14 09:32:04 -08:00
|
|
|
ACTION_SET_RELATIVE_LOCALPREF,
|
2004-11-23 05:07:01 -08:00
|
|
|
ACTION_SET_MED,
|
2005-03-14 09:32:04 -08:00
|
|
|
ACTION_SET_RELATIVE_MED,
|
2005-04-12 07:32:00 -07:00
|
|
|
ACTION_SET_WEIGHT,
|
|
|
|
ACTION_SET_RELATIVE_WEIGHT,
|
2004-11-23 05:07:01 -08:00
|
|
|
ACTION_SET_PREPEND_SELF,
|
|
|
|
ACTION_SET_PREPEND_PEER,
|
|
|
|
ACTION_SET_NEXTHOP,
|
|
|
|
ACTION_SET_NEXTHOP_REJECT,
|
|
|
|
ACTION_SET_NEXTHOP_BLACKHOLE,
|
2005-03-11 04:54:19 -08:00
|
|
|
ACTION_SET_NEXTHOP_NOMODIFY,
|
2006-04-04 05:03:26 -07:00
|
|
|
ACTION_SET_NEXTHOP_SELF,
|
2004-11-23 05:07:01 -08:00
|
|
|
ACTION_SET_COMMUNITY,
|
2006-02-09 13:05:09 -08:00
|
|
|
ACTION_DEL_COMMUNITY,
|
2016-10-14 09:05:35 -07:00
|
|
|
ACTION_DEL_LARGE_COMMUNITY,
|
|
|
|
ACTION_SET_LARGE_COMMUNITY,
|
2009-12-16 07:40:55 -08:00
|
|
|
ACTION_SET_EXT_COMMUNITY,
|
|
|
|
ACTION_DEL_EXT_COMMUNITY,
|
2005-06-29 02:43:25 -07:00
|
|
|
ACTION_PFTABLE,
|
2005-07-01 02:19:24 -07:00
|
|
|
ACTION_PFTABLE_ID,
|
2005-06-29 02:43:25 -07:00
|
|
|
ACTION_RTLABEL,
|
2009-11-26 05:40:43 -08:00
|
|
|
ACTION_RTLABEL_ID,
|
|
|
|
ACTION_SET_ORIGIN
|
2004-11-23 05:07:01 -08:00
|
|
|
};
|
|
|
|
|
2018-06-25 07:28:33 -07:00
|
|
|
struct nexthop;
|
2004-11-23 05:07:01 -08:00
|
|
|
struct filter_set {
|
2005-07-01 06:38:14 -07:00
|
|
|
TAILQ_ENTRY(filter_set) entry;
|
2004-11-23 05:07:01 -08:00
|
|
|
union {
|
2018-06-25 07:28:33 -07:00
|
|
|
u_int8_t prepend;
|
|
|
|
u_int16_t id;
|
|
|
|
u_int32_t metric;
|
|
|
|
int32_t relative;
|
|
|
|
struct bgpd_addr nexthop;
|
|
|
|
struct nexthop *nh;
|
|
|
|
struct filter_community community;
|
|
|
|
struct filter_largecommunity large_community;
|
|
|
|
struct filter_extcommunity ext_community;
|
|
|
|
char pftable[PFTABLE_LEN];
|
|
|
|
char rtlabel[RTLABEL_LEN];
|
|
|
|
u_int8_t origin;
|
2004-11-23 05:07:01 -08:00
|
|
|
} action;
|
2004-12-23 07:08:43 -08:00
|
|
|
enum action_types type;
|
2004-02-06 12:18:18 -08:00
|
|
|
};
|
|
|
|
|
2018-02-09 17:24:28 -08:00
|
|
|
struct prefixset_item {
|
|
|
|
struct filter_prefix p;
|
|
|
|
SIMPLEQ_ENTRY(prefixset_item) entry;
|
|
|
|
};
|
|
|
|
SIMPLEQ_HEAD(prefixset_items_h, prefixset_item);
|
|
|
|
|
|
|
|
struct prefixset {
|
|
|
|
int sflags;
|
2018-09-06 22:43:33 -07:00
|
|
|
char name[SET_NAME_LEN];
|
2018-02-09 17:24:28 -08:00
|
|
|
struct prefixset_items_h psitems;
|
|
|
|
SIMPLEQ_ENTRY(prefixset) entry;
|
|
|
|
};
|
|
|
|
|
2010-05-17 08:49:29 -07:00
|
|
|
struct rdomain {
|
|
|
|
SIMPLEQ_ENTRY(rdomain) entry;
|
|
|
|
char descr[PEER_DESCR_LEN];
|
|
|
|
char ifmpe[IFNAMSIZ];
|
|
|
|
struct filter_set_head import;
|
|
|
|
struct filter_set_head export;
|
|
|
|
struct network_head net_l;
|
|
|
|
u_int64_t rd;
|
|
|
|
u_int rtableid;
|
|
|
|
u_int label;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
2009-06-03 21:46:42 -07:00
|
|
|
struct rde_rib {
|
|
|
|
SIMPLEQ_ENTRY(rde_rib) entry;
|
|
|
|
char name[PEER_DESCR_LEN];
|
2010-05-03 06:09:38 -07:00
|
|
|
u_int rtableid;
|
2009-06-03 21:46:42 -07:00
|
|
|
u_int16_t id;
|
|
|
|
u_int16_t flags;
|
|
|
|
};
|
|
|
|
SIMPLEQ_HEAD(rib_names, rde_rib);
|
|
|
|
extern struct rib_names ribnames;
|
|
|
|
|
2010-05-03 06:09:38 -07:00
|
|
|
/* rde_rib flags */
|
2017-01-24 16:11:07 -08:00
|
|
|
#define F_RIB_LOCAL 0x0001
|
2010-05-03 06:09:38 -07:00
|
|
|
#define F_RIB_NOEVALUATE 0x0002
|
|
|
|
#define F_RIB_NOFIB 0x0004
|
|
|
|
#define F_RIB_NOFIBSYNC 0x0008
|
|
|
|
#define F_RIB_HASNOFIB (F_RIB_NOFIB | F_RIB_NOEVALUATE)
|
|
|
|
|
2007-04-23 06:04:24 -07:00
|
|
|
/* 4-byte magic AS number */
|
|
|
|
#define AS_TRANS 23456
|
|
|
|
|
2009-12-01 06:28:05 -08:00
|
|
|
struct rde_memstats {
|
|
|
|
int64_t path_cnt;
|
|
|
|
int64_t prefix_cnt;
|
|
|
|
int64_t rib_cnt;
|
|
|
|
int64_t pt_cnt[AID_MAX];
|
|
|
|
int64_t nexthop_cnt;
|
|
|
|
int64_t aspath_cnt;
|
|
|
|
int64_t aspath_size;
|
|
|
|
int64_t aspath_refs;
|
|
|
|
int64_t attr_cnt;
|
|
|
|
int64_t attr_refs;
|
|
|
|
int64_t attr_data;
|
|
|
|
int64_t attr_dcnt;
|
|
|
|
};
|
|
|
|
|
2018-07-11 09:34:36 -07:00
|
|
|
struct rde_hashstats {
|
|
|
|
char name[16];
|
|
|
|
int64_t num;
|
|
|
|
int64_t min;
|
|
|
|
int64_t max;
|
|
|
|
int64_t sum;
|
|
|
|
int64_t sumq;
|
|
|
|
};
|
|
|
|
|
2011-09-18 02:31:25 -07:00
|
|
|
#define MRT_FILE_LEN 512
|
|
|
|
#define MRT2MC(x) ((struct mrt_config *)(x))
|
|
|
|
#define MRT_MAX_TIMEOUT 7200
|
|
|
|
|
|
|
|
enum mrt_type {
|
|
|
|
MRT_NONE,
|
|
|
|
MRT_TABLE_DUMP,
|
|
|
|
MRT_TABLE_DUMP_MP,
|
|
|
|
MRT_TABLE_DUMP_V2,
|
|
|
|
MRT_ALL_IN,
|
|
|
|
MRT_ALL_OUT,
|
|
|
|
MRT_UPDATE_IN,
|
|
|
|
MRT_UPDATE_OUT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum mrt_state {
|
|
|
|
MRT_STATE_RUNNING,
|
|
|
|
MRT_STATE_OPEN,
|
|
|
|
MRT_STATE_REOPEN,
|
|
|
|
MRT_STATE_REMOVE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mrt {
|
|
|
|
char rib[PEER_DESCR_LEN];
|
|
|
|
struct msgbuf wbuf;
|
|
|
|
LIST_ENTRY(mrt) entry;
|
|
|
|
u_int32_t peer_id;
|
|
|
|
u_int32_t group_id;
|
|
|
|
enum mrt_type type;
|
|
|
|
enum mrt_state state;
|
|
|
|
u_int16_t seqnum;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mrt_config {
|
|
|
|
struct mrt conf;
|
|
|
|
char name[MRT_FILE_LEN]; /* base file name */
|
|
|
|
char file[MRT_FILE_LEN]; /* actual file name */
|
|
|
|
time_t ReopenTimer;
|
2013-05-11 07:42:28 -07:00
|
|
|
int ReopenTimerInterval;
|
2011-09-18 02:31:25 -07:00
|
|
|
};
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
/* prototypes */
|
2003-12-25 16:14:04 -08:00
|
|
|
/* bgpd.c */
|
|
|
|
void send_nexthop_update(struct kroute_nexthop *);
|
2004-01-09 05:47:07 -08:00
|
|
|
void send_imsg_session(int, pid_t, void *, u_int16_t);
|
2010-05-17 08:49:29 -07:00
|
|
|
int send_network(int, struct network_config *,
|
|
|
|
struct filter_set_head *);
|
2006-03-22 05:30:35 -08:00
|
|
|
int bgpd_filternexthop(struct kroute *, struct kroute6 *);
|
2015-07-20 09:10:37 -07:00
|
|
|
void set_pollfd(struct pollfd *, struct imsgbuf *);
|
|
|
|
int handle_pollfd(struct pollfd *, struct imsgbuf *);
|
2003-12-25 16:14:04 -08:00
|
|
|
|
2011-09-18 02:31:25 -07:00
|
|
|
/* control.c */
|
|
|
|
void control_cleanup(const char *);
|
|
|
|
int control_imsg_relay(struct imsg *);
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2004-02-10 15:10:23 -08:00
|
|
|
/* config.c */
|
2015-07-16 11:26:04 -07:00
|
|
|
struct bgpd_config *new_config(void);
|
2018-02-09 17:24:28 -08:00
|
|
|
void free_config(struct bgpd_config *);
|
|
|
|
void free_prefixsets(struct prefixset_head *);
|
2015-03-13 20:52:42 -07:00
|
|
|
void filterlist_free(struct filter_head *);
|
|
|
|
int host(const char *, struct bgpd_addr *, u_int8_t *);
|
2004-02-10 15:10:23 -08:00
|
|
|
|
2003-12-22 07:22:13 -08:00
|
|
|
/* kroute.c */
|
2010-05-03 06:09:38 -07:00
|
|
|
int kr_init(void);
|
2013-11-13 01:14:48 -08:00
|
|
|
int ktable_update(u_int, char *, char *, int, u_int8_t);
|
2010-05-03 06:09:38 -07:00
|
|
|
void ktable_preload(void);
|
2013-11-13 01:14:48 -08:00
|
|
|
void ktable_postload(u_int8_t);
|
2010-05-03 06:09:38 -07:00
|
|
|
int ktable_exists(u_int, u_int *);
|
2013-11-13 01:14:48 -08:00
|
|
|
int kr_change(u_int, struct kroute_full *, u_int8_t);
|
|
|
|
int kr_delete(u_int, struct kroute_full *, u_int8_t);
|
2018-07-14 05:32:35 -07:00
|
|
|
void kr_shutdown(u_int8_t, u_int);
|
2013-11-13 01:14:48 -08:00
|
|
|
void kr_fib_couple(u_int, u_int8_t);
|
|
|
|
void kr_fib_couple_all(u_int8_t);
|
|
|
|
void kr_fib_decouple(u_int, u_int8_t);
|
|
|
|
void kr_fib_decouple_all(u_int8_t);
|
|
|
|
void kr_fib_update_prio_all(u_int8_t);
|
2018-07-14 05:32:35 -07:00
|
|
|
int kr_dispatch_msg(u_int rdomain);
|
2017-05-28 08:16:33 -07:00
|
|
|
int kr_nexthop_add(u_int32_t, struct bgpd_addr *,
|
|
|
|
struct bgpd_config *);
|
|
|
|
void kr_nexthop_delete(u_int32_t, struct bgpd_addr *,
|
|
|
|
struct bgpd_config *);
|
2004-06-25 13:08:46 -07:00
|
|
|
void kr_show_route(struct imsg *);
|
2004-10-19 05:02:49 -07:00
|
|
|
void kr_ifinfo(char *);
|
2010-05-03 06:09:38 -07:00
|
|
|
int kr_net_reload(u_int, struct network_head *);
|
2006-03-22 05:30:35 -08:00
|
|
|
int kr_reload(void);
|
2004-06-25 13:08:46 -07:00
|
|
|
struct in6_addr *prefixlen2mask6(u_int8_t prefixlen);
|
2004-06-22 13:28:58 -07:00
|
|
|
|
2011-09-18 02:31:25 -07:00
|
|
|
/* log.c */
|
2017-05-28 13:14:15 -07:00
|
|
|
void log_peer_info(const struct peer_config *, const char *, ...)
|
|
|
|
__attribute__((__format__ (printf, 2, 3)));
|
2016-06-06 08:59:10 -07:00
|
|
|
void log_peer_warn(const struct peer_config *, const char *, ...)
|
|
|
|
__attribute__((__format__ (printf, 2, 3)));
|
|
|
|
void log_peer_warnx(const struct peer_config *, const char *, ...)
|
|
|
|
__attribute__((__format__ (printf, 2, 3)));
|
2004-01-01 15:46:47 -08:00
|
|
|
|
2011-09-18 02:31:25 -07:00
|
|
|
/* mrt.c */
|
|
|
|
void mrt_clear_seq(void);
|
|
|
|
void mrt_write(struct mrt *);
|
|
|
|
void mrt_clean(struct mrt *);
|
|
|
|
void mrt_init(struct imsgbuf *, struct imsgbuf *);
|
|
|
|
int mrt_timeout(struct mrt_head *);
|
|
|
|
void mrt_reconfigure(struct mrt_head *);
|
|
|
|
void mrt_handler(struct mrt_head *);
|
|
|
|
struct mrt *mrt_get(struct mrt_head *, struct mrt *);
|
|
|
|
int mrt_mergeconfig(struct mrt_head *, struct mrt_head *);
|
2004-05-07 03:06:15 -07:00
|
|
|
|
2005-06-25 12:24:37 -07:00
|
|
|
/* name2id.c */
|
2009-05-17 05:25:15 -07:00
|
|
|
u_int16_t rib_name2id(const char *);
|
|
|
|
const char *rib_id2name(u_int16_t);
|
|
|
|
void rib_unref(u_int16_t);
|
|
|
|
void rib_ref(u_int16_t);
|
2005-11-02 07:34:43 -08:00
|
|
|
u_int16_t rtlabel_name2id(const char *);
|
2005-06-25 12:24:37 -07:00
|
|
|
const char *rtlabel_id2name(u_int16_t);
|
|
|
|
void rtlabel_unref(u_int16_t);
|
2018-06-29 04:45:50 -07:00
|
|
|
u_int16_t rtlabel_ref(u_int16_t);
|
2005-11-02 07:34:43 -08:00
|
|
|
u_int16_t pftable_name2id(const char *);
|
2005-07-01 02:19:24 -07:00
|
|
|
const char *pftable_id2name(u_int16_t);
|
|
|
|
void pftable_unref(u_int16_t);
|
2018-06-29 04:45:50 -07:00
|
|
|
u_int16_t pftable_ref(u_int16_t);
|
2005-07-01 02:19:24 -07:00
|
|
|
|
2011-09-18 02:31:25 -07:00
|
|
|
/* parse.y */
|
2018-02-09 17:24:28 -08:00
|
|
|
int cmdline_symset(char *);
|
|
|
|
struct prefixset *find_prefixset(char *, struct prefixset_head *);
|
2011-09-18 02:31:25 -07:00
|
|
|
|
|
|
|
/* pftable.c */
|
|
|
|
int pftable_exists(const char *);
|
|
|
|
int pftable_add(const char *);
|
|
|
|
int pftable_clear_all(void);
|
|
|
|
int pftable_addr_add(struct pftable_msg *);
|
|
|
|
int pftable_addr_remove(struct pftable_msg *);
|
|
|
|
int pftable_commit(void);
|
2005-06-29 02:43:25 -07:00
|
|
|
|
|
|
|
/* rde_filter.c */
|
2005-07-04 02:37:24 -07:00
|
|
|
void filterset_free(struct filter_set_head *);
|
|
|
|
int filterset_cmp(struct filter_set *, struct filter_set *);
|
2011-05-01 05:56:04 -07:00
|
|
|
void filterset_move(struct filter_set_head *,
|
|
|
|
struct filter_set_head *);
|
2006-04-26 10:13:14 -07:00
|
|
|
const char *filterset_name(enum action_types);
|
2005-06-25 12:24:37 -07:00
|
|
|
|
2018-09-06 22:43:33 -07:00
|
|
|
/* rde_sets.c */
|
|
|
|
void as_sets_insert(struct as_set_head *, struct as_set *);
|
|
|
|
struct as_set *as_sets_lookup(struct as_set_head *, const char *);
|
|
|
|
void as_sets_free(struct as_set_head *);
|
|
|
|
void print_as_sets(struct as_set_head *);
|
|
|
|
int as_sets_send(struct imsgbuf *, struct as_set_head *);
|
|
|
|
void as_sets_mark_dirty(struct as_set_head *, struct as_set_head *);
|
|
|
|
|
|
|
|
struct as_set *as_set_new(const char *, size_t);
|
|
|
|
int as_set_add(struct as_set *, u_int32_t *, size_t);
|
|
|
|
void as_set_prep(struct as_set *);
|
|
|
|
int as_set_match(const struct as_set *, u_int32_t);
|
|
|
|
int as_set_equal(const struct as_set *, const struct as_set *);
|
|
|
|
int as_set_dirty(const struct as_set *);
|
|
|
|
|
2006-01-03 14:19:59 -08:00
|
|
|
/* util.c */
|
|
|
|
const char *log_addr(const struct bgpd_addr *);
|
|
|
|
const char *log_in6addr(const struct in6_addr *);
|
2007-04-23 06:04:24 -07:00
|
|
|
const char *log_sockaddr(struct sockaddr *);
|
|
|
|
const char *log_as(u_int32_t);
|
2010-03-29 02:04:43 -07:00
|
|
|
const char *log_rd(u_int64_t);
|
2017-05-31 03:44:00 -07:00
|
|
|
const char *log_ext_subtype(u_int8_t, u_int8_t);
|
2017-01-13 10:59:12 -08:00
|
|
|
const char *log_shutcomm(const char *);
|
2006-01-03 14:19:59 -08:00
|
|
|
int aspath_snprint(char *, size_t, void *, u_int16_t);
|
|
|
|
int aspath_asprint(char **, void *, u_int16_t);
|
|
|
|
size_t aspath_strlen(void *, u_int16_t);
|
2016-06-03 10:36:37 -07:00
|
|
|
int aspath_match(void *, u_int16_t, struct filter_as *, u_int32_t);
|
2011-09-20 14:19:06 -07:00
|
|
|
u_int32_t aspath_extract(const void *, int);
|
2018-07-20 07:58:20 -07:00
|
|
|
int aspath_verify(void *, u_int16_t, int);
|
|
|
|
#define AS_ERR_LEN -1
|
|
|
|
#define AS_ERR_TYPE -2
|
|
|
|
#define AS_ERR_BAD -3
|
|
|
|
#define AS_ERR_SOFT -4
|
|
|
|
u_char *aspath_inflate(void *, u_int16_t, u_int16_t *);
|
|
|
|
int nlri_get_prefix(u_char *, u_int16_t, struct bgpd_addr *,
|
|
|
|
u_int8_t *);
|
|
|
|
int nlri_get_prefix6(u_char *, u_int16_t, struct bgpd_addr *,
|
|
|
|
u_int8_t *);
|
|
|
|
int nlri_get_vpn4(u_char *, u_int16_t, struct bgpd_addr *,
|
|
|
|
u_int8_t *, int);
|
2011-09-20 14:19:06 -07:00
|
|
|
int prefix_compare(const struct bgpd_addr *,
|
|
|
|
const struct bgpd_addr *, int);
|
2009-06-12 09:42:53 -07:00
|
|
|
in_addr_t prefixlen2mask(u_int8_t);
|
2018-09-04 05:00:29 -07:00
|
|
|
void inet4applymask(struct in_addr *, const struct in_addr *, int);
|
2009-06-12 09:42:53 -07:00
|
|
|
void inet6applymask(struct in6_addr *, const struct in6_addr *,
|
|
|
|
int);
|
2009-12-08 06:03:40 -08:00
|
|
|
const char *aid2str(u_int8_t);
|
2009-12-01 06:28:05 -08:00
|
|
|
int aid2afi(u_int8_t, u_int16_t *, u_int8_t *);
|
|
|
|
int afi2aid(u_int16_t, u_int8_t, u_int8_t *);
|
|
|
|
sa_family_t aid2af(u_int8_t);
|
|
|
|
int af2aid(sa_family_t, u_int8_t, u_int8_t *);
|
|
|
|
struct sockaddr *addr2sa(struct bgpd_addr *, u_int16_t);
|
|
|
|
void sa2addr(struct sockaddr *, struct bgpd_addr *);
|
2018-07-22 09:52:27 -07:00
|
|
|
uint64_t ift2ifm(uint8_t);
|
|
|
|
const char * get_media_descr(uint64_t);
|
|
|
|
const char * get_linkstate(uint8_t, int);
|
|
|
|
const char * get_baudrate(u_int64_t, char *);
|
2005-06-25 12:24:37 -07:00
|
|
|
|
2016-09-02 07:00:29 -07:00
|
|
|
static const char * const log_procnames[] = {
|
|
|
|
"parent",
|
|
|
|
"SE",
|
|
|
|
"RDE"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* logmsg.c and needed by bgpctl */
|
|
|
|
static const char * const statenames[] = {
|
|
|
|
"None",
|
|
|
|
"Idle",
|
|
|
|
"Connect",
|
|
|
|
"Active",
|
|
|
|
"OpenSent",
|
|
|
|
"OpenConfirm",
|
|
|
|
"Established"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const msgtypenames[] = {
|
|
|
|
"NONE",
|
|
|
|
"OPEN",
|
|
|
|
"UPDATE",
|
|
|
|
"NOTIFICATION",
|
|
|
|
"KEEPALIVE",
|
|
|
|
"RREFRESH"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const eventnames[] = {
|
|
|
|
"None",
|
|
|
|
"Start",
|
|
|
|
"Stop",
|
|
|
|
"Connection opened",
|
|
|
|
"Connection closed",
|
|
|
|
"Connection open failed",
|
|
|
|
"Fatal error",
|
|
|
|
"ConnectRetryTimer expired",
|
|
|
|
"HoldTimer expired",
|
|
|
|
"KeepaliveTimer expired",
|
|
|
|
"OPEN message received",
|
|
|
|
"KEEPALIVE message received",
|
|
|
|
"UPDATE message received",
|
|
|
|
"NOTIFICATION received"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const errnames[] = {
|
|
|
|
"none",
|
|
|
|
"Header error",
|
|
|
|
"error in OPEN message",
|
|
|
|
"error in UPDATE message",
|
|
|
|
"HoldTimer expired",
|
|
|
|
"Finite State Machine error",
|
|
|
|
"Cease"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const suberr_header_names[] = {
|
|
|
|
"none",
|
|
|
|
"synchronization error",
|
|
|
|
"wrong length",
|
|
|
|
"unknown message type"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const suberr_open_names[] = {
|
|
|
|
"none",
|
|
|
|
"version mismatch",
|
|
|
|
"AS unacceptable",
|
|
|
|
"BGPID invalid",
|
|
|
|
"optional parameter error",
|
|
|
|
"authentication error",
|
|
|
|
"unacceptable holdtime",
|
|
|
|
"unsupported capability",
|
|
|
|
"group membership conflict", /* draft-ietf-idr-bgp-multisession-07 */
|
|
|
|
"group membership required" /* draft-ietf-idr-bgp-multisession-07 */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const suberr_fsm_names[] = {
|
|
|
|
"unspecified error",
|
|
|
|
"received unexpected message in OpenSent",
|
|
|
|
"received unexpected message in OpenConfirm",
|
|
|
|
"received unexpected message in Established"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const suberr_update_names[] = {
|
|
|
|
"none",
|
|
|
|
"attribute list error",
|
|
|
|
"unknown well-known attribute",
|
|
|
|
"well-known attribute missing",
|
|
|
|
"attribute flags error",
|
|
|
|
"attribute length wrong",
|
|
|
|
"origin unacceptable",
|
|
|
|
"loop detected",
|
|
|
|
"nexthop unacceptable",
|
|
|
|
"optional attribute error",
|
|
|
|
"network unacceptable",
|
|
|
|
"AS-Path unacceptable"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const suberr_cease_names[] = {
|
|
|
|
"none",
|
|
|
|
"max-prefix exceeded",
|
|
|
|
"administratively down",
|
|
|
|
"peer unconfigured",
|
|
|
|
"administrative reset",
|
|
|
|
"connection rejected",
|
|
|
|
"other config change",
|
|
|
|
"collision",
|
|
|
|
"resource exhaustion"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const ctl_res_strerror[] = {
|
|
|
|
"no error",
|
|
|
|
"no such neighbor",
|
|
|
|
"permission denied",
|
|
|
|
"neighbor does not have this capability",
|
|
|
|
"config file has errors, reload failed",
|
|
|
|
"previous reload still running",
|
|
|
|
"out of memory",
|
|
|
|
"not a cloned peer",
|
|
|
|
"peer still active, down peer first"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const timernames[] = {
|
|
|
|
"None",
|
|
|
|
"ConnectRetryTimer",
|
|
|
|
"KeepaliveTimer",
|
|
|
|
"HoldTimer",
|
|
|
|
"IdleHoldTimer",
|
|
|
|
"IdleHoldResetTimer",
|
|
|
|
"CarpUndemoteTimer",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
#endif /* __BGPD_H__ */
|