]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_import.h
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
22 * File: rfapi_import.h
23 * Purpose: Handle import of routes from BGP to RFAPI
26 #ifndef QUAGGA_HGP_RFAPI_IMPORT_H
27 #define QUAGGA_HGP_RFAPI_IMPORT_H
29 #include "lib/thread.h"
32 * These are per-rt-import-list
34 * routes are not segregated by RD - the RD is stored in bgp_info_extra
35 * and is needed to determine if two prefixes are the same.
37 struct rfapi_import_table
39 struct rfapi_import_table
*next
;
40 struct rfapi_nve_group_cfg
*rfg
;
41 struct ecommunity
*rt_import_list
; /* copied from nve grp */
42 int refcount
; /* nve grps and nves */
43 uint32_t l2_logical_net_id
; /* L2 only: EVPN Eth Seg Id */
44 struct route_table
*imported_vpn
[AFI_MAX
];
45 struct rfapi_monitor_vpn
*vpn0_queries
[AFI_MAX
];
46 struct rfapi_monitor_eth
*eth0_queries
;
47 struct route_table
*imported_encap
[AFI_MAX
];
48 struct skiplist
*monitor_exterior_orphans
;
49 int local_count
[AFI_MAX
];
50 int remote_count
[AFI_MAX
];
51 int holddown_count
[AFI_MAX
];
52 int imported_count
[AFI_MAX
];
55 #define RFAPI_LOCAL_BI(bi) \
56 (((bi)->type == ZEBRA_ROUTE_BGP) && ((bi)->sub_type == BGP_ROUTE_RFP))
58 #define RFAPI_DIRECT_IMPORT_BI(bi) \
59 (((bi)->type == ZEBRA_ROUTE_BGP_DIRECT) || ((bi)->type == ZEBRA_ROUTE_BGP_DIRECT_EXT))
61 #define RFAPI_UPDATE_ITABLE_COUNT(bi, itable, afi, cnt) \
62 if (RFAPI_LOCAL_BI(bi)) { \
63 (itable)->local_count[(afi)] += (cnt); \
65 if (RFAPI_DIRECT_IMPORT_BI(bi)) \
66 (itable)->imported_count[(afi)] += (cnt); \
68 (itable)->remote_count[(afi)] += (cnt); \
72 rfapiRfpCost (struct attr
*attr
);
75 rfapiDebugBacktrace (void);
78 rfapiCheckRouteCount (void);
81 * Print BI in an Import Table
84 rfapiPrintBi (void *stream
, struct bgp_info
*bi
);
87 rfapiShowImportTable (
90 struct route_table
*rt
,
93 extern struct rfapi_import_table
*
94 rfapiImportTableRefAdd (
96 struct ecommunity
*rt_import_list
,
97 struct rfapi_nve_group_cfg
*rfg
);
100 rfapiImportTableRefDelByIt (
102 struct rfapi_import_table
*it_target
);
106 * Construct an rfapi nexthop list based on the routes attached to
107 * the specified node.
109 * If there are any routes that do NOT have BGP_INFO_REMOVED set,
110 * return those only. If there are ONLY routes with BGP_INFO_REMOVED,
111 * then return those, and also include all the non-removed routes from the
112 * next less-specific node (i.e., this node's parent) at the end.
114 extern struct rfapi_next_hop_entry
*
115 rfapiRouteNode2NextHopList (
116 struct route_node
*rn
,
117 uint32_t lifetime
, /* put into nexthop entries */
118 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
119 struct route_table
*rfd_rib_table
, /* preload this NVE rib table */
120 struct prefix
*pfx_target_original
); /* query target */
122 extern struct rfapi_next_hop_entry
*
123 rfapiRouteTable2NextHopList (
124 struct route_table
*rt
,
125 uint32_t lifetime
, /* put into nexthop entries */
126 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
127 struct route_table
*rfd_rib_table
, /* preload this NVE rib table */
128 struct prefix
*pfx_target_original
); /* query target */
130 extern struct rfapi_next_hop_entry
*
131 rfapiEthRouteTable2NextHopList (
132 uint32_t logical_net_id
,
133 struct rfapi_ip_prefix
*rprefix
,
134 uint32_t lifetime
, /* put into nexthop entries */
135 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
136 struct route_table
*rib_route_table
,/* preload NVE rib node */
137 struct prefix
*pfx_target_original
); /* query target */
140 rfapiEcommunitiesIntersect (struct ecommunity
*e1
, struct ecommunity
*e2
);
143 rfapiCheckRefcount (struct route_node
*rn
, safi_t safi
, int lockoffset
);
146 rfapiHasNonRemovedRoutes (struct route_node
*rn
);
149 rfapiProcessDeferredClose (struct thread
*t
);
152 rfapiGetUnAddrOfVpnBi (struct bgp_info
*bi
, struct prefix
*p
);
155 rfapiNexthop2Prefix (struct attr
*attr
, struct prefix
*p
);
158 rfapiUnicastNexthop2Prefix (
163 /* Filtered Import Function actions */
164 #define FIF_ACTION_UPDATE 0
165 #define FIF_ACTION_WITHDRAW 1
166 #define FIF_ACTION_KILL 2
169 rfapiBgpInfoFilteredImportVPN (
170 struct rfapi_import_table
*import_table
,
173 void *rfd
, /* set for looped back routes */
175 struct prefix
*aux_prefix
, /* AFI_ETHER: optional IP */
177 struct prefix_rd
*prd
,
178 struct attr
*attr
, /* part of bgp_info */
179 u_char type
, /* part of bgp_info */
180 u_char sub_type
, /* part of bgp_info */
181 uint32_t *label
); /* part of bgp_info */
183 extern struct rfapi_next_hop_entry
*
184 rfapiEthRouteNode2NextHopList (
185 struct route_node
*rn
,
186 struct rfapi_ip_prefix
*rprefix
,
187 uint32_t lifetime
, /* put into nexthop entries */
188 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
189 struct route_table
*rib_route_table
,/* preload NVE rib table */
190 struct prefix
*pfx_target_original
); /* query target */
192 extern struct rfapi_import_table
*
193 rfapiMacImportTableGetNoAlloc (
197 extern struct rfapi_import_table
*
198 rfapiMacImportTableGet (
205 struct rfapi_l2address_option
*l2o
);
207 extern int rfapiEcommunityGetLNI (
208 struct ecommunity
*ecom
,
211 extern int rfapiEcommunityGetEthernetTag (
212 struct ecommunity
*ecom
,
215 /* enable for debugging; disable for performance */
217 #define RFAPI_CHECK_REFCOUNT(rn, safi, lo) rfapiCheckRefcount((rn),(safi),(lo))
219 #define RFAPI_CHECK_REFCOUNT(rn, safi, lo) {}
222 /*------------------------------------------
223 * rfapiDeleteRemotePrefixes
225 * UI helper: For use by the "clear vnc prefixes" command
228 * un if set, tunnel must match this prefix
229 * vn if set, nexthop prefix must match this prefix
230 * p if set, prefix must match this prefix
231 * it if set, only look in this import table
234 * pARcount number of active routes deleted
235 * pAHcount number of active nves deleted
236 * pHRcount number of holddown routes deleted
237 * pHHcount number of holddown nves deleted
241 --------------------------------------------*/
243 rfapiDeleteRemotePrefixes (
247 struct rfapi_import_table
*it
,
250 uint32_t *pARcount
, /* active routes */
251 uint32_t *pAHcount
, /* active nves */
252 uint32_t *pHRcount
, /* holddown routes */
253 uint32_t *pHHcount
); /* holddown nves */
255 /*------------------------------------------
256 * rfapiCountAllItRoutes
258 * UI helper: count VRF routes from BGP side
263 * pARcount count of active routes
264 * pHRcount count of holddown routes
265 * pIRcount count of holddown routes
269 --------------------------------------------*/
271 rfapiCountAllItRoutes (
272 int *pALRcount
, /* active local routes */
273 int *pARRcount
, /* active remote routes */
274 int *pHRcount
, /* holddown routes */
275 int *pIRcount
); /* direct imported routes */
277 /*------------------------------------------
278 * rfapiGetHolddownFromLifetime
280 * calculate holddown value based on lifetime
286 * Holddown value based on lifetime, holddown_factor,
287 * and RFAPI_LIFETIME_INFINITE_WITHDRAW_DELAY
289 --------------------------------------------*/
291 rfapiGetHolddownFromLifetime (uint32_t lifetime
);
293 #endif /* QUAGGA_HGP_RFAPI_IMPORT_H */