]>
Commit | Line | Data |
---|---|---|
7c551956 DS |
1 | /* |
2 | * Zebra Vrf Header | |
3 | * Copyright (C) 2016 Cumulus Networks | |
7cdb1a84 | 4 | * Donald Sharp |
7c551956 DS |
5 | * |
6 | * This file is part of Quagga. | |
7 | * | |
8 | * Quagga is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * Quagga is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
896014f4 DL |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; see the file COPYING; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
7c551956 | 21 | */ |
736d41ad PG |
22 | #if !defined(__ZEBRA_VRF_H__) |
23 | #define __ZEBRA_VRF_H__ | |
7c551956 | 24 | |
fbac9605 DS |
25 | #include "vxlan.h" |
26 | ||
7c551956 | 27 | #include <zebra/zebra_ns.h> |
6833ae01 | 28 | #include <zebra/zebra_pw.h> |
b7cfce93 | 29 | #include <lib/vxlan.h> |
7c551956 | 30 | |
51e94aa7 EDP |
31 | #ifdef __cplusplus |
32 | extern "C" { | |
33 | #endif | |
34 | ||
1b6d5c7e | 35 | /* MPLS (Segment Routing) global block */ |
d62a17ae | 36 | typedef struct mpls_srgb_t_ { |
d7c0a89a QY |
37 | uint32_t start_label; |
38 | uint32_t end_label; | |
1b6d5c7e VV |
39 | } mpls_srgb_t; |
40 | ||
ac6eebce | 41 | struct zebra_rmap { |
42 | char *name; | |
43 | struct route_map *map; | |
44 | }; | |
45 | ||
d8612e65 DS |
46 | PREDECL_RBTREE_UNIQ(otable); |
47 | ||
48 | struct other_route_table { | |
49 | struct otable_item next; | |
50 | ||
51 | afi_t afi; | |
52 | safi_t safi; | |
53 | uint32_t table_id; | |
54 | ||
55 | struct route_table *table; | |
56 | }; | |
57 | ||
7c551956 | 58 | /* Routing table instance. */ |
d62a17ae | 59 | struct zebra_vrf { |
60 | /* Back pointer */ | |
61 | struct vrf *vrf; | |
7c551956 | 62 | |
d62a17ae | 63 | /* Description. */ |
64 | char *desc; | |
7c551956 | 65 | |
d62a17ae | 66 | /* FIB identifier. */ |
d7c0a89a | 67 | uint8_t fib_id; |
7c551956 | 68 | |
d62a17ae | 69 | /* Flags. */ |
d7c0a89a | 70 | uint16_t flags; |
f4c6e2a8 | 71 | #define ZEBRA_VRF_RETAIN (1 << 0) |
ecbbc3a7 | 72 | #define ZEBRA_PIM_SEND_VXLAN_SG (1 << 1) |
7c551956 | 73 | |
d7c0a89a | 74 | uint32_t table_id; |
7c551956 | 75 | |
d62a17ae | 76 | /* Routing table. */ |
77 | struct route_table *table[AFI_MAX][SAFI_MAX]; | |
7c551956 | 78 | |
d62a17ae | 79 | /* Recursive Nexthop table */ |
80 | struct route_table *rnh_table[AFI_MAX]; | |
7c551956 | 81 | |
d62a17ae | 82 | /* Import check table (used mostly by BGP */ |
83 | struct route_table *import_check_table[AFI_MAX]; | |
7c551956 | 84 | |
d8612e65 DS |
85 | struct otable_head other_tables; |
86 | ||
d62a17ae | 87 | /* 2nd pointer type used primarily to quell a warning on |
88 | * ALL_LIST_ELEMENTS_RO | |
89 | */ | |
90 | struct list _rid_all_sorted_list; | |
91 | struct list _rid_lo_sorted_list; | |
92 | struct list *rid_all_sorted_list; | |
93 | struct list *rid_lo_sorted_list; | |
94 | struct prefix rid_user_assigned; | |
7c551956 | 95 | |
d62a17ae | 96 | /* |
97 | * Back pointer to the owning namespace. | |
98 | */ | |
99 | struct zebra_ns *zns; | |
54d48ea1 | 100 | |
c83c5e44 | 101 | /* MPLS Label to handle L3VPN <-> vrf popping */ |
7d061b3c | 102 | mpls_label_t label[AFI_MAX]; |
c83c5e44 | 103 | |
d62a17ae | 104 | /* MPLS static LSP config table */ |
105 | struct hash *slsp_table; | |
54d48ea1 | 106 | |
d62a17ae | 107 | /* MPLS label forwarding table */ |
108 | struct hash *lsp_table; | |
939fba27 | 109 | |
d62a17ae | 110 | /* MPLS FEC binding table */ |
111 | struct route_table *fec_table[AFI_MAX]; | |
f31e084c | 112 | |
d62a17ae | 113 | /* MPLS Segment Routing Global block */ |
114 | mpls_srgb_t mpls_srgb; | |
1b6d5c7e | 115 | |
6833ae01 | 116 | /* Pseudowires. */ |
117 | struct zebra_pw_head pseudowires; | |
2dd0d726 | 118 | struct zebra_static_pw_head static_pseudowires; |
6833ae01 | 119 | |
ac6eebce | 120 | struct zebra_rmap proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1]; |
121 | struct zebra_rmap nht_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1]; | |
122 | ||
d62a17ae | 123 | /* MPLS processing flags */ |
d7c0a89a | 124 | uint16_t mpls_flags; |
939fba27 | 125 | #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) |
57282a31 | 126 | |
d62a17ae | 127 | /* |
150971b5 | 128 | * VNI hash table (for EVPN). Only in the EVPN instance. |
d62a17ae | 129 | */ |
130 | struct hash *vni_table; | |
2853fed6 | 131 | |
d62a17ae | 132 | /* |
150971b5 | 133 | * Whether EVPN is enabled or not. Only in the EVPN instance. |
d62a17ae | 134 | */ |
135 | int advertise_all_vni; | |
136 | ||
1a98c087 MK |
137 | /* |
138 | * Whether we are advertising g/w macip in EVPN or not. | |
150971b5 | 139 | * Only in the EVPN instance. |
1a98c087 MK |
140 | */ |
141 | int advertise_gw_macip; | |
142 | ||
278e26de CS |
143 | int advertise_svi_macip; |
144 | ||
b7cfce93 MK |
145 | /* l3-vni info */ |
146 | vni_t l3vni; | |
147 | ||
8a93734c AK |
148 | /* pim mroutes installed for vxlan flooding */ |
149 | struct hash *vxlan_sg_table; | |
150 | ||
3950b52c CS |
151 | bool dup_addr_detect; |
152 | ||
153 | int dad_time; | |
154 | uint32_t dad_max_moves; | |
155 | bool dad_freeze; | |
156 | uint32_t dad_freeze_time; | |
157 | ||
fbac9605 DS |
158 | /* |
159 | * Flooding mechanism for BUM packets for VxLAN-EVPN. | |
160 | */ | |
161 | enum vxlan_flood_control vxlan_flood_ctrl; | |
162 | ||
d37f4d6c | 163 | /* Install stats */ |
d62a17ae | 164 | uint64_t installs; |
165 | uint64_t removals; | |
97f5b441 MS |
166 | uint64_t installs_queued; |
167 | uint64_t removals_queued; | |
d62a17ae | 168 | uint64_t neigh_updates; |
d37f4d6c MS |
169 | uint64_t lsp_installs_queued; |
170 | uint64_t lsp_removals_queued; | |
d62a17ae | 171 | uint64_t lsp_installs; |
172 | uint64_t lsp_removals; | |
df9c8c57 PG |
173 | |
174 | #if defined(HAVE_RTADV) | |
175 | struct rtadv rtadv; | |
176 | #endif /* HAVE_RTADV */ | |
5a0bdc78 PG |
177 | |
178 | int zebra_rnh_ip_default_route; | |
179 | int zebra_rnh_ipv6_default_route; | |
7c551956 | 180 | }; |
ac6eebce | 181 | #define PROTO_RM_NAME(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].name |
182 | #define NHT_RM_NAME(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].name | |
183 | #define PROTO_RM_MAP(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].map | |
184 | #define NHT_RM_MAP(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].map | |
7c551956 | 185 | |
214e5c26 | 186 | /* |
187 | * special macro to allow us to get the correct zebra_vrf | |
188 | */ | |
189 | #define ZEBRA_DECLVAR_CONTEXT(A, B) \ | |
190 | struct vrf *A = VTY_GET_CONTEXT(vrf); \ | |
191 | struct zebra_vrf *B = (A) ? A->info : vrf_info_lookup(VRF_DEFAULT) | |
192 | ||
d62a17ae | 193 | static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf) |
661512bf | 194 | { |
2c7d4021 | 195 | if (!zvrf || !zvrf->vrf) |
bd47f3a3 | 196 | return VRF_DEFAULT; |
d62a17ae | 197 | return zvrf->vrf->vrf_id; |
661512bf RW |
198 | } |
199 | ||
81c9005f PG |
200 | static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf) |
201 | { | |
202 | if (!zvrf->vrf || !zvrf->vrf->ns_ctxt) | |
203 | return NULL; | |
204 | return ns_get_name((struct ns *)zvrf->vrf->ns_ctxt); | |
205 | } | |
206 | ||
d62a17ae | 207 | static inline const char *zvrf_name(struct zebra_vrf *zvrf) |
661512bf | 208 | { |
bd47f3a3 JU |
209 | if (!zvrf || !zvrf->vrf) |
210 | return "Unknown"; | |
d62a17ae | 211 | return zvrf->vrf->name; |
661512bf RW |
212 | } |
213 | ||
81c9005f PG |
214 | static inline bool zvrf_is_active(struct zebra_vrf *zvrf) |
215 | { | |
216 | return zvrf->vrf->status & VRF_ACTIVE; | |
217 | } | |
218 | ||
d8612e65 DS |
219 | static inline int |
220 | zvrf_other_table_compare_func(const struct other_route_table *a, | |
221 | const struct other_route_table *b) | |
222 | { | |
223 | if (a->afi != b->afi) | |
224 | return a->afi - b->afi; | |
225 | ||
226 | if (a->safi != b->safi) | |
227 | return a->safi - b->safi; | |
228 | ||
229 | if (a->table_id != b->table_id) | |
230 | return a->table_id - b->table_id; | |
231 | ||
232 | return 0; | |
233 | } | |
234 | ||
235 | DECLARE_RBTREE_UNIQ(otable, struct other_route_table, next, | |
236 | zvrf_other_table_compare_func) | |
237 | ||
c7c0b007 SW |
238 | extern struct route_table * |
239 | zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi, vrf_id_t vrf_id, | |
240 | uint32_t table_id); | |
241 | extern struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi, | |
242 | safi_t safi, | |
243 | vrf_id_t vrf_id, | |
244 | uint32_t table_id); | |
d62a17ae | 245 | |
d62a17ae | 246 | extern void zebra_vrf_update_all(struct zserv *client); |
247 | extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id); | |
248 | extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *); | |
249 | extern struct zebra_vrf *zebra_vrf_alloc(void); | |
250 | extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t); | |
7e24fdf3 | 251 | |
22bd3e94 | 252 | extern int zebra_vrf_has_config(struct zebra_vrf *zvrf); |
d62a17ae | 253 | extern void zebra_vrf_init(void); |
5335613b DS |
254 | |
255 | extern void zebra_rtable_node_cleanup(struct route_table *table, | |
256 | struct route_node *node); | |
51e94aa7 EDP |
257 | |
258 | #ifdef __cplusplus | |
259 | } | |
260 | #endif | |
261 | ||
736d41ad | 262 | #endif /* ZEBRA_VRF_H */ |