]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* BGP nexthop scan |
896014f4 | 3 | * Copyright (C) 2000 Kunihiro Ishiguro |
896014f4 | 4 | */ |
718e3744 | 5 | |
00d252cb | 6 | #ifndef _QUAGGA_BGP_NEXTHOP_H |
7 | #define _QUAGGA_BGP_NEXTHOP_H | |
8 | ||
5304cb52 | 9 | #include "if.h" |
fb018d25 DS |
10 | #include "queue.h" |
11 | #include "prefix.h" | |
f663c581 | 12 | #include "bgp_table.h" |
5304cb52 | 13 | |
d62a17ae | 14 | #define NEXTHOP_FAMILY(nexthop_len) \ |
15 | (((nexthop_len) == 4 || (nexthop_len) == 12 \ | |
16 | ? AF_INET \ | |
17 | : ((nexthop_len) == 16 || (nexthop_len) == 24 \ | |
77e62f2b | 18 | || (nexthop_len) == 32 \ |
d62a17ae | 19 | || (nexthop_len) == 48 \ |
20 | ? AF_INET6 \ | |
21 | : AF_UNSPEC))) | |
95b9c671 | 22 | |
65efcfce LB |
23 | #define BGP_MP_NEXTHOP_FAMILY NEXTHOP_FAMILY |
24 | ||
f663c581 RW |
25 | PREDECL_RBTREE_UNIQ(bgp_nexthop_cache); |
26 | ||
718e3744 | 27 | /* BGP nexthop cache value structure. */ |
d62a17ae | 28 | struct bgp_nexthop_cache { |
8761cd6d DS |
29 | /* The ifindex of the outgoing interface *if* it's a v6 LL */ |
30 | ifindex_t ifindex; | |
31 | ||
f663c581 RW |
32 | /* RB-tree entry. */ |
33 | struct bgp_nexthop_cache_item entry; | |
34 | ||
d62a17ae | 35 | /* IGP route's metric. */ |
d7c0a89a | 36 | uint32_t metric; |
718e3744 | 37 | |
d62a17ae | 38 | /* Nexthop number and nexthop linked list.*/ |
d7c0a89a | 39 | uint8_t nexthop_num; |
d62a17ae | 40 | struct nexthop *nexthop; |
41 | time_t last_update; | |
d7c0a89a | 42 | uint16_t flags; |
fb018d25 | 43 | |
021b6596 AD |
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 | */ | |
fc9a856f DS |
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) | |
078430f6 DS |
52 | #define BGP_STATIC_ROUTE (1 << 4) |
53 | #define BGP_STATIC_ROUTE_EXACT_MATCH (1 << 5) | |
960035b2 | 54 | #define BGP_NEXTHOP_LABELED_VALID (1 << 6) |
fb018d25 | 55 | |
021b6596 AD |
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 | ||
d7c0a89a | 73 | uint16_t change_flags; |
fb018d25 | 74 | |
fc9a856f DS |
75 | #define BGP_NEXTHOP_CHANGED (1 << 0) |
76 | #define BGP_NEXTHOP_METRIC_CHANGED (1 << 1) | |
77 | #define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2) | |
021b6596 | 78 | #define BGP_NEXTHOP_MACIP_CHANGED (1 << 3) |
fb018d25 | 79 | |
f663c581 RW |
80 | /* Back pointer to the cache tree this entry belongs to. */ |
81 | struct bgp_nexthop_cache_head *tree; | |
82 | ||
545aeef1 | 83 | uint32_t srte_color; |
f663c581 | 84 | struct prefix prefix; |
d62a17ae | 85 | void *nht_info; /* In BGP, peer session */ |
4b7e6066 | 86 | LIST_HEAD(path_list, bgp_path_info) paths; |
d62a17ae | 87 | unsigned int path_count; |
88 | struct bgp *bgp; | |
021b6596 AD |
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; | |
718e3744 | 94 | }; |
95 | ||
f663c581 RW |
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 | ||
db0e1937 MK |
101 | /* Own tunnel-ip address structure */ |
102 | struct tip_addr { | |
103 | struct in_addr addr; | |
104 | int refcnt; | |
105 | }; | |
106 | ||
737af885 BS |
107 | struct bgp_addrv6 { |
108 | struct in6_addr addrv6; | |
109 | struct list *ifp_name_list; | |
110 | }; | |
111 | ||
f663c581 RW |
112 | /* Forward declaration(s). */ |
113 | struct peer; | |
114 | struct update_subgroup; | |
115 | struct bgp_dest; | |
116 | struct attr; | |
117 | ||
987a720a DS |
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); | |
df2a41a9 DS |
121 | extern char *bgp_nexthop_dump_bnc_change_flags(struct bgp_nexthop_cache *bnc, |
122 | char *buf, size_t len); | |
d62a17ae | 123 | extern void bgp_connected_add(struct bgp *bgp, struct connected *c); |
124 | extern void bgp_connected_delete(struct bgp *bgp, struct connected *c); | |
3dc339cd DA |
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); | |
d62a17ae | 134 | extern int bgp_config_write_scan_time(struct vty *); |
3dc339cd DA |
135 | extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, |
136 | uint8_t sub_type, struct attr *attr, | |
9bcb3eef | 137 | struct bgp_dest *dest); |
f663c581 | 138 | extern struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree, |
545aeef1 | 139 | struct prefix *prefix, |
35aae5c9 DS |
140 | uint32_t srte_color, |
141 | ifindex_t ifindex); | |
e37e1e27 | 142 | extern bool bnc_existing_for_prefix(struct bgp_nexthop_cache *bnc); |
fb018d25 | 143 | extern void bnc_free(struct bgp_nexthop_cache *bnc); |
f663c581 | 144 | extern struct bgp_nexthop_cache *bnc_find(struct bgp_nexthop_cache_head *tree, |
545aeef1 | 145 | struct prefix *prefix, |
35aae5c9 DS |
146 | uint32_t srte_color, |
147 | ifindex_t ifindex); | |
fb018d25 | 148 | extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc); |
6aeb9e78 DS |
149 | extern void bgp_scan_init(struct bgp *bgp); |
150 | extern void bgp_scan_finish(struct bgp *bgp); | |
ffd0c037 | 151 | extern void bgp_scan_vty_init(void); |
d62a17ae | 152 | extern void bgp_address_init(struct bgp *bgp); |
153 | extern void bgp_address_destroy(struct bgp *bgp); | |
826c3f6d | 154 | extern bool bgp_tip_add(struct bgp *bgp, struct in_addr *tip); |
db0e1937 MK |
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); | |
00d252cb | 158 | |
af97a18b | 159 | extern void bgp_nexthop_show_address_hash(struct vty *vty, struct bgp *bgp); |
00d252cb | 160 | #endif /* _QUAGGA_BGP_NEXTHOP_H */ |