+// SPDX-License-Identifier: GPL-2.0-or-later
/* BGP message definition header.
* Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QUAGGA_BGPD_H
#include "vty.h"
#include "srv6.h"
#include "iana_afi.h"
+#include "asn.h"
/* For union sockunion. */
#include "queue.h"
#include "bgp_io.h"
#include "lib/bfd.h"
-#include "lib/orr_msg.h"
#define BGP_MAX_HOSTNAME 64 /* Linux max, is larger than most other sys */
#define BGP_PEER_MAX_HASH_SIZE 16384
};
/* Typedef BGP specific types. */
-typedef uint32_t as_t;
typedef uint16_t as16_t; /* we may still encounter 16 Bit asnums */
typedef uint16_t bgp_size_t;
/* DSCP value for TCP sessions */
uint8_t tcp_dscp;
-#define BM_DEFAULT_INQ_LIMIT 10000
+#define BM_DEFAULT_Q_LIMIT 10000
uint32_t inq_limit;
+ uint32_t outq_limit;
QOBJ_FIELDS;
};
struct bgp_rmap rmap;
};
-struct bgp_orr_igp_metric {
- struct prefix prefix;
- uint32_t igp_metric;
-};
-
-struct bgp_orr_group {
- /* Name of this ORR group */
- char *name;
-
- /* Address Family Identifiers */
- afi_t afi;
- safi_t safi;
-
- /* Pointer to BGP */
- struct bgp *bgp;
-
- /* Root Routers of the group */
- struct peer *primary;
- struct peer *secondary;
- struct peer *tertiary;
-
- /* Active Root Router of the group */
- struct peer *active;
-
- /* RR clients belong to this group */
- struct list *rr_client_list;
-
- /* IGP metric data from active root */
- struct list *igp_metric_info;
-
- /* Route table calculated from active root for this group */
- struct bgp_table *route_table;
-};
-
enum vpn_policy_direction {
BGP_VPN_POLICY_DIR_FROMVPN = 0,
BGP_VPN_POLICY_DIR_TOVPN = 1,
/* should be mpls_label_t? */
uint32_t tovpn_label; /* may be MPLS_LABEL_NONE */
uint32_t tovpn_zebra_vrf_label_last_sent;
+ char *tovpn_rd_pretty;
struct prefix_rd tovpn_rd;
struct prefix tovpn_nexthop; /* unset => set to 0 */
uint32_t flags;
char locator_name[SRV6_LOCNAME_SIZE];
};
+struct as_confed {
+ as_t as;
+ char *as_pretty;
+};
+
/* BGP instance structure. */
struct bgp {
/* AS number of this BGP instance. */
as_t as;
+ char *as_pretty;
/* Name of this BGP instance. */
char *name;
uint16_t config;
#define BGP_CONFIG_CLUSTER_ID (1 << 0)
#define BGP_CONFIG_CONFEDERATION (1 << 1)
+#define BGP_CONFIG_ASNOTATION (1 << 2)
/* BGP router identifier. */
struct in_addr router_id;
/* BGP confederation information. */
as_t confed_id;
- as_t *confed_peers;
+ char *confed_id_pretty;
+ struct as_confed *confed_peers;
int confed_peers_cnt;
struct thread
/* RD for this VRF */
struct prefix_rd vrf_prd;
+ char *vrf_prd_pretty;
/* import rt list for the vrf instance */
struct list *vrf_import_rtl;
bool allow_martian;
- /* BGP optimal route reflection group and Root Router configuration */
- uint32_t orr_group_count;
- struct list *orr_group[AFI_MAX][SAFI_MAX];
+ enum asnotation_mode asnotation;
QOBJ_FIELDS;
};
/* Peer's remote AS number. */
int as_type;
as_t as;
+ /* for vty as format */
+ char *as_pretty;
/* Peer's local AS number. */
as_t local_as;
/* Peer's Change local AS number. */
as_t change_local_as;
+ /* for vty as format */
+ char *change_local_as_pretty;
/* Remote router ID. */
struct in_addr remote_id;
#define PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV (1U << 24)
#define PEER_CAP_ROLE_ADV (1U << 25) /* role advertised */
#define PEER_CAP_ROLE_RCV (1U << 26) /* role received */
+#define PEER_CAP_SOFT_VERSION_ADV (1U << 27)
+#define PEER_CAP_SOFT_VERSION_RCV (1U << 28)
/* Capability flags (reset in bgp_stop) */
uint32_t af_cap[AFI_MAX][SAFI_MAX];
* so if a flag is unset, the corresponding override flag is unset too.
* However if a flag is set, the corresponding override flag is set.
*/
- uint32_t flags_override;
+ uint64_t flags_override;
/*
* Parallel array to flags that indicates whether the default behavior
* of *flags_override* should be inverted. If a flag is unset and the
* inversion state of the flag differs between peer and peer-group, the
* newly set value must equal to the inverted state of the peer-group.
*/
- uint32_t flags_invert;
+ uint64_t flags_invert;
/*
* Effective array for storing the peer/peer-group flags. In case of a
* peer-group, the peer-specific overrides (see flags_override and
* flags_invert) must be respected.
+ * When changing the structure of flags/af_flags, do not forget to
+ * change flags_invert/flags_override too.
*/
uint64_t flags;
#define PEER_FLAG_PASSIVE (1ULL << 0) /* passive mode */
#define PEER_FLAG_PORT (1ULL << 33)
#define PEER_FLAG_AIGP (1ULL << 34)
#define PEER_FLAG_GRACEFUL_SHUTDOWN (1ULL << 35)
+#define PEER_FLAG_CAPABILITY_SOFT_VERSION (1ULL << 36)
/*
*GR-Disabled mode means unset PEER_FLAG_GRACEFUL_RESTART
#define PEER_FLAG_MAX_PREFIX_FORCE (1ULL << 28)
#define PEER_FLAG_DISABLE_ADDPATH_RX (1ULL << 29)
#define PEER_FLAG_SOO (1ULL << 30)
-#define PEER_FLAG_ORR_GROUP (1ULL << 31) /* Optimal-Route-Reflection */
-#define PEER_FLAG_ACCEPT_OWN (1ULL << 32)
-
- /* BGP Optimal Route Reflection Group name */
- char *orr_group_name[AFI_MAX][SAFI_MAX];
+#define PEER_FLAG_ACCEPT_OWN (1ULL << 31)
enum bgp_addpath_strat addpath_type[AFI_MAX][SAFI_MAX];
bool shut_during_cfg;
+#define BGP_ATTR_MAX 255
+ /* Path attributes discard */
+ bool discard_attrs[BGP_ATTR_MAX];
+
+ /* Path attributes treat-as-withdraw */
+ bool withdraw_attrs[BGP_ATTR_MAX];
+
+ /* BGP Software Version Capability */
+#define BGP_MAX_SOFT_VERSION 64
+ char *soft_version;
+
QOBJ_FIELDS;
};
DECLARE_QOBJ_TYPE(peer);
#define BGP_MSG_ROUTE_REFRESH_OLD 128
/* BGP open optional parameter. */
-#define BGP_OPEN_OPT_AUTH 1
#define BGP_OPEN_OPT_CAP 2
/* BGP4 attribute type codes. */
#define BGP_ATTR_EXT_COMMUNITIES 16
#define BGP_ATTR_AS4_PATH 17
#define BGP_ATTR_AS4_AGGREGATOR 18
-#define BGP_ATTR_AS_PATHLIMIT 21
#define BGP_ATTR_PMSI_TUNNEL 22
#define BGP_ATTR_ENCAP 23
#define BGP_ATTR_IPV6_EXT_COMMUNITIES 25
#define BGP_NOTIFY_OPEN_BAD_PEER_AS 2
#define BGP_NOTIFY_OPEN_BAD_BGP_IDENT 3
#define BGP_NOTIFY_OPEN_UNSUP_PARAM 4
-#define BGP_NOTIFY_OPEN_AUTH_FAILURE 5
#define BGP_NOTIFY_OPEN_UNACEP_HOLDTIME 6
#define BGP_NOTIFY_OPEN_UNSUP_CAPBL 7
#define BGP_NOTIFY_OPEN_ROLE_MISMATCH 11
#define BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR 4
#define BGP_NOTIFY_UPDATE_ATTR_LENG_ERR 5
#define BGP_NOTIFY_UPDATE_INVAL_ORIGIN 6
-#define BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP 7
#define BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP 8
#define BGP_NOTIFY_UPDATE_OPT_ATTR_ERR 9
#define BGP_NOTIFY_UPDATE_INVAL_NETWORK 10
/*BGP Open Policy ERRORS */
BGP_ERR_INVALID_ROLE_NAME = -35,
- BGP_ERR_INVALID_INTERNAL_ROLE = -36,
-
- /* BGP ORR ERRORS */
- BGP_ERR_PEER_ORR_CONFIGURED = -37,
+ BGP_ERR_INVALID_INTERNAL_ROLE = -36
};
/*
extern struct peer *peer_lookup_dynamic_neighbor(struct bgp *,
union sockunion *);
-extern bool peer_orr_rrclient_check(struct peer *peer, afi_t afi, safi_t safi);
/*
* Peers are incredibly easy to memory leak
* due to the various ways that they are actually used
extern bool peer_afc_received(struct peer *peer);
extern bool peer_afc_advertised(struct peer *peer);
extern void bgp_recalculate_all_bestpaths(struct bgp *bgp);
-extern struct peer *peer_create(union sockunion *, const char *, struct bgp *,
- as_t, as_t, int, struct peer_group *);
+extern struct peer *peer_create(union sockunion *su, const char *conf_if,
+ struct bgp *bgp, as_t local_as, as_t remote_as,
+ int as_type, struct peer_group *group,
+ bool config_node, const char *as_str);
extern struct peer *peer_create_accept(struct bgp *);
extern void peer_xfer_config(struct peer *dst, struct peer *src);
extern char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json,
/* unset the bgp no-rib option during runtime and reset all peers */
extern void bgp_option_norib_unset_runtime(void);
-extern int bgp_get(struct bgp **, as_t *, const char *, enum bgp_instance_type);
+extern int bgp_get(struct bgp **bgp, as_t *as, const char *name,
+ enum bgp_instance_type kind, const char *as_pretty,
+ enum asnotation_mode asnotation);
extern void bgp_instance_up(struct bgp *);
extern void bgp_instance_down(struct bgp *);
extern int bgp_delete(struct bgp *);
extern void bgp_cluster_id_set(struct bgp *bgp, struct in_addr *cluster_id);
extern void bgp_cluster_id_unset(struct bgp *bgp);
-extern void bgp_confederation_id_set(struct bgp *bgp, as_t as);
+extern void bgp_confederation_id_set(struct bgp *bgp, as_t as,
+ const char *as_str);
extern void bgp_confederation_id_unset(struct bgp *bgp);
extern bool bgp_confederation_peers_check(struct bgp *, as_t);
-extern void bgp_confederation_peers_add(struct bgp *bgp, as_t as);
+extern void bgp_confederation_peers_add(struct bgp *bgp, as_t as,
+ const char *as_str);
extern void bgp_confederation_peers_remove(struct bgp *bgp, as_t as);
extern void bgp_timers_set(struct bgp *, uint32_t keepalive, uint32_t holdtime,
extern bool bgp_update_delay_active(struct bgp *);
extern bool bgp_update_delay_configured(struct bgp *);
extern bool bgp_afi_safi_peer_exists(struct bgp *bgp, afi_t afi, safi_t safi);
-extern void peer_as_change(struct peer *, as_t, int);
-extern int peer_remote_as(struct bgp *, union sockunion *, const char *, as_t *,
- int);
-extern int peer_group_remote_as(struct bgp *, const char *, as_t *, int);
+extern void peer_as_change(struct peer *peer, as_t as, int as_type,
+ const char *as_str);
+extern int peer_remote_as(struct bgp *bgp, union sockunion *su,
+ const char *conf_if, as_t *as, int as_type,
+ const char *as_str);
+extern int peer_group_remote_as(struct bgp *bgp, const char *peer_str, as_t *as,
+ int as_type, const char *as_str);
extern int peer_delete(struct peer *peer);
extern void peer_notify_unconfig(struct peer *peer);
extern int peer_group_delete(struct peer_group *);
extern int peer_allowas_in_set(struct peer *, afi_t, safi_t, int, int);
extern int peer_allowas_in_unset(struct peer *, afi_t, safi_t);
-extern int peer_local_as_set(struct peer *, as_t, bool no_prepend,
- bool replace_as);
+extern int peer_local_as_set(struct peer *peer, as_t as, bool no_prepend,
+ bool replace_as, const char *as_str);
extern int peer_local_as_unset(struct peer *);
extern int peer_prefix_list_set(struct peer *, afi_t, safi_t, int,
extern void bgp_route_map_update_timer(struct thread *thread);
extern const char *bgp_get_name_by_role(uint8_t role);
+extern enum asnotation_mode bgp_get_asnotation(struct bgp *bgp);
extern void bgp_route_map_terminate(void);
extern void bgp_close(void);
extern void bgp_free(struct bgp *);
void bgp_gr_apply_running_config(void);
-extern int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
- const char *name, struct peer *primary,
- struct peer *secondary,
- struct peer *tertiary);
-extern int bgp_afi_safi_orr_group_unset(struct bgp *bgp, afi_t afi, safi_t safi,
- const char *name);
/* BGP GR */
int bgp_global_gr_init(struct bgp *bgp);
return BGP_AF_IPV4_ENCAP;
case SAFI_FLOWSPEC:
return BGP_AF_IPV4_FLOWSPEC;
- default:
+ case SAFI_EVPN:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return BGP_AF_MAX;
}
break;
return BGP_AF_IPV6_ENCAP;
case SAFI_FLOWSPEC:
return BGP_AF_IPV6_FLOWSPEC;
- default:
+ case SAFI_EVPN:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return BGP_AF_MAX;
}
break;
switch (safi) {
case SAFI_EVPN:
return BGP_AF_L2VPN_EVPN;
- default:
+ case SAFI_UNICAST:
+ case SAFI_MULTICAST:
+ case SAFI_LABELED_UNICAST:
+ case SAFI_MPLS_VPN:
+ case SAFI_ENCAP:
+ case SAFI_FLOWSPEC:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return BGP_AF_MAX;
}
- default:
+ break;
+ case AFI_UNSPEC:
+ case AFI_MAX:
return BGP_AF_MAX;
}
+
+ assert(!"Reached end of function we should never hit");
}
/* If the peer is not a peer-group but is bound to a peer-group return 1 */
safi_t safi);
extern void peer_on_policy_change(struct peer *peer, afi_t afi, safi_t safi,
int outbound);
+extern bool bgp_path_attribute_discard(struct peer *peer, char *buf,
+ size_t size);
+extern bool bgp_path_attribute_treat_as_withdraw(struct peer *peer, char *buf,
+ size_t size);
#ifdef _FRR_ATTRIBUTE_PRINTFRR
/* clang-format off */
#pragma FRR printfrr_ext "%pBP" (struct peer *)