]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/bgp_rfapi_cfg.h
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[mirror_frr.git] / bgpd / rfapi / bgp_rfapi_cfg.h
1 /*
2 *
3 * Copyright 2009-2016, LabN Consulting, L.L.C.
4 *
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef _QUAGGA_BGP_RFAPI_CFG_H
22 #define _QUAGGA_BGP_RFAPI_CFG_H
23
24 #include "lib/table.h"
25 #include "lib/routemap.h"
26
27 #ifdef ENABLE_BGP_VNC
28 #include "rfapi.h"
29
30 struct rfapi_l2_group_cfg {
31 char *name;
32 uint32_t logical_net_id;
33 struct list *labels; /* list of uint32_t */
34 struct ecommunity *rt_import_list;
35 struct ecommunity *rt_export_list;
36 void *rfp_cfg; /* rfp owned group config */
37
38 QOBJ_FIELDS;
39 };
40 DECLARE_QOBJ_TYPE(rfapi_l2_group_cfg);
41
42 typedef enum {
43 RFAPI_GROUP_CFG_NVE = 1,
44 RFAPI_GROUP_CFG_VRF,
45 RFAPI_GROUP_CFG_L2,
46 RFAPI_GROUP_CFG_MAX
47 } rfapi_group_cfg_type_t;
48
49 struct rfapi_nve_group_cfg {
50 struct agg_node *vn_node; /* backref */
51 struct agg_node *un_node; /* backref */
52
53 rfapi_group_cfg_type_t type; /* NVE|VPN */
54 char *name; /* unique by type! */
55 struct prefix vn_prefix;
56 struct prefix un_prefix;
57
58 struct prefix_rd rd;
59 uint8_t l2rd; /* 0 = VN addr LSB */
60 uint32_t response_lifetime;
61 uint32_t flags;
62 #define RFAPI_RFG_RESPONSE_LIFETIME 0x01 /* bits */
63 #define RFAPI_RFG_L2RD 0x02
64 #define RFAPI_RFG_VPN_NH_SELF 0x04
65 struct ecommunity *rt_import_list;
66 struct ecommunity *rt_export_list;
67 struct rfapi_import_table *rfapi_import_table;
68
69 void *rfp_cfg; /* rfp owned group config */
70 /*
71 * List of NVE descriptors that are assigned to this NVE group
72 *
73 * Currently (Mar 2010) this list is used only by the route
74 * export code to generate per-NVE nexthops for each route.
75 *
76 * The nve descriptors listed here have pointers back to
77 * this nve group config structure to enable them to delete
78 * their own list entries when they are closed. Consequently,
79 * if an instance of this nve group config structure is deleted,
80 * we must first set the nve descriptor references to it to NULL.
81 */
82 struct list *nves;
83
84 /*
85 * Route filtering
86 *
87 * Prefix lists are segregated by afi (part of the base plist code)
88 * Route-maps are not segregated
89 */
90 char *plist_export_bgp_name[AFI_MAX];
91 struct prefix_list *plist_export_bgp[AFI_MAX];
92
93 char *plist_export_zebra_name[AFI_MAX];
94 struct prefix_list *plist_export_zebra[AFI_MAX];
95
96 char *plist_redist_name[ZEBRA_ROUTE_MAX][AFI_MAX];
97 struct prefix_list *plist_redist[ZEBRA_ROUTE_MAX][AFI_MAX];
98
99 char *routemap_export_bgp_name;
100 struct route_map *routemap_export_bgp;
101
102 char *routemap_export_zebra_name;
103 struct route_map *routemap_export_zebra;
104
105 char *routemap_redist_name[ZEBRA_ROUTE_MAX];
106 struct route_map *routemap_redist[ZEBRA_ROUTE_MAX];
107
108 /* for VRF type groups */
109 uint32_t label;
110 struct rfapi_descriptor *rfd;
111 QOBJ_FIELDS;
112 };
113 DECLARE_QOBJ_TYPE(rfapi_nve_group_cfg);
114
115 struct rfapi_rfg_name {
116 struct rfapi_nve_group_cfg *rfg;
117 char *name;
118 };
119
120 typedef enum {
121 VNC_REDIST_MODE_PLAIN = 0, /* 0 = default */
122 VNC_REDIST_MODE_RFG,
123 VNC_REDIST_MODE_RESOLVE_NVE
124 } vnc_redist_mode_t;
125
126 struct rfapi_cfg {
127 struct prefix_rd default_rd;
128 uint8_t default_l2rd;
129 struct ecommunity *default_rt_import_list;
130 struct ecommunity *default_rt_export_list;
131 uint32_t default_response_lifetime;
132 #define BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT 3600
133 void *default_rfp_cfg; /* rfp owned group config */
134
135 struct list *l2_groups; /* rfapi_l2_group_cfg list */
136 /* three views into the same collection of rfapi_nve_group_cfg */
137 struct list *nve_groups_sequential;
138 struct agg_table *nve_groups_vn[AFI_MAX];
139 struct agg_table *nve_groups_un[AFI_MAX];
140
141 /*
142 * For Single VRF export to ordinary routing protocols. This is
143 * the nve-group that the ordinary protocols belong to. We use it
144 * to set the RD when sending unicast Zebra routes to VNC
145 */
146 uint8_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
147 uint32_t redist_lifetime;
148 vnc_redist_mode_t redist_mode;
149
150 /*
151 * view name of BGP unicast instance that holds
152 * exterior routes
153 */
154 char *redist_bgp_exterior_view_name;
155 struct bgp *redist_bgp_exterior_view;
156
157 /*
158 * nve group for redistribution of routes from zebra to VNC
159 * (which is probably not useful for production networks)
160 */
161 char *rfg_redist_name;
162 struct rfapi_nve_group_cfg *rfg_redist;
163
164 /*
165 * List of NVE groups on whose behalf we will export VNC
166 * routes to zebra. ((NB: it's actually a list of <struct
167 * rfapi_rfg_name>)
168 * This list is used when BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS is
169 * BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
170 */
171 struct list *rfg_export_zebra_l;
172
173 /*
174 * List of NVE groups on whose behalf we will export VNC
175 * routes directly to the bgp unicast RIB. (NB: it's actually
176 * a list of <struct rfapi_rfg_name>)
177 * This list is used when BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS is
178 * BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
179 */
180 struct list *rfg_export_direct_bgp_l;
181
182 /*
183 * Exported Route filtering
184 *
185 * Prefix lists are segregated by afi (part of the base plist code)
186 * Route-maps are not segregated
187 */
188 char *plist_export_bgp_name[AFI_MAX];
189 struct prefix_list *plist_export_bgp[AFI_MAX];
190
191 char *plist_export_zebra_name[AFI_MAX];
192 struct prefix_list *plist_export_zebra[AFI_MAX];
193
194 char *routemap_export_bgp_name;
195 struct route_map *routemap_export_bgp;
196
197 char *routemap_export_zebra_name;
198 struct route_map *routemap_export_zebra;
199
200 /*
201 * Redistributed route filtering (routes from other
202 * protocols into VNC)
203 */
204 char *plist_redist_name[ZEBRA_ROUTE_MAX][AFI_MAX];
205 struct prefix_list *plist_redist[ZEBRA_ROUTE_MAX][AFI_MAX];
206
207 char *routemap_redist_name[ZEBRA_ROUTE_MAX];
208 struct route_map *routemap_redist[ZEBRA_ROUTE_MAX];
209
210 /*
211 * For importing bgp unicast routes to VNC, we encode the CE
212 * (route nexthop) in a Route Origin extended community. The
213 * local part (16-bit) is user-configurable.
214 */
215 uint16_t resolve_nve_roo_local_admin;
216 #define BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT 5226
217
218 uint32_t flags;
219 #define BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP 0x00000001
220 #define BGP_VNC_CONFIG_CALLBACK_DISABLE 0x00000002
221 #define BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE 0x00000004
222
223 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS 0x000000f0
224 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS 0x00000f00
225
226 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_NONE 0x00000000
227 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP 0x00000010
228 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH 0x00000020 /* registerd nve */
229 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE 0x00000040
230
231 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_NONE 0x00000000
232 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP 0x00000100
233 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH 0x00000200
234
235 #define BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP 0x00001000
236 #define BGP_VNC_CONFIG_L2RD 0x00002000
237
238 /* Use new NVE RIB to filter callback routes */
239 /* Filter querying NVE's registrations from responses */
240 /* Default to updated-responses off */
241 /* Default to removal-responses off */
242 #define BGP_VNC_CONFIG_FLAGS_DEFAULT \
243 (BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP | BGP_VNC_CONFIG_CALLBACK_DISABLE \
244 | BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE)
245
246 struct rfapi_rfp_cfg rfp_cfg; /* rfp related configuration */
247 };
248
249 #define VNC_EXPORT_ZEBRA_GRP_ENABLED(hc) \
250 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS) \
251 == BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP)
252
253 #define VNC_EXPORT_ZEBRA_RH_ENABLED(hc) \
254 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS) \
255 == BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH)
256
257 #define VNC_EXPORT_BGP_GRP_ENABLED(hc) \
258 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) \
259 == BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP)
260
261 #define VNC_EXPORT_BGP_RH_ENABLED(hc) \
262 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) \
263 == BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH)
264
265 #define VNC_EXPORT_BGP_CE_ENABLED(hc) \
266 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) \
267 == BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE)
268
269
270 void bgp_rfapi_cfg_init(void);
271
272 struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg);
273
274 void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h);
275
276 int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp);
277
278 extern int bgp_rfapi_is_vnc_configured(struct bgp *bgp);
279
280 extern void nve_group_to_nve_list(struct rfapi_nve_group_cfg *rfg,
281 struct list **nves,
282 uint8_t family); /* AF_INET, AF_INET6 */
283
284 struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
285 struct prefix *vn,
286 struct prefix *un);
287
288 struct rfapi_nve_group_cfg *
289 bgp_rfapi_cfg_match_byname(struct bgp *bgp, const char *name,
290 rfapi_group_cfg_type_t type); /* _MAX = any */
291
292 extern void vnc_prefix_list_update(struct bgp *bgp);
293
294 extern void vnc_routemap_update(struct bgp *bgp, const char *unused);
295
296 extern void bgp_rfapi_show_summary(struct bgp *bgp, struct vty *vty);
297
298 extern struct rfapi_cfg *bgp_rfapi_get_config(struct bgp *bgp);
299
300 extern struct rfapi_l2_group_cfg *
301 bgp_rfapi_get_group_by_lni_label(struct bgp *bgp, uint32_t logical_net_id,
302 uint32_t label);
303
304 extern struct ecommunity *
305 bgp_rfapi_get_ecommunity_by_lni_label(struct bgp *bgp, uint32_t is_import,
306 uint32_t logical_net_id,
307 uint32_t label); /* note, 20bit label! */
308
309 extern struct list *
310 bgp_rfapi_get_labellist_by_lni_label(struct bgp *bgp, uint32_t logical_net_id,
311 uint32_t label); /* note, 20bit label! */
312
313 #endif /* ENABLE_BGP_VNC */
314
315 #endif /* _QUAGGA_BGP_RFAPI_CFG_H */