diff options
Diffstat (limited to 'bgpd/bgp_route.h')
| -rw-r--r-- | bgpd/bgp_route.h | 169 |
1 files changed, 101 insertions, 68 deletions
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 9bd9e48e22..e9f48ea647 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -145,6 +145,54 @@ struct bgp_sid_info { uint8_t transposition_offset; }; +/* new structure for EVPN */ +struct bgp_path_info_extra_evpn { +#define BGP_EVPN_MACIP_TYPE_SVI_IP (1 << 0) + /* af specific flags */ + uint16_t af_flags; + union { + struct ethaddr mac; /* MAC set here for VNI IP table */ + struct ipaddr ip; /* IP set here for VNI MAC table */ + } vni_info; + /* Destination Ethernet Segment links for EVPN MH */ + struct bgp_path_mh_info *mh_info; +}; + +/* new structure for flowspec*/ +struct bgp_path_info_extra_fs { + /* presence of FS pbr firewall based entry */ + struct list *bgp_fs_pbr; + /* presence of FS pbr iprule based entry */ + struct list *bgp_fs_iprule; +}; + +/* new structure for vrfleak*/ +struct bgp_path_info_extra_vrfleak { + void *parent; /* parent from global table */ + /* + * Original bgp instance for imported routes. Needed for: + * 1. Find all routes from a specific vrf for deletion + * 2. vrf context of original nexthop + * + * Store pointer to bgp instance rather than bgp->vrf_id because + * bgp->vrf_id is not always valid (or may change?). + * + * Set to NULL if route is not imported from another bgp instance. + */ + struct bgp *bgp_orig; + /* + * Original bgp session to know if the session is a + * connected EBGP session or not + */ + struct peer *peer_orig; + /* + * Nexthop in context of original bgp instance. Needed + * for label resolution of core mpls routes exported to a vrf. + * Set nexthop_orig.family to 0 if not valid. + */ + struct prefix nexthop_orig; +}; + /* Ancillary information to struct bgp_path_info, * used for uncommonly used data (aggregation, MPLS, etc.) * and lazily allocated to save memory. @@ -163,13 +211,8 @@ struct bgp_path_info_extra { mpls_label_t label[BGP_MAX_LABELS]; uint32_t num_labels; - /* af specific flags */ - uint16_t af_flags; -#define BGP_EVPN_MACIP_TYPE_SVI_IP (1 << 0) - - /* SRv6 SID(s) for SRv6-VPN */ - struct bgp_sid_info sid[BGP_MAX_SIDS]; - uint32_t num_sids; + /*For EVPN*/ + struct bgp_path_info_extra_evpn *evpn; #ifdef ENABLE_BGP_VNC union { @@ -200,50 +243,27 @@ struct bgp_path_info_extra { } vnc; #endif - /* - * For imported routes into a VNI (or VRF) - */ - void *parent; /* parent from global table */ - union { - struct ethaddr mac; /* MAC set here for VNI IP table */ - struct ipaddr ip; /* IP set here for VNI MAC table */ - } vni_info; + /* For flowspec*/ + struct bgp_path_info_extra_fs *flowspec; - /* - * Some tunnelish parameters follow. Maybe consolidate into an - * internal tunnel structure? - */ + /* For vrf leaking*/ + struct bgp_path_info_extra_vrfleak *vrfleak; +}; - /* - * Original bgp instance for imported routes. Needed for: - * 1. Find all routes from a specific vrf for deletion - * 2. vrf context of original nexthop - * - * Store pointer to bgp instance rather than bgp->vrf_id because - * bgp->vrf_id is not always valid (or may change?). - * - * Set to NULL if route is not imported from another bgp instance. - */ - struct bgp *bgp_orig; +struct bgp_mplsvpn_label_nh { + /* For nexthop per label linked list */ + LIST_ENTRY(bgp_path_info) label_nh_thread; - /* - * Original bgp session to know if the session is a - * connected EBGP session or not - */ - struct peer *peer_orig; + /* Back pointer to the bgp label per nexthop structure */ + struct bgp_label_per_nexthop_cache *label_nexthop_cache; +}; - /* - * Nexthop in context of original bgp instance. Needed - * for label resolution of core mpls routes exported to a vrf. - * Set nexthop_orig.family to 0 if not valid. - */ - struct prefix nexthop_orig; - /* presence of FS pbr firewall based entry */ - struct list *bgp_fs_pbr; - /* presence of FS pbr iprule based entry */ - struct list *bgp_fs_iprule; - /* Destination Ethernet Segment links for EVPN MH */ - struct bgp_path_mh_info *mh_info; +struct bgp_mplsvpn_nh_label_bind { + /* For mplsvpn nexthop label bind linked list */ + LIST_ENTRY(bgp_path_info) nh_label_bind_thread; + + /* Back pointer to the bgp mplsvpn nexthop label bind structure */ + struct bgp_mplsvpn_nh_label_bind_cache *nh_label_bind_cache; }; struct bgp_path_info { @@ -298,6 +318,8 @@ struct bgp_path_info { #define BGP_PATH_ANNC_NH_SELF (1 << 14) #define BGP_PATH_LINK_BW_CHG (1 << 15) #define BGP_PATH_ACCEPT_OWN (1 << 16) +#define BGP_PATH_MPLSVPN_LABEL_NH (1 << 17) +#define BGP_PATH_MPLSVPN_NH_LABEL_BIND (1 << 18) /* BGP route type. This can be static, RIP, OSPF, BGP etc. */ uint8_t type; @@ -320,11 +342,10 @@ struct bgp_path_info { uint32_t addpath_rx_id; struct bgp_addpath_info_data tx_addpath; - /* For nexthop per label linked list */ - LIST_ENTRY(bgp_path_info) label_nh_thread; - - /* Back pointer to the bgp label per nexthop structure */ - struct bgp_label_per_nexthop_cache *label_nexthop_cache; + union { + struct bgp_mplsvpn_label_nh blnc; + struct bgp_mplsvpn_nh_label_bind bmnc; + } mplsvpn; }; /* Structure used in BGP path selection */ @@ -592,8 +613,12 @@ static inline void prep_for_rmap_apply(struct bgp_path_info *dst_pi, } } -static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest) +static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest, + safi_t safi) { + if (!bgp_fibupd_safi(safi)) + return true; + return (!(BGP_SUPPRESS_FIB_ENABLED(bgp) && CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING) && (!bgp_option_check(BGP_OPT_NO_FIB)))); @@ -605,11 +630,12 @@ static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest) * This function assumes that bgp_check_advertise was already returned * as good to go. */ -static inline bool bgp_check_withdrawal(struct bgp *bgp, struct bgp_dest *dest) +static inline bool bgp_check_withdrawal(struct bgp *bgp, struct bgp_dest *dest, + safi_t safi) { struct bgp_path_info *pi, *selected = NULL; - if (!BGP_SUPPRESS_FIB_ENABLED(bgp)) + if (!bgp_fibupd_safi(safi) || !BGP_SUPPRESS_FIB_ENABLED(bgp)) return false; for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) { @@ -644,7 +670,7 @@ static inline bool bgp_check_withdrawal(struct bgp *bgp, struct bgp_dest *dest) /* called before bgp_process() */ DECLARE_HOOK(bgp_process, - (struct bgp * bgp, afi_t afi, safi_t safi, struct bgp_dest *bn, + (struct bgp *bgp, afi_t afi, safi_t safi, struct bgp_dest *bn, struct peer *peer, bool withdraw), (bgp, afi, safi, bn, peer, withdraw)); @@ -695,11 +721,14 @@ extern struct bgp_dest *bgp_afi_node_get(struct bgp_table *table, afi_t afi, struct prefix_rd *prd); extern struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path); extern struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path); +extern bool bgp_path_info_nexthop_changed(struct bgp_path_info *pi, + struct peer *to, afi_t afi); extern struct bgp_path_info * bgp_get_imported_bpi_ultimate(struct bgp_path_info *info); extern void bgp_path_info_add(struct bgp_dest *dest, struct bgp_path_info *pi); extern void bgp_path_info_extra_free(struct bgp_path_info_extra **extra); -extern void bgp_path_info_reap(struct bgp_dest *dest, struct bgp_path_info *pi); +extern struct bgp_dest *bgp_path_info_reap(struct bgp_dest *dest, + struct bgp_path_info *pi); extern void bgp_path_info_delete(struct bgp_dest *dest, struct bgp_path_info *pi); extern struct bgp_path_info_extra * @@ -732,16 +761,14 @@ extern void bgp_purge_static_redist_routes(struct bgp *bgp); extern void bgp_static_update(struct bgp *bgp, const struct prefix *p, struct bgp_static *s, afi_t afi, safi_t safi); extern void bgp_static_withdraw(struct bgp *bgp, const struct prefix *p, - afi_t afi, safi_t safi); - -extern int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty, - const char *, const char *, const char *, - const char *, int, const char *, const char *, - const char *, const char *); + afi_t afi, safi_t safi, struct prefix_rd *prd); -extern int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *, - const char *, const char *, const char *, int, - const char *, const char *, const char *); +extern int bgp_static_set(struct vty *vty, bool negate, const char *ip_str, + const char *rd_str, const char *label_str, afi_t afi, + safi_t safi, const char *rmap, int backdoor, + uint32_t label_index, int evpn_type, const char *esi, + const char *gwip, const char *ethtag, + const char *routermac); /* this is primarily for MPLS-VPN */ extern void bgp_update(struct peer *peer, const struct prefix *p, @@ -860,7 +887,7 @@ extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_path_info *path, afi_t afi, safi_t safi, enum rpki_states, json_object *json_paths); -extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, +extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, struct bgp_table *table, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, uint16_t show_flags); @@ -869,7 +896,8 @@ extern bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, uint8_t type, uint8_t stype, struct attr *attr, struct bgp_dest *dest); extern int bgp_evpn_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, - struct bgp_path_info *exist, int *paths_eq); + struct bgp_path_info *exist, int *paths_eq, + bool debug); extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate, struct bgp *bgp, const struct prefix *p, afi_t afi, @@ -886,6 +914,11 @@ extern void bgp_path_info_add_with_caller(const char *caller, struct bgp_dest *dest, struct bgp_path_info *pi); extern void bgp_aggregate_free(struct bgp_aggregate *aggregate); +extern int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, + struct bgp_path_info *exist, int *paths_eq, + struct bgp_maxpaths_cfg *mpath_cfg, bool debug, + char *pfx_buf, afi_t afi, safi_t safi, + enum bgp_path_selection_reason *reason); #define bgp_path_info_add(A, B) \ bgp_path_info_add_with_caller(__func__, (A), (B)) #define bgp_path_info_free(B) bgp_path_info_free_with_caller(__func__, (B)) |
