]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_route.h
7609f7196dead193b438682da05887184095fef0
[mirror_frr.git] / bgpd / bgp_route.h
1 /* BGP routing information base
2 * Copyright (C) 1996, 97, 98, 2000 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef _QUAGGA_BGP_ROUTE_H
22 #define _QUAGGA_BGP_ROUTE_H
23
24 #include <stdbool.h>
25
26 #include "hook.h"
27 #include "queue.h"
28 #include "nexthop.h"
29 #include "bgp_table.h"
30 #include "bgp_addpath_types.h"
31 #include "bgp_rpki.h"
32
33 struct bgp_nexthop_cache;
34 struct bgp_route_evpn;
35
36 enum bgp_show_type {
37 bgp_show_type_normal,
38 bgp_show_type_regexp,
39 bgp_show_type_prefix_list,
40 bgp_show_type_filter_list,
41 bgp_show_type_route_map,
42 bgp_show_type_neighbor,
43 bgp_show_type_cidr_only,
44 bgp_show_type_prefix_longer,
45 bgp_show_type_community_alias,
46 bgp_show_type_community_all,
47 bgp_show_type_community,
48 bgp_show_type_community_exact,
49 bgp_show_type_community_list,
50 bgp_show_type_community_list_exact,
51 bgp_show_type_lcommunity_all,
52 bgp_show_type_lcommunity,
53 bgp_show_type_lcommunity_exact,
54 bgp_show_type_lcommunity_list,
55 bgp_show_type_lcommunity_list_exact,
56 bgp_show_type_flap_statistics,
57 bgp_show_type_flap_neighbor,
58 bgp_show_type_dampend_paths,
59 bgp_show_type_damp_neighbor,
60 bgp_show_type_detail,
61 bgp_show_type_rpki,
62 bgp_show_type_prefix_version,
63 };
64
65 enum bgp_show_adj_route_type {
66 bgp_show_adj_route_advertised,
67 bgp_show_adj_route_received,
68 bgp_show_adj_route_filtered,
69 bgp_show_adj_route_bestpath,
70 };
71
72
73 #define BGP_SHOW_SCODE_HEADER \
74 "Status codes: s suppressed, d damped, " \
75 "h history, * valid, > best, = multipath,\n" \
76 " i internal, r RIB-failure, S Stale, R Removed\n"
77 #define BGP_SHOW_OCODE_HEADER \
78 "Origin codes: i - IGP, e - EGP, ? - incomplete\n"
79 #define BGP_SHOW_NCODE_HEADER "Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self\n"
80 #define BGP_SHOW_RPKI_HEADER \
81 "RPKI validation codes: V valid, I invalid, N Not found\n\n"
82 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path\n"
83 #define BGP_SHOW_HEADER_WIDE " Network Next Hop Metric LocPrf Weight Path\n"
84
85 /* Maximum number of labels we can process or send with a prefix. We
86 * really do only 1 for MPLS (BGP-LU) but we can do 2 for EVPN-VxLAN.
87 */
88 #define BGP_MAX_LABELS 2
89
90 /* Maximum number of sids we can process or send with a prefix. */
91 #define BGP_MAX_SIDS 6
92
93 /* Error codes for handling NLRI */
94 #define BGP_NLRI_PARSE_OK 0
95 #define BGP_NLRI_PARSE_ERROR_PREFIX_OVERFLOW -1
96 #define BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW -2
97 #define BGP_NLRI_PARSE_ERROR_PREFIX_LENGTH -3
98 #define BGP_NLRI_PARSE_ERROR_PACKET_LENGTH -4
99 #define BGP_NLRI_PARSE_ERROR_LABEL_LENGTH -5
100 #define BGP_NLRI_PARSE_ERROR_EVPN_MISSING_TYPE -6
101 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE2_SIZE -7
102 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE3_SIZE -8
103 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE4_SIZE -9
104 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE5_SIZE -10
105 #define BGP_NLRI_PARSE_ERROR_FLOWSPEC_IPV6_NOT_SUPPORTED -11
106 #define BGP_NLRI_PARSE_ERROR_FLOWSPEC_NLRI_SIZELIMIT -12
107 #define BGP_NLRI_PARSE_ERROR_FLOWSPEC_BAD_FORMAT -13
108 #define BGP_NLRI_PARSE_ERROR_ADDRESS_FAMILY -14
109 #define BGP_NLRI_PARSE_ERROR_EVPN_TYPE1_SIZE -15
110 #define BGP_NLRI_PARSE_ERROR -32
111
112 /* 1. local MAC-IP/type-2 paths in the VNI routing table are linked to the
113 * destination ES
114 * 2. remote MAC-IP paths in the global routing table are linked to the
115 * destination ES
116 */
117 struct bgp_path_es_info {
118 /* back pointer to the route */
119 struct bgp_path_info *pi;
120 vni_t vni;
121 /* destination ES */
122 struct bgp_evpn_es *es;
123 /* memory used for linking the path to the destination ES */
124 struct listnode es_listnode;
125 uint8_t flags;
126 /* Path is linked to the VNI list */
127 #define BGP_EVPN_PATH_ES_INFO_VNI_LIST (1 << 0)
128 /* Path is linked to the global list */
129 #define BGP_EVPN_PATH_ES_INFO_GLOBAL_LIST (1 << 1)
130 };
131
132 /* IP paths imported into the VRF from an EVPN route source
133 * are linked to the nexthop/VTEP IP
134 */
135 struct bgp_path_evpn_nh_info {
136 /* back pointer to the route */
137 struct bgp_path_info *pi;
138 struct bgp_evpn_nh *nh;
139 /* memory used for linking the path to the nexthop */
140 struct listnode nh_listnode;
141 };
142
143 struct bgp_path_mh_info {
144 struct bgp_path_es_info *es_info;
145 struct bgp_path_evpn_nh_info *nh_info;
146 };
147
148 struct bgp_sid_info {
149 struct in6_addr sid;
150 uint8_t loc_block_len;
151 uint8_t loc_node_len;
152 uint8_t func_len;
153 uint8_t arg_len;
154 };
155
156 /* Ancillary information to struct bgp_path_info,
157 * used for uncommonly used data (aggregation, MPLS, etc.)
158 * and lazily allocated to save memory.
159 */
160 struct bgp_path_info_extra {
161 /* Pointer to dampening structure. */
162 struct bgp_damp_info *damp_info;
163
164 /** List of aggregations that suppress this path. */
165 struct list *aggr_suppressors;
166
167 /* Nexthop reachability check. */
168 uint32_t igpmetric;
169
170 /* MPLS label(s) - VNI(s) for EVPN-VxLAN */
171 mpls_label_t label[BGP_MAX_LABELS];
172 uint32_t num_labels;
173
174 /* af specific flags */
175 uint16_t af_flags;
176 #define BGP_EVPN_MACIP_TYPE_SVI_IP (1 << 0)
177
178 /* SRv6 SID(s) for SRv6-VPN */
179 struct bgp_sid_info sid[BGP_MAX_SIDS];
180 uint32_t num_sids;
181
182 #ifdef ENABLE_BGP_VNC
183 union {
184
185 struct {
186 void *rfapi_handle; /* export: NVE advertising this
187 route */
188 struct list *local_nexthops; /* optional, for static
189 routes */
190 } export;
191
192 struct {
193 struct thread *timer;
194 void *hme; /* encap monitor, if this is a VPN route */
195 struct prefix_rd
196 rd; /* import: route's route-distinguisher */
197 uint8_t un_family; /* family of cached un address, 0 if
198 unset */
199 union {
200 struct in_addr addr4;
201 struct in6_addr addr6;
202 } un; /* cached un address */
203 time_t create_time;
204 struct prefix aux_prefix; /* AFI_L2VPN: the IP addr,
205 if family set */
206 } import;
207
208 } vnc;
209 #endif
210
211 /* For imported routes into a VNI (or VRF), this points to the parent.
212 */
213 void *parent;
214
215 /*
216 * Some tunnelish parameters follow. Maybe consolidate into an
217 * internal tunnel structure?
218 */
219
220 /*
221 * Original bgp instance for imported routes. Needed for:
222 * 1. Find all routes from a specific vrf for deletion
223 * 2. vrf context of original nexthop
224 *
225 * Store pointer to bgp instance rather than bgp->vrf_id because
226 * bgp->vrf_id is not always valid (or may change?).
227 *
228 * Set to NULL if route is not imported from another bgp instance.
229 */
230 struct bgp *bgp_orig;
231
232 /*
233 * Nexthop in context of original bgp instance. Needed
234 * for label resolution of core mpls routes exported to a vrf.
235 * Set nexthop_orig.family to 0 if not valid.
236 */
237 struct prefix nexthop_orig;
238 /* presence of FS pbr firewall based entry */
239 struct list *bgp_fs_pbr;
240 /* presence of FS pbr iprule based entry */
241 struct list *bgp_fs_iprule;
242 /* Destination Ethernet Segment links for EVPN MH */
243 struct bgp_path_mh_info *mh_info;
244 };
245
246 struct bgp_path_info {
247 /* For linked list. */
248 struct bgp_path_info *next;
249 struct bgp_path_info *prev;
250
251 /* For nexthop linked list */
252 LIST_ENTRY(bgp_path_info) nh_thread;
253
254 /* Back pointer to the prefix node */
255 struct bgp_dest *net;
256
257 /* Back pointer to the nexthop structure */
258 struct bgp_nexthop_cache *nexthop;
259
260 /* Peer structure. */
261 struct peer *peer;
262
263 /* Attribute structure. */
264 struct attr *attr;
265
266 /* Extra information */
267 struct bgp_path_info_extra *extra;
268
269
270 /* Multipath information */
271 struct bgp_path_info_mpath *mpath;
272
273 /* Uptime. */
274 time_t uptime;
275
276 /* reference count */
277 int lock;
278
279 /* BGP information status. */
280 uint16_t flags;
281 #define BGP_PATH_IGP_CHANGED (1 << 0)
282 #define BGP_PATH_DAMPED (1 << 1)
283 #define BGP_PATH_HISTORY (1 << 2)
284 #define BGP_PATH_SELECTED (1 << 3)
285 #define BGP_PATH_VALID (1 << 4)
286 #define BGP_PATH_ATTR_CHANGED (1 << 5)
287 #define BGP_PATH_DMED_CHECK (1 << 6)
288 #define BGP_PATH_DMED_SELECTED (1 << 7)
289 #define BGP_PATH_STALE (1 << 8)
290 #define BGP_PATH_REMOVED (1 << 9)
291 #define BGP_PATH_COUNTED (1 << 10)
292 #define BGP_PATH_MULTIPATH (1 << 11)
293 #define BGP_PATH_MULTIPATH_CHG (1 << 12)
294 #define BGP_PATH_RIB_ATTR_CHG (1 << 13)
295 #define BGP_PATH_ANNC_NH_SELF (1 << 14)
296 #define BGP_PATH_LINK_BW_CHG (1 << 15)
297
298 /* BGP route type. This can be static, RIP, OSPF, BGP etc. */
299 uint8_t type;
300
301 /* When above type is BGP. This sub type specify BGP sub type
302 information. */
303 uint8_t sub_type;
304 #define BGP_ROUTE_NORMAL 0
305 #define BGP_ROUTE_STATIC 1
306 #define BGP_ROUTE_AGGREGATE 2
307 #define BGP_ROUTE_REDISTRIBUTE 3
308 #ifdef ENABLE_BGP_VNC
309 # define BGP_ROUTE_RFP 4
310 #endif
311 #define BGP_ROUTE_IMPORTED 5 /* from another bgp instance/safi */
312
313 unsigned short instance;
314
315 /* Addpath identifiers */
316 uint32_t addpath_rx_id;
317 struct bgp_addpath_info_data tx_addpath;
318 };
319
320 /* Structure used in BGP path selection */
321 struct bgp_path_info_pair {
322 struct bgp_path_info *old;
323 struct bgp_path_info *new;
324 };
325
326 /* BGP static route configuration. */
327 struct bgp_static {
328 /* Backdoor configuration. */
329 int backdoor;
330
331 /* Label index configuration; applies to LU prefixes. */
332 uint32_t label_index;
333 #define BGP_INVALID_LABEL_INDEX 0xFFFFFFFF
334
335 /* Import check status. */
336 uint8_t valid;
337
338 /* IGP metric. */
339 uint32_t igpmetric;
340
341 /* IGP nexthop. */
342 struct in_addr igpnexthop;
343
344 /* Atomic set reference count (ie cause of pathlimit) */
345 uint32_t atomic;
346
347 /* BGP redistribute route-map. */
348 struct {
349 char *name;
350 struct route_map *map;
351 } rmap;
352
353 /* Route Distinguisher */
354 struct prefix_rd prd;
355
356 /* MPLS label. */
357 mpls_label_t label;
358
359 /* EVPN */
360 esi_t *eth_s_id;
361 struct ethaddr *router_mac;
362 uint16_t encap_tunneltype;
363 struct prefix gatewayIp;
364 };
365
366 /* Aggreagete address:
367 *
368 * advertise-map Set condition to advertise attribute
369 * as-set Generate AS set path information
370 * attribute-map Set attributes of aggregate
371 * route-map Set parameters of aggregate
372 * summary-only Filter more specific routes from updates
373 * suppress-map Conditionally filter more specific routes from updates
374 * <cr>
375 */
376 struct bgp_aggregate {
377 /* Summary-only flag. */
378 uint8_t summary_only;
379
380 /* AS set generation. */
381 uint8_t as_set;
382
383 /* Route-map for aggregated route. */
384 struct {
385 char *name;
386 struct route_map *map;
387 } rmap;
388
389 /* Suppress-count. */
390 unsigned long count;
391
392 /* Count of routes of origin type incomplete under this aggregate. */
393 unsigned long incomplete_origin_count;
394
395 /* Count of routes of origin type egp under this aggregate. */
396 unsigned long egp_origin_count;
397
398 /* Optional modify flag to override ORIGIN */
399 uint8_t origin;
400
401 /* Hash containing the communities of all the
402 * routes under this aggregate.
403 */
404 struct hash *community_hash;
405
406 /* Hash containing the extended communities of all the
407 * routes under this aggregate.
408 */
409 struct hash *ecommunity_hash;
410
411 /* Hash containing the large communities of all the
412 * routes under this aggregate.
413 */
414 struct hash *lcommunity_hash;
415
416 /* Hash containing the AS-Path of all the
417 * routes under this aggregate.
418 */
419 struct hash *aspath_hash;
420
421 /* Aggregate route's community. */
422 struct community *community;
423
424 /* Aggregate route's extended community. */
425 struct ecommunity *ecommunity;
426
427 /* Aggregate route's large community. */
428 struct lcommunity *lcommunity;
429
430 /* Aggregate route's as-path. */
431 struct aspath *aspath;
432
433 /* SAFI configuration. */
434 safi_t safi;
435
436 /** Match only equal MED. */
437 bool match_med;
438 /* MED matching state. */
439 /** Did we get the first MED value? */
440 bool med_initialized;
441 /** Are there MED mismatches? */
442 bool med_mismatched;
443 /** MED value found in current group. */
444 uint32_t med_matched_value;
445
446 /**
447 * Test if aggregated address MED of all route match, otherwise
448 * returns `false`. This macro will also return `true` if MED
449 * matching is disabled.
450 */
451 #define AGGREGATE_MED_VALID(aggregate) \
452 (((aggregate)->match_med && !(aggregate)->med_mismatched) \
453 || !(aggregate)->match_med)
454
455 /** Suppress map route map name (`NULL` when disabled). */
456 char *suppress_map_name;
457 /** Suppress map route map pointer. */
458 struct route_map *suppress_map;
459 };
460
461 #define BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen) \
462 ((nhlen) < IPV4_MAX_BYTELEN \
463 ? 0 \
464 : ((nhlen) < IPV6_MAX_BYTELEN ? AFI_IP : AFI_IP6))
465
466 #define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \
467 (!CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) \
468 && ((attr)->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL \
469 || (attr)->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL \
470 || (attr)->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL \
471 || (attr)->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL))
472 #define BGP_PATH_COUNTABLE(BI) \
473 (!CHECK_FLAG((BI)->flags, BGP_PATH_HISTORY) \
474 && !CHECK_FLAG((BI)->flags, BGP_PATH_REMOVED))
475
476 /* Flags which indicate a route is unuseable in some form */
477 #define BGP_PATH_UNUSEABLE \
478 (BGP_PATH_HISTORY | BGP_PATH_DAMPED | BGP_PATH_REMOVED)
479 /* Macro to check BGP information is alive or not. Sadly,
480 * not equivalent to just checking previous, because of the
481 * sense of the additional VALID flag.
482 */
483 #define BGP_PATH_HOLDDOWN(BI) \
484 (!CHECK_FLAG((BI)->flags, BGP_PATH_VALID) \
485 || CHECK_FLAG((BI)->flags, BGP_PATH_UNUSEABLE))
486
487 #define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
488 #define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
489 #define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
490 #define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
491
492 #define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
493 #define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
494 #define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
495 #define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
496
497 #define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
498 #define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
499 #define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
500 #define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
501
502 #define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
503 #define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
504 #define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
505 #define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
506
507 #define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
508 #define UNSUPPRESS_MAP(F) ((F)->usmap.map)
509
510 #define ADVERTISE_MAP_NAME(F) ((F)->advmap.aname)
511 #define ADVERTISE_MAP(F) ((F)->advmap.amap)
512
513 #define ADVERTISE_CONDITION(F) ((F)->advmap.condition)
514
515 #define CONDITION_MAP_NAME(F) ((F)->advmap.cname)
516 #define CONDITION_MAP(F) ((F)->advmap.cmap)
517
518 /* path PREFIX (addpath rxid NUMBER) */
519 #define PATH_ADDPATH_STR_BUFFER PREFIX2STR_BUFFER + 32
520
521 enum bgp_path_type {
522 BGP_PATH_SHOW_ALL,
523 BGP_PATH_SHOW_BESTPATH,
524 BGP_PATH_SHOW_MULTIPATH
525 };
526
527 static inline void bgp_bump_version(struct bgp_dest *dest)
528 {
529 dest->version = bgp_table_next_version(bgp_dest_table(dest));
530 }
531
532 static inline int bgp_fibupd_safi(safi_t safi)
533 {
534 if (safi == SAFI_UNICAST || safi == SAFI_MULTICAST
535 || safi == SAFI_LABELED_UNICAST
536 || safi == SAFI_FLOWSPEC)
537 return 1;
538 return 0;
539 }
540
541 /* Flag if the route path's family matches params. */
542 static inline bool is_pi_family_matching(struct bgp_path_info *pi,
543 afi_t afi, safi_t safi)
544 {
545 struct bgp_table *table;
546 struct bgp_dest *dest;
547
548 dest = pi->net;
549 if (!dest)
550 return false;
551 table = bgp_dest_table(dest);
552 if (table &&
553 table->afi == afi &&
554 table->safi == safi)
555 return true;
556 return false;
557 }
558
559 static inline void prep_for_rmap_apply(struct bgp_path_info *dst_pi,
560 struct bgp_path_info_extra *dst_pie,
561 struct bgp_dest *dest,
562 struct bgp_path_info *src_pi,
563 struct peer *peer, struct attr *attr)
564 {
565 memset(dst_pi, 0, sizeof(struct bgp_path_info));
566 dst_pi->peer = peer;
567 dst_pi->attr = attr;
568 dst_pi->net = dest;
569 dst_pi->flags = src_pi->flags;
570 dst_pi->type = src_pi->type;
571 dst_pi->sub_type = src_pi->sub_type;
572 dst_pi->mpath = src_pi->mpath;
573 if (src_pi->extra) {
574 memcpy(dst_pie, src_pi->extra,
575 sizeof(struct bgp_path_info_extra));
576 dst_pi->extra = dst_pie;
577 }
578 }
579
580 static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest)
581 {
582 return (!(BGP_SUPPRESS_FIB_ENABLED(bgp) &&
583 CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING) &&
584 (!bgp_option_check(BGP_OPT_NO_FIB))));
585 }
586
587 /* called before bgp_process() */
588 DECLARE_HOOK(bgp_process,
589 (struct bgp * bgp, afi_t afi, safi_t safi, struct bgp_dest *bn,
590 struct peer *peer, bool withdraw),
591 (bgp, afi, safi, bn, peer, withdraw));
592
593 /* BGP show options */
594 #define BGP_SHOW_OPT_JSON (1 << 0)
595 #define BGP_SHOW_OPT_WIDE (1 << 1)
596 #define BGP_SHOW_OPT_AFI_ALL (1 << 2)
597 #define BGP_SHOW_OPT_AFI_IP (1 << 3)
598 #define BGP_SHOW_OPT_AFI_IP6 (1 << 4)
599 #define BGP_SHOW_OPT_ESTABLISHED (1 << 5)
600 #define BGP_SHOW_OPT_FAILED (1 << 6)
601 #define BGP_SHOW_OPT_DETAIL (1 << 7)
602 #define BGP_SHOW_OPT_TERSE (1 << 8)
603
604 /* Prototypes. */
605 extern void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi,
606 struct peer *peer, afi_t afi, safi_t safi);
607 extern void bgp_process_queue_init(struct bgp *bgp);
608 extern void bgp_route_init(void);
609 extern void bgp_route_finish(void);
610 extern void bgp_cleanup_routes(struct bgp *);
611 extern void bgp_announce_route(struct peer *, afi_t, safi_t);
612 extern void bgp_stop_announce_route_timer(struct peer_af *paf);
613 extern void bgp_announce_route_all(struct peer *);
614 extern void bgp_default_originate(struct peer *, afi_t, safi_t, int);
615 extern void bgp_soft_reconfig_table_task_cancel(const struct bgp *bgp,
616 const struct bgp_table *table,
617 const struct peer *peer);
618 extern void bgp_soft_reconfig_in(struct peer *, afi_t, safi_t);
619 extern void bgp_clear_route(struct peer *, afi_t, safi_t);
620 extern void bgp_clear_route_all(struct peer *);
621 extern void bgp_clear_adj_in(struct peer *, afi_t, safi_t);
622 extern void bgp_clear_stale_route(struct peer *, afi_t, safi_t);
623 extern void bgp_set_stale_route(struct peer *peer, afi_t afi, safi_t safi);
624 extern bool bgp_outbound_policy_exists(struct peer *, struct bgp_filter *);
625 extern bool bgp_inbound_policy_exists(struct peer *, struct bgp_filter *);
626
627 extern struct bgp_dest *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
628 safi_t safi, const struct prefix *p,
629 struct prefix_rd *prd);
630 extern struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path);
631 extern struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path);
632 extern void bgp_path_info_add(struct bgp_dest *dest, struct bgp_path_info *pi);
633 extern void bgp_path_info_extra_free(struct bgp_path_info_extra **extra);
634 extern void bgp_path_info_reap(struct bgp_dest *dest, struct bgp_path_info *pi);
635 extern void bgp_path_info_delete(struct bgp_dest *dest,
636 struct bgp_path_info *pi);
637 extern struct bgp_path_info_extra *
638 bgp_path_info_extra_get(struct bgp_path_info *path);
639 extern void bgp_path_info_set_flag(struct bgp_dest *dest,
640 struct bgp_path_info *path, uint32_t flag);
641 extern void bgp_path_info_unset_flag(struct bgp_dest *dest,
642 struct bgp_path_info *path, uint32_t flag);
643 extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
644 char *buf, size_t buf_len);
645
646 extern int bgp_nlri_parse_ip(struct peer *, struct attr *, struct bgp_nlri *);
647
648 extern bool bgp_maximum_prefix_overflow(struct peer *, afi_t, safi_t, int);
649
650 extern void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
651 const union g_addr *nexthop, ifindex_t ifindex,
652 enum nexthop_types_t nhtype, uint8_t distance,
653 enum blackhole_type bhtype, uint32_t metric,
654 uint8_t type, unsigned short instance,
655 route_tag_t tag);
656 extern void bgp_redistribute_delete(struct bgp *, struct prefix *, uint8_t,
657 unsigned short);
658 extern void bgp_redistribute_withdraw(struct bgp *, afi_t, int, unsigned short);
659
660 extern void bgp_static_add(struct bgp *);
661 extern void bgp_static_delete(struct bgp *);
662 extern void bgp_static_redo_import_check(struct bgp *);
663 extern void bgp_purge_static_redist_routes(struct bgp *bgp);
664 extern void bgp_static_update(struct bgp *bgp, const struct prefix *p,
665 struct bgp_static *s, afi_t afi, safi_t safi);
666 extern void bgp_static_withdraw(struct bgp *bgp, const struct prefix *p,
667 afi_t afi, safi_t safi);
668
669 extern int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
670 const char *, const char *, const char *,
671 const char *, int, const char *, const char *,
672 const char *, const char *);
673
674 extern int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *,
675 const char *, const char *, const char *, int,
676 const char *, const char *, const char *);
677
678 /* this is primarily for MPLS-VPN */
679 extern int bgp_update(struct peer *peer, const struct prefix *p,
680 uint32_t addpath_id, struct attr *attr,
681 afi_t afi, safi_t safi, int type, int sub_type,
682 struct prefix_rd *prd, mpls_label_t *label,
683 uint32_t num_labels, int soft_reconfig,
684 struct bgp_route_evpn *evpn);
685 extern int bgp_withdraw(struct peer *peer, const struct prefix *p,
686 uint32_t addpath_id, struct attr *attr, afi_t afi,
687 safi_t safi, int type, int sub_type,
688 struct prefix_rd *prd, mpls_label_t *label,
689 uint32_t num_labels, struct bgp_route_evpn *evpn);
690
691 /* for bgp_nexthop and bgp_damp */
692 extern void bgp_process(struct bgp *, struct bgp_dest *, afi_t, safi_t);
693
694 /*
695 * Add an end-of-initial-update marker to the process queue. This is just a
696 * queue element with NULL bgp node.
697 */
698 extern void bgp_add_eoiu_mark(struct bgp *);
699 extern void bgp_config_write_table_map(struct vty *, struct bgp *, afi_t,
700 safi_t);
701 extern void bgp_config_write_network(struct vty *, struct bgp *, afi_t, safi_t);
702 extern void bgp_config_write_distance(struct vty *, struct bgp *, afi_t,
703 safi_t);
704
705 extern void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p,
706 afi_t afi, safi_t safi,
707 struct bgp_aggregate *aggregate);
708 extern void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p,
709 afi_t afi, safi_t safi,
710 struct bgp_aggregate *aggregate);
711 extern void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
712 struct bgp_path_info *path, afi_t afi,
713 safi_t safi);
714 extern void bgp_aggregate_decrement(struct bgp *bgp, const struct prefix *p,
715 struct bgp_path_info *path, afi_t afi,
716 safi_t safi);
717
718 extern uint8_t bgp_distance_apply(const struct prefix *p,
719 struct bgp_path_info *path, afi_t afi,
720 safi_t safi, struct bgp *bgp);
721
722 extern afi_t bgp_node_afi(struct vty *);
723 extern safi_t bgp_node_safi(struct vty *);
724
725 extern struct bgp_path_info *info_make(int type, int sub_type,
726 unsigned short instance,
727 struct peer *peer, struct attr *attr,
728 struct bgp_dest *dest);
729
730 extern void route_vty_out(struct vty *vty, const struct prefix *p,
731 struct bgp_path_info *path, int display, safi_t safi,
732 json_object *json_paths, bool wide);
733 extern void route_vty_out_tag(struct vty *vty, const struct prefix *p,
734 struct bgp_path_info *path, int display,
735 safi_t safi, json_object *json);
736 extern void route_vty_out_tmp(struct vty *vty, struct bgp_dest *dest,
737 const struct prefix *p, struct attr *attr,
738 safi_t safi, bool use_json, json_object *json_ar,
739 bool wide);
740 extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
741 struct bgp_path_info *path, int display,
742 json_object *json);
743
744 extern void bgp_notify_conditional_adv_scanner(struct update_subgroup *subgrp);
745
746 extern void subgroup_process_announce_selected(struct update_subgroup *subgrp,
747 struct bgp_path_info *selected,
748 struct bgp_dest *dest,
749 uint32_t addpath_tx_id);
750
751 extern bool subgroup_announce_check(struct bgp_dest *dest,
752 struct bgp_path_info *pi,
753 struct update_subgroup *subgrp,
754 const struct prefix *p, struct attr *attr,
755 bool skip_rmap_check);
756
757 extern void bgp_peer_clear_node_queue_drain_immediate(struct peer *peer);
758 extern void bgp_process_queues_drain_immediate(void);
759
760 /* for encap/vpn */
761 extern struct bgp_dest *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
762 safi_t safi, const struct prefix *p,
763 struct prefix_rd *prd);
764 extern void bgp_path_info_restore(struct bgp_dest *dest,
765 struct bgp_path_info *path);
766
767 extern int bgp_path_info_cmp_compatible(struct bgp *bgp,
768 struct bgp_path_info *new,
769 struct bgp_path_info *exist,
770 char *pfx_buf, afi_t afi, safi_t safi,
771 enum bgp_path_selection_reason *reason);
772 extern void bgp_attr_add_gshut_community(struct attr *attr);
773
774 extern void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
775 struct bgp_maxpaths_cfg *mpath_cfg,
776 struct bgp_path_info_pair *result, afi_t afi,
777 safi_t safi);
778 extern void bgp_zebra_clear_route_change_flags(struct bgp_dest *dest);
779 extern bool bgp_zebra_has_route_changed(struct bgp_path_info *selected);
780
781 extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
782 struct bgp_dest *dest,
783 struct prefix_rd *prd, afi_t afi,
784 safi_t safi, json_object *json);
785 extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
786 struct bgp_dest *bn,
787 struct bgp_path_info *path, afi_t afi,
788 safi_t safi, enum rpki_states,
789 json_object *json_paths);
790 extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
791 struct bgp_table *table, struct prefix_rd *prd,
792 enum bgp_show_type type, void *output_arg,
793 bool use_json);
794 extern int bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi);
795 extern bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
796 uint8_t type, uint8_t stype,
797 struct attr *attr, struct bgp_dest *dest);
798 extern int bgp_evpn_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
799 struct bgp_path_info *exist, int *paths_eq);
800 extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
801 struct bgp *bgp,
802 const struct prefix *p, afi_t afi,
803 safi_t safi, bool suppress);
804 extern void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr);
805 #endif /* _QUAGGA_BGP_ROUTE_H */