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