1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright 2009-2016, LabN Consulting, L.L.C.
8 #ifndef _QUAGGA_BGP_RFAPI_CFG_H
9 #define _QUAGGA_BGP_RFAPI_CFG_H
11 #include "lib/table.h"
12 #include "lib/routemap.h"
17 struct rfapi_l2_group_cfg
{
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 */
27 DECLARE_QOBJ_TYPE(rfapi_l2_group_cfg
);
30 RFAPI_GROUP_CFG_NVE
= 1,
34 } rfapi_group_cfg_type_t
;
36 struct rfapi_nve_group_cfg
{
37 struct agg_node
*vn_node
; /* backref */
38 struct agg_node
*un_node
; /* backref */
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
;
46 uint8_t l2rd
; /* 0 = VN addr LSB */
47 uint32_t response_lifetime
;
49 #define RFAPI_RFG_RESPONSE_LIFETIME 0x01 /* bits */
50 #define RFAPI_RFG_L2RD 0x02
51 #define RFAPI_RFG_VPN_NH_SELF 0x04
52 struct ecommunity
*rt_import_list
;
53 struct ecommunity
*rt_export_list
;
54 struct rfapi_import_table
*rfapi_import_table
;
56 void *rfp_cfg
; /* rfp owned group config */
58 * List of NVE descriptors that are assigned to this NVE group
60 * Currently (Mar 2010) this list is used only by the route
61 * export code to generate per-NVE nexthops for each route.
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.
74 * Prefix lists are segregated by afi (part of the base plist code)
75 * Route-maps are not segregated
77 char *plist_export_bgp_name
[AFI_MAX
];
78 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
80 char *plist_export_zebra_name
[AFI_MAX
];
81 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
83 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
84 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
86 char *routemap_export_bgp_name
;
87 struct route_map
*routemap_export_bgp
;
89 char *routemap_export_zebra_name
;
90 struct route_map
*routemap_export_zebra
;
92 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
93 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
95 /* for VRF type groups */
97 struct rfapi_descriptor
*rfd
;
100 DECLARE_QOBJ_TYPE(rfapi_nve_group_cfg
);
102 struct rfapi_rfg_name
{
103 struct rfapi_nve_group_cfg
*rfg
;
108 VNC_REDIST_MODE_PLAIN
= 0, /* 0 = default */
110 VNC_REDIST_MODE_RESOLVE_NVE
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
;
119 #define BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT 3600
120 void *default_rfp_cfg
; /* rfp owned group config */
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
;
125 struct agg_table
*nve_groups_vn
[AFI_MAX
];
126 struct agg_table
*nve_groups_un
[AFI_MAX
];
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
133 uint8_t redist
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
134 uint32_t redist_lifetime
;
135 vnc_redist_mode_t redist_mode
;
138 * view name of BGP unicast instance that holds
141 char *redist_bgp_exterior_view_name
;
142 struct bgp
*redist_bgp_exterior_view
;
145 * nve group for redistribution of routes from zebra to VNC
146 * (which is probably not useful for production networks)
148 char *rfg_redist_name
;
149 struct rfapi_nve_group_cfg
*rfg_redist
;
152 * List of NVE groups on whose behalf we will export VNC
153 * routes to zebra. ((NB: it's actually a list of <struct
155 * This list is used when BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS is
156 * BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
158 struct list
*rfg_export_zebra_l
;
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
167 struct list
*rfg_export_direct_bgp_l
;
170 * Exported Route filtering
172 * Prefix lists are segregated by afi (part of the base plist code)
173 * Route-maps are not segregated
175 char *plist_export_bgp_name
[AFI_MAX
];
176 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
178 char *plist_export_zebra_name
[AFI_MAX
];
179 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
181 char *routemap_export_bgp_name
;
182 struct route_map
*routemap_export_bgp
;
184 char *routemap_export_zebra_name
;
185 struct route_map
*routemap_export_zebra
;
188 * Redistributed route filtering (routes from other
189 * protocols into VNC)
191 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
192 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
194 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
195 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
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.
202 uint16_t resolve_nve_roo_local_admin
;
203 #define BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT 5226
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
210 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS 0x000000f0
211 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS 0x00000f00
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
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
222 #define BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP 0x00001000
223 #define BGP_VNC_CONFIG_L2RD 0x00002000
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 */
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)
233 struct rfapi_rfp_cfg rfp_cfg
; /* rfp related configuration */
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)
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)
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)
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)
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)
257 void bgp_rfapi_cfg_init(void);
259 struct rfapi_cfg
*bgp_rfapi_cfg_new(struct rfapi_rfp_cfg
*cfg
);
261 void bgp_rfapi_cfg_destroy(struct bgp
*bgp
, struct rfapi_cfg
*h
);
263 int bgp_rfapi_cfg_write(struct vty
*vty
, struct bgp
*bgp
);
265 extern int bgp_rfapi_is_vnc_configured(struct bgp
*bgp
);
267 extern void nve_group_to_nve_list(struct rfapi_nve_group_cfg
*rfg
,
269 uint8_t family
); /* AF_INET, AF_INET6 */
271 struct rfapi_nve_group_cfg
*bgp_rfapi_cfg_match_group(struct rfapi_cfg
*hc
,
275 struct rfapi_nve_group_cfg
*
276 bgp_rfapi_cfg_match_byname(struct bgp
*bgp
, const char *name
,
277 rfapi_group_cfg_type_t type
); /* _MAX = any */
279 extern void vnc_prefix_list_update(struct bgp
*bgp
);
281 extern void vnc_routemap_update(struct bgp
*bgp
, const char *unused
);
283 extern void bgp_rfapi_show_summary(struct bgp
*bgp
, struct vty
*vty
);
285 extern struct rfapi_cfg
*bgp_rfapi_get_config(struct bgp
*bgp
);
287 extern struct rfapi_l2_group_cfg
*
288 bgp_rfapi_get_group_by_lni_label(struct bgp
*bgp
, uint32_t logical_net_id
,
291 extern struct ecommunity
*
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! */
297 bgp_rfapi_get_labellist_by_lni_label(struct bgp
*bgp
, uint32_t logical_net_id
,
298 uint32_t label
); /* note, 20bit label! */
300 #endif /* ENABLE_BGP_VNC */
302 #endif /* _QUAGGA_BGP_RFAPI_CFG_H */