]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_import.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright 2009-2016, LabN Consulting, L.L.C.
10 * Purpose: Handle import of routes from BGP to RFAPI
13 #ifndef QUAGGA_HGP_RFAPI_IMPORT_H
14 #define QUAGGA_HGP_RFAPI_IMPORT_H
16 #include "lib/thread.h"
19 * These are per-rt-import-list
21 * routes are not segregated by RD - the RD is stored in bgp_path_info_extra
22 * and is needed to determine if two prefixes are the same.
24 struct rfapi_import_table
{
25 struct rfapi_import_table
*next
;
26 struct rfapi_nve_group_cfg
*rfg
;
27 struct ecommunity
*rt_import_list
; /* copied from nve grp */
28 int refcount
; /* nve grps and nves */
29 uint32_t l2_logical_net_id
; /* L2 only: EVPN Eth Seg Id */
30 struct agg_table
*imported_vpn
[AFI_MAX
];
31 struct rfapi_monitor_vpn
*vpn0_queries
[AFI_MAX
];
32 struct rfapi_monitor_eth
*eth0_queries
;
33 struct agg_table
*imported_encap
[AFI_MAX
];
34 struct skiplist
*monitor_exterior_orphans
;
35 int local_count
[AFI_MAX
];
36 int remote_count
[AFI_MAX
];
37 int holddown_count
[AFI_MAX
];
38 int imported_count
[AFI_MAX
];
41 #define RFAPI_LOCAL_BI(bpi) \
42 (((bpi)->type == ZEBRA_ROUTE_BGP) && ((bpi)->sub_type == BGP_ROUTE_RFP))
44 #define RFAPI_DIRECT_IMPORT_BI(bpi) \
45 (((bpi)->type == ZEBRA_ROUTE_BGP_DIRECT) \
46 || ((bpi)->type == ZEBRA_ROUTE_BGP_DIRECT_EXT))
48 #define RFAPI_UPDATE_ITABLE_COUNT(bpi, itable, afi, cnt) \
49 if (RFAPI_LOCAL_BI(bpi)) { \
50 (itable)->local_count[(afi)] += (cnt); \
52 if (RFAPI_DIRECT_IMPORT_BI(bpi)) \
53 (itable)->imported_count[(afi)] += (cnt); \
55 (itable)->remote_count[(afi)] += (cnt); \
58 extern uint8_t rfapiRfpCost(struct attr
*attr
);
60 extern void rfapiDebugBacktrace(void);
62 extern void rfapiCheckRouteCount(void);
65 * Print BPI in an Import Table
67 extern void rfapiPrintBi(void *stream
, struct bgp_path_info
*bpi
);
69 extern void rfapiShowImportTable(void *stream
, const char *label
,
70 struct agg_table
*rt
, int isvpn
);
72 extern struct rfapi_import_table
*
73 rfapiImportTableRefAdd(struct bgp
*bgp
, struct ecommunity
*rt_import_list
,
74 struct rfapi_nve_group_cfg
*rfg
);
76 extern void rfapiImportTableRefDelByIt(struct bgp
*bgp
,
77 struct rfapi_import_table
*it_target
);
81 * Construct an rfapi nexthop list based on the routes attached to
84 * If there are any routes that do NOT have BGP_PATH_REMOVED set,
85 * return those only. If there are ONLY routes with BGP_INFO_REMOVED,
86 * then return those, and also include all the non-removed routes from the
87 * next less-specific node (i.e., this node's parent) at the end.
89 extern struct rfapi_next_hop_entry
*rfapiRouteNode2NextHopList(
90 struct agg_node
*rn
, uint32_t lifetime
, /* put into nexthop entries */
91 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
92 struct agg_table
*rfd_rib_table
, /* preload this NVE rib table */
93 struct prefix
*pfx_target_original
); /* query target */
95 extern struct rfapi_next_hop_entry
*rfapiRouteTable2NextHopList(
96 struct agg_table
*rt
, uint32_t lifetime
, /* put into nexthop entries */
97 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
98 struct agg_table
*rfd_rib_table
, /* preload this NVE rib table */
99 struct prefix
*pfx_target_original
); /* query target */
101 extern struct rfapi_next_hop_entry
*rfapiEthRouteTable2NextHopList(
102 uint32_t logical_net_id
, struct rfapi_ip_prefix
*rprefix
,
103 uint32_t lifetime
, /* put into nexthop entries */
104 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
105 struct agg_table
*rib_route_table
, /* preload NVE rib node */
106 struct prefix
*pfx_target_original
); /* query target */
108 extern int rfapiEcommunitiesIntersect(struct ecommunity
*e1
,
109 struct ecommunity
*e2
);
111 extern void rfapiCheckRefcount(struct agg_node
*rn
, safi_t safi
,
114 extern int rfapiHasNonRemovedRoutes(struct agg_node
*rn
);
116 extern int rfapiGetUnAddrOfVpnBi(struct bgp_path_info
*bpi
, struct prefix
*p
);
118 extern void rfapiNexthop2Prefix(struct attr
*attr
, struct prefix
*p
);
120 extern void rfapiUnicastNexthop2Prefix(afi_t afi
, struct attr
*attr
,
123 /* Filtered Import Function actions */
124 #define FIF_ACTION_UPDATE 0
125 #define FIF_ACTION_WITHDRAW 1
126 #define FIF_ACTION_KILL 2
128 extern void rfapiBgpInfoFilteredImportVPN(
129 struct rfapi_import_table
*import_table
, int action
, struct peer
*peer
,
130 void *rfd
, /* set for looped back routes */
131 const struct prefix
*p
,
132 const struct prefix
*aux_prefix
, /* AFI_ETHER: optional IP */
133 afi_t afi
, struct prefix_rd
*prd
,
134 struct attr
*attr
, /* part of bgp_path_info */
135 uint8_t type
, /* part of bgp_path_info */
136 uint8_t sub_type
, /* part of bgp_path_info */
137 uint32_t *label
); /* part of bgp_path_info */
139 extern struct rfapi_next_hop_entry
*rfapiEthRouteNode2NextHopList(
140 struct agg_node
*rn
, struct rfapi_ip_prefix
*rprefix
,
141 uint32_t lifetime
, /* put into nexthop entries */
142 struct rfapi_ip_addr
*exclude_vnaddr
, /* omit routes to same NVE */
143 struct agg_table
*rib_route_table
, /* preload NVE rib table */
144 struct prefix
*pfx_target_original
); /* query target */
146 extern struct rfapi_import_table
*rfapiMacImportTableGetNoAlloc(struct bgp
*bgp
,
149 extern struct rfapi_import_table
*rfapiMacImportTableGet(struct bgp
*bgp
,
152 extern int rfapiGetL2o(struct attr
*attr
, struct rfapi_l2address_option
*l2o
);
154 extern int rfapiEcommunityGetLNI(struct ecommunity
*ecom
, uint32_t *lni
);
156 extern int rfapiEcommunityGetEthernetTag(struct ecommunity
*ecom
,
159 /* enable for debugging; disable for performance */
161 #define RFAPI_CHECK_REFCOUNT(rn, safi, lo) rfapiCheckRefcount((rn),(safi),(lo))
163 #define RFAPI_CHECK_REFCOUNT(rn, safi, lo) {}
166 /*------------------------------------------
167 * rfapiDeleteRemotePrefixes
169 * UI helper: For use by the "clear vnc prefixes" command
172 * un if set, tunnel must match this prefix
173 * vn if set, nexthop prefix must match this prefix
174 * p if set, prefix must match this prefix
175 * it if set, only look in this import table
178 * pARcount number of active routes deleted
179 * pAHcount number of active nves deleted
180 * pHRcount number of holddown routes deleted
181 * pHHcount number of holddown nves deleted
185 --------------------------------------------*/
186 extern void rfapiDeleteRemotePrefixes(struct prefix
*un
, struct prefix
*vn
,
188 struct rfapi_import_table
*it
,
189 int delete_active
, int delete_holddown
,
190 uint32_t *pARcount
, /* active routes */
191 uint32_t *pAHcount
, /* active nves */
192 uint32_t *pHRcount
, /* holddown routes */
193 uint32_t *pHHcount
); /* holddown nves */
195 /*------------------------------------------
196 * rfapiCountAllItRoutes
198 * UI helper: count VRF routes from BGP side
203 * pARcount count of active routes
204 * pHRcount count of holddown routes
205 * pIRcount count of holddown routes
209 --------------------------------------------*/
210 extern void rfapiCountAllItRoutes(int *pALRcount
, /* active local routes */
211 int *pARRcount
, /* active remote routes */
212 int *pHRcount
, /* holddown routes */
213 int *pIRcount
); /* direct imported routes */
215 /*------------------------------------------
216 * rfapiGetHolddownFromLifetime
218 * calculate holddown value based on lifetime
224 * Holddown value based on lifetime, holddown_factor,
225 * and RFAPI_LIFETIME_INFINITE_WITHDRAW_DELAY
227 --------------------------------------------*/
228 extern uint32_t rfapiGetHolddownFromLifetime(uint32_t lifetime
);
230 #endif /* QUAGGA_HGP_RFAPI_IMPORT_H */