]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_vrf.h
Merge pull request #5789 from donaldsharp/bgp_ebgp_reason
[mirror_frr.git] / zebra / zebra_vrf.h
CommitLineData
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
32extern "C" {
33#endif
34
1b6d5c7e 35/* MPLS (Segment Routing) global block */
d62a17ae 36typedef struct mpls_srgb_t_ {
d7c0a89a
QY
37 uint32_t start_label;
38 uint32_t end_label;
1b6d5c7e
VV
39} mpls_srgb_t;
40
ac6eebce 41struct zebra_rmap {
42 char *name;
43 struct route_map *map;
44};
45
d8612e65
DS
46PREDECL_RBTREE_UNIQ(otable);
47
48struct 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 59struct 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 193static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf)
661512bf 194{
2c7d4021
PG
195 if (!zvrf || !zvrf->vrf)
196 return VRF_UNKNOWN;
d62a17ae 197 return zvrf->vrf->vrf_id;
661512bf
RW
198}
199
81c9005f
PG
200static 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 207static inline const char *zvrf_name(struct zebra_vrf *zvrf)
661512bf 208{
d62a17ae 209 return zvrf->vrf->name;
661512bf
RW
210}
211
81c9005f
PG
212static inline bool zvrf_is_active(struct zebra_vrf *zvrf)
213{
214 return zvrf->vrf->status & VRF_ACTIVE;
215}
216
d8612e65
DS
217static inline int
218zvrf_other_table_compare_func(const struct other_route_table *a,
219 const struct other_route_table *b)
220{
221 if (a->afi != b->afi)
222 return a->afi - b->afi;
223
224 if (a->safi != b->safi)
225 return a->safi - b->safi;
226
227 if (a->table_id != b->table_id)
228 return a->table_id - b->table_id;
229
230 return 0;
231}
232
233DECLARE_RBTREE_UNIQ(otable, struct other_route_table, next,
234 zvrf_other_table_compare_func)
235
c7c0b007
SW
236extern struct route_table *
237zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi, vrf_id_t vrf_id,
238 uint32_t table_id);
239extern struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi,
240 safi_t safi,
241 vrf_id_t vrf_id,
242 uint32_t table_id);
d62a17ae 243
d62a17ae 244extern void zebra_vrf_update_all(struct zserv *client);
245extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id);
246extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
247extern struct zebra_vrf *zebra_vrf_alloc(void);
248extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t);
7e24fdf3 249
22bd3e94 250extern int zebra_vrf_has_config(struct zebra_vrf *zvrf);
d62a17ae 251extern void zebra_vrf_init(void);
5335613b
DS
252
253extern void zebra_rtable_node_cleanup(struct route_table *table,
254 struct route_node *node);
51e94aa7
EDP
255
256#ifdef __cplusplus
257}
258#endif
259
736d41ad 260#endif /* ZEBRA_VRF_H */