1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
/*
*
* Copyright 2009-2016, LabN Consulting, L.L.C.
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/*
* File: rfapi_import.h
* Purpose: Handle import of routes from BGP to RFAPI
*/
#ifndef QUAGGA_HGP_RFAPI_IMPORT_H
#define QUAGGA_HGP_RFAPI_IMPORT_H
#include "thread.h"
/*
* These are per-rt-import-list
*
* routes are not segregated by RD - the RD is stored in bgp_info_extra
* and is needed to determine if two prefixes are the same.
*/
struct rfapi_import_table
{
struct rfapi_import_table *next;
struct ecommunity *rt_import_list; /* copied from nve grp */
int refcount; /* nve grps and nves */
uint32_t l2_logical_net_id; /* L2 only: EVPN Eth Seg Id */
struct route_table *imported_vpn[AFI_MAX];
struct rfapi_monitor_vpn *vpn0_queries[AFI_MAX];
struct rfapi_monitor_eth *eth0_queries;
struct route_table *imported_encap[AFI_MAX];
struct skiplist *monitor_exterior_orphans;
int local_count[AFI_MAX];
int remote_count[AFI_MAX];
int holddown_count[AFI_MAX];
int imported_count[AFI_MAX];
};
#define RFAPI_LOCAL_BI(bi) \
(((bi)->type == ZEBRA_ROUTE_BGP) && ((bi)->sub_type == BGP_ROUTE_RFP))
#define RFAPI_DIRECT_IMPORT_BI(bi) \
(((bi)->type == ZEBRA_ROUTE_BGP_DIRECT) || ((bi)->type == ZEBRA_ROUTE_BGP_DIRECT_EXT))
#define RFAPI_UPDATE_ITABLE_COUNT(bi, itable, afi, cnt) \
if (RFAPI_LOCAL_BI(bi)) { \
(itable)->local_count[(afi)] += (cnt); \
} else { \
if (RFAPI_DIRECT_IMPORT_BI(bi)) \
(itable)->imported_count[(afi)] += (cnt); \
else \
(itable)->remote_count[(afi)] += (cnt); \
}
extern uint8_t
rfapiRfpCost (struct attr *attr);
extern void
rfapiDebugBacktrace (void);
extern void
rfapiCheckRouteCount (void);
/*
* Print BI in an Import Table
*/
extern void
rfapiPrintBi (void *stream, struct bgp_info *bi);
extern void
rfapiShowImportTable (
void *stream,
const char *label,
struct route_table *rt,
int isvpn);
extern void
rfapiImportTableRefDelByIt (
struct bgp *bgp,
struct rfapi_import_table *it_target);
/*
* Construct an rfapi nexthop list based on the routes attached to
* the specified node.
*
* If there are any routes that do NOT have BGP_INFO_REMOVED set,
* return those only. If there are ONLY routes with BGP_INFO_REMOVED,
* then return those, and also include all the non-removed routes from the
* next less-specific node (i.e., this node's parent) at the end.
*/
extern struct rfapi_next_hop_entry *
rfapiRouteNode2NextHopList (
struct route_node *rn,
uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload this NVE rib table */
struct prefix *pfx_target_original); /* query target */
extern struct rfapi_next_hop_entry *
rfapiRouteTable2NextHopList (
struct route_table *rt,
uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload this NVE rib table */
struct prefix *pfx_target_original); /* query target */
extern struct rfapi_next_hop_entry *
rfapiEthRouteTable2NextHopList (
uint32_t logical_net_id,
struct rfapi_ip_prefix *rprefix,
uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rib_route_table,/* preload NVE rib node */
struct prefix *pfx_target_original); /* query target */
extern int
rfapiEcommunitiesIntersect (struct ecommunity *e1, struct ecommunity *e2);
extern void
rfapiCheckRefcount (struct route_node *rn, safi_t safi, int lockoffset);
extern int
rfapiHasNonRemovedRoutes (struct route_node *rn);
extern int
rfapiProcessDeferredClose (struct thread *t);
extern int
rfapiGetUnAddrOfVpnBi (struct bgp_info *bi, struct prefix *p);
extern void
rfapiNexthop2Prefix (struct attr *attr, struct prefix *p);
extern void
rfapiUnicastNexthop2Prefix (
afi_t afi,
struct attr *attr,
struct prefix *p);
/* Filtered Import Function actions */
#define FIF_ACTION_UPDATE 0
#define FIF_ACTION_WITHDRAW 1
#define FIF_ACTION_KILL 2
extern void
rfapiBgpInfoFilteredImportVPN (
struct rfapi_import_table *import_table,
int action,
struct peer *peer,
void *rfd, /* set for looped back routes */
struct prefix *p,
struct prefix *aux_prefix, /* AFI_ETHER: optional IP */
afi_t afi,
struct prefix_rd *prd,
struct attr *attr, /* part of bgp_info */
u_char type, /* part of bgp_info */
u_char sub_type, /* part of bgp_info */
uint32_t *label); /* part of bgp_info */
extern struct rfapi_next_hop_entry *
rfapiEthRouteNode2NextHopList (
struct route_node *rn,
struct rfapi_ip_prefix *rprefix,
uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rib_route_table,/* preload NVE rib table */
struct prefix *pfx_target_original); /* query target */
extern struct rfapi_import_table *
rfapiMacImportTableGetNoAlloc (
struct bgp *bgp,
uint32_t lni);
extern struct rfapi_import_table *
rfapiMacImportTableGet (
struct bgp *bgp,
uint32_t lni);
extern int
rfapiGetL2o (
struct attr *attr,
struct rfapi_l2address_option *l2o);
extern int rfapiEcommunityGetLNI (
struct ecommunity *ecom,
uint32_t *lni);
/* enable for debugging; disable for performance */
#if 0
#define RFAPI_CHECK_REFCOUNT(rn, safi, lo) rfapiCheckRefcount((rn),(safi),(lo))
#else
#define RFAPI_CHECK_REFCOUNT(rn, safi, lo) {}
#endif
/*------------------------------------------
* rfapiDeleteRemotePrefixes
*
* UI helper: For use by the "clear vnc prefixes" command
*
* input:
* un if set, tunnel must match this prefix
* vn if set, nexthop prefix must match this prefix
* p if set, prefix must match this prefix
*
* output
* pARcount number of active routes deleted
* pAHcount number of active nves deleted
* pHRcount number of holddown routes deleted
* pHHcount number of holddown nves deleted
*
* return value:
* void
--------------------------------------------*/
extern void
rfapiDeleteRemotePrefixes (
struct prefix *un,
struct prefix *vn,
struct prefix *p,
int delete_active,
int delete_holddown,
uint32_t *pARcount, /* active routes */
uint32_t *pAHcount, /* active nves */
uint32_t *pHRcount, /* holddown routes */
uint32_t *pHHcount); /* holddown nves */
/*------------------------------------------
* rfapiCountAllItRoutes
*
* UI helper: count VRF routes from BGP side
*
* input:
*
* output
* pARcount count of active routes
* pHRcount count of holddown routes
* pIRcount count of holddown routes
*
* return value:
* void
--------------------------------------------*/
extern void
rfapiCountAllItRoutes (
int *pALRcount, /* active local routes */
int *pARRcount, /* active remote routes */
int *pHRcount, /* holddown routes */
int *pIRcount); /* direct imported routes */
/*------------------------------------------
* rfapiGetHolddownFromLifetime
*
* calculate holddown value based on lifetime
*
* input:
* lifetime lifetime
*
* return value:
* Holddown value based on lifetime, holddown_factor,
* and RFAPI_LIFETIME_INFINITE_WITHDRAW_DELAY
*
--------------------------------------------*/
extern uint32_t
rfapiGetHolddownFromLifetime (uint32_t lifetime);
#endif /* QUAGGA_HGP_RFAPI_IMPORT_H */
|