2024-09-25 07:46:51 -07:00
|
|
|
/* $OpenBSD: rde.h,v 1.306 2024/09/25 14:46:51 claudio Exp $ */
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
/*
|
2004-01-06 02:51:14 -08:00
|
|
|
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
|
2012-10-28 06:16:11 -07:00
|
|
|
* Andre Oppermann <oppermann@networx.ch>
|
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 __RDE_H__
|
|
|
|
#define __RDE_H__
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/queue.h>
|
2004-01-10 08:20:29 -08:00
|
|
|
#include <sys/tree.h>
|
2017-01-24 15:38:12 -08:00
|
|
|
#include <stdint.h>
|
2018-10-25 08:49:42 -07:00
|
|
|
#include <stddef.h>
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
#include "bgpd.h"
|
2018-02-04 19:55:54 -08:00
|
|
|
#include "log.h"
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
/* rde internal structures */
|
|
|
|
|
|
|
|
enum peer_state {
|
|
|
|
PEER_NONE,
|
|
|
|
PEER_DOWN,
|
2004-01-13 05:34:56 -08:00
|
|
|
PEER_UP,
|
2004-07-13 10:57:20 -07:00
|
|
|
PEER_ERR /* error occurred going to PEER_DOWN state */
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2018-10-24 01:26:37 -07:00
|
|
|
LIST_HEAD(prefix_list, prefix);
|
2022-03-22 03:53:08 -07:00
|
|
|
TAILQ_HEAD(prefix_queue, prefix);
|
2018-10-24 01:26:37 -07:00
|
|
|
RB_HEAD(rib_tree, rib_entry);
|
|
|
|
|
|
|
|
struct rib_entry {
|
|
|
|
RB_ENTRY(rib_entry) rib_e;
|
2022-03-22 03:53:08 -07:00
|
|
|
struct prefix_queue prefix_h;
|
2018-10-24 01:26:37 -07:00
|
|
|
struct pt_entry *prefix;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint16_t rib_id;
|
|
|
|
uint16_t lock;
|
2018-10-24 01:26:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rib {
|
|
|
|
struct rib_tree tree;
|
2019-08-14 00:39:04 -07:00
|
|
|
char name[PEER_DESCR_LEN];
|
|
|
|
struct filter_head *in_rules;
|
|
|
|
struct filter_head *in_rules_tmp;
|
2018-10-24 01:26:37 -07:00
|
|
|
u_int rtableid;
|
2019-08-07 03:26:41 -07:00
|
|
|
u_int rtableid_tmp;
|
2021-07-27 00:50:01 -07:00
|
|
|
enum reconf_action state, fibstate;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint16_t id;
|
|
|
|
uint16_t flags;
|
|
|
|
uint16_t flags_tmp;
|
2018-10-24 01:26:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define RIB_ADJ_IN 0
|
2019-07-17 03:13:26 -07:00
|
|
|
#define RIB_LOC_START 1
|
2018-10-24 01:26:37 -07:00
|
|
|
#define RIB_NOTFOUND 0xffff
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
/*
|
|
|
|
* How do we identify peers between the session handler and the rde?
|
|
|
|
* Currently I assume that we can do that with the neighbor_ip...
|
|
|
|
*/
|
2022-09-01 06:23:24 -07:00
|
|
|
RB_HEAD(peer_tree, rde_peer);
|
2019-01-20 18:07:56 -08:00
|
|
|
RB_HEAD(prefix_tree, prefix);
|
2019-07-17 03:13:26 -07:00
|
|
|
RB_HEAD(prefix_index, prefix);
|
2019-12-31 23:25:04 -08:00
|
|
|
struct iq;
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
struct rde_peer {
|
2022-09-01 06:23:24 -07:00
|
|
|
RB_ENTRY(rde_peer) entry;
|
2019-12-31 23:25:04 -08:00
|
|
|
SIMPLEQ_HEAD(, iq) imsg_queue;
|
2004-01-10 08:20:29 -08:00
|
|
|
struct peer_config conf;
|
2023-02-09 05:43:23 -08:00
|
|
|
struct rde_peer_stats stats;
|
2004-01-11 12:13:00 -08:00
|
|
|
struct bgpd_addr remote_addr;
|
2004-11-11 05:06:44 -08:00
|
|
|
struct bgpd_addr local_v4_addr;
|
|
|
|
struct bgpd_addr local_v6_addr;
|
2018-07-31 08:30:04 -07:00
|
|
|
struct capabilities capa;
|
2022-07-11 10:08:21 -07:00
|
|
|
struct addpath_eval eval;
|
2019-07-17 03:13:26 -07:00
|
|
|
struct prefix_index adj_rib_out;
|
2019-01-20 18:07:56 -08:00
|
|
|
struct prefix_tree updates[AID_MAX];
|
|
|
|
struct prefix_tree withdraws[AID_MAX];
|
2023-03-09 23:57:15 -08:00
|
|
|
struct filter_head *out_rules;
|
2019-01-20 18:07:56 -08:00
|
|
|
time_t staletime[AID_MAX];
|
2024-05-22 01:41:14 -07:00
|
|
|
uint32_t remote_bgpid;
|
2022-09-21 03:39:17 -07:00
|
|
|
uint32_t path_id_tx;
|
2023-10-16 03:25:45 -07:00
|
|
|
unsigned int local_if_scope;
|
2004-12-23 07:08:43 -08:00
|
|
|
enum peer_state state;
|
2021-05-06 02:18:54 -07:00
|
|
|
enum export_type export_type;
|
2023-01-24 03:28:41 -08:00
|
|
|
enum role role;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint16_t loc_rib_id;
|
|
|
|
uint16_t short_as;
|
|
|
|
uint16_t mrt_idx;
|
|
|
|
uint8_t recv_eor; /* bitfield per AID */
|
|
|
|
uint8_t sent_eor; /* bitfield per AID */
|
|
|
|
uint8_t reconf_out; /* out filter changed */
|
|
|
|
uint8_t reconf_rib; /* rib changed */
|
|
|
|
uint8_t throttled;
|
|
|
|
uint8_t flags;
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2023-01-17 08:09:01 -08:00
|
|
|
struct rde_aspa;
|
2023-01-24 03:28:41 -08:00
|
|
|
struct rde_aspa_state {
|
2023-08-16 01:26:35 -07:00
|
|
|
uint8_t onlyup;
|
|
|
|
uint8_t downup;
|
2023-01-24 03:28:41 -08:00
|
|
|
};
|
2023-01-17 08:09:01 -08:00
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
#define AS_SET 1
|
|
|
|
#define AS_SEQUENCE 2
|
2010-11-18 04:18:31 -08:00
|
|
|
#define AS_CONFED_SEQUENCE 3
|
|
|
|
#define AS_CONFED_SET 4
|
2018-10-25 08:49:42 -07:00
|
|
|
#define ASPATH_HEADER_SIZE (offsetof(struct aspath, data))
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
struct aspath {
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t source_as; /* cached source_as */
|
|
|
|
uint16_t len; /* total length of aspath in octets */
|
|
|
|
uint16_t ascnt; /* number of AS hops in data */
|
2004-09-28 08:48:52 -07:00
|
|
|
u_char data[1]; /* placeholder for actual data */
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum attrtypes {
|
|
|
|
ATTR_UNDEF,
|
|
|
|
ATTR_ORIGIN,
|
|
|
|
ATTR_ASPATH,
|
|
|
|
ATTR_NEXTHOP,
|
|
|
|
ATTR_MED,
|
|
|
|
ATTR_LOCALPREF,
|
|
|
|
ATTR_ATOMIC_AGGREGATE,
|
2004-03-11 09:12:51 -08:00
|
|
|
ATTR_AGGREGATOR,
|
2004-05-21 08:36:40 -07:00
|
|
|
ATTR_COMMUNITIES,
|
|
|
|
ATTR_ORIGINATOR_ID,
|
2004-06-24 16:15:58 -07:00
|
|
|
ATTR_CLUSTER_LIST,
|
|
|
|
ATTR_MP_REACH_NLRI=14,
|
2007-04-23 06:04:24 -07:00
|
|
|
ATTR_MP_UNREACH_NLRI=15,
|
2008-01-23 00:11:32 -08:00
|
|
|
ATTR_EXT_COMMUNITIES=16,
|
2009-01-13 13:35:16 -08:00
|
|
|
ATTR_AS4_PATH=17,
|
2016-10-14 09:05:35 -07:00
|
|
|
ATTR_AS4_AGGREGATOR=18,
|
2016-10-27 01:21:58 -07:00
|
|
|
ATTR_LARGE_COMMUNITIES=32,
|
2022-06-27 06:26:51 -07:00
|
|
|
ATTR_OTC=35,
|
2019-05-31 02:46:31 -07:00
|
|
|
ATTR_FIRST_UNKNOWN, /* after this all attributes are unknown */
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* attribute flags. 4 low order bits reserved */
|
|
|
|
#define ATTR_EXTLEN 0x10
|
|
|
|
#define ATTR_PARTIAL 0x20
|
|
|
|
#define ATTR_TRANSITIVE 0x40
|
|
|
|
#define ATTR_OPTIONAL 0x80
|
2012-08-12 07:24:56 -07:00
|
|
|
#define ATTR_RESERVED 0x0f
|
|
|
|
/* by default mask the reserved bits and the ext len bit */
|
|
|
|
#define ATTR_DEFMASK (ATTR_RESERVED | ATTR_EXTLEN)
|
2003-12-17 03:46:54 -08:00
|
|
|
|
|
|
|
/* default attribute flags for well known attributes */
|
2004-01-10 08:20:29 -08:00
|
|
|
#define ATTR_WELL_KNOWN ATTR_TRANSITIVE
|
|
|
|
|
|
|
|
struct attr {
|
2022-08-31 07:29:36 -07:00
|
|
|
RB_ENTRY(attr) entry;
|
2004-12-23 07:08:43 -08:00
|
|
|
u_char *data;
|
2006-01-05 08:00:07 -08:00
|
|
|
int refcnt;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint16_t len;
|
|
|
|
uint8_t flags;
|
|
|
|
uint8_t type;
|
2004-08-06 05:04:08 -07:00
|
|
|
};
|
|
|
|
|
2019-06-17 04:02:19 -07:00
|
|
|
struct rde_community {
|
2022-08-29 09:44:47 -07:00
|
|
|
RB_ENTRY(rde_community) entry;
|
|
|
|
int size;
|
|
|
|
int nentries;
|
2019-06-17 04:02:19 -07:00
|
|
|
int flags;
|
|
|
|
int refcnt;
|
2019-06-17 06:35:42 -07:00
|
|
|
struct community *communities;
|
2019-06-17 04:02:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define PARTIAL_COMMUNITIES 0x01
|
|
|
|
#define PARTIAL_LARGE_COMMUNITIES 0x02
|
|
|
|
#define PARTIAL_EXT_COMMUNITIES 0x04
|
|
|
|
|
2007-04-23 06:04:24 -07:00
|
|
|
#define F_ATTR_ORIGIN 0x00001
|
|
|
|
#define F_ATTR_ASPATH 0x00002
|
|
|
|
#define F_ATTR_NEXTHOP 0x00004
|
|
|
|
#define F_ATTR_LOCALPREF 0x00008
|
|
|
|
#define F_ATTR_MED 0x00010
|
|
|
|
#define F_ATTR_MED_ANNOUNCE 0x00020
|
|
|
|
#define F_ATTR_MP_REACH 0x00040
|
|
|
|
#define F_ATTR_MP_UNREACH 0x00080
|
2009-01-13 13:35:16 -08:00
|
|
|
#define F_ATTR_AS4BYTE_NEW 0x00100 /* AS4_PATH or AS4_AGGREGATOR */
|
2007-11-26 17:13:54 -08:00
|
|
|
#define F_ATTR_LOOP 0x00200 /* path would cause a route loop */
|
2009-05-17 07:45:25 -07:00
|
|
|
#define F_PREFIX_ANNOUNCED 0x00400
|
|
|
|
#define F_ANN_DYNAMIC 0x00800
|
2022-06-27 06:26:51 -07:00
|
|
|
#define F_ATTR_OTC 0x01000 /* OTC present */
|
2023-03-13 09:52:41 -07:00
|
|
|
#define F_ATTR_OTC_LEAK 0x02000 /* otc leak, not eligible */
|
2022-12-28 13:30:15 -08:00
|
|
|
#define F_ATTR_PARSE_ERR 0x10000 /* parse error, not eligible */
|
2018-02-06 16:02:02 -08:00
|
|
|
#define F_ATTR_LINKED 0x20000 /* if set path is on various lists */
|
2006-01-14 14:39:49 -08:00
|
|
|
|
2004-01-10 08:20:29 -08:00
|
|
|
#define ORIGIN_IGP 0
|
|
|
|
#define ORIGIN_EGP 1
|
|
|
|
#define ORIGIN_INCOMPLETE 2
|
|
|
|
|
2004-07-28 09:02:14 -07:00
|
|
|
#define DEFAULT_LPREF 100
|
|
|
|
|
2004-08-06 05:04:08 -07:00
|
|
|
struct rde_aspath {
|
2022-08-29 09:43:07 -07:00
|
|
|
RB_ENTRY(rde_aspath) entry;
|
2006-01-05 08:00:07 -08:00
|
|
|
struct attr **others;
|
2003-12-17 03:46:54 -08:00
|
|
|
struct aspath *aspath;
|
2023-01-24 03:28:41 -08:00
|
|
|
struct rde_aspa_state aspa_state;
|
2020-01-09 07:50:34 -08:00
|
|
|
int refcnt;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t flags; /* internally used */
|
|
|
|
uint32_t med; /* multi exit disc */
|
|
|
|
uint32_t lpref; /* local pref */
|
|
|
|
uint32_t weight; /* low prio lpref */
|
|
|
|
uint16_t rtlabelid; /* route label id */
|
|
|
|
uint16_t pftableid; /* pf table id */
|
|
|
|
uint8_t origin;
|
|
|
|
uint8_t others_len;
|
2023-01-24 03:28:41 -08:00
|
|
|
uint8_t aspa_generation;
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum nexthop_state {
|
2003-12-25 15:22:13 -08:00
|
|
|
NEXTHOP_LOOKUP,
|
2003-12-17 03:46:54 -08:00
|
|
|
NEXTHOP_UNREACH,
|
2019-06-20 06:18:19 -07:00
|
|
|
NEXTHOP_REACH,
|
2022-08-03 01:56:23 -07:00
|
|
|
NEXTHOP_FLAPPED /* only used by oldstate */
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2003-12-26 13:30:20 -08:00
|
|
|
struct nexthop {
|
2022-08-30 11:50:21 -07:00
|
|
|
RB_ENTRY(nexthop) entry;
|
2019-06-20 06:18:19 -07:00
|
|
|
TAILQ_ENTRY(nexthop) runner_l;
|
2018-08-03 09:31:22 -07:00
|
|
|
struct prefix_list prefix_h;
|
2019-06-20 06:18:19 -07:00
|
|
|
struct prefix *next_prefix;
|
2004-12-23 07:08:43 -08:00
|
|
|
struct bgpd_addr exit_nexthop;
|
|
|
|
struct bgpd_addr true_nexthop;
|
|
|
|
struct bgpd_addr nexthop_net;
|
2003-12-26 13:30:20 -08:00
|
|
|
#if 0
|
2004-01-17 11:35:35 -08:00
|
|
|
/*
|
|
|
|
* currently we use the boolean nexthop state, this could be exchanged
|
2004-06-24 16:15:58 -07:00
|
|
|
* with a variable cost with a max for unreachable.
|
2004-01-17 11:35:35 -08:00
|
|
|
*/
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t costs;
|
2003-12-26 13:30:20 -08:00
|
|
|
#endif
|
2018-06-25 07:28:33 -07:00
|
|
|
int refcnt;
|
2004-08-06 05:04:08 -07:00
|
|
|
enum nexthop_state state;
|
2019-06-20 06:18:19 -07:00
|
|
|
enum nexthop_state oldstate;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint8_t nexthop_netlen;
|
|
|
|
uint8_t flags;
|
2004-08-06 05:04:08 -07:00
|
|
|
#define NEXTHOP_CONNECTED 0x01
|
2003-12-17 03:46:54 -08:00
|
|
|
};
|
|
|
|
|
2004-06-22 13:28:58 -07:00
|
|
|
/* generic entry without address specific part */
|
2003-12-17 03:46:54 -08:00
|
|
|
struct pt_entry {
|
2004-06-22 13:28:58 -07:00
|
|
|
RB_ENTRY(pt_entry) pt_e;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint8_t aid;
|
|
|
|
uint8_t prefixlen;
|
2023-03-30 05:11:18 -07:00
|
|
|
uint16_t len;
|
|
|
|
uint32_t refcnt;
|
2023-03-28 06:30:31 -07:00
|
|
|
uint8_t data[4]; /* data depending on aid */
|
2018-12-30 05:53:07 -08:00
|
|
|
};
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
struct prefix {
|
2019-07-17 03:13:26 -07:00
|
|
|
union {
|
|
|
|
struct {
|
2022-03-22 03:53:08 -07:00
|
|
|
TAILQ_ENTRY(prefix) rib;
|
|
|
|
LIST_ENTRY(prefix) nexthop;
|
2021-07-27 00:50:01 -07:00
|
|
|
struct rib_entry *re;
|
2019-07-17 03:13:26 -07:00
|
|
|
} list;
|
|
|
|
struct {
|
|
|
|
RB_ENTRY(prefix) index, update;
|
|
|
|
} tree;
|
|
|
|
} entry;
|
2019-06-21 22:44:05 -07:00
|
|
|
struct pt_entry *pt;
|
2018-06-27 06:14:44 -07:00
|
|
|
struct rde_aspath *aspath;
|
2019-06-17 04:02:19 -07:00
|
|
|
struct rde_community *communities;
|
2018-06-27 06:14:44 -07:00
|
|
|
struct rde_peer *peer;
|
2018-08-03 09:31:22 -07:00
|
|
|
struct nexthop *nexthop; /* may be NULL */
|
2003-12-17 03:46:54 -08:00
|
|
|
time_t lastchange;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t path_id;
|
|
|
|
uint32_t path_id_tx;
|
2024-08-14 12:09:51 -07:00
|
|
|
uint16_t flags;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint8_t validation_state;
|
|
|
|
uint8_t nhflags;
|
2022-07-07 05:16:04 -07:00
|
|
|
int8_t dmetric; /* decision metric */
|
2024-08-14 12:09:51 -07:00
|
|
|
};
|
|
|
|
#define PREFIX_FLAG_WITHDRAW 0x0001 /* enqueued on withdraw queue */
|
|
|
|
#define PREFIX_FLAG_UPDATE 0x0002 /* enqueued on update queue */
|
|
|
|
#define PREFIX_FLAG_DEAD 0x0004 /* locked but removed */
|
|
|
|
#define PREFIX_FLAG_STALE 0x0008 /* stale entry (graceful reload) */
|
|
|
|
#define PREFIX_FLAG_MASK 0x000f /* mask for the prefix types */
|
|
|
|
#define PREFIX_FLAG_ADJOUT 0x0010 /* prefix is in the adj-out rib */
|
|
|
|
#define PREFIX_FLAG_EOR 0x0020 /* prefix is EoR */
|
|
|
|
#define PREFIX_NEXTHOP_LINKED 0x0040 /* prefix is linked onto nexthop list */
|
|
|
|
#define PREFIX_FLAG_LOCKED 0x0080 /* locked by rib walker */
|
|
|
|
#define PREFIX_FLAG_FILTERED 0x0100 /* prefix is filtered (ineligible) */
|
2022-07-07 05:16:04 -07:00
|
|
|
|
|
|
|
#define PREFIX_DMETRIC_NONE 0
|
|
|
|
#define PREFIX_DMETRIC_INVALID 1
|
|
|
|
#define PREFIX_DMETRIC_VALID 2
|
|
|
|
#define PREFIX_DMETRIC_AS_WIDE 3
|
|
|
|
#define PREFIX_DMETRIC_ECMP 4
|
|
|
|
#define PREFIX_DMETRIC_BEST 5
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2019-07-17 03:13:26 -07:00
|
|
|
/* possible states for nhflags */
|
2018-08-03 09:31:22 -07:00
|
|
|
#define NEXTHOP_SELF 0x01
|
|
|
|
#define NEXTHOP_REJECT 0x02
|
|
|
|
#define NEXTHOP_BLACKHOLE 0x04
|
|
|
|
#define NEXTHOP_NOMODIFY 0x08
|
2022-07-25 09:37:55 -07:00
|
|
|
#define NEXTHOP_MASK 0x0f
|
|
|
|
#define NEXTHOP_VALID 0x80
|
2018-08-03 09:31:22 -07:00
|
|
|
|
2018-07-09 07:08:48 -07:00
|
|
|
struct filterstate {
|
2018-08-03 09:31:22 -07:00
|
|
|
struct rde_aspath aspath;
|
2019-06-17 04:02:19 -07:00
|
|
|
struct rde_community communities;
|
2018-07-22 09:59:08 -07:00
|
|
|
struct nexthop *nexthop;
|
2022-02-06 01:51:19 -08:00
|
|
|
uint8_t nhflags;
|
2023-01-11 09:10:25 -08:00
|
|
|
uint8_t vstate;
|
2018-07-09 07:08:48 -07:00
|
|
|
};
|
|
|
|
|
2022-07-07 03:46:54 -07:00
|
|
|
enum eval_mode {
|
|
|
|
EVAL_DEFAULT,
|
|
|
|
EVAL_ALL,
|
|
|
|
EVAL_RECONF,
|
|
|
|
};
|
|
|
|
|
2006-01-03 14:49:17 -08:00
|
|
|
extern struct rde_memstats rdemem;
|
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
/* prototypes */
|
2011-09-18 02:31:25 -07:00
|
|
|
/* mrt.c */
|
2022-09-01 06:23:24 -07:00
|
|
|
int mrt_dump_v2_hdr(struct mrt *, struct bgpd_config *);
|
2017-01-24 16:15:38 -08:00
|
|
|
void mrt_dump_upcall(struct rib_entry *, void *);
|
2011-09-18 02:31:25 -07:00
|
|
|
|
2003-12-23 07:59:02 -08:00
|
|
|
/* rde.c */
|
2022-02-06 01:51:19 -08:00
|
|
|
void rde_update_err(struct rde_peer *, uint8_t , uint8_t,
|
2024-01-23 08:13:35 -08:00
|
|
|
struct ibuf *);
|
2022-02-06 01:51:19 -08:00
|
|
|
void rde_update_log(const char *, uint16_t,
|
2022-07-28 06:11:48 -07:00
|
|
|
const struct rde_peer *, const struct bgpd_addr *,
|
|
|
|
const struct bgpd_addr *, uint8_t);
|
2019-08-07 03:26:41 -07:00
|
|
|
void rde_send_kroute_flush(struct rib *);
|
2017-01-24 16:15:38 -08:00
|
|
|
void rde_send_kroute(struct rib *, struct prefix *, struct prefix *);
|
|
|
|
void rde_send_nexthop(struct bgpd_addr *, int);
|
2022-02-06 01:51:19 -08:00
|
|
|
void rde_pftable_add(uint16_t, struct prefix *);
|
|
|
|
void rde_pftable_del(uint16_t, struct prefix *);
|
2017-01-24 16:15:38 -08:00
|
|
|
|
2021-03-02 01:45:07 -08:00
|
|
|
int rde_evaluate_all(void);
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t rde_local_as(void);
|
2017-01-24 16:15:38 -08:00
|
|
|
int rde_decisionflags(void);
|
2022-02-06 01:51:19 -08:00
|
|
|
void rde_peer_send_rrefresh(struct rde_peer *, uint8_t, uint8_t);
|
2020-01-09 05:31:52 -08:00
|
|
|
int rde_match_peer(struct rde_peer *, struct ctl_neighbor *);
|
2003-12-23 07:59:02 -08:00
|
|
|
|
2019-12-31 23:25:04 -08:00
|
|
|
/* rde_peer.c */
|
2021-05-27 07:32:08 -07:00
|
|
|
int peer_has_as4byte(struct rde_peer *);
|
2022-02-06 01:51:19 -08:00
|
|
|
int peer_has_add_path(struct rde_peer *, uint8_t, int);
|
2021-05-27 07:32:08 -07:00
|
|
|
int peer_accept_no_as_set(struct rde_peer *);
|
2023-03-09 23:57:15 -08:00
|
|
|
void peer_init(struct filter_head *);
|
2020-01-09 05:31:52 -08:00
|
|
|
void peer_shutdown(void);
|
|
|
|
void peer_foreach(void (*)(struct rde_peer *, void *), void *);
|
2022-02-06 01:51:19 -08:00
|
|
|
struct rde_peer *peer_get(uint32_t);
|
|
|
|
struct rde_peer *peer_match(struct ctl_neighbor *, uint32_t);
|
2023-03-09 23:57:15 -08:00
|
|
|
struct rde_peer *peer_add(uint32_t, struct peer_config *, struct filter_head *);
|
|
|
|
struct filter_head *peer_apply_out_filter(struct rde_peer *,
|
|
|
|
struct filter_head *);
|
2020-01-09 05:31:52 -08:00
|
|
|
|
2023-02-13 10:07:53 -08:00
|
|
|
void rde_generate_updates(struct rib_entry *, struct prefix *,
|
|
|
|
struct prefix *, enum eval_mode);
|
|
|
|
|
2022-08-26 07:10:52 -07:00
|
|
|
void peer_up(struct rde_peer *, struct session_up *);
|
2020-01-09 05:31:52 -08:00
|
|
|
void peer_down(struct rde_peer *, void *);
|
2022-02-06 01:51:19 -08:00
|
|
|
void peer_flush(struct rde_peer *, uint8_t, time_t);
|
2022-08-26 07:10:52 -07:00
|
|
|
void peer_stale(struct rde_peer *, uint8_t, int);
|
2022-02-06 01:51:19 -08:00
|
|
|
void peer_dump(struct rde_peer *, uint8_t);
|
|
|
|
void peer_begin_rrefresh(struct rde_peer *, uint8_t);
|
2020-01-09 06:44:55 -08:00
|
|
|
|
|
|
|
void peer_imsg_push(struct rde_peer *, struct imsg *);
|
|
|
|
int peer_imsg_pop(struct rde_peer *, struct imsg *);
|
|
|
|
int peer_imsg_pending(void);
|
|
|
|
void peer_imsg_flush(struct rde_peer *);
|
2019-12-31 23:25:04 -08:00
|
|
|
|
2024-08-28 06:21:39 -07:00
|
|
|
static inline int
|
|
|
|
peer_is_up(struct rde_peer *peer)
|
|
|
|
{
|
|
|
|
return (peer->state == PEER_UP);
|
|
|
|
}
|
|
|
|
|
2022-09-01 06:23:24 -07:00
|
|
|
RB_PROTOTYPE(peer_tree, rde_peer, entry, peer_cmp);
|
|
|
|
|
2004-02-16 04:58:45 -08:00
|
|
|
/* rde_attr.c */
|
2022-02-06 01:51:19 -08:00
|
|
|
int attr_writebuf(struct ibuf *, uint8_t, uint8_t, void *,
|
2022-07-28 06:11:48 -07:00
|
|
|
uint16_t);
|
2006-01-05 08:00:07 -08:00
|
|
|
void attr_shutdown(void);
|
2022-02-06 01:51:19 -08:00
|
|
|
int attr_optadd(struct rde_aspath *, uint8_t, uint8_t,
|
2022-07-28 06:11:48 -07:00
|
|
|
void *, uint16_t);
|
2022-02-06 01:51:19 -08:00
|
|
|
struct attr *attr_optget(const struct rde_aspath *, uint8_t);
|
2018-06-29 04:45:50 -07:00
|
|
|
void attr_copy(struct rde_aspath *, const struct rde_aspath *);
|
2006-01-05 08:00:07 -08:00
|
|
|
int attr_compare(struct rde_aspath *, struct rde_aspath *);
|
|
|
|
void attr_freeall(struct rde_aspath *);
|
2006-04-12 07:05:46 -07:00
|
|
|
void attr_free(struct rde_aspath *, struct attr *);
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2022-02-06 01:51:19 -08:00
|
|
|
struct aspath *aspath_get(void *, uint16_t);
|
2022-08-29 11:18:55 -07:00
|
|
|
struct aspath *aspath_copy(struct aspath *);
|
2004-08-05 11:44:19 -07:00
|
|
|
void aspath_put(struct aspath *);
|
2022-02-06 01:51:19 -08:00
|
|
|
u_char *aspath_deflate(u_char *, uint16_t *, int *);
|
2007-04-23 06:04:24 -07:00
|
|
|
void aspath_merge(struct rde_aspath *, struct attr *);
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t aspath_neighbor(struct aspath *);
|
|
|
|
int aspath_loopfree(struct aspath *, uint32_t);
|
2004-01-10 08:20:29 -08:00
|
|
|
int aspath_compare(struct aspath *, struct aspath *);
|
2022-02-06 01:51:19 -08:00
|
|
|
int aspath_match(struct aspath *, struct filter_as *, uint32_t);
|
|
|
|
u_char *aspath_prepend(struct aspath *, uint32_t, int, uint16_t *);
|
|
|
|
u_char *aspath_override(struct aspath *, uint32_t, uint32_t,
|
|
|
|
uint16_t *);
|
2010-05-17 09:08:20 -07:00
|
|
|
int aspath_lenmatch(struct aspath *, enum aslen_spec, u_int);
|
2018-11-28 00:32:26 -08:00
|
|
|
|
2022-12-14 04:37:15 -08:00
|
|
|
static inline u_char *
|
|
|
|
aspath_dump(struct aspath *aspath)
|
|
|
|
{
|
|
|
|
return (aspath->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint16_t
|
|
|
|
aspath_length(struct aspath *aspath)
|
|
|
|
{
|
|
|
|
return (aspath->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
aspath_origin(struct aspath *aspath)
|
|
|
|
{
|
|
|
|
return (aspath->source_as);
|
|
|
|
}
|
|
|
|
|
2019-07-17 03:13:26 -07:00
|
|
|
/* rde_community.c */
|
2019-06-23 23:39:49 -07:00
|
|
|
int community_match(struct rde_community *, struct community *,
|
2018-11-28 00:32:26 -08:00
|
|
|
struct rde_peer *);
|
2022-05-31 02:45:33 -07:00
|
|
|
int community_count(struct rde_community *, uint8_t type);
|
2019-06-23 23:39:49 -07:00
|
|
|
int community_set(struct rde_community *, struct community *,
|
2018-11-28 00:32:26 -08:00
|
|
|
struct rde_peer *);
|
2019-06-23 23:39:49 -07:00
|
|
|
void community_delete(struct rde_community *, struct community *,
|
2018-11-28 00:32:26 -08:00
|
|
|
struct rde_peer *);
|
2019-06-17 04:02:19 -07:00
|
|
|
|
2024-01-24 06:51:11 -08:00
|
|
|
int community_add(struct rde_community *, int, struct ibuf *);
|
|
|
|
int community_large_add(struct rde_community *, int, struct ibuf *);
|
|
|
|
int community_ext_add(struct rde_community *, int, int, struct ibuf *);
|
2023-07-12 07:45:42 -07:00
|
|
|
int community_writebuf(struct rde_community *, uint8_t, int, struct ibuf *);
|
2019-06-17 04:02:19 -07:00
|
|
|
|
|
|
|
void communities_shutdown(void);
|
|
|
|
struct rde_community *communities_lookup(struct rde_community *);
|
|
|
|
struct rde_community *communities_link(struct rde_community *);
|
2019-06-17 06:35:42 -07:00
|
|
|
void communities_unlink(struct rde_community *);
|
2019-06-17 04:02:19 -07:00
|
|
|
|
|
|
|
int communities_equal(struct rde_community *, struct rde_community *);
|
|
|
|
void communities_copy(struct rde_community *, struct rde_community *);
|
|
|
|
void communities_clean(struct rde_community *);
|
|
|
|
|
|
|
|
static inline struct rde_community *
|
2019-07-01 00:07:08 -07:00
|
|
|
communities_ref(struct rde_community *comm)
|
2019-06-17 04:02:19 -07:00
|
|
|
{
|
|
|
|
if (comm->refcnt == 0)
|
|
|
|
fatalx("%s: not-referenced community", __func__);
|
|
|
|
comm->refcnt++;
|
|
|
|
rdemem.comm_refs++;
|
|
|
|
return comm;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2019-07-01 00:07:08 -07:00
|
|
|
communities_unref(struct rde_community *comm)
|
2019-06-17 04:02:19 -07:00
|
|
|
{
|
|
|
|
if (comm == NULL)
|
|
|
|
return;
|
|
|
|
rdemem.comm_refs--;
|
2019-07-01 00:07:08 -07:00
|
|
|
if (--comm->refcnt == 1) /* last ref is hold internally */
|
2019-06-17 04:02:19 -07:00
|
|
|
communities_unlink(comm);
|
|
|
|
}
|
|
|
|
|
2022-02-06 01:51:19 -08:00
|
|
|
int community_to_rd(struct community *, uint64_t *);
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2011-09-18 02:31:25 -07:00
|
|
|
/* rde_decide.c */
|
2022-03-21 10:35:56 -07:00
|
|
|
int prefix_eligible(struct prefix *);
|
|
|
|
struct prefix *prefix_best(struct rib_entry *);
|
|
|
|
void prefix_evaluate(struct rib_entry *, struct prefix *,
|
2022-07-28 06:11:48 -07:00
|
|
|
struct prefix *);
|
2022-07-25 09:37:55 -07:00
|
|
|
void prefix_evaluate_nexthop(struct prefix *, enum nexthop_state,
|
2022-07-28 06:11:48 -07:00
|
|
|
enum nexthop_state);
|
2011-09-18 02:31:25 -07:00
|
|
|
|
|
|
|
/* rde_filter.c */
|
2019-08-13 05:16:20 -07:00
|
|
|
void rde_apply_set(struct filter_set_head *, struct rde_peer *,
|
2023-03-09 23:57:15 -08:00
|
|
|
struct rde_peer *, struct filterstate *, u_int8_t);
|
2023-01-12 09:35:51 -08:00
|
|
|
void rde_filterstate_init(struct filterstate *);
|
|
|
|
void rde_filterstate_prep(struct filterstate *, struct prefix *);
|
|
|
|
void rde_filterstate_copy(struct filterstate *, struct filterstate *);
|
2023-01-24 03:28:41 -08:00
|
|
|
void rde_filterstate_set_vstate(struct filterstate *, uint8_t, uint8_t);
|
2019-08-13 05:16:20 -07:00
|
|
|
void rde_filterstate_clean(struct filterstate *);
|
2023-03-09 23:57:15 -08:00
|
|
|
int rde_filter_skip_rule(struct rde_peer *, struct filter_rule *);
|
|
|
|
int rde_filter_equal(struct filter_head *, struct filter_head *);
|
2019-08-13 05:16:20 -07:00
|
|
|
void rde_filter_calc_skip_steps(struct filter_head *);
|
2018-06-28 01:07:21 -07:00
|
|
|
enum filter_actions rde_filter(struct filter_head *, struct rde_peer *,
|
2023-01-11 09:10:25 -08:00
|
|
|
struct rde_peer *, struct bgpd_addr *, uint8_t,
|
2019-08-13 05:16:20 -07:00
|
|
|
struct filterstate *);
|
2011-09-18 02:31:25 -07:00
|
|
|
|
|
|
|
/* rde_prefix.c */
|
2019-07-01 00:07:08 -07:00
|
|
|
void pt_init(void);
|
|
|
|
void pt_shutdown(void);
|
|
|
|
void pt_getaddr(struct pt_entry *, struct bgpd_addr *);
|
2023-04-19 00:09:47 -07:00
|
|
|
int pt_getflowspec(struct pt_entry *, uint8_t **);
|
2019-07-01 00:07:08 -07:00
|
|
|
struct pt_entry *pt_fill(struct bgpd_addr *, int);
|
|
|
|
struct pt_entry *pt_get(struct bgpd_addr *, int);
|
|
|
|
struct pt_entry *pt_add(struct bgpd_addr *, int);
|
2023-04-19 00:09:47 -07:00
|
|
|
struct pt_entry *pt_get_flow(struct flowspec *);
|
|
|
|
struct pt_entry *pt_add_flow(struct flowspec *);
|
2019-07-01 00:07:08 -07:00
|
|
|
void pt_remove(struct pt_entry *);
|
|
|
|
struct pt_entry *pt_lookup(struct bgpd_addr *);
|
|
|
|
int pt_prefix_cmp(const struct pt_entry *, const struct pt_entry *);
|
2023-07-12 07:45:42 -07:00
|
|
|
int pt_writebuf(struct ibuf *, struct pt_entry *, int, int, uint32_t);
|
2018-02-04 19:55:54 -08:00
|
|
|
|
2019-06-21 22:44:05 -07:00
|
|
|
static inline struct pt_entry *
|
2018-02-04 19:55:54 -08:00
|
|
|
pt_ref(struct pt_entry *pt)
|
|
|
|
{
|
|
|
|
++pt->refcnt;
|
|
|
|
if (pt->refcnt == 0)
|
|
|
|
fatalx("pt_ref: overflow");
|
2019-06-21 22:44:05 -07:00
|
|
|
return pt;
|
2018-02-04 19:55:54 -08:00
|
|
|
}
|
|
|
|
|
2019-07-01 00:07:08 -07:00
|
|
|
static inline void
|
2018-02-04 19:55:54 -08:00
|
|
|
pt_unref(struct pt_entry *pt)
|
|
|
|
{
|
|
|
|
if (pt->refcnt == 0)
|
|
|
|
fatalx("pt_unref: underflow");
|
2019-07-01 00:07:08 -07:00
|
|
|
if (--pt->refcnt == 0)
|
|
|
|
pt_remove(pt);
|
2018-02-04 19:55:54 -08:00
|
|
|
}
|
2011-09-18 02:31:25 -07:00
|
|
|
|
2004-02-16 04:58:45 -08:00
|
|
|
/* rde_rib.c */
|
2022-02-06 01:51:19 -08:00
|
|
|
extern uint16_t rib_size;
|
2009-05-17 05:25:15 -07:00
|
|
|
|
2022-02-06 01:51:19 -08:00
|
|
|
struct rib *rib_new(char *, u_int, uint16_t);
|
2022-03-21 06:33:20 -07:00
|
|
|
int rib_update(struct rib *);
|
2022-02-06 01:51:19 -08:00
|
|
|
struct rib *rib_byid(uint16_t);
|
|
|
|
uint16_t rib_find(char *);
|
2017-01-24 19:21:55 -08:00
|
|
|
void rib_free(struct rib *);
|
2018-11-04 04:34:54 -08:00
|
|
|
void rib_shutdown(void);
|
2023-04-07 06:49:03 -07:00
|
|
|
struct rib_entry *rib_get(struct rib *, struct pt_entry *);
|
|
|
|
struct rib_entry *rib_get_addr(struct rib *, struct bgpd_addr *, int);
|
2019-07-17 03:13:26 -07:00
|
|
|
struct rib_entry *rib_match(struct rib *, struct bgpd_addr *);
|
2018-10-24 01:26:37 -07:00
|
|
|
int rib_dump_pending(void);
|
|
|
|
void rib_dump_runner(void);
|
2022-02-06 01:51:19 -08:00
|
|
|
int rib_dump_new(uint16_t, uint8_t, unsigned int, void *,
|
2019-06-17 06:35:42 -07:00
|
|
|
void (*)(struct rib_entry *, void *),
|
2022-02-06 01:51:19 -08:00
|
|
|
void (*)(void *, uint8_t),
|
2018-10-24 01:26:37 -07:00
|
|
|
int (*)(void *));
|
2022-09-12 03:03:17 -07:00
|
|
|
int rib_dump_subtree(uint16_t, struct bgpd_addr *, uint8_t,
|
|
|
|
unsigned int count, void *arg,
|
|
|
|
void (*)(struct rib_entry *, void *),
|
|
|
|
void (*)(void *, uint8_t),
|
|
|
|
int (*)(void *));
|
2019-07-17 03:13:26 -07:00
|
|
|
void rib_dump_terminate(void *);
|
2009-05-17 05:25:15 -07:00
|
|
|
|
2023-04-19 06:23:33 -07:00
|
|
|
extern struct rib flowrib;
|
|
|
|
|
2017-01-24 15:38:12 -08:00
|
|
|
static inline struct rib *
|
|
|
|
re_rib(struct rib_entry *re)
|
|
|
|
{
|
2023-04-19 06:23:33 -07:00
|
|
|
if (re->prefix->aid == AID_FLOWSPECv4 ||
|
|
|
|
re->prefix->aid == AID_FLOWSPECv6)
|
|
|
|
return &flowrib;
|
2018-10-24 01:26:37 -07:00
|
|
|
return rib_byid(re->rib_id);
|
2017-01-24 15:38:12 -08:00
|
|
|
}
|
|
|
|
|
2004-03-11 06:22:22 -08:00
|
|
|
void path_shutdown(void);
|
2018-06-29 04:45:50 -07:00
|
|
|
struct rde_aspath *path_copy(struct rde_aspath *, const struct rde_aspath *);
|
|
|
|
struct rde_aspath *path_prep(struct rde_aspath *);
|
2004-08-06 05:04:08 -07:00
|
|
|
struct rde_aspath *path_get(void);
|
2018-07-09 07:08:48 -07:00
|
|
|
void path_clean(struct rde_aspath *);
|
2004-08-06 05:04:08 -07:00
|
|
|
void path_put(struct rde_aspath *);
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2004-08-13 07:03:20 -07:00
|
|
|
#define PREFIX_SIZE(x) (((x) + 7) / 8 + 1)
|
2022-02-06 01:51:19 -08:00
|
|
|
struct prefix *prefix_get(struct rib *, struct rde_peer *, uint32_t,
|
2018-09-09 05:33:51 -07:00
|
|
|
struct bgpd_addr *, int);
|
2022-02-25 03:36:54 -08:00
|
|
|
struct prefix *prefix_adjout_get(struct rde_peer *, uint32_t,
|
2023-03-29 03:46:11 -07:00
|
|
|
struct pt_entry *);
|
|
|
|
struct prefix *prefix_adjout_first(struct rde_peer *, struct pt_entry *);
|
|
|
|
struct prefix *prefix_adjout_next(struct rde_peer *, struct prefix *);
|
2022-02-25 03:36:54 -08:00
|
|
|
struct prefix *prefix_adjout_lookup(struct rde_peer *, struct bgpd_addr *,
|
2022-07-28 06:11:48 -07:00
|
|
|
int);
|
2023-03-29 03:46:11 -07:00
|
|
|
struct prefix *prefix_adjout_match(struct rde_peer *, struct bgpd_addr *);
|
2022-02-06 01:51:19 -08:00
|
|
|
int prefix_update(struct rib *, struct rde_peer *, uint32_t,
|
2024-08-14 12:09:51 -07:00
|
|
|
uint32_t, struct filterstate *, int, struct bgpd_addr *,
|
|
|
|
int);
|
2022-02-06 01:51:19 -08:00
|
|
|
int prefix_withdraw(struct rib *, struct rde_peer *, uint32_t,
|
2018-09-09 05:33:51 -07:00
|
|
|
struct bgpd_addr *, int);
|
2023-04-19 06:23:33 -07:00
|
|
|
int prefix_flowspec_update(struct rde_peer *, struct filterstate *,
|
|
|
|
struct pt_entry *, uint32_t);
|
|
|
|
int prefix_flowspec_withdraw(struct rde_peer *, struct pt_entry *);
|
|
|
|
void prefix_flowspec_dump(uint8_t, void *,
|
|
|
|
void (*)(struct rib_entry *, void *),
|
|
|
|
void (*)(void *, uint8_t));
|
2022-02-06 01:51:19 -08:00
|
|
|
void prefix_add_eor(struct rde_peer *, uint8_t);
|
2022-07-08 03:01:52 -07:00
|
|
|
void prefix_adjout_update(struct prefix *, struct rde_peer *,
|
2023-03-29 03:46:11 -07:00
|
|
|
struct filterstate *, struct pt_entry *, uint32_t);
|
2022-03-02 06:44:46 -08:00
|
|
|
void prefix_adjout_withdraw(struct prefix *);
|
2022-03-02 06:49:25 -08:00
|
|
|
void prefix_adjout_destroy(struct prefix *);
|
2022-02-06 01:51:19 -08:00
|
|
|
int prefix_dump_new(struct rde_peer *, uint8_t, unsigned int,
|
2019-07-17 03:13:26 -07:00
|
|
|
void *, void (*)(struct prefix *, void *),
|
2022-02-06 01:51:19 -08:00
|
|
|
void (*)(void *, uint8_t), int (*)(void *));
|
2022-09-12 03:03:17 -07:00
|
|
|
int prefix_dump_subtree(struct rde_peer *, struct bgpd_addr *,
|
|
|
|
uint8_t, unsigned int, void *,
|
|
|
|
void (*)(struct prefix *, void *),
|
|
|
|
void (*)(void *, uint8_t), int (*)(void *));
|
2021-08-09 01:15:34 -07:00
|
|
|
struct prefix *prefix_bypeer(struct rib_entry *, struct rde_peer *,
|
2022-02-06 01:51:19 -08:00
|
|
|
uint32_t);
|
2003-12-17 03:46:54 -08:00
|
|
|
void prefix_destroy(struct prefix *);
|
2018-02-04 19:55:54 -08:00
|
|
|
|
2019-01-20 18:07:56 -08:00
|
|
|
RB_PROTOTYPE(prefix_tree, prefix, entry, prefix_cmp)
|
|
|
|
|
2018-08-03 09:31:22 -07:00
|
|
|
static inline struct rde_peer *
|
|
|
|
prefix_peer(struct prefix *p)
|
|
|
|
{
|
|
|
|
return (p->peer);
|
|
|
|
}
|
|
|
|
|
2018-02-04 19:55:54 -08:00
|
|
|
static inline struct rde_aspath *
|
|
|
|
prefix_aspath(struct prefix *p)
|
|
|
|
{
|
2018-06-27 06:14:44 -07:00
|
|
|
return (p->aspath);
|
2018-02-04 19:55:54 -08:00
|
|
|
}
|
|
|
|
|
2019-06-17 04:02:19 -07:00
|
|
|
static inline struct rde_community *
|
|
|
|
prefix_communities(struct prefix *p)
|
|
|
|
{
|
|
|
|
return (p->communities);
|
|
|
|
}
|
|
|
|
|
2018-07-22 09:59:08 -07:00
|
|
|
static inline struct nexthop *
|
|
|
|
prefix_nexthop(struct prefix *p)
|
|
|
|
{
|
2018-08-03 09:31:22 -07:00
|
|
|
return (p->nexthop);
|
2018-07-22 09:59:08 -07:00
|
|
|
}
|
|
|
|
|
2022-02-06 01:51:19 -08:00
|
|
|
static inline uint8_t
|
2018-08-03 09:31:22 -07:00
|
|
|
prefix_nhflags(struct prefix *p)
|
2018-02-04 19:55:54 -08:00
|
|
|
{
|
2022-07-25 09:37:55 -07:00
|
|
|
return (p->nhflags & NEXTHOP_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
prefix_nhvalid(struct prefix *p)
|
|
|
|
{
|
|
|
|
return ((p->nhflags & NEXTHOP_VALID) != 0);
|
2018-02-04 19:55:54 -08:00
|
|
|
}
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2022-02-06 01:51:19 -08:00
|
|
|
static inline uint8_t
|
2023-01-11 09:10:25 -08:00
|
|
|
prefix_roa_vstate(struct prefix *p)
|
2018-09-29 01:11:11 -07:00
|
|
|
{
|
|
|
|
return (p->validation_state & ROA_MASK);
|
|
|
|
}
|
|
|
|
|
2023-01-24 03:28:41 -08:00
|
|
|
static inline uint8_t
|
|
|
|
prefix_aspa_vstate(struct prefix *p)
|
|
|
|
{
|
|
|
|
return (p->validation_state >> 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
prefix_set_vstate(struct prefix *p, uint8_t roa_vstate, uint8_t aspa_vstate)
|
|
|
|
{
|
|
|
|
p->validation_state = roa_vstate & ROA_MASK;
|
|
|
|
p->validation_state |= aspa_vstate << 4;
|
|
|
|
}
|
|
|
|
|
2021-07-27 00:50:01 -07:00
|
|
|
static inline struct rib_entry *
|
|
|
|
prefix_re(struct prefix *p)
|
|
|
|
{
|
|
|
|
if (p->flags & PREFIX_FLAG_ADJOUT)
|
|
|
|
return NULL;
|
|
|
|
return (p->entry.list.re);
|
|
|
|
}
|
|
|
|
|
2024-08-14 12:09:51 -07:00
|
|
|
static inline int
|
|
|
|
prefix_filtered(struct prefix *p)
|
|
|
|
{
|
|
|
|
return ((p->flags & PREFIX_FLAG_FILTERED) != 0);
|
|
|
|
}
|
|
|
|
|
2004-03-11 06:22:22 -08:00
|
|
|
void nexthop_shutdown(void);
|
2019-06-20 06:18:19 -07:00
|
|
|
int nexthop_pending(void);
|
|
|
|
void nexthop_runner(void);
|
2022-02-06 01:51:19 -08:00
|
|
|
void nexthop_modify(struct nexthop *, enum action_types, uint8_t,
|
|
|
|
struct nexthop **, uint8_t *);
|
2018-08-03 09:31:22 -07:00
|
|
|
void nexthop_link(struct prefix *);
|
|
|
|
void nexthop_unlink(struct prefix *);
|
2003-12-25 15:22:13 -08:00
|
|
|
void nexthop_update(struct kroute_nexthop *);
|
2004-08-12 03:24:16 -07:00
|
|
|
struct nexthop *nexthop_get(struct bgpd_addr *);
|
2018-06-25 07:28:33 -07:00
|
|
|
struct nexthop *nexthop_ref(struct nexthop *);
|
2019-07-01 00:07:08 -07:00
|
|
|
int nexthop_unref(struct nexthop *);
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2005-11-01 06:37:16 -08:00
|
|
|
/* rde_update.c */
|
2023-03-09 23:57:15 -08:00
|
|
|
void up_generate_updates(struct rde_peer *, struct rib_entry *);
|
|
|
|
void up_generate_addpath(struct rde_peer *, struct rib_entry *);
|
|
|
|
void up_generate_addpath_all(struct rde_peer *, struct rib_entry *,
|
|
|
|
struct prefix *, struct prefix *);
|
|
|
|
void up_generate_default(struct rde_peer *, uint8_t);
|
2022-02-06 01:51:19 -08:00
|
|
|
int up_is_eor(struct rde_peer *, uint8_t);
|
2024-09-25 07:46:51 -07:00
|
|
|
struct ibuf *up_dump_withdraws(struct rde_peer *, uint8_t);
|
|
|
|
struct ibuf *up_dump_update(struct rde_peer *, uint8_t);
|
2003-12-17 03:46:54 -08:00
|
|
|
|
2023-01-11 05:53:17 -08:00
|
|
|
/* rde_aspa.c */
|
2023-01-24 03:28:41 -08:00
|
|
|
void aspa_validation(struct rde_aspa *, struct aspath *,
|
|
|
|
struct rde_aspa_state *);
|
2023-01-11 05:53:17 -08:00
|
|
|
struct rde_aspa *aspa_table_prep(uint32_t, size_t);
|
|
|
|
void aspa_add_set(struct rde_aspa *, uint32_t, const uint32_t *,
|
2023-08-16 01:26:35 -07:00
|
|
|
uint32_t);
|
2023-01-11 05:53:17 -08:00
|
|
|
void aspa_table_free(struct rde_aspa *);
|
2023-01-17 08:09:01 -08:00
|
|
|
void aspa_table_stats(const struct rde_aspa *,
|
|
|
|
struct ctl_show_set *);
|
|
|
|
int aspa_table_equal(const struct rde_aspa *,
|
|
|
|
const struct rde_aspa *);
|
|
|
|
void aspa_table_unchanged(struct rde_aspa *,
|
|
|
|
const struct rde_aspa *);
|
2023-01-11 05:53:17 -08:00
|
|
|
|
2003-12-17 03:46:54 -08:00
|
|
|
#endif /* __RDE_H__ */
|