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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifndef _QUAGGA_BGP_RFAPI_CFG_H
23 #define _QUAGGA_BGP_RFAPI_CFG_H
25 #include "lib/table.h"
26 #include "lib/routemap.h"
31 struct rfapi_l2_group_cfg
34 uint32_t logical_net_id
;
35 struct list
*labels
; /* list of uint32_t */
36 struct ecommunity
*rt_import_list
;
37 struct ecommunity
*rt_export_list
;
38 void *rfp_cfg
; /* rfp owned group config */
42 DECLARE_QOBJ_TYPE(rfapi_l2_group_cfg
)
44 struct rfapi_nve_group_cfg
46 struct route_node
*vn_node
; /* backref */
47 struct route_node
*un_node
; /* backref */
50 struct prefix vn_prefix
;
51 struct prefix un_prefix
;
54 uint8_t l2rd
; /* 0 = VN addr LSB */
55 uint32_t response_lifetime
;
57 #define RFAPI_RFG_RESPONSE_LIFETIME 0x1
58 #define RFAPI_RFG_L2RD 0x02
59 struct ecommunity
*rt_import_list
;
60 struct ecommunity
*rt_export_list
;
61 struct rfapi_import_table
*rfapi_import_table
;
63 void *rfp_cfg
; /* rfp owned group config */
65 * List of NVE descriptors that are assigned to this NVE group
67 * Currently (Mar 2010) this list is used only by the route
68 * export code to generate per-NVE nexthops for each route.
70 * The nve descriptors listed here have pointers back to
71 * this nve group config structure to enable them to delete
72 * their own list entries when they are closed. Consequently,
73 * if an instance of this nve group config structure is deleted,
74 * we must first set the nve descriptor references to it to NULL.
81 * Prefix lists are segregated by afi (part of the base plist code)
82 * Route-maps are not segregated
84 char *plist_export_bgp_name
[AFI_MAX
];
85 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
87 char *plist_export_zebra_name
[AFI_MAX
];
88 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
90 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
91 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
93 char *routemap_export_bgp_name
;
94 struct route_map
*routemap_export_bgp
;
96 char *routemap_export_zebra_name
;
97 struct route_map
*routemap_export_zebra
;
99 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
100 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
104 DECLARE_QOBJ_TYPE(rfapi_nve_group_cfg
)
106 struct rfapi_rfg_name
108 struct rfapi_nve_group_cfg
*rfg
;
114 VNC_REDIST_MODE_PLAIN
= 0, /* 0 = default */
116 VNC_REDIST_MODE_RESOLVE_NVE
121 struct prefix_rd default_rd
;
122 uint8_t default_l2rd
;
123 struct ecommunity
*default_rt_import_list
;
124 struct ecommunity
*default_rt_export_list
;
125 uint32_t default_response_lifetime
;
126 #define BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT 3600
127 void *default_rfp_cfg
; /* rfp owned group config */
129 struct list
*l2_groups
; /* rfapi_l2_group_cfg list */
130 /* three views into the same collection of rfapi_nve_group_cfg */
131 struct list
*nve_groups_sequential
;
132 struct route_table nve_groups_vn
[AFI_MAX
];
133 struct route_table nve_groups_un
[AFI_MAX
];
136 * For Single VRF export to ordinary routing protocols. This is
137 * the nve-group that the ordinary protocols belong to. We use it
138 * to set the RD when sending unicast Zebra routes to VNC
140 uint8_t redist
[AFI_MAX
][ZEBRA_ROUTE_MAX
];
141 uint32_t redist_lifetime
;
142 vnc_redist_mode_t redist_mode
;
145 * view name of BGP unicast instance that holds
148 char *redist_bgp_exterior_view_name
;
149 struct bgp
*redist_bgp_exterior_view
;
152 * nve group for redistribution of routes from zebra to VNC
153 * (which is probably not useful for production networks)
155 char *rfg_redist_name
;
156 struct rfapi_nve_group_cfg
*rfg_redist
;
159 * List of NVE groups on whose behalf we will export VNC
160 * routes to zebra. ((NB: it's actually a list of <struct rfapi_rfg_name>)
161 * This list is used when BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS is
162 * BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP
164 struct list
*rfg_export_zebra_l
;
167 * List of NVE groups on whose behalf we will export VNC
168 * routes directly to the bgp unicast RIB. (NB: it's actually
169 * a list of <struct rfapi_rfg_name>)
170 * This list is used when BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS is
171 * BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP
173 struct list
*rfg_export_direct_bgp_l
;
176 * Exported Route filtering
178 * Prefix lists are segregated by afi (part of the base plist code)
179 * Route-maps are not segregated
181 char *plist_export_bgp_name
[AFI_MAX
];
182 struct prefix_list
*plist_export_bgp
[AFI_MAX
];
184 char *plist_export_zebra_name
[AFI_MAX
];
185 struct prefix_list
*plist_export_zebra
[AFI_MAX
];
187 char *routemap_export_bgp_name
;
188 struct route_map
*routemap_export_bgp
;
190 char *routemap_export_zebra_name
;
191 struct route_map
*routemap_export_zebra
;
194 * Redistributed route filtering (routes from other
195 * protocols into VNC)
197 char *plist_redist_name
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
198 struct prefix_list
*plist_redist
[ZEBRA_ROUTE_MAX
][AFI_MAX
];
200 char *routemap_redist_name
[ZEBRA_ROUTE_MAX
];
201 struct route_map
*routemap_redist
[ZEBRA_ROUTE_MAX
];
204 * For importing bgp unicast routes to VNC, we encode the CE
205 * (route nexthop) in a Route Origin extended community. The
206 * local part (16-bit) is user-configurable.
208 uint16_t resolve_nve_roo_local_admin
;
209 #define BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT 5226
212 #define BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP 0x00000001
213 #define BGP_VNC_CONFIG_CALLBACK_DISABLE 0x00000002
214 #define BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE 0x00000004
216 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS 0x000000f0
217 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS 0x00000f00
219 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_NONE 0x00000000
220 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP 0x00000010
221 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH 0x00000020 /* registerd nve */
222 #define BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE 0x00000040
224 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_NONE 0x00000000
225 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP 0x00000100
226 #define BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH 0x00000200
228 #define BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP 0x00001000
229 #define BGP_VNC_CONFIG_L2RD 0x00002000
231 /* Use new NVE RIB to filter callback routes */
232 /* Filter querying NVE's registrations from responses */
233 /* Default to updated-responses off */
234 /* Default to removal-responses off */
235 #define BGP_VNC_CONFIG_FLAGS_DEFAULT \
236 (BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP |\
237 BGP_VNC_CONFIG_CALLBACK_DISABLE |\
238 BGP_VNC_CONFIG_RESPONSE_REMOVAL_DISABLE)
240 struct rfapi_rfp_cfg rfp_cfg
; /* rfp related configuration */
243 #define VNC_EXPORT_ZEBRA_GRP_ENABLED(hc) \
244 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS) == \
245 BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_GRP)
247 #define VNC_EXPORT_ZEBRA_RH_ENABLED(hc) \
248 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS) == \
249 BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_RH)
251 #define VNC_EXPORT_BGP_GRP_ENABLED(hc) \
252 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) == \
253 BGP_VNC_CONFIG_EXPORT_BGP_MODE_GRP)
255 #define VNC_EXPORT_BGP_RH_ENABLED(hc) \
256 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) == \
257 BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH)
259 #define VNC_EXPORT_BGP_CE_ENABLED(hc) \
260 (((hc)->flags & BGP_VNC_CONFIG_EXPORT_BGP_MODE_BITS) == \
261 BGP_VNC_CONFIG_EXPORT_BGP_MODE_CE)
265 bgp_rfapi_cfg_init (void);
268 bgp_rfapi_cfg_new (struct rfapi_rfp_cfg
*cfg
);
271 bgp_rfapi_cfg_destroy (struct bgp
*bgp
, struct rfapi_cfg
*h
);
274 bgp_rfapi_cfg_write (struct vty
*vty
, struct bgp
*bgp
);
277 bgp_rfapi_is_vnc_configured (struct bgp
*bgp
);
280 nve_group_to_nve_list (
281 struct rfapi_nve_group_cfg
*rfg
,
283 uint8_t family
); /* AF_INET, AF_INET6 */
285 struct rfapi_nve_group_cfg
*
286 bgp_rfapi_cfg_match_group (
287 struct rfapi_cfg
*hc
,
292 vnc_prefix_list_update (struct bgp
*bgp
);
295 vnc_routemap_update (struct bgp
*bgp
, const char *unused
);
298 bgp_rfapi_show_summary (struct bgp
*bgp
, struct vty
*vty
);
300 extern struct rfapi_cfg
*
301 bgp_rfapi_get_config (struct bgp
*bgp
);
303 extern struct rfapi_l2_group_cfg
*
304 bgp_rfapi_get_group_by_lni_label (
306 uint32_t logical_net_id
,
309 extern struct ecommunity
*
310 bgp_rfapi_get_ecommunity_by_lni_label (
313 uint32_t logical_net_id
,
314 uint32_t label
); /* note, 20bit label! */
317 bgp_rfapi_get_labellist_by_lni_label (
319 uint32_t logical_net_id
,
320 uint32_t label
); /* note, 20bit label! */
322 #endif /* ENABLE_BGP_VNC */
324 #endif /* _QUAGGA_BGP_RFAPI_CFG_H */