1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP routing information base
3 * Copyright (C) 1996, 97, 98, 2000 Kunihiro Ishiguro
6 #ifndef _QUAGGA_BGP_ROUTE_H
7 #define _QUAGGA_BGP_ROUTE_H
14 #include "bgp_table.h"
15 #include "bgp_addpath_types.h"
18 struct bgp_nexthop_cache
;
19 struct bgp_route_evpn
;
24 bgp_show_type_prefix_list
,
25 bgp_show_type_access_list
,
26 bgp_show_type_filter_list
,
27 bgp_show_type_route_map
,
28 bgp_show_type_neighbor
,
29 bgp_show_type_cidr_only
,
30 bgp_show_type_prefix_longer
,
31 bgp_show_type_community_alias
,
32 bgp_show_type_community_all
,
33 bgp_show_type_community
,
34 bgp_show_type_community_exact
,
35 bgp_show_type_community_list
,
36 bgp_show_type_community_list_exact
,
37 bgp_show_type_lcommunity_all
,
38 bgp_show_type_lcommunity
,
39 bgp_show_type_lcommunity_exact
,
40 bgp_show_type_lcommunity_list
,
41 bgp_show_type_lcommunity_list_exact
,
42 bgp_show_type_flap_statistics
,
43 bgp_show_type_flap_neighbor
,
44 bgp_show_type_dampend_paths
,
45 bgp_show_type_damp_neighbor
,
48 bgp_show_type_prefix_version
,
49 bgp_show_type_self_originated
,
52 enum bgp_show_adj_route_type
{
53 bgp_show_adj_route_advertised
,
54 bgp_show_adj_route_received
,
55 bgp_show_adj_route_filtered
,
56 bgp_show_adj_route_bestpath
,
60 #define BGP_SHOW_SCODE_HEADER \
61 "Status codes: s suppressed, d damped, " \
62 "h history, * valid, > best, = multipath,\n" \
63 " i internal, r RIB-failure, S Stale, R Removed\n"
64 #define BGP_SHOW_OCODE_HEADER \
65 "Origin codes: i - IGP, e - EGP, ? - incomplete\n"
66 #define BGP_SHOW_NCODE_HEADER "Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self\n"
67 #define BGP_SHOW_RPKI_HEADER \
68 "RPKI validation codes: V valid, I invalid, N Not found\n\n"
69 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path\n"
70 #define BGP_SHOW_HEADER_WIDE " Network Next Hop Metric LocPrf Weight Path\n"
72 /* Maximum number of labels we can process or send with a prefix. We
73 * really do only 1 for MPLS (BGP-LU) but we can do 2 for EVPN-VxLAN.
75 #define BGP_MAX_LABELS 2
77 /* Maximum number of sids we can process or send with a prefix. */
78 #define BGP_MAX_SIDS 6
80 /* Maximum buffer length for storing BGP best path selection reason */
81 #define BGP_MAX_SELECTION_REASON_STR_BUF 32
83 /* Error codes for handling NLRI */
84 #define BGP_NLRI_PARSE_OK 0
85 #define BGP_NLRI_PARSE_ERROR_PREFIX_OVERFLOW -1
86 #define BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW -2
87 #define BGP_NLRI_PARSE_ERROR_PREFIX_LENGTH -3
88 #define BGP_NLRI_PARSE_ERROR_PACKET_LENGTH -4
89 #define BGP_NLRI_PARSE_ERROR_LABEL_LENGTH -5
90 #define BGP_NLRI_PARSE_ERROR_EVPN_MISSING_TYPE -6
91 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE2_SIZE -7
92 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE3_SIZE -8
93 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE4_SIZE -9
94 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE5_SIZE -10
95 #define BGP_NLRI_PARSE_ERROR_FLOWSPEC_IPV6_NOT_SUPPORTED -11
96 #define BGP_NLRI_PARSE_ERROR_FLOWSPEC_NLRI_SIZELIMIT -12
97 #define BGP_NLRI_PARSE_ERROR_FLOWSPEC_BAD_FORMAT -13
98 #define BGP_NLRI_PARSE_ERROR_ADDRESS_FAMILY -14
99 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE1_SIZE -15
100 #define BGP_NLRI_PARSE_ERROR -32
102 /* 1. local MAC-IP/type-2 paths in the VNI routing table are linked to the
104 * 2. remote MAC-IP paths in the global routing table are linked to the
107 struct bgp_path_es_info
{
108 /* back pointer to the route */
109 struct bgp_path_info
*pi
;
112 struct bgp_evpn_es
*es
;
113 /* memory used for linking the path to the destination ES */
114 struct listnode es_listnode
;
116 /* Path is linked to the VNI list */
117 #define BGP_EVPN_PATH_ES_INFO_VNI_LIST (1 << 0)
118 /* Path is linked to the global list */
119 #define BGP_EVPN_PATH_ES_INFO_GLOBAL_LIST (1 << 1)
122 /* IP paths imported into the VRF from an EVPN route source
123 * are linked to the nexthop/VTEP IP
125 struct bgp_path_evpn_nh_info
{
126 /* back pointer to the route */
127 struct bgp_path_info
*pi
;
128 struct bgp_evpn_nh
*nh
;
129 /* memory used for linking the path to the nexthop */
130 struct listnode nh_listnode
;
133 struct bgp_path_mh_info
{
134 struct bgp_path_es_info
*es_info
;
135 struct bgp_path_evpn_nh_info
*nh_info
;
138 struct bgp_sid_info
{
140 uint8_t loc_block_len
;
141 uint8_t loc_node_len
;
144 uint8_t transposition_len
;
145 uint8_t transposition_offset
;
148 /* Ancillary information to struct bgp_path_info,
149 * used for uncommonly used data (aggregation, MPLS, etc.)
150 * and lazily allocated to save memory.
152 struct bgp_path_info_extra
{
153 /* Pointer to dampening structure. */
154 struct bgp_damp_info
*damp_info
;
156 /** List of aggregations that suppress this path. */
157 struct list
*aggr_suppressors
;
159 /* Nexthop reachability check. */
162 /* MPLS label(s) - VNI(s) for EVPN-VxLAN */
163 mpls_label_t label
[BGP_MAX_LABELS
];
166 /* af specific flags */
168 #define BGP_EVPN_MACIP_TYPE_SVI_IP (1 << 0)
170 /* SRv6 SID(s) for SRv6-VPN */
171 struct bgp_sid_info sid
[BGP_MAX_SIDS
];
174 #ifdef ENABLE_BGP_VNC
178 void *rfapi_handle
; /* export: NVE advertising this
180 struct list
*local_nexthops
; /* optional, for static
186 void *hme
; /* encap monitor, if this is a VPN route */
188 rd
; /* import: route's route-distinguisher */
189 uint8_t un_family
; /* family of cached un address, 0 if
192 struct in_addr addr4
;
193 struct in6_addr addr6
;
194 } un
; /* cached un address */
196 struct prefix aux_prefix
; /* AFI_L2VPN: the IP addr,
204 * For imported routes into a VNI (or VRF)
206 void *parent
; /* parent from global table */
208 struct ethaddr mac
; /* MAC set here for VNI IP table */
209 struct ipaddr ip
; /* IP set here for VNI MAC table */
213 * Some tunnelish parameters follow. Maybe consolidate into an
214 * internal tunnel structure?
218 * Original bgp instance for imported routes. Needed for:
219 * 1. Find all routes from a specific vrf for deletion
220 * 2. vrf context of original nexthop
222 * Store pointer to bgp instance rather than bgp->vrf_id because
223 * bgp->vrf_id is not always valid (or may change?).
225 * Set to NULL if route is not imported from another bgp instance.
227 struct bgp
*bgp_orig
;
230 * Original bgp session to know if the session is a
231 * connected EBGP session or not
233 struct peer
*peer_orig
;
236 * Nexthop in context of original bgp instance. Needed
237 * for label resolution of core mpls routes exported to a vrf.
238 * Set nexthop_orig.family to 0 if not valid.
240 struct prefix nexthop_orig
;
241 /* presence of FS pbr firewall based entry */
242 struct list
*bgp_fs_pbr
;
243 /* presence of FS pbr iprule based entry */
244 struct list
*bgp_fs_iprule
;
245 /* Destination Ethernet Segment links for EVPN MH */
246 struct bgp_path_mh_info
*mh_info
;
249 struct bgp_path_info
{
250 /* For linked list. */
251 struct bgp_path_info
*next
;
252 struct bgp_path_info
*prev
;
254 /* For nexthop linked list */
255 LIST_ENTRY(bgp_path_info
) nh_thread
;
257 /* Back pointer to the prefix node */
258 struct bgp_dest
*net
;
260 /* Back pointer to the nexthop structure */
261 struct bgp_nexthop_cache
*nexthop
;
263 /* Peer structure. */
266 /* Attribute structure. */
269 /* Extra information */
270 struct bgp_path_info_extra
*extra
;
273 /* Multipath information */
274 struct bgp_path_info_mpath
*mpath
;
279 /* reference count */
282 /* BGP information status. */
284 #define BGP_PATH_IGP_CHANGED (1 << 0)
285 #define BGP_PATH_DAMPED (1 << 1)
286 #define BGP_PATH_HISTORY (1 << 2)
287 #define BGP_PATH_SELECTED (1 << 3)
288 #define BGP_PATH_VALID (1 << 4)
289 #define BGP_PATH_ATTR_CHANGED (1 << 5)
290 #define BGP_PATH_DMED_CHECK (1 << 6)
291 #define BGP_PATH_DMED_SELECTED (1 << 7)
292 #define BGP_PATH_STALE (1 << 8)
293 #define BGP_PATH_REMOVED (1 << 9)
294 #define BGP_PATH_COUNTED (1 << 10)
295 #define BGP_PATH_MULTIPATH (1 << 11)
296 #define BGP_PATH_MULTIPATH_CHG (1 << 12)
297 #define BGP_PATH_RIB_ATTR_CHG (1 << 13)
298 #define BGP_PATH_ANNC_NH_SELF (1 << 14)
299 #define BGP_PATH_LINK_BW_CHG (1 << 15)
300 #define BGP_PATH_ACCEPT_OWN (1 << 16)
302 /* BGP route type. This can be static, RIP, OSPF, BGP etc. */
305 /* When above type is BGP. This sub type specify BGP sub type
308 #define BGP_ROUTE_NORMAL 0
309 #define BGP_ROUTE_STATIC 1
310 #define BGP_ROUTE_AGGREGATE 2
311 #define BGP_ROUTE_REDISTRIBUTE 3
312 #ifdef ENABLE_BGP_VNC
313 # define BGP_ROUTE_RFP 4
315 #define BGP_ROUTE_IMPORTED 5 /* from another bgp instance/safi */
317 unsigned short instance
;
319 /* Addpath identifiers */
320 uint32_t addpath_rx_id
;
321 struct bgp_addpath_info_data tx_addpath
;
324 /* Structure used in BGP path selection */
325 struct bgp_path_info_pair
{
326 struct bgp_path_info
*old
;
327 struct bgp_path_info
*new;
330 /* BGP static route configuration. */
332 /* Backdoor configuration. */
335 /* Label index configuration; applies to LU prefixes. */
336 uint32_t label_index
;
337 #define BGP_INVALID_LABEL_INDEX 0xFFFFFFFF
339 /* Import check status. */
346 struct in_addr igpnexthop
;
348 /* Atomic set reference count (ie cause of pathlimit) */
351 /* BGP redistribute route-map. */
354 struct route_map
*map
;
357 /* Route Distinguisher */
358 struct prefix_rd prd
;
366 struct ethaddr
*router_mac
;
367 uint16_t encap_tunneltype
;
368 struct prefix gatewayIp
;
371 /* Aggreagete address:
373 * advertise-map Set condition to advertise attribute
374 * as-set Generate AS set path information
375 * attribute-map Set attributes of aggregate
376 * route-map Set parameters of aggregate
377 * summary-only Filter more specific routes from updates
378 * suppress-map Conditionally filter more specific routes from updates
381 struct bgp_aggregate
{
382 /* Summary-only flag. */
383 uint8_t summary_only
;
385 /* AS set generation. */
388 /* Route-map for aggregated route. */
391 struct route_map
*map
;
394 /* Suppress-count. */
397 /* Count of routes of origin type incomplete under this aggregate. */
398 unsigned long incomplete_origin_count
;
400 /* Count of routes of origin type egp under this aggregate. */
401 unsigned long egp_origin_count
;
403 /* Optional modify flag to override ORIGIN */
406 /* Hash containing the communities of all the
407 * routes under this aggregate.
409 struct hash
*community_hash
;
411 /* Hash containing the extended communities of all the
412 * routes under this aggregate.
414 struct hash
*ecommunity_hash
;
416 /* Hash containing the large communities of all the
417 * routes under this aggregate.
419 struct hash
*lcommunity_hash
;
421 /* Hash containing the AS-Path of all the
422 * routes under this aggregate.
424 struct hash
*aspath_hash
;
426 /* Aggregate route's community. */
427 struct community
*community
;
429 /* Aggregate route's extended community. */
430 struct ecommunity
*ecommunity
;
432 /* Aggregate route's large community. */
433 struct lcommunity
*lcommunity
;
435 /* Aggregate route's as-path. */
436 struct aspath
*aspath
;
438 /* SAFI configuration. */
441 /** Match only equal MED. */
443 /* MED matching state. */
444 /** Did we get the first MED value? */
445 bool med_initialized
;
446 /** Are there MED mismatches? */
448 /** MED value found in current group. */
449 uint32_t med_matched_value
;
452 * Test if aggregated address MED of all route match, otherwise
453 * returns `false`. This macro will also return `true` if MED
454 * matching is disabled.
456 #define AGGREGATE_MED_VALID(aggregate) \
457 (((aggregate)->match_med && !(aggregate)->med_mismatched) \
458 || !(aggregate)->match_med)
460 /** Suppress map route map name (`NULL` when disabled). */
461 char *suppress_map_name
;
462 /** Suppress map route map pointer. */
463 struct route_map
*suppress_map
;
466 #define BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen) \
467 ((nhlen) < IPV4_MAX_BYTELEN \
469 : ((nhlen) < IPV6_MAX_BYTELEN ? AFI_IP : AFI_IP6))
471 #define BGP_ATTR_MP_NEXTHOP_LEN_IP6(attr) \
472 ((attr)->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || \
473 (attr)->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL || \
474 (attr)->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL || \
475 (attr)->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
477 #define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \
478 (!CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) && \
479 BGP_ATTR_MP_NEXTHOP_LEN_IP6(attr))
481 #define BGP_PATH_COUNTABLE(BI) \
482 (!CHECK_FLAG((BI)->flags, BGP_PATH_HISTORY) \
483 && !CHECK_FLAG((BI)->flags, BGP_PATH_REMOVED))
485 /* Flags which indicate a route is unuseable in some form */
486 #define BGP_PATH_UNUSEABLE \
487 (BGP_PATH_HISTORY | BGP_PATH_DAMPED | BGP_PATH_REMOVED)
488 /* Macro to check BGP information is alive or not. Sadly,
489 * not equivalent to just checking previous, because of the
490 * sense of the additional VALID flag.
492 #define BGP_PATH_HOLDDOWN(BI) \
493 (!CHECK_FLAG((BI)->flags, BGP_PATH_VALID) \
494 || CHECK_FLAG((BI)->flags, BGP_PATH_UNUSEABLE))
496 #define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
497 #define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
498 #define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
499 #define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
501 #define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
502 #define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
503 #define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
504 #define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
506 #define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
507 #define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
508 #define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
509 #define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
511 #define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
512 #define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
513 #define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
514 #define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
516 #define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
517 #define UNSUPPRESS_MAP(F) ((F)->usmap.map)
519 #define ADVERTISE_MAP_NAME(F) ((F)->advmap.aname)
520 #define ADVERTISE_MAP(F) ((F)->advmap.amap)
522 #define ADVERTISE_CONDITION(F) ((F)->advmap.condition)
524 #define CONDITION_MAP_NAME(F) ((F)->advmap.cname)
525 #define CONDITION_MAP(F) ((F)->advmap.cmap)
527 /* path PREFIX (addpath rxid NUMBER) */
528 #define PATH_ADDPATH_STR_BUFFER PREFIX2STR_BUFFER + 32
532 BGP_PATH_SHOW_BESTPATH
,
533 BGP_PATH_SHOW_MULTIPATH
536 static inline void bgp_bump_version(struct bgp_dest
*dest
)
538 dest
->version
= bgp_table_next_version(bgp_dest_table(dest
));
541 static inline int bgp_fibupd_safi(safi_t safi
)
543 if (safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
544 || safi
== SAFI_LABELED_UNICAST
545 || safi
== SAFI_FLOWSPEC
)
550 /* Flag if the route path's family matches params. */
551 static inline bool is_pi_family_matching(struct bgp_path_info
*pi
,
552 afi_t afi
, safi_t safi
)
554 struct bgp_table
*table
;
555 struct bgp_dest
*dest
;
560 table
= bgp_dest_table(dest
);
568 static inline void prep_for_rmap_apply(struct bgp_path_info
*dst_pi
,
569 struct bgp_path_info_extra
*dst_pie
,
570 struct bgp_dest
*dest
,
571 struct bgp_path_info
*src_pi
,
572 struct peer
*peer
, struct attr
*attr
)
574 memset(dst_pi
, 0, sizeof(struct bgp_path_info
));
578 dst_pi
->flags
= src_pi
->flags
;
579 dst_pi
->type
= src_pi
->type
;
580 dst_pi
->sub_type
= src_pi
->sub_type
;
581 dst_pi
->mpath
= src_pi
->mpath
;
583 memcpy(dst_pie
, src_pi
->extra
,
584 sizeof(struct bgp_path_info_extra
));
585 dst_pi
->extra
= dst_pie
;
589 static inline bool bgp_check_advertise(struct bgp
*bgp
, struct bgp_dest
*dest
)
591 return (!(BGP_SUPPRESS_FIB_ENABLED(bgp
) &&
592 CHECK_FLAG(dest
->flags
, BGP_NODE_FIB_INSTALL_PENDING
) &&
593 (!bgp_option_check(BGP_OPT_NO_FIB
))));
597 * If we have a fib result and it failed to install( or was withdrawn due
598 * to better admin distance we need to send down the wire a withdrawal.
599 * This function assumes that bgp_check_advertise was already returned
602 static inline bool bgp_check_withdrawal(struct bgp
*bgp
, struct bgp_dest
*dest
)
604 struct bgp_path_info
*pi
, *selected
= NULL
;
606 if (!BGP_SUPPRESS_FIB_ENABLED(bgp
))
609 for (pi
= bgp_dest_get_bgp_path_info(dest
); pi
; pi
= pi
->next
) {
610 if (CHECK_FLAG(pi
->flags
, BGP_PATH_SELECTED
)) {
615 if (pi
->sub_type
!= BGP_ROUTE_NORMAL
)
620 * pi is selected and bgp is dealing with a static route
621 * ( ie a network statement of some sort ). FIB installed
624 * I am not sure what the above for loop is wanted in this
625 * manner at this point. But I do know that if I have
626 * a static route that is selected and it's the one
627 * being checked for should I withdrawal we do not
628 * want to withdraw the route on installation :)
630 if (selected
&& selected
->sub_type
== BGP_ROUTE_STATIC
)
633 if (CHECK_FLAG(dest
->flags
, BGP_NODE_FIB_INSTALLED
))
639 /* called before bgp_process() */
640 DECLARE_HOOK(bgp_process
,
641 (struct bgp
* bgp
, afi_t afi
, safi_t safi
, struct bgp_dest
*bn
,
642 struct peer
*peer
, bool withdraw
),
643 (bgp
, afi
, safi
, bn
, peer
, withdraw
));
645 /* BGP show options */
646 #define BGP_SHOW_OPT_JSON (1 << 0)
647 #define BGP_SHOW_OPT_WIDE (1 << 1)
648 #define BGP_SHOW_OPT_AFI_ALL (1 << 2)
649 #define BGP_SHOW_OPT_AFI_IP (1 << 3)
650 #define BGP_SHOW_OPT_AFI_IP6 (1 << 4)
651 #define BGP_SHOW_OPT_ESTABLISHED (1 << 5)
652 #define BGP_SHOW_OPT_FAILED (1 << 6)
653 #define BGP_SHOW_OPT_JSON_DETAIL (1 << 7)
654 #define BGP_SHOW_OPT_TERSE (1 << 8)
655 #define BGP_SHOW_OPT_ROUTES_DETAIL (1 << 9)
658 extern void bgp_rib_remove(struct bgp_dest
*dest
, struct bgp_path_info
*pi
,
659 struct peer
*peer
, afi_t afi
, safi_t safi
);
660 extern void bgp_process_queue_init(struct bgp
*bgp
);
661 extern void bgp_route_init(void);
662 extern void bgp_route_finish(void);
663 extern void bgp_cleanup_routes(struct bgp
*);
664 extern void bgp_free_aggregate_info(struct bgp_aggregate
*aggregate
);
665 extern void bgp_announce_route(struct peer
*peer
, afi_t afi
, safi_t safi
,
667 extern void bgp_stop_announce_route_timer(struct peer_af
*paf
);
668 extern void bgp_announce_route_all(struct peer
*);
669 extern void bgp_default_originate(struct peer
*, afi_t
, safi_t
, int);
670 extern void bgp_soft_reconfig_table_task_cancel(const struct bgp
*bgp
,
671 const struct bgp_table
*table
,
672 const struct peer
*peer
);
675 * If this peer is configured for soft reconfig in then do the work
676 * and return true. If it is not return false; and do nothing
678 extern bool bgp_soft_reconfig_in(struct peer
*peer
, afi_t afi
, safi_t safi
);
679 extern void bgp_clear_route(struct peer
*, afi_t
, safi_t
);
680 extern void bgp_clear_route_all(struct peer
*);
681 extern void bgp_clear_adj_in(struct peer
*, afi_t
, safi_t
);
682 extern void bgp_clear_stale_route(struct peer
*, afi_t
, safi_t
);
683 extern void bgp_set_stale_route(struct peer
*peer
, afi_t afi
, safi_t safi
);
684 extern bool bgp_outbound_policy_exists(struct peer
*, struct bgp_filter
*);
685 extern bool bgp_inbound_policy_exists(struct peer
*, struct bgp_filter
*);
687 extern struct bgp_dest
*bgp_afi_node_get(struct bgp_table
*table
, afi_t afi
,
688 safi_t safi
, const struct prefix
*p
,
689 struct prefix_rd
*prd
);
690 extern struct bgp_path_info
*bgp_path_info_lock(struct bgp_path_info
*path
);
691 extern struct bgp_path_info
*bgp_path_info_unlock(struct bgp_path_info
*path
);
692 extern struct bgp_path_info
*
693 bgp_get_imported_bpi_ultimate(struct bgp_path_info
*info
);
694 extern void bgp_path_info_add(struct bgp_dest
*dest
, struct bgp_path_info
*pi
);
695 extern void bgp_path_info_extra_free(struct bgp_path_info_extra
**extra
);
696 extern void bgp_path_info_reap(struct bgp_dest
*dest
, struct bgp_path_info
*pi
);
697 extern void bgp_path_info_delete(struct bgp_dest
*dest
,
698 struct bgp_path_info
*pi
);
699 extern struct bgp_path_info_extra
*
700 bgp_path_info_extra_get(struct bgp_path_info
*path
);
701 extern void bgp_path_info_set_flag(struct bgp_dest
*dest
,
702 struct bgp_path_info
*path
, uint32_t flag
);
703 extern void bgp_path_info_unset_flag(struct bgp_dest
*dest
,
704 struct bgp_path_info
*path
, uint32_t flag
);
705 extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info
*pi
,
706 char *buf
, size_t buf_len
);
708 extern int bgp_nlri_parse_ip(struct peer
*, struct attr
*, struct bgp_nlri
*);
710 extern bool bgp_maximum_prefix_overflow(struct peer
*, afi_t
, safi_t
, int);
712 extern void bgp_redistribute_add(struct bgp
*bgp
, struct prefix
*p
,
713 const union g_addr
*nexthop
, ifindex_t ifindex
,
714 enum nexthop_types_t nhtype
, uint8_t distance
,
715 enum blackhole_type bhtype
, uint32_t metric
,
716 uint8_t type
, unsigned short instance
,
718 extern void bgp_redistribute_delete(struct bgp
*, struct prefix
*, uint8_t,
720 extern void bgp_redistribute_withdraw(struct bgp
*, afi_t
, int, unsigned short);
722 extern void bgp_static_add(struct bgp
*);
723 extern void bgp_static_delete(struct bgp
*);
724 extern void bgp_static_redo_import_check(struct bgp
*);
725 extern void bgp_purge_static_redist_routes(struct bgp
*bgp
);
726 extern void bgp_static_update(struct bgp
*bgp
, const struct prefix
*p
,
727 struct bgp_static
*s
, afi_t afi
, safi_t safi
);
728 extern void bgp_static_withdraw(struct bgp
*bgp
, const struct prefix
*p
,
729 afi_t afi
, safi_t safi
);
731 extern int bgp_static_set_safi(afi_t afi
, safi_t safi
, struct vty
*vty
,
732 const char *, const char *, const char *,
733 const char *, int, const char *, const char *,
734 const char *, const char *);
736 extern int bgp_static_unset_safi(afi_t afi
, safi_t safi
, struct vty
*,
737 const char *, const char *, const char *, int,
738 const char *, const char *, const char *);
740 /* this is primarily for MPLS-VPN */
741 extern void bgp_update(struct peer
*peer
, const struct prefix
*p
,
742 uint32_t addpath_id
, struct attr
*attr
, afi_t afi
,
743 safi_t safi
, int type
, int sub_type
,
744 struct prefix_rd
*prd
, mpls_label_t
*label
,
745 uint32_t num_labels
, int soft_reconfig
,
746 struct bgp_route_evpn
*evpn
);
747 extern void bgp_withdraw(struct peer
*peer
, const struct prefix
*p
,
748 uint32_t addpath_id
, afi_t afi
, safi_t safi
, int type
,
749 int sub_type
, struct prefix_rd
*prd
,
750 mpls_label_t
*label
, uint32_t num_labels
,
751 struct bgp_route_evpn
*evpn
);
753 /* for bgp_nexthop and bgp_damp */
754 extern void bgp_process(struct bgp
*, struct bgp_dest
*, afi_t
, safi_t
);
757 * Add an end-of-initial-update marker to the process queue. This is just a
758 * queue element with NULL bgp node.
760 extern void bgp_add_eoiu_mark(struct bgp
*);
761 extern void bgp_config_write_table_map(struct vty
*, struct bgp
*, afi_t
,
763 extern void bgp_config_write_network(struct vty
*, struct bgp
*, afi_t
, safi_t
);
764 extern void bgp_config_write_distance(struct vty
*, struct bgp
*, afi_t
,
767 extern void bgp_aggregate_delete(struct bgp
*bgp
, const struct prefix
*p
,
768 afi_t afi
, safi_t safi
,
769 struct bgp_aggregate
*aggregate
);
770 extern bool bgp_aggregate_route(struct bgp
*bgp
, const struct prefix
*p
,
771 afi_t afi
, safi_t safi
,
772 struct bgp_aggregate
*aggregate
);
773 extern void bgp_aggregate_increment(struct bgp
*bgp
, const struct prefix
*p
,
774 struct bgp_path_info
*path
, afi_t afi
,
776 extern void bgp_aggregate_decrement(struct bgp
*bgp
, const struct prefix
*p
,
777 struct bgp_path_info
*path
, afi_t afi
,
780 extern uint8_t bgp_distance_apply(const struct prefix
*p
,
781 struct bgp_path_info
*path
, afi_t afi
,
782 safi_t safi
, struct bgp
*bgp
);
784 extern afi_t
bgp_node_afi(struct vty
*);
785 extern safi_t
bgp_node_safi(struct vty
*);
787 extern struct bgp_path_info
*info_make(int type
, int sub_type
,
788 unsigned short instance
,
789 struct peer
*peer
, struct attr
*attr
,
790 struct bgp_dest
*dest
);
792 extern void route_vty_out(struct vty
*vty
, const struct prefix
*p
,
793 struct bgp_path_info
*path
, int display
, safi_t safi
,
794 json_object
*json_paths
, bool wide
);
795 extern void route_vty_out_tag(struct vty
*vty
, const struct prefix
*p
,
796 struct bgp_path_info
*path
, int display
,
797 safi_t safi
, json_object
*json
);
798 extern void route_vty_out_tmp(struct vty
*vty
, struct bgp_dest
*dest
,
799 const struct prefix
*p
, struct attr
*attr
,
800 safi_t safi
, bool use_json
, json_object
*json_ar
,
802 extern void route_vty_out_overlay(struct vty
*vty
, const struct prefix
*p
,
803 struct bgp_path_info
*path
, int display
,
806 extern void bgp_notify_conditional_adv_scanner(struct update_subgroup
*subgrp
);
808 extern void subgroup_process_announce_selected(struct update_subgroup
*subgrp
,
809 struct bgp_path_info
*selected
,
810 struct bgp_dest
*dest
,
811 uint32_t addpath_tx_id
);
813 extern bool subgroup_announce_check(struct bgp_dest
*dest
,
814 struct bgp_path_info
*pi
,
815 struct update_subgroup
*subgrp
,
816 const struct prefix
*p
, struct attr
*attr
,
817 struct attr
*post_attr
);
819 extern void bgp_peer_clear_node_queue_drain_immediate(struct peer
*peer
);
820 extern void bgp_process_queues_drain_immediate(void);
823 extern struct bgp_dest
*bgp_safi_node_lookup(struct bgp_table
*table
,
825 const struct prefix
*p
,
826 struct prefix_rd
*prd
);
827 extern void bgp_path_info_restore(struct bgp_dest
*dest
,
828 struct bgp_path_info
*path
);
830 extern int bgp_path_info_cmp_compatible(struct bgp
*bgp
,
831 struct bgp_path_info
*new,
832 struct bgp_path_info
*exist
,
833 char *pfx_buf
, afi_t afi
, safi_t safi
,
834 enum bgp_path_selection_reason
*reason
);
835 extern void bgp_attr_add_llgr_community(struct attr
*attr
);
836 extern void bgp_attr_add_gshut_community(struct attr
*attr
);
838 extern void bgp_best_selection(struct bgp
*bgp
, struct bgp_dest
*dest
,
839 struct bgp_maxpaths_cfg
*mpath_cfg
,
840 struct bgp_path_info_pair
*result
, afi_t afi
,
842 extern void bgp_zebra_clear_route_change_flags(struct bgp_dest
*dest
);
843 extern bool bgp_zebra_has_route_changed(struct bgp_path_info
*selected
);
845 extern void route_vty_out_detail_header(struct vty
*vty
, struct bgp
*bgp
,
846 struct bgp_dest
*dest
,
847 const struct prefix
*p
,
848 const struct prefix_rd
*prd
, afi_t afi
,
849 safi_t safi
, json_object
*json
,
850 bool incremental_print
);
851 extern void route_vty_out_detail(struct vty
*vty
, struct bgp
*bgp
,
852 struct bgp_dest
*bn
, const struct prefix
*p
,
853 struct bgp_path_info
*path
, afi_t afi
,
854 safi_t safi
, enum rpki_states
,
855 json_object
*json_paths
);
856 extern int bgp_show_table_rd(struct vty
*vty
, struct bgp
*bgp
, safi_t safi
,
857 struct bgp_table
*table
, struct prefix_rd
*prd
,
858 enum bgp_show_type type
, void *output_arg
,
859 uint16_t show_flags
);
860 extern void bgp_best_path_select_defer(struct bgp
*bgp
, afi_t afi
, safi_t safi
);
861 extern bool bgp_update_martian_nexthop(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
862 uint8_t type
, uint8_t stype
,
863 struct attr
*attr
, struct bgp_dest
*dest
);
864 extern int bgp_evpn_path_info_cmp(struct bgp
*bgp
, struct bgp_path_info
*new,
865 struct bgp_path_info
*exist
, int *paths_eq
);
866 extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate
*aggregate
,
868 const struct prefix
*p
, afi_t afi
,
869 safi_t safi
, bool suppress
);
870 extern void subgroup_announce_reset_nhop(uint8_t family
, struct attr
*attr
);
872 bgp_path_selection_reason2str(enum bgp_path_selection_reason reason
);
873 extern bool bgp_addpath_encode_rx(struct peer
*peer
, afi_t afi
, safi_t safi
);
874 extern const struct prefix_rd
*bgp_rd_from_dest(const struct bgp_dest
*dest
,
876 extern void bgp_path_info_free_with_caller(const char *caller
,
877 struct bgp_path_info
*path
);
878 extern void bgp_path_info_add_with_caller(const char *caller
,
879 struct bgp_dest
*dest
,
880 struct bgp_path_info
*pi
);
881 extern void bgp_aggregate_free(struct bgp_aggregate
*aggregate
);
882 #define bgp_path_info_add(A, B) \
883 bgp_path_info_add_with_caller(__func__, (A), (B))
884 #define bgp_path_info_free(B) bgp_path_info_free_with_caller(__func__, (B))
885 #endif /* _QUAGGA_BGP_ROUTE_H */