]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_nexthop.h
Merge pull request #12819 from isabelladeleon12/isis_load_config_before_lsp_gen
[mirror_frr.git] / bgpd / bgp_nexthop.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP nexthop scan
3 * Copyright (C) 2000 Kunihiro Ishiguro
4 */
5
6 #ifndef _QUAGGA_BGP_NEXTHOP_H
7 #define _QUAGGA_BGP_NEXTHOP_H
8
9 #include "if.h"
10 #include "queue.h"
11 #include "prefix.h"
12 #include "bgp_table.h"
13
14 #define NEXTHOP_FAMILY(nexthop_len) \
15 (((nexthop_len) == 4 || (nexthop_len) == 12 \
16 ? AF_INET \
17 : ((nexthop_len) == 16 || (nexthop_len) == 24 \
18 || (nexthop_len) == 32 \
19 || (nexthop_len) == 48 \
20 ? AF_INET6 \
21 : AF_UNSPEC)))
22
23 #define BGP_MP_NEXTHOP_FAMILY NEXTHOP_FAMILY
24
25 PREDECL_RBTREE_UNIQ(bgp_nexthop_cache);
26
27 /* BGP nexthop cache value structure. */
28 struct bgp_nexthop_cache {
29 /* The ifindex of the outgoing interface *if* it's a v6 LL */
30 ifindex_t ifindex;
31
32 /* RB-tree entry. */
33 struct bgp_nexthop_cache_item entry;
34
35 /* IGP route's metric. */
36 uint32_t metric;
37
38 /* Nexthop number and nexthop linked list.*/
39 uint8_t nexthop_num;
40 struct nexthop *nexthop;
41 time_t last_update;
42 uint16_t flags;
43
44 /*
45 * If the nexthop is EVPN gateway IP NH, VALID flag is set only if the nexthop
46 * is RIB reachable as well as MAC/IP is present
47 */
48 #define BGP_NEXTHOP_VALID (1 << 0)
49 #define BGP_NEXTHOP_REGISTERED (1 << 1)
50 #define BGP_NEXTHOP_CONNECTED (1 << 2)
51 #define BGP_NEXTHOP_PEER_NOTIFIED (1 << 3)
52 #define BGP_STATIC_ROUTE (1 << 4)
53 #define BGP_STATIC_ROUTE_EXACT_MATCH (1 << 5)
54 #define BGP_NEXTHOP_LABELED_VALID (1 << 6)
55
56 /*
57 * This flag is added for EVPN gateway IP nexthops.
58 * If the nexthop is RIB reachable, but a MAC/IP is not yet
59 * resolved, this flag is set.
60 * Following table explains the combination of L3 and L2 reachability w.r.t.
61 * VALID and INCOMPLETE flags
62 *
63 * | MACIP resolved | MACIP unresolved
64 *----------------|----------------|------------------
65 * L3 reachable | VALID = 1 | VALID = 0
66 * | INCOMPLETE = 0 | INCOMPLETE = 1
67 * ---------------|----------------|--------------------
68 * L3 unreachable | VALID = 0 | VALID = 0
69 * | INCOMPLETE = 0 | INCOMPLETE = 0
70 */
71 #define BGP_NEXTHOP_EVPN_INCOMPLETE (1 << 7)
72
73 uint16_t change_flags;
74
75 #define BGP_NEXTHOP_CHANGED (1 << 0)
76 #define BGP_NEXTHOP_METRIC_CHANGED (1 << 1)
77 #define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2)
78 #define BGP_NEXTHOP_MACIP_CHANGED (1 << 3)
79
80 /* Back pointer to the cache tree this entry belongs to. */
81 struct bgp_nexthop_cache_head *tree;
82
83 uint32_t srte_color;
84 struct prefix prefix;
85 void *nht_info; /* In BGP, peer session */
86 LIST_HEAD(path_list, bgp_path_info) paths;
87 unsigned int path_count;
88 struct bgp *bgp;
89
90 /* This flag is set to TRUE for a bnc that is gateway IP overlay index
91 * nexthop.
92 */
93 bool is_evpn_gwip_nexthop;
94 };
95
96 extern int bgp_nexthop_cache_compare(const struct bgp_nexthop_cache *a,
97 const struct bgp_nexthop_cache *b);
98 DECLARE_RBTREE_UNIQ(bgp_nexthop_cache, struct bgp_nexthop_cache, entry,
99 bgp_nexthop_cache_compare);
100
101 /* Own tunnel-ip address structure */
102 struct tip_addr {
103 struct in_addr addr;
104 int refcnt;
105 };
106
107 struct bgp_addrv6 {
108 struct in6_addr addrv6;
109 struct list *ifp_name_list;
110 };
111
112 /* Forward declaration(s). */
113 struct peer;
114 struct update_subgroup;
115 struct bgp_dest;
116 struct attr;
117
118 #define BNC_FLAG_DUMP_SIZE 180
119 extern char *bgp_nexthop_dump_bnc_flags(struct bgp_nexthop_cache *bnc,
120 char *buf, size_t len);
121 extern char *bgp_nexthop_dump_bnc_change_flags(struct bgp_nexthop_cache *bnc,
122 char *buf, size_t len);
123 extern void bgp_connected_add(struct bgp *bgp, struct connected *c);
124 extern void bgp_connected_delete(struct bgp *bgp, struct connected *c);
125 extern bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
126 struct update_subgroup *subgrp,
127 struct peer *exclude);
128 extern bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
129 struct update_subgroup *subgrp,
130 struct peer *exclude);
131 extern bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer);
132 extern bool bgp_multiaccess_check_v6(struct in6_addr nexthop,
133 struct peer *peer);
134 extern int bgp_config_write_scan_time(struct vty *);
135 extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
136 uint8_t sub_type, struct attr *attr,
137 struct bgp_dest *dest);
138 extern struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
139 struct prefix *prefix,
140 uint32_t srte_color,
141 ifindex_t ifindex);
142 extern bool bnc_existing_for_prefix(struct bgp_nexthop_cache *bnc);
143 extern void bnc_free(struct bgp_nexthop_cache *bnc);
144 extern struct bgp_nexthop_cache *bnc_find(struct bgp_nexthop_cache_head *tree,
145 struct prefix *prefix,
146 uint32_t srte_color,
147 ifindex_t ifindex);
148 extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc);
149 extern void bgp_scan_init(struct bgp *bgp);
150 extern void bgp_scan_finish(struct bgp *bgp);
151 extern void bgp_scan_vty_init(void);
152 extern void bgp_address_init(struct bgp *bgp);
153 extern void bgp_address_destroy(struct bgp *bgp);
154 extern bool bgp_tip_add(struct bgp *bgp, struct in_addr *tip);
155 extern void bgp_tip_del(struct bgp *bgp, struct in_addr *tip);
156 extern void bgp_tip_hash_init(struct bgp *bgp);
157 extern void bgp_tip_hash_destroy(struct bgp *bgp);
158
159 extern void bgp_nexthop_show_address_hash(struct vty *vty, struct bgp *bgp);
160 #endif /* _QUAGGA_BGP_NEXTHOP_H */