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
33 uint32_t logical_net_id
;
34 struct list
*labels
; /* list of uint32_t */
35 struct ecommunity
*rt_import_list
;
36 struct ecommunity
*rt_export_list
;
37 void *rfp_cfg
; /* rfp owned group config */
41 DECLARE_QOBJ_TYPE(rfapi_l2_group_cfg
)
45 RFAPI_GROUP_CFG_NVE
= 1,
49 } rfapi_group_cfg_type_t
;
51 struct rfapi_nve_group_cfg
53 struct route_node
*vn_node
; /* backref */
54 struct route_node
*un_node
; /* backref */
56 rfapi_group_cfg_type_t type
; /* NVE|VPN */
57 char *name
; /* unique by type! */
58 struct prefix vn_prefix
;
59 struct prefix un_prefix
;
62 uint8_t l2rd
; /* 0 = VN addr LSB */
63 uint32_t response_lifetime
;
65 #define RFAPI_RFG_RESPONSE_LIFETIME 0x01 /* bits */
66 #define RFAPI_RFG_L2RD 0x02
67 #define RFAPI_RFG_VPN_NH_SELF 0x04
68 struct ecommunity
*rt_import_list
;
69 struct ecommunity
*rt_export_list
;
70 struct rfapi_import_table
*rfapi_import_table
;
72 void *rfp_cfg
; /* rfp owned group config */
74 * List of NVE descriptors that are assigned to this NVE group
76 * Currently (Mar 2010) this list is used only by the route
77 * export code to generate per-NVE nexthops for each route.
79 * The nve descriptors listed here have pointers back to
80 * this nve group config structure to enable them to delete
81 * their own list entries when they are closed. Consequently,
82 * if an instance of this nve group config structure is deleted,
83 * we must first set the nve descriptor references to it to NULL.
90 * Prefix lists are segregated by afi (part of the base plist code)
91 * Route-maps are not segregated
93 char *plist_export_bgp_name
[AFI_MAX
];
94 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
96 char *plist_export_zebra_name
[AFI_MAX
];
97 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
99 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
100 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
102 char *routemap_export_bgp_name
;
103 struct route_map
*routemap_export_bgp
;
105 char *routemap_export_zebra_name
;
106 struct route_map
*routemap_export_zebra
;
108 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
109 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
111 /* for VRF type groups */
113 struct rfapi_descriptor
*rfd
;
116 DECLARE_QOBJ_TYPE(rfapi_nve_group_cfg
)
118 struct rfapi_rfg_name
120 struct rfapi_nve_group_cfg
*rfg
;
126 VNC_REDIST_MODE_PLAIN
= 0, /* 0 = default */
128 VNC_REDIST_MODE_RESOLVE_NVE
133 struct prefix_rd default_rd
;
134 uint8_t default_l2rd
;
135 struct ecommunity
*default_rt_import_list
;
136 struct ecommunity
*default_rt_export_list
;
137 uint32_t default_response_lifetime
;
138 #define BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT 3600
139 void *default_rfp_cfg
; /* rfp owned group config */
141 struct list
*l2_groups
; /* rfapi_l2_group_cfg list */
142 /* three views into the same collection of rfapi_nve_group_cfg */
143 struct list
*nve_groups_sequential
;
144 struct route_table nve_groups_vn
[AFI_MAX
];
145 struct route_table nve_groups_un
[AFI_MAX
];
148 * For Single VRF export to ordinary routing protocols. This is
149 * the nve-group that the ordinary protocols belong to. We use it
150 * to set the RD when sending unicast Zebra routes to VNC
152 uint8_t redist
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
153 uint32_t redist_lifetime
;
154 vnc_redist_mode_t redist_mode
;
157 * view name of BGP unicast instance that holds
160 char *redist_bgp_exterior_view_name
;
161 struct bgp
*redist_bgp_exterior_view
;
164 * nve group for redistribution of routes from zebra to VNC
165 * (which is probably not useful for production networks)
167 char *rfg_redist_name
;
168 struct rfapi_nve_group_cfg
*rfg_redist
;
171 * List of NVE groups on whose behalf we will export VNC
172 * routes to zebra. ((NB: it's actually a list of <struct rfapi_rfg_name>)
173 * This list is used when BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS is
174 * BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
176 struct list
*rfg_export_zebra_l
;
179 * List of NVE groups on whose behalf we will export VNC
180 * routes directly to the bgp unicast RIB. (NB: it's actually
181 * a list of <struct rfapi_rfg_name>)
182 * This list is used when BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS is
183 * BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
185 struct list
*rfg_export_direct_bgp_l
;
188 * Exported Route filtering
190 * Prefix lists are segregated by afi (part of the base plist code)
191 * Route-maps are not segregated
193 char *plist_export_bgp_name
[AFI_MAX
];
194 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
196 char *plist_export_zebra_name
[AFI_MAX
];
197 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
199 char *routemap_export_bgp_name
;
200 struct route_map
*routemap_export_bgp
;
202 char *routemap_export_zebra_name
;
203 struct route_map
*routemap_export_zebra
;
206 * Redistributed route filtering (routes from other
207 * protocols into VNC)
209 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
210 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
212 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
213 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
216 * For importing bgp unicast routes to VNC, we encode the CE
217 * (route nexthop) in a Route Origin extended community. The
218 * local part (16-bit) is user-configurable.
220 uint16_t resolve_nve_roo_local_admin
;
221 #define BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT 5226
224 #define BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP 0x00000001
225 #define BGP_VNC_CONFIG_CALLBACK_DISABLE 0x00000002
226 #define BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE 0x00000004
228 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS 0x000000f0
229 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS 0x00000f00
231 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_NONE 0x00000000
232 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP 0x00000010
233 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH 0x00000020 /* registerd nve */
234 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE 0x00000040
236 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_NONE 0x00000000
237 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP 0x00000100
238 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH 0x00000200
240 #define BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP 0x00001000
241 #define BGP_VNC_CONFIG_L2RD 0x00002000
243 /* Use new NVE RIB to filter callback routes */
244 /* Filter querying NVE's registrations from responses */
245 /* Default to updated-responses off */
246 /* Default to removal-responses off */
247 #define BGP_VNC_CONFIG_FLAGS_DEFAULT \
248 (BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP |\
249 BGP_VNC_CONFIG_CALLBACK_DISABLE |\
250 BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE)
252 struct rfapi_rfp_cfg rfp_cfg
; /* rfp related configuration */
255 #define VNC_EXPORT_ZEBRA_GRP_ENABLED(hc) \
256 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS) == \
257 BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP)
259 #define VNC_EXPORT_ZEBRA_RH_ENABLED(hc) \
260 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS) == \
261 BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH)
263 #define VNC_EXPORT_BGP_GRP_ENABLED(hc) \
264 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) == \
265 BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP)
267 #define VNC_EXPORT_BGP_RH_ENABLED(hc) \
268 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) == \
269 BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH)
271 #define VNC_EXPORT_BGP_CE_ENABLED(hc) \
272 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) == \
273 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE)
277 bgp_rfapi_cfg_init (void);
280 bgp_rfapi_cfg_new (struct rfapi_rfp_cfg
*cfg
);
283 bgp_rfapi_cfg_destroy (struct bgp
*bgp
, struct rfapi_cfg
*h
);
286 bgp_rfapi_cfg_write (struct vty
*vty
, struct bgp
*bgp
);
289 bgp_rfapi_is_vnc_configured (struct bgp
*bgp
);
292 nve_group_to_nve_list (
293 struct rfapi_nve_group_cfg
*rfg
,
295 uint8_t family
); /* AF_INET, AF_INET6 */
297 struct rfapi_nve_group_cfg
*
298 bgp_rfapi_cfg_match_group (
299 struct rfapi_cfg
*hc
,
303 struct rfapi_nve_group_cfg
*
304 bgp_rfapi_cfg_match_byname (
307 rfapi_group_cfg_type_t type
); /* _MAX = any */
310 vnc_prefix_list_update (struct bgp
*bgp
);
313 vnc_routemap_update (struct bgp
*bgp
, const char *unused
);
316 bgp_rfapi_show_summary (struct bgp
*bgp
, struct vty
*vty
);
318 extern struct rfapi_cfg
*
319 bgp_rfapi_get_config (struct bgp
*bgp
);
321 extern struct rfapi_l2_group_cfg
*
322 bgp_rfapi_get_group_by_lni_label (
324 uint32_t logical_net_id
,
327 extern struct ecommunity
*
328 bgp_rfapi_get_ecommunity_by_lni_label (
331 uint32_t logical_net_id
,
332 uint32_t label
); /* note, 20bit label! */
335 bgp_rfapi_get_labellist_by_lni_label (
337 uint32_t logical_net_id
,
338 uint32_t label
); /* note, 20bit label! */
340 #endif /* ENABLE_BGP_VNC */
342 #endif /* _QUAGGA_BGP_RFAPI_CFG_H */