]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/rfapi/bgp_rfapi_cfg.h
*: reindent
[mirror_frr.git] / bgpd / rfapi / bgp_rfapi_cfg.h
CommitLineData
d62a17ae 1/*
65efcfce
LB
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 *
896014f4
DL
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
65efcfce
LB
19 */
20
21#ifndef _QUAGGA_BGP_RFAPI_CFG_H
22#define _QUAGGA_BGP_RFAPI_CFG_H
23
f8b6f499
LB
24#include "lib/table.h"
25#include "lib/routemap.h"
65efcfce
LB
26
27#if ENABLE_BGP_VNC
28#include "rfapi.h"
29
d62a17ae 30struct 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 */
c77272a1 37
d62a17ae 38 QOBJ_FIELDS
65efcfce 39};
c77272a1 40DECLARE_QOBJ_TYPE(rfapi_l2_group_cfg)
65efcfce 41
d62a17ae 42typedef enum {
43 RFAPI_GROUP_CFG_NVE = 1,
44 RFAPI_GROUP_CFG_VRF,
45 RFAPI_GROUP_CFG_L2,
46 RFAPI_GROUP_CFG_MAX
5ff06872
LB
47} rfapi_group_cfg_type_t;
48
d62a17ae 49struct rfapi_nve_group_cfg {
50 struct route_node *vn_node; /* backref */
51 struct route_node *un_node; /* backref */
65efcfce 52
d62a17ae 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;
65efcfce 57
d62a17ae 58 struct prefix_rd rd;
59 uint8_t l2rd; /* 0 = VN addr LSB */
60 uint32_t response_lifetime;
61 uint32_t flags;
5ff06872 62#define RFAPI_RFG_RESPONSE_LIFETIME 0x01 /* bits */
65efcfce 63#define RFAPI_RFG_L2RD 0x02
5ff06872 64#define RFAPI_RFG_VPN_NH_SELF 0x04
d62a17ae 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
65efcfce 112};
c77272a1 113DECLARE_QOBJ_TYPE(rfapi_nve_group_cfg)
65efcfce 114
d62a17ae 115struct rfapi_rfg_name {
116 struct rfapi_nve_group_cfg *rfg;
117 char *name;
65efcfce
LB
118};
119
d62a17ae 120typedef enum {
121 VNC_REDIST_MODE_PLAIN = 0, /* 0 = default */
122 VNC_REDIST_MODE_RFG,
123 VNC_REDIST_MODE_RESOLVE_NVE
65efcfce
LB
124} vnc_redist_mode_t;
125
d62a17ae 126struct 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;
65efcfce 132#define BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT 3600
d62a17ae 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 route_table nve_groups_vn[AFI_MAX];
139 struct route_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;
65efcfce
LB
216#define BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT 5226
217
d62a17ae 218 uint32_t flags;
65efcfce
LB
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 */
d62a17ae 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)
65efcfce 245
d62a17ae 246 struct rfapi_rfp_cfg rfp_cfg; /* rfp related configuration */
65efcfce
LB
247};
248
d62a17ae 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)
65efcfce 252
d62a17ae 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)
65efcfce 256
d62a17ae 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)
65efcfce 260
d62a17ae 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)
65efcfce 264
d62a17ae 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)
65efcfce
LB
268
269
d62a17ae 270void bgp_rfapi_cfg_init(void);
65efcfce 271
d62a17ae 272struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg);
65efcfce 273
d62a17ae 274void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h);
65efcfce 275
d62a17ae 276int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp);
65efcfce 277
d62a17ae 278extern int bgp_rfapi_is_vnc_configured(struct bgp *bgp);
65efcfce 279
d62a17ae 280extern void nve_group_to_nve_list(struct rfapi_nve_group_cfg *rfg,
281 struct list **nves,
282 uint8_t family); /* AF_INET, AF_INET6 */
65efcfce 283
d62a17ae 284struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
285 struct prefix *vn,
286 struct prefix *un);
65efcfce 287
5ff06872 288struct rfapi_nve_group_cfg *
d62a17ae 289bgp_rfapi_cfg_match_byname(struct bgp *bgp, const char *name,
290 rfapi_group_cfg_type_t type); /* _MAX = any */
5ff06872 291
d62a17ae 292extern void vnc_prefix_list_update(struct bgp *bgp);
65efcfce 293
d62a17ae 294extern void vnc_routemap_update(struct bgp *bgp, const char *unused);
65efcfce 295
d62a17ae 296extern void bgp_rfapi_show_summary(struct bgp *bgp, struct vty *vty);
65efcfce 297
d62a17ae 298extern struct rfapi_cfg *bgp_rfapi_get_config(struct bgp *bgp);
65efcfce 299
79799987 300extern struct rfapi_l2_group_cfg *
d62a17ae 301bgp_rfapi_get_group_by_lni_label(struct bgp *bgp, uint32_t logical_net_id,
302 uint32_t label);
79799987 303
65efcfce 304extern struct ecommunity *
d62a17ae 305bgp_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! */
65efcfce
LB
308
309extern struct list *
d62a17ae 310bgp_rfapi_get_labellist_by_lni_label(struct bgp *bgp, uint32_t logical_net_id,
311 uint32_t label); /* note, 20bit label! */
65efcfce
LB
312
313#endif /* ENABLE_BGP_VNC */
314
315#endif /* _QUAGGA_BGP_RFAPI_CFG_H */