]>
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> |
7ca9c407 | 29 | #include <zebra/rtadv.h> |
b7cfce93 | 30 | #include <lib/vxlan.h> |
7c551956 | 31 | |
51e94aa7 EDP |
32 | #ifdef __cplusplus |
33 | extern "C" { | |
34 | #endif | |
35 | ||
1b6d5c7e | 36 | /* MPLS (Segment Routing) global block */ |
c4528712 | 37 | struct mpls_srgb { |
d7c0a89a QY |
38 | uint32_t start_label; |
39 | uint32_t end_label; | |
c4528712 | 40 | }; |
1b6d5c7e | 41 | |
ac6eebce | 42 | struct zebra_rmap { |
43 | char *name; | |
44 | struct route_map *map; | |
45 | }; | |
46 | ||
d8612e65 DS |
47 | PREDECL_RBTREE_UNIQ(otable); |
48 | ||
49 | struct other_route_table { | |
50 | struct otable_item next; | |
51 | ||
52 | afi_t afi; | |
53 | safi_t safi; | |
54 | uint32_t table_id; | |
55 | ||
56 | struct route_table *table; | |
57 | }; | |
58 | ||
7c551956 | 59 | /* Routing table instance. */ |
d62a17ae | 60 | struct zebra_vrf { |
61 | /* Back pointer */ | |
62 | struct vrf *vrf; | |
7c551956 | 63 | |
d62a17ae | 64 | /* Description. */ |
65 | char *desc; | |
7c551956 | 66 | |
d62a17ae | 67 | /* FIB identifier. */ |
d7c0a89a | 68 | uint8_t fib_id; |
7c551956 | 69 | |
d62a17ae | 70 | /* Flags. */ |
d7c0a89a | 71 | uint16_t flags; |
f4c6e2a8 | 72 | #define ZEBRA_VRF_RETAIN (1 << 0) |
ecbbc3a7 | 73 | #define ZEBRA_PIM_SEND_VXLAN_SG (1 << 1) |
7c551956 | 74 | |
d7c0a89a | 75 | uint32_t table_id; |
7c551956 | 76 | |
d62a17ae | 77 | /* Routing table. */ |
78 | struct route_table *table[AFI_MAX][SAFI_MAX]; | |
7c551956 | 79 | |
d62a17ae | 80 | /* Recursive Nexthop table */ |
81 | struct route_table *rnh_table[AFI_MAX]; | |
a4598b97 | 82 | struct route_table *rnh_table_multicast[AFI_MAX]; |
7c551956 | 83 | |
d8612e65 DS |
84 | struct otable_head other_tables; |
85 | ||
d62a17ae | 86 | /* 2nd pointer type used primarily to quell a warning on |
87 | * ALL_LIST_ELEMENTS_RO | |
88 | */ | |
89 | struct list _rid_all_sorted_list; | |
90 | struct list _rid_lo_sorted_list; | |
91 | struct list *rid_all_sorted_list; | |
92 | struct list *rid_lo_sorted_list; | |
93 | struct prefix rid_user_assigned; | |
98a3fb0a SM |
94 | struct list _rid6_all_sorted_list; |
95 | struct list _rid6_lo_sorted_list; | |
96 | struct list *rid6_all_sorted_list; | |
97 | struct list *rid6_lo_sorted_list; | |
98 | struct prefix rid6_user_assigned; | |
7c551956 | 99 | |
d62a17ae | 100 | /* |
101 | * Back pointer to the owning namespace. | |
102 | */ | |
103 | struct zebra_ns *zns; | |
54d48ea1 | 104 | |
c83c5e44 | 105 | /* MPLS Label to handle L3VPN <-> vrf popping */ |
7d061b3c | 106 | mpls_label_t label[AFI_MAX]; |
06302ecb | 107 | uint8_t label_proto[AFI_MAX]; |
c83c5e44 | 108 | |
d62a17ae | 109 | /* MPLS static LSP config table */ |
110 | struct hash *slsp_table; | |
54d48ea1 | 111 | |
d62a17ae | 112 | /* MPLS label forwarding table */ |
113 | struct hash *lsp_table; | |
939fba27 | 114 | |
d62a17ae | 115 | /* MPLS FEC binding table */ |
116 | struct route_table *fec_table[AFI_MAX]; | |
f31e084c | 117 | |
d62a17ae | 118 | /* MPLS Segment Routing Global block */ |
c4528712 | 119 | struct mpls_srgb mpls_srgb; |
1b6d5c7e | 120 | |
6833ae01 | 121 | /* Pseudowires. */ |
122 | struct zebra_pw_head pseudowires; | |
2dd0d726 | 123 | struct zebra_static_pw_head static_pseudowires; |
6833ae01 | 124 | |
ac6eebce | 125 | struct zebra_rmap proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1]; |
126 | struct zebra_rmap nht_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1]; | |
127 | ||
d62a17ae | 128 | /* MPLS processing flags */ |
d7c0a89a | 129 | uint16_t mpls_flags; |
939fba27 | 130 | #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) |
57282a31 | 131 | |
d62a17ae | 132 | /* |
87d76d54 | 133 | * EVPN hash table. Only in the EVPN instance. |
d62a17ae | 134 | */ |
87d76d54 | 135 | struct hash *evpn_table; |
2853fed6 | 136 | |
d62a17ae | 137 | /* |
150971b5 | 138 | * Whether EVPN is enabled or not. Only in the EVPN instance. |
d62a17ae | 139 | */ |
140 | int advertise_all_vni; | |
141 | ||
1a98c087 MK |
142 | /* |
143 | * Whether we are advertising g/w macip in EVPN or not. | |
150971b5 | 144 | * Only in the EVPN instance. |
1a98c087 MK |
145 | */ |
146 | int advertise_gw_macip; | |
147 | ||
278e26de CS |
148 | int advertise_svi_macip; |
149 | ||
b7cfce93 MK |
150 | /* l3-vni info */ |
151 | vni_t l3vni; | |
152 | ||
8a93734c AK |
153 | /* pim mroutes installed for vxlan flooding */ |
154 | struct hash *vxlan_sg_table; | |
155 | ||
3950b52c CS |
156 | bool dup_addr_detect; |
157 | ||
158 | int dad_time; | |
159 | uint32_t dad_max_moves; | |
160 | bool dad_freeze; | |
161 | uint32_t dad_freeze_time; | |
162 | ||
fbac9605 DS |
163 | /* |
164 | * Flooding mechanism for BUM packets for VxLAN-EVPN. | |
165 | */ | |
166 | enum vxlan_flood_control vxlan_flood_ctrl; | |
167 | ||
d37f4d6c | 168 | /* Install stats */ |
d62a17ae | 169 | uint64_t installs; |
170 | uint64_t removals; | |
97f5b441 MS |
171 | uint64_t installs_queued; |
172 | uint64_t removals_queued; | |
d62a17ae | 173 | uint64_t neigh_updates; |
d37f4d6c MS |
174 | uint64_t lsp_installs_queued; |
175 | uint64_t lsp_removals_queued; | |
d62a17ae | 176 | uint64_t lsp_installs; |
177 | uint64_t lsp_removals; | |
df9c8c57 | 178 | |
42d4b30e PG |
179 | struct table_manager *tbl_mgr; |
180 | ||
df9c8c57 | 181 | struct rtadv rtadv; |
5a0bdc78 | 182 | |
4aabcba0 DS |
183 | bool zebra_rnh_ip_default_route; |
184 | bool zebra_rnh_ipv6_default_route; | |
7c551956 | 185 | }; |
ac6eebce | 186 | #define PROTO_RM_NAME(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].name |
187 | #define NHT_RM_NAME(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].name | |
188 | #define PROTO_RM_MAP(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].map | |
189 | #define NHT_RM_MAP(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].map | |
7c551956 | 190 | |
214e5c26 | 191 | /* |
192 | * special macro to allow us to get the correct zebra_vrf | |
193 | */ | |
0cbed951 DL |
194 | #define ZEBRA_DECLVAR_CONTEXT_VRF(vrfptr, zvrfptr) \ |
195 | VTY_DECLVAR_CONTEXT_VRF(vrfptr); \ | |
196 | struct zebra_vrf *zvrfptr = vrfptr->info; \ | |
197 | MACRO_REQUIRE_SEMICOLON() /* end */ | |
214e5c26 | 198 | |
d62a17ae | 199 | static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf) |
661512bf | 200 | { |
2c7d4021 | 201 | if (!zvrf || !zvrf->vrf) |
bd47f3a3 | 202 | return VRF_DEFAULT; |
d62a17ae | 203 | return zvrf->vrf->vrf_id; |
661512bf RW |
204 | } |
205 | ||
81c9005f PG |
206 | static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf) |
207 | { | |
208 | if (!zvrf->vrf || !zvrf->vrf->ns_ctxt) | |
209 | return NULL; | |
210 | return ns_get_name((struct ns *)zvrf->vrf->ns_ctxt); | |
211 | } | |
212 | ||
d62a17ae | 213 | static inline const char *zvrf_name(struct zebra_vrf *zvrf) |
661512bf | 214 | { |
bd47f3a3 JU |
215 | if (!zvrf || !zvrf->vrf) |
216 | return "Unknown"; | |
d62a17ae | 217 | return zvrf->vrf->name; |
661512bf RW |
218 | } |
219 | ||
81c9005f PG |
220 | static inline bool zvrf_is_active(struct zebra_vrf *zvrf) |
221 | { | |
222 | return zvrf->vrf->status & VRF_ACTIVE; | |
223 | } | |
224 | ||
d8612e65 DS |
225 | static inline int |
226 | zvrf_other_table_compare_func(const struct other_route_table *a, | |
227 | const struct other_route_table *b) | |
228 | { | |
229 | if (a->afi != b->afi) | |
230 | return a->afi - b->afi; | |
231 | ||
232 | if (a->safi != b->safi) | |
233 | return a->safi - b->safi; | |
234 | ||
235 | if (a->table_id != b->table_id) | |
236 | return a->table_id - b->table_id; | |
237 | ||
238 | return 0; | |
239 | } | |
240 | ||
241 | DECLARE_RBTREE_UNIQ(otable, struct other_route_table, next, | |
960b9a53 | 242 | zvrf_other_table_compare_func); |
d8612e65 | 243 | |
c7c0b007 SW |
244 | extern struct route_table * |
245 | zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi, vrf_id_t vrf_id, | |
246 | uint32_t table_id); | |
247 | extern struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi, | |
248 | safi_t safi, | |
249 | vrf_id_t vrf_id, | |
250 | uint32_t table_id); | |
d62a17ae | 251 | |
d62a17ae | 252 | extern void zebra_vrf_update_all(struct zserv *client); |
253 | extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id); | |
254 | extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *); | |
ec64a634 | 255 | extern struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf); |
d62a17ae | 256 | extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t); |
7e24fdf3 | 257 | |
62d89c64 IR |
258 | /* |
259 | * API to associate a VRF with a NETNS. | |
260 | * Called either from vty or through discovery. | |
261 | */ | |
262 | extern int zebra_vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, | |
263 | char *pathname, ns_id_t ext_ns_id, | |
264 | ns_id_t ns_id, ns_id_t rel_def_ns_id); | |
265 | ||
d62a17ae | 266 | extern void zebra_vrf_init(void); |
5335613b DS |
267 | |
268 | extern void zebra_rtable_node_cleanup(struct route_table *table, | |
269 | struct route_node *node); | |
51e94aa7 EDP |
270 | |
271 | #ifdef __cplusplus | |
272 | } | |
273 | #endif | |
274 | ||
736d41ad | 275 | #endif /* ZEBRA_VRF_H */ |