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