]>
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 | ||
7c551956 | 46 | /* Routing table instance. */ |
d62a17ae | 47 | struct zebra_vrf { |
48 | /* Back pointer */ | |
49 | struct vrf *vrf; | |
7c551956 | 50 | |
d62a17ae | 51 | /* Description. */ |
52 | char *desc; | |
7c551956 | 53 | |
d62a17ae | 54 | /* FIB identifier. */ |
d7c0a89a | 55 | uint8_t fib_id; |
7c551956 | 56 | |
d62a17ae | 57 | /* Flags. */ |
d7c0a89a | 58 | uint16_t flags; |
f4c6e2a8 | 59 | #define ZEBRA_VRF_RETAIN (1 << 0) |
7c551956 | 60 | |
d7c0a89a | 61 | uint32_t table_id; |
7c551956 | 62 | |
d62a17ae | 63 | /* Routing table. */ |
64 | struct route_table *table[AFI_MAX][SAFI_MAX]; | |
7c551956 | 65 | |
d62a17ae | 66 | /* Recursive Nexthop table */ |
67 | struct route_table *rnh_table[AFI_MAX]; | |
7c551956 | 68 | |
d62a17ae | 69 | /* Import check table (used mostly by BGP */ |
70 | struct route_table *import_check_table[AFI_MAX]; | |
7c551956 | 71 | |
d62a17ae | 72 | /* 2nd pointer type used primarily to quell a warning on |
73 | * ALL_LIST_ELEMENTS_RO | |
74 | */ | |
75 | struct list _rid_all_sorted_list; | |
76 | struct list _rid_lo_sorted_list; | |
77 | struct list *rid_all_sorted_list; | |
78 | struct list *rid_lo_sorted_list; | |
79 | struct prefix rid_user_assigned; | |
7c551956 | 80 | |
d62a17ae | 81 | /* |
82 | * Back pointer to the owning namespace. | |
83 | */ | |
84 | struct zebra_ns *zns; | |
54d48ea1 | 85 | |
c83c5e44 | 86 | /* MPLS Label to handle L3VPN <-> vrf popping */ |
7d061b3c | 87 | mpls_label_t label[AFI_MAX]; |
c83c5e44 | 88 | |
d62a17ae | 89 | /* MPLS static LSP config table */ |
90 | struct hash *slsp_table; | |
54d48ea1 | 91 | |
d62a17ae | 92 | /* MPLS label forwarding table */ |
93 | struct hash *lsp_table; | |
939fba27 | 94 | |
d62a17ae | 95 | /* MPLS FEC binding table */ |
96 | struct route_table *fec_table[AFI_MAX]; | |
f31e084c | 97 | |
d62a17ae | 98 | /* MPLS Segment Routing Global block */ |
99 | mpls_srgb_t mpls_srgb; | |
1b6d5c7e | 100 | |
6833ae01 | 101 | /* Pseudowires. */ |
102 | struct zebra_pw_head pseudowires; | |
2dd0d726 | 103 | struct zebra_static_pw_head static_pseudowires; |
6833ae01 | 104 | |
ac6eebce | 105 | struct zebra_rmap proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1]; |
106 | struct zebra_rmap nht_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1]; | |
107 | ||
d62a17ae | 108 | /* MPLS processing flags */ |
d7c0a89a | 109 | uint16_t mpls_flags; |
939fba27 | 110 | #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) |
57282a31 | 111 | |
d62a17ae | 112 | /* |
150971b5 | 113 | * VNI hash table (for EVPN). Only in the EVPN instance. |
d62a17ae | 114 | */ |
115 | struct hash *vni_table; | |
2853fed6 | 116 | |
d62a17ae | 117 | /* |
150971b5 | 118 | * Whether EVPN is enabled or not. Only in the EVPN instance. |
d62a17ae | 119 | */ |
120 | int advertise_all_vni; | |
121 | ||
1a98c087 MK |
122 | /* |
123 | * Whether we are advertising g/w macip in EVPN or not. | |
150971b5 | 124 | * Only in the EVPN instance. |
1a98c087 MK |
125 | */ |
126 | int advertise_gw_macip; | |
127 | ||
278e26de CS |
128 | int advertise_svi_macip; |
129 | ||
b7cfce93 MK |
130 | /* l3-vni info */ |
131 | vni_t l3vni; | |
132 | ||
8a93734c AK |
133 | /* pim mroutes installed for vxlan flooding */ |
134 | struct hash *vxlan_sg_table; | |
135 | ||
3950b52c CS |
136 | bool dup_addr_detect; |
137 | ||
138 | int dad_time; | |
139 | uint32_t dad_max_moves; | |
140 | bool dad_freeze; | |
141 | uint32_t dad_freeze_time; | |
142 | ||
fbac9605 DS |
143 | /* |
144 | * Flooding mechanism for BUM packets for VxLAN-EVPN. | |
145 | */ | |
146 | enum vxlan_flood_control vxlan_flood_ctrl; | |
147 | ||
d37f4d6c | 148 | /* Install stats */ |
d62a17ae | 149 | uint64_t installs; |
150 | uint64_t removals; | |
97f5b441 MS |
151 | uint64_t installs_queued; |
152 | uint64_t removals_queued; | |
d62a17ae | 153 | uint64_t neigh_updates; |
d37f4d6c MS |
154 | uint64_t lsp_installs_queued; |
155 | uint64_t lsp_removals_queued; | |
d62a17ae | 156 | uint64_t lsp_installs; |
157 | uint64_t lsp_removals; | |
7c551956 | 158 | }; |
ac6eebce | 159 | #define PROTO_RM_NAME(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].name |
160 | #define NHT_RM_NAME(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].name | |
161 | #define PROTO_RM_MAP(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].map | |
162 | #define NHT_RM_MAP(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].map | |
7c551956 | 163 | |
214e5c26 | 164 | /* |
165 | * special macro to allow us to get the correct zebra_vrf | |
166 | */ | |
167 | #define ZEBRA_DECLVAR_CONTEXT(A, B) \ | |
168 | struct vrf *A = VTY_GET_CONTEXT(vrf); \ | |
169 | struct zebra_vrf *B = (A) ? A->info : vrf_info_lookup(VRF_DEFAULT) | |
170 | ||
d62a17ae | 171 | static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf) |
661512bf | 172 | { |
2c7d4021 PG |
173 | if (!zvrf || !zvrf->vrf) |
174 | return VRF_UNKNOWN; | |
d62a17ae | 175 | return zvrf->vrf->vrf_id; |
661512bf RW |
176 | } |
177 | ||
81c9005f PG |
178 | static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf) |
179 | { | |
180 | if (!zvrf->vrf || !zvrf->vrf->ns_ctxt) | |
181 | return NULL; | |
182 | return ns_get_name((struct ns *)zvrf->vrf->ns_ctxt); | |
183 | } | |
184 | ||
d62a17ae | 185 | static inline const char *zvrf_name(struct zebra_vrf *zvrf) |
661512bf | 186 | { |
d62a17ae | 187 | return zvrf->vrf->name; |
661512bf RW |
188 | } |
189 | ||
81c9005f PG |
190 | static inline bool zvrf_is_active(struct zebra_vrf *zvrf) |
191 | { | |
192 | return zvrf->vrf->status & VRF_ACTIVE; | |
193 | } | |
194 | ||
d62a17ae | 195 | struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi, |
196 | vrf_id_t vrf_id, | |
d7c0a89a | 197 | uint32_t table_id); |
d62a17ae | 198 | |
d62a17ae | 199 | extern void zebra_vrf_update_all(struct zserv *client); |
200 | extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id); | |
201 | extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *); | |
202 | extern struct zebra_vrf *zebra_vrf_alloc(void); | |
203 | extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t); | |
7e24fdf3 | 204 | |
d62a17ae | 205 | extern struct route_table * |
d7c0a89a | 206 | zebra_vrf_other_route_table(afi_t afi, uint32_t table_id, vrf_id_t vrf_id); |
22bd3e94 | 207 | extern int zebra_vrf_has_config(struct zebra_vrf *zvrf); |
d62a17ae | 208 | extern void zebra_vrf_init(void); |
5335613b DS |
209 | |
210 | extern void zebra_rtable_node_cleanup(struct route_table *table, | |
211 | struct route_node *node); | |
51e94aa7 EDP |
212 | |
213 | #ifdef __cplusplus | |
214 | } | |
215 | #endif | |
216 | ||
736d41ad | 217 | #endif /* ZEBRA_VRF_H */ |