3 * Copyright 2009-2016, LabN Consulting, L.L.C.
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.
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.
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
21 #ifndef _QUAGGA_BGP_RFAPI_CFG_H
22 #define _QUAGGA_BGP_RFAPI_CFG_H
24 #include "lib/table.h"
25 #include "lib/routemap.h"
30 struct rfapi_l2_group_cfg
{
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 */
40 DECLARE_QOBJ_TYPE(rfapi_l2_group_cfg
)
43 RFAPI_GROUP_CFG_NVE
= 1,
47 } rfapi_group_cfg_type_t
;
49 struct rfapi_nve_group_cfg
{
50 struct agg_node
*vn_node
; /* backref */
51 struct agg_node
*un_node
; /* backref */
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
;
59 uint8_t l2rd
; /* 0 = VN addr LSB */
60 uint32_t response_lifetime
;
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
;
69 void *rfp_cfg
; /* rfp owned group config */
71 * List of NVE descriptors that are assigned to this NVE group
73 * Currently (Mar 2010) this list is used only by the route
74 * export code to generate per-NVE nexthops for each route.
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.
87 * Prefix lists are segregated by afi (part of the base plist code)
88 * Route-maps are not segregated
90 char *plist_export_bgp_name
[AFI_MAX
];
91 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
93 char *plist_export_zebra_name
[AFI_MAX
];
94 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
96 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
97 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
99 char *routemap_export_bgp_name
;
100 struct route_map
*routemap_export_bgp
;
102 char *routemap_export_zebra_name
;
103 struct route_map
*routemap_export_zebra
;
105 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
106 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
108 /* for VRF type groups */
110 struct rfapi_descriptor
*rfd
;
113 DECLARE_QOBJ_TYPE(rfapi_nve_group_cfg
)
115 struct rfapi_rfg_name
{
116 struct rfapi_nve_group_cfg
*rfg
;
121 VNC_REDIST_MODE_PLAIN
= 0, /* 0 = default */
123 VNC_REDIST_MODE_RESOLVE_NVE
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 */
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
];
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
146 uint8_t redist
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
147 uint32_t redist_lifetime
;
148 vnc_redist_mode_t redist_mode
;
151 * view name of BGP unicast instance that holds
154 char *redist_bgp_exterior_view_name
;
155 struct bgp
*redist_bgp_exterior_view
;
158 * nve group for redistribution of routes from zebra to VNC
159 * (which is probably not useful for production networks)
161 char *rfg_redist_name
;
162 struct rfapi_nve_group_cfg
*rfg_redist
;
165 * List of NVE groups on whose behalf we will export VNC
166 * routes to zebra. ((NB: it's actually a list of <struct
168 * This list is used when BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS is
169 * BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
171 struct list
*rfg_export_zebra_l
;
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
180 struct list
*rfg_export_direct_bgp_l
;
183 * Exported Route filtering
185 * Prefix lists are segregated by afi (part of the base plist code)
186 * Route-maps are not segregated
188 char *plist_export_bgp_name
[AFI_MAX
];
189 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
191 char *plist_export_zebra_name
[AFI_MAX
];
192 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
194 char *routemap_export_bgp_name
;
195 struct route_map
*routemap_export_bgp
;
197 char *routemap_export_zebra_name
;
198 struct route_map
*routemap_export_zebra
;
201 * Redistributed route filtering (routes from other
202 * protocols into VNC)
204 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
205 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
207 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
208 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
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.
215 uint16_t resolve_nve_roo_local_admin
;
216 #define BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT 5226
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
223 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS 0x000000f0
224 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS 0x00000f00
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
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
235 #define BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP 0x00001000
236 #define BGP_VNC_CONFIG_L2RD 0x00002000
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)
246 struct rfapi_rfp_cfg rfp_cfg
; /* rfp related configuration */
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)
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)
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)
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)
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)
270 void bgp_rfapi_cfg_init(void);
272 struct rfapi_cfg
*bgp_rfapi_cfg_new(struct rfapi_rfp_cfg
*cfg
);
274 void bgp_rfapi_cfg_destroy(struct bgp
*bgp
, struct rfapi_cfg
*h
);
276 int bgp_rfapi_cfg_write(struct vty
*vty
, struct bgp
*bgp
);
278 extern int bgp_rfapi_is_vnc_configured(struct bgp
*bgp
);
280 extern void nve_group_to_nve_list(struct rfapi_nve_group_cfg
*rfg
,
282 uint8_t family
); /* AF_INET, AF_INET6 */
284 struct rfapi_nve_group_cfg
*bgp_rfapi_cfg_match_group(struct rfapi_cfg
*hc
,
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 */
292 extern void vnc_prefix_list_update(struct bgp
*bgp
);
294 extern void vnc_routemap_update(struct bgp
*bgp
, const char *unused
);
296 extern void bgp_rfapi_show_summary(struct bgp
*bgp
, struct vty
*vty
);
298 extern struct rfapi_cfg
*bgp_rfapi_get_config(struct bgp
*bgp
);
300 extern struct rfapi_l2_group_cfg
*
301 bgp_rfapi_get_group_by_lni_label(struct bgp
*bgp
, uint32_t logical_net_id
,
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! */
310 bgp_rfapi_get_labellist_by_lni_label(struct bgp
*bgp
, uint32_t logical_net_id
,
311 uint32_t label
); /* note, 20bit label! */
313 #endif /* ENABLE_BGP_VNC */
315 #endif /* _QUAGGA_BGP_RFAPI_CFG_H */