X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=bgpd%2Fbgp_route.h;h=0b3a203af760299d67bdb7c47dfb03b91978ac23;hb=86afd5292f1769c6c1c1db7a1e65f09fed27b87d;hp=c4f3ad1120f80a061ae1e8caaf70392c0fc9b010;hpb=9f049418bc2fe2500a4c7dbba11d1eefa9c1408c;p=mirror_frr.git diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index c4f3ad112..0b3a203af 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -24,6 +24,7 @@ #include "queue.h" #include "nexthop.h" #include "bgp_table.h" +#include "bgp_addpath_types.h" struct bgp_nexthop_cache; struct bgp_route_evpn; @@ -72,11 +73,11 @@ enum bgp_show_adj_route_type { */ #define BGP_MAX_LABELS 2 -/* Ancillary information to struct bgp_info, +/* Ancillary information to struct bgp_path_info, * used for uncommonly used data (aggregation, MPLS, etc.) * and lazily allocated to save memory. */ -struct bgp_info_extra { +struct bgp_path_info_extra { /* Pointer to dampening structure. */ struct bgp_damp_info *damp_info; @@ -150,13 +151,13 @@ struct bgp_info_extra { struct list *bgp_fs_pbr; }; -struct bgp_info { +struct bgp_path_info { /* For linked list. */ - struct bgp_info *next; - struct bgp_info *prev; + struct bgp_path_info *next; + struct bgp_path_info *prev; /* For nexthop linked list */ - LIST_ENTRY(bgp_info) nh_thread; + LIST_ENTRY(bgp_path_info) nh_thread; /* Back pointer to the prefix node */ struct bgp_node *net; @@ -171,11 +172,11 @@ struct bgp_info { struct attr *attr; /* Extra information */ - struct bgp_info_extra *extra; + struct bgp_path_info_extra *extra; /* Multipath information */ - struct bgp_info_mpath *mpath; + struct bgp_path_info_mpath *mpath; /* Uptime. */ time_t uptime; @@ -185,21 +186,21 @@ struct bgp_info { /* BGP information status. */ uint16_t flags; -#define BGP_INFO_IGP_CHANGED (1 << 0) -#define BGP_INFO_DAMPED (1 << 1) -#define BGP_INFO_HISTORY (1 << 2) -#define BGP_INFO_SELECTED (1 << 3) -#define BGP_INFO_VALID (1 << 4) -#define BGP_INFO_ATTR_CHANGED (1 << 5) -#define BGP_INFO_DMED_CHECK (1 << 6) -#define BGP_INFO_DMED_SELECTED (1 << 7) -#define BGP_INFO_STALE (1 << 8) -#define BGP_INFO_REMOVED (1 << 9) -#define BGP_INFO_COUNTED (1 << 10) -#define BGP_INFO_MULTIPATH (1 << 11) -#define BGP_INFO_MULTIPATH_CHG (1 << 12) -#define BGP_INFO_RIB_ATTR_CHG (1 << 13) -#define BGP_INFO_ANNC_NH_SELF (1 << 14) +#define BGP_PATH_IGP_CHANGED (1 << 0) +#define BGP_PATH_DAMPED (1 << 1) +#define BGP_PATH_HISTORY (1 << 2) +#define BGP_PATH_SELECTED (1 << 3) +#define BGP_PATH_VALID (1 << 4) +#define BGP_PATH_ATTR_CHANGED (1 << 5) +#define BGP_PATH_DMED_CHECK (1 << 6) +#define BGP_PATH_DMED_SELECTED (1 << 7) +#define BGP_PATH_STALE (1 << 8) +#define BGP_PATH_REMOVED (1 << 9) +#define BGP_PATH_COUNTED (1 << 10) +#define BGP_PATH_MULTIPATH (1 << 11) +#define BGP_PATH_MULTIPATH_CHG (1 << 12) +#define BGP_PATH_RIB_ATTR_CHG (1 << 13) +#define BGP_PATH_ANNC_NH_SELF (1 << 14) /* BGP route type. This can be static, RIP, OSPF, BGP etc. */ uint8_t type; @@ -220,13 +221,13 @@ struct bgp_info { /* Addpath identifiers */ uint32_t addpath_rx_id; - uint32_t addpath_tx_id; + struct bgp_addpath_info_data tx_addpath; }; /* Structure used in BGP path selection */ -struct bgp_info_pair { - struct bgp_info *old; - struct bgp_info *new; +struct bgp_path_info_pair { + struct bgp_path_info *old; + struct bgp_path_info *new; }; /* BGP static route configuration. */ @@ -277,20 +278,20 @@ struct bgp_static { #define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \ (!CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) \ && ((attr)->mp_nexthop_len == 16 || (attr)->mp_nexthop_len == 32)) -#define BGP_INFO_COUNTABLE(BI) \ - (!CHECK_FLAG((BI)->flags, BGP_INFO_HISTORY) \ - && !CHECK_FLAG((BI)->flags, BGP_INFO_REMOVED)) +#define BGP_PATH_COUNTABLE(BI) \ + (!CHECK_FLAG((BI)->flags, BGP_PATH_HISTORY) \ + && !CHECK_FLAG((BI)->flags, BGP_PATH_REMOVED)) /* Flags which indicate a route is unuseable in some form */ -#define BGP_INFO_UNUSEABLE \ - (BGP_INFO_HISTORY | BGP_INFO_DAMPED | BGP_INFO_REMOVED) +#define BGP_PATH_UNUSEABLE \ + (BGP_PATH_HISTORY | BGP_PATH_DAMPED | BGP_PATH_REMOVED) /* Macro to check BGP information is alive or not. Sadly, * not equivalent to just checking previous, because of the * sense of the additional VALID flag. */ -#define BGP_INFO_HOLDDOWN(BI) \ - (!CHECK_FLAG((BI)->flags, BGP_INFO_VALID) \ - || CHECK_FLAG((BI)->flags, BGP_INFO_UNUSEABLE)) +#define BGP_PATH_HOLDDOWN(BI) \ + (!CHECK_FLAG((BI)->flags, BGP_PATH_VALID) \ + || CHECK_FLAG((BI)->flags, BGP_PATH_UNUSEABLE)) #define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name) #define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist) @@ -318,7 +319,11 @@ struct bgp_static { /* path PREFIX (addpath rxid NUMBER) */ #define PATH_ADDPATH_STR_BUFFER PREFIX2STR_BUFFER + 32 -enum bgp_path_type { BGP_PATH_ALL, BGP_PATH_BESTPATH, BGP_PATH_MULTIPATH }; +enum bgp_path_type { + BGP_PATH_SHOW_ALL, + BGP_PATH_SHOW_BESTPATH, + BGP_PATH_SHOW_MULTIPATH +}; static inline void bgp_bump_version(struct bgp_node *node) { @@ -335,7 +340,7 @@ static inline int bgp_fibupd_safi(safi_t safi) } /* Prototypes. */ -extern void bgp_rib_remove(struct bgp_node *rn, struct bgp_info *ri, +extern void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *pi, struct peer *peer, afi_t afi, safi_t safi); extern void bgp_process_queue_init(void); extern void bgp_route_init(void); @@ -354,15 +359,20 @@ extern void bgp_clear_stale_route(struct peer *, afi_t, safi_t); extern struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, struct prefix_rd *prd); -extern struct bgp_info *bgp_info_lock(struct bgp_info *); -extern struct bgp_info *bgp_info_unlock(struct bgp_info *); -extern void bgp_info_add(struct bgp_node *rn, struct bgp_info *ri); -extern void bgp_info_reap(struct bgp_node *rn, struct bgp_info *ri); -extern void bgp_info_delete(struct bgp_node *rn, struct bgp_info *ri); -extern struct bgp_info_extra *bgp_info_extra_get(struct bgp_info *); -extern void bgp_info_set_flag(struct bgp_node *, struct bgp_info *, uint32_t); -extern void bgp_info_unset_flag(struct bgp_node *, struct bgp_info *, uint32_t); -extern void bgp_info_path_with_addpath_rx_str(struct bgp_info *ri, char *buf); +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 void bgp_path_info_add(struct bgp_node *rn, 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_node *rn, struct bgp_path_info *pi); +extern void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *pi); +extern struct bgp_path_info_extra * +bgp_path_info_extra_get(struct bgp_path_info *path); +extern void bgp_path_info_set_flag(struct bgp_node *rn, + struct bgp_path_info *path, uint32_t flag); +extern void bgp_path_info_unset_flag(struct bgp_node *rn, + struct bgp_path_info *path, uint32_t flag); +extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi, + char *buf); extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *); @@ -416,37 +426,44 @@ extern void bgp_config_write_network(struct vty *, struct bgp *, afi_t, safi_t); extern void bgp_config_write_distance(struct vty *, struct bgp *, afi_t, safi_t); -extern void bgp_aggregate_increment(struct bgp *, struct prefix *, - struct bgp_info *, afi_t, safi_t); -extern void bgp_aggregate_decrement(struct bgp *, struct prefix *, - struct bgp_info *, afi_t, safi_t); +extern void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p, + struct bgp_path_info *path, afi_t afi, + safi_t safi); +extern void bgp_aggregate_decrement(struct bgp *bgp, struct prefix *p, + struct bgp_path_info *path, afi_t afi, + safi_t safi); -extern uint8_t bgp_distance_apply(struct prefix *, struct bgp_info *, afi_t, - safi_t, struct bgp *); +extern uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *path, + afi_t afi, safi_t safi, struct bgp *bgp); extern afi_t bgp_node_afi(struct vty *); extern safi_t bgp_node_safi(struct vty *); -extern struct bgp_info *info_make(int type, int sub_type, - unsigned short instance, struct peer *peer, - struct attr *attr, struct bgp_node *rn); - -extern void route_vty_out(struct vty *, struct prefix *, struct bgp_info *, int, - safi_t, json_object *); -extern void route_vty_out_tag(struct vty *, struct prefix *, struct bgp_info *, - int, safi_t, json_object *); -extern void route_vty_out_tmp(struct vty *, struct prefix *, struct attr *, - safi_t, bool, json_object *); +extern struct bgp_path_info *info_make(int type, int sub_type, + unsigned short instance, + struct peer *peer, struct attr *attr, + struct bgp_node *rn); + +extern void route_vty_out(struct vty *vty, struct prefix *p, + struct bgp_path_info *path, int display, safi_t safi, + json_object *json_paths); +extern void route_vty_out_tag(struct vty *vty, struct prefix *p, + struct bgp_path_info *path, int display, + safi_t safi, json_object *json); +extern void route_vty_out_tmp(struct vty *vty, struct prefix *p, + struct attr *attr, safi_t safi, bool use_json, + json_object *json_ar); extern void route_vty_out_overlay(struct vty *vty, struct prefix *p, - struct bgp_info *binfo, int display, + struct bgp_path_info *path, int display, json_object *json); extern int subgroup_process_announce_selected(struct update_subgroup *subgrp, - struct bgp_info *selected, + struct bgp_path_info *selected, struct bgp_node *rn, uint32_t addpath_tx_id); -extern int subgroup_announce_check(struct bgp_node *rn, struct bgp_info *ri, +extern int subgroup_announce_check(struct bgp_node *rn, + struct bgp_path_info *pi, struct update_subgroup *subgrp, struct prefix *p, struct attr *attr); @@ -457,28 +474,30 @@ extern void bgp_process_queues_drain_immediate(void); extern struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, struct prefix_rd *prd); -extern struct bgp_info *bgp_info_new(void); -extern void bgp_info_restore(struct bgp_node *, struct bgp_info *); - -extern int bgp_info_cmp_compatible(struct bgp *, struct bgp_info *, - struct bgp_info *, char *pfx_buf, afi_t afi, - safi_t safi); +extern struct bgp_path_info *bgp_path_info_new(void); +extern void bgp_path_info_restore(struct bgp_node *rn, + struct bgp_path_info *path); + +extern int bgp_path_info_cmp_compatible(struct bgp *bgp, + struct bgp_path_info *new, + struct bgp_path_info *exist, + char *pfx_buf, afi_t afi, safi_t safi); extern void bgp_attr_add_gshut_community(struct attr *attr); extern void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, struct bgp_maxpaths_cfg *mpath_cfg, - struct bgp_info_pair *result, afi_t afi, + struct bgp_path_info_pair *result, afi_t afi, safi_t safi); extern void bgp_zebra_clear_route_change_flags(struct bgp_node *rn); extern int bgp_zebra_has_route_changed(struct bgp_node *rn, - struct bgp_info *selected); + struct bgp_path_info *selected); extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, struct bgp_node *rn, struct prefix_rd *prd, afi_t afi, safi_t safi, json_object *json); extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, - struct prefix *p, struct bgp_info *binfo, + struct prefix *p, struct bgp_path_info *path, afi_t afi, safi_t safi, json_object *json_paths); extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,