]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_vrf.h
Merge branch 'master' into evpn-session-vrf
[mirror_frr.git] / zebra / zebra_vrf.h
1 /*
2 * Zebra Vrf Header
3 * Copyright (C) 2016 Cumulus Networks
4 * Donald Sharp
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 *
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
21 */
22 #if !defined(__ZEBRA_VRF_H__)
23 #define __ZEBRA_VRF_H__
24
25 #include "vxlan.h"
26
27 #include <zebra/zebra_ns.h>
28 #include <zebra/zebra_pw.h>
29 #include <lib/vxlan.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* MPLS (Segment Routing) global block */
36 typedef struct mpls_srgb_t_ {
37 uint32_t start_label;
38 uint32_t end_label;
39 } mpls_srgb_t;
40
41 struct zebra_rmap {
42 char *name;
43 struct route_map *map;
44 };
45
46 /* Routing table instance. */
47 struct zebra_vrf {
48 /* Back pointer */
49 struct vrf *vrf;
50
51 /* Description. */
52 char *desc;
53
54 /* FIB identifier. */
55 uint8_t fib_id;
56
57 /* Flags. */
58 uint16_t flags;
59 #define ZEBRA_VRF_RIB_SCHEDULED (1 << 0)
60 #define ZEBRA_VRF_RETAIN (2 << 0)
61
62 uint32_t table_id;
63
64 /* Routing table. */
65 struct route_table *table[AFI_MAX][SAFI_MAX];
66
67 /* Recursive Nexthop table */
68 struct route_table *rnh_table[AFI_MAX];
69
70 /* Import check table (used mostly by BGP */
71 struct route_table *import_check_table[AFI_MAX];
72
73 /* 2nd pointer type used primarily to quell a warning on
74 * ALL_LIST_ELEMENTS_RO
75 */
76 struct list _rid_all_sorted_list;
77 struct list _rid_lo_sorted_list;
78 struct list *rid_all_sorted_list;
79 struct list *rid_lo_sorted_list;
80 struct prefix rid_user_assigned;
81
82 /*
83 * Back pointer to the owning namespace.
84 */
85 struct zebra_ns *zns;
86
87 /* MPLS Label to handle L3VPN <-> vrf popping */
88 mpls_label_t label[AFI_MAX];
89
90 /* MPLS static LSP config table */
91 struct hash *slsp_table;
92
93 /* MPLS label forwarding table */
94 struct hash *lsp_table;
95
96 /* MPLS FEC binding table */
97 struct route_table *fec_table[AFI_MAX];
98
99 /* MPLS Segment Routing Global block */
100 mpls_srgb_t mpls_srgb;
101
102 /* Pseudowires. */
103 struct zebra_pw_head pseudowires;
104 struct zebra_static_pw_head static_pseudowires;
105
106 struct zebra_rmap proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1];
107 struct zebra_rmap nht_rm[AFI_MAX][ZEBRA_ROUTE_MAX + 1];
108
109 /* MPLS processing flags */
110 uint16_t mpls_flags;
111 #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0)
112
113 /*
114 * VNI hash table (for EVPN). Only in the EVPN instance.
115 */
116 struct hash *vni_table;
117
118 /*
119 * Whether EVPN is enabled or not. Only in the EVPN instance.
120 */
121 int advertise_all_vni;
122
123 /*
124 * Whether we are advertising g/w macip in EVPN or not.
125 * Only in the EVPN instance.
126 */
127 int advertise_gw_macip;
128
129 int advertise_svi_macip;
130
131 /* l3-vni info */
132 vni_t l3vni;
133
134 bool dup_addr_detect;
135
136 int dad_time;
137 uint32_t dad_max_moves;
138 bool dad_freeze;
139 uint32_t dad_freeze_time;
140
141 /*
142 * Flooding mechanism for BUM packets for VxLAN-EVPN.
143 */
144 enum vxlan_flood_control vxlan_flood_ctrl;
145
146 /* Install stats */
147 uint64_t installs;
148 uint64_t removals;
149 uint64_t installs_queued;
150 uint64_t removals_queued;
151 uint64_t neigh_updates;
152 uint64_t lsp_installs_queued;
153 uint64_t lsp_removals_queued;
154 uint64_t lsp_installs;
155 uint64_t lsp_removals;
156 };
157 #define PROTO_RM_NAME(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].name
158 #define NHT_RM_NAME(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].name
159 #define PROTO_RM_MAP(zvrf, afi, rtype) zvrf->proto_rm[afi][rtype].map
160 #define NHT_RM_MAP(zvrf, afi, rtype) zvrf->nht_rm[afi][rtype].map
161
162 /*
163 * special macro to allow us to get the correct zebra_vrf
164 */
165 #define ZEBRA_DECLVAR_CONTEXT(A, B) \
166 struct vrf *A = VTY_GET_CONTEXT(vrf); \
167 struct zebra_vrf *B = (A) ? A->info : vrf_info_lookup(VRF_DEFAULT)
168
169 static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf)
170 {
171 if (!zvrf || !zvrf->vrf)
172 return VRF_UNKNOWN;
173 return zvrf->vrf->vrf_id;
174 }
175
176 static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf)
177 {
178 if (!zvrf->vrf || !zvrf->vrf->ns_ctxt)
179 return NULL;
180 return ns_get_name((struct ns *)zvrf->vrf->ns_ctxt);
181 }
182
183 static inline const char *zvrf_name(struct zebra_vrf *zvrf)
184 {
185 return zvrf->vrf->name;
186 }
187
188 static inline bool zvrf_is_active(struct zebra_vrf *zvrf)
189 {
190 return zvrf->vrf->status & VRF_ACTIVE;
191 }
192
193 struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
194 vrf_id_t vrf_id,
195 uint32_t table_id);
196
197 extern void zebra_vrf_update_all(struct zserv *client);
198 extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id);
199 extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
200 extern struct zebra_vrf *zebra_vrf_alloc(void);
201 extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t);
202
203 extern struct route_table *
204 zebra_vrf_other_route_table(afi_t afi, uint32_t table_id, vrf_id_t vrf_id);
205 extern int zebra_vrf_has_config(struct zebra_vrf *zvrf);
206 extern void zebra_vrf_init(void);
207
208 extern void zebra_rtable_node_cleanup(struct route_table *table,
209 struct route_node *node);
210
211 #ifdef __cplusplus
212 }
213 #endif
214
215 #endif /* ZEBRA_VRF_H */