]>
Commit | Line | Data |
---|---|---|
ea1c14f6 MS |
1 | /* |
2 | * Zebra dataplane layer api interfaces. | |
3 | * Copyright (c) 2018 Volta Networks, Inc. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; see the file COPYING; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | */ | |
19 | ||
20 | #ifndef _ZEBRA_DPLANE_H | |
21 | #define _ZEBRA_DPLANE_H 1 | |
22 | ||
7cdb1a84 MS |
23 | #include "lib/zebra.h" |
24 | #include "lib/prefix.h" | |
25 | #include "lib/nexthop.h" | |
26 | #include "lib/nexthop_group.h" | |
214fc2bd | 27 | #include "lib/queue.h" |
7597ac7b | 28 | #include "lib/vlan.h" |
7cdb1a84 MS |
29 | #include "zebra/zebra_ns.h" |
30 | #include "zebra/rib.h" | |
31 | #include "zebra/zserv.h" | |
0f461727 | 32 | #include "zebra/zebra_mpls.h" |
f820d025 | 33 | #include "zebra/zebra_nhg.h" |
ea1c14f6 | 34 | |
51e94aa7 EDP |
35 | #ifdef __cplusplus |
36 | extern "C" { | |
37 | #endif | |
38 | ||
85a75f1e MS |
39 | /* Key netlink info from zebra ns */ |
40 | struct zebra_dplane_info { | |
41 | ns_id_t ns_id; | |
42 | ||
43 | #if defined(HAVE_NETLINK) | |
d4000d7b | 44 | int sock; |
3670f504 | 45 | int seq; |
85a75f1e MS |
46 | bool is_cmd; |
47 | #endif | |
48 | }; | |
49 | ||
50 | /* Utility to fill in zns info from main zns struct */ | |
51 | static inline void | |
52 | zebra_dplane_info_from_zns(struct zebra_dplane_info *zns_info, | |
53 | const struct zebra_ns *zns, bool is_cmd) | |
54 | { | |
55 | zns_info->ns_id = zns->ns_id; | |
56 | ||
57 | #if defined(HAVE_NETLINK) | |
58 | zns_info->is_cmd = is_cmd; | |
59 | if (is_cmd) { | |
d4000d7b | 60 | zns_info->sock = zns->netlink_cmd.sock; |
3670f504 | 61 | zns_info->seq = zns->netlink_cmd.seq; |
85a75f1e | 62 | } else { |
d4000d7b | 63 | zns_info->sock = zns->netlink.sock; |
3670f504 | 64 | zns_info->seq = zns->netlink.seq; |
85a75f1e MS |
65 | } |
66 | #endif /* NETLINK */ | |
67 | } | |
68 | ||
971bad84 MS |
69 | /* |
70 | * Notify dplane when namespaces are enabled and disabled. The dplane | |
71 | * needs to start and stop reading incoming events from the ns. | |
72 | */ | |
73 | void zebra_dplane_ns_enable(struct zebra_ns *zns, bool enabled); | |
74 | ||
ea1c14f6 MS |
75 | /* |
76 | * Result codes used when returning status back to the main zebra context. | |
77 | */ | |
78 | ||
79 | /* | |
80 | * Philosophy Note: | |
81 | * | |
82 | * Flags being SET/UNSET do not belong in the South Bound | |
83 | * Interface. This Setting belongs at the calling level | |
84 | * because we can and will have multiple different interfaces | |
85 | * and we will have potentially multiple different | |
86 | * modules/filters to call. As such Setting/Unsetting | |
87 | * success failure should be handled by the caller. | |
88 | */ | |
89 | enum zebra_dplane_status { | |
90 | ZEBRA_DPLANE_STATUS_NONE = 0, | |
91 | ZEBRA_DPLANE_INSTALL_SUCCESS, | |
92 | ZEBRA_DPLANE_INSTALL_FAILURE, | |
93 | ZEBRA_DPLANE_DELETE_SUCCESS, | |
94 | ZEBRA_DPLANE_DELETE_FAILURE, | |
95 | ||
96 | }; | |
97 | ||
98 | enum zebra_dplane_result { | |
99 | ZEBRA_DPLANE_REQUEST_QUEUED, | |
100 | ZEBRA_DPLANE_REQUEST_SUCCESS, | |
101 | ZEBRA_DPLANE_REQUEST_FAILURE, | |
102 | }; | |
103 | ||
7cdb1a84 MS |
104 | /* |
105 | * API between the zebra dataplane system and the main zebra processing | |
106 | * context. | |
107 | */ | |
108 | ||
109 | /* | |
9d59df63 | 110 | * Operations that the dataplane can process. |
7cdb1a84 | 111 | */ |
5709131c | 112 | enum dplane_op_e { |
7cdb1a84 MS |
113 | DPLANE_OP_NONE = 0, |
114 | ||
115 | /* Route update */ | |
116 | DPLANE_OP_ROUTE_INSTALL, | |
117 | DPLANE_OP_ROUTE_UPDATE, | |
118 | DPLANE_OP_ROUTE_DELETE, | |
54818e3b | 119 | DPLANE_OP_ROUTE_NOTIFY, |
7cdb1a84 | 120 | |
f820d025 SW |
121 | /* Nexthop update */ |
122 | DPLANE_OP_NH_INSTALL, | |
123 | DPLANE_OP_NH_UPDATE, | |
124 | DPLANE_OP_NH_DELETE, | |
125 | ||
16c628de MS |
126 | /* LSP update */ |
127 | DPLANE_OP_LSP_INSTALL, | |
128 | DPLANE_OP_LSP_UPDATE, | |
97d8d05a | 129 | DPLANE_OP_LSP_DELETE, |
104e3ad9 | 130 | DPLANE_OP_LSP_NOTIFY, |
97d8d05a MS |
131 | |
132 | /* Pseudowire update */ | |
133 | DPLANE_OP_PW_INSTALL, | |
134 | DPLANE_OP_PW_UNINSTALL, | |
cf363e1b MS |
135 | |
136 | /* System route notification */ | |
137 | DPLANE_OP_SYS_ROUTE_ADD, | |
138 | DPLANE_OP_SYS_ROUTE_DELETE, | |
a4a4802a MS |
139 | |
140 | /* Interface address update */ | |
141 | DPLANE_OP_ADDR_INSTALL, | |
142 | DPLANE_OP_ADDR_UNINSTALL, | |
7597ac7b MS |
143 | |
144 | /* MAC address update */ | |
145 | DPLANE_OP_MAC_INSTALL, | |
146 | DPLANE_OP_MAC_DELETE, | |
f2412b2d MS |
147 | |
148 | /* EVPN neighbor updates */ | |
149 | DPLANE_OP_NEIGH_INSTALL, | |
931fa60c | 150 | DPLANE_OP_NEIGH_UPDATE, |
f2412b2d | 151 | DPLANE_OP_NEIGH_DELETE, |
0bbd4ff4 MS |
152 | |
153 | /* EVPN VTEP updates */ | |
154 | DPLANE_OP_VTEP_ADD, | |
155 | DPLANE_OP_VTEP_DELETE, | |
60d8d43b JU |
156 | |
157 | /* Policy based routing rule update */ | |
158 | DPLANE_OP_RULE_ADD, | |
159 | DPLANE_OP_RULE_DELETE, | |
160 | DPLANE_OP_RULE_UPDATE, | |
d68e74b4 JU |
161 | |
162 | /* Link layer address discovery */ | |
163 | DPLANE_OP_NEIGH_DISCOVER, | |
c60522f7 AK |
164 | |
165 | /* bridge port update */ | |
166 | DPLANE_OP_BR_PORT_UPDATE, | |
5162e000 | 167 | |
ef524230 | 168 | /* Policy based routing iptable update */ |
5162e000 PG |
169 | DPLANE_OP_IPTABLE_ADD, |
170 | DPLANE_OP_IPTABLE_DELETE, | |
ef524230 PG |
171 | |
172 | /* Policy based routing ipset update */ | |
173 | DPLANE_OP_IPSET_ADD, | |
174 | DPLANE_OP_IPSET_DELETE, | |
175 | DPLANE_OP_IPSET_ENTRY_ADD, | |
176 | DPLANE_OP_IPSET_ENTRY_DELETE, | |
0a27a2fe PG |
177 | |
178 | /* LINK LAYER IP address update */ | |
179 | DPLANE_OP_NEIGH_IP_INSTALL, | |
180 | DPLANE_OP_NEIGH_IP_DELETE, | |
e18747a9 PG |
181 | |
182 | DPLANE_OP_NEIGH_TABLE_UPDATE, | |
62b4b7e4 | 183 | DPLANE_OP_GRE_SET, |
9d59df63 MS |
184 | |
185 | /* Incoming interface address events */ | |
186 | DPLANE_OP_INTF_ADDR_ADD, | |
187 | DPLANE_OP_INTF_ADDR_DEL, | |
728f2017 MS |
188 | |
189 | /* Incoming interface config events */ | |
190 | DPLANE_OP_INTF_NETCONFIG, | |
5d414138 SW |
191 | |
192 | /* Interface update */ | |
193 | DPLANE_OP_INTF_INSTALL, | |
194 | DPLANE_OP_INTF_UPDATE, | |
195 | DPLANE_OP_INTF_DELETE, | |
449a30ed SY |
196 | |
197 | /* Traffic control */ | |
c317d3f2 SY |
198 | DPLANE_OP_TC_QDISC_INSTALL, |
199 | DPLANE_OP_TC_QDISC_UNINSTALL, | |
200 | DPLANE_OP_TC_CLASS_ADD, | |
201 | DPLANE_OP_TC_CLASS_DELETE, | |
202 | DPLANE_OP_TC_CLASS_UPDATE, | |
203 | DPLANE_OP_TC_FILTER_ADD, | |
204 | DPLANE_OP_TC_FILTER_DELETE, | |
205 | DPLANE_OP_TC_FILTER_UPDATE | |
5709131c | 206 | }; |
7cdb1a84 | 207 | |
931fa60c MS |
208 | /* |
209 | * The vxlan/evpn neighbor management code needs some values to use | |
210 | * when programming neighbor changes. Offer some platform-neutral values | |
211 | * here for use within the dplane apis and plugins. | |
212 | */ | |
213 | ||
214 | /* Neighbor cache flags */ | |
215 | #define DPLANE_NTF_EXT_LEARNED 0x01 | |
216 | #define DPLANE_NTF_ROUTER 0x02 | |
d68e74b4 | 217 | #define DPLANE_NTF_USE 0x04 |
931fa60c MS |
218 | |
219 | /* Neighbor cache states */ | |
220 | #define DPLANE_NUD_REACHABLE 0x01 | |
221 | #define DPLANE_NUD_STALE 0x02 | |
222 | #define DPLANE_NUD_NOARP 0x04 | |
223 | #define DPLANE_NUD_PROBE 0x08 | |
d68e74b4 | 224 | #define DPLANE_NUD_INCOMPLETE 0x10 |
0a27a2fe PG |
225 | #define DPLANE_NUD_PERMANENT 0x20 |
226 | #define DPLANE_NUD_FAILED 0x40 | |
931fa60c | 227 | |
f188e68e AK |
228 | /* MAC update flags - dplane_mac_info.update_flags */ |
229 | #define DPLANE_MAC_REMOTE (1 << 0) | |
230 | #define DPLANE_MAC_WAS_STATIC (1 << 1) | |
231 | #define DPLANE_MAC_SET_STATIC (1 << 2) | |
232 | #define DPLANE_MAC_SET_INACTIVE (1 << 3) | |
233 | ||
234 | /* Neigh update flags - dplane_neigh_info.update_flags */ | |
235 | #define DPLANE_NEIGH_REMOTE (1 << 0) | |
236 | #define DPLANE_NEIGH_WAS_STATIC (1 << 1) | |
237 | #define DPLANE_NEIGH_SET_STATIC (1 << 2) | |
238 | #define DPLANE_NEIGH_SET_INACTIVE (1 << 3) | |
0a27a2fe | 239 | #define DPLANE_NEIGH_NO_EXTENSION (1 << 4) |
f188e68e | 240 | |
c60522f7 AK |
241 | #define DPLANE_BR_PORT_NON_DF (1 << 0) |
242 | ||
728f2017 MS |
243 | /* Definitions for the dplane 'netconf' apis, corresponding to the netlink |
244 | * NETCONF api. | |
245 | * Sadly, netlink sends incremental updates, so its messages may contain | |
246 | * just a single changed attribute, and not necessarily | |
247 | * a complete snapshot of the attributes. | |
248 | */ | |
249 | enum dplane_netconf_status_e { | |
250 | DPLANE_NETCONF_STATUS_UNKNOWN = 0, | |
251 | DPLANE_NETCONF_STATUS_ENABLED, | |
252 | DPLANE_NETCONF_STATUS_DISABLED | |
253 | }; | |
254 | ||
255 | /* Some special ifindex values that may be part of the dplane netconf api. */ | |
256 | #define DPLANE_NETCONF_IFINDEX_ALL -1 | |
257 | #define DPLANE_NETCONF_IFINDEX_DEFAULT -2 | |
258 | ||
cf363e1b MS |
259 | /* Enable system route notifications */ |
260 | void dplane_enable_sys_route_notifs(void); | |
261 | ||
7cdb1a84 | 262 | /* |
25779064 | 263 | * The dataplane context struct is used to exchange info between the main zebra |
7cdb1a84 MS |
264 | * context and the dataplane module(s). If these are two independent pthreads, |
265 | * they cannot share existing global data structures safely. | |
266 | */ | |
7cdb1a84 MS |
267 | |
268 | /* Define a tailq list type for context blocks. The list is exposed/public, | |
269 | * but the internal linkage in the context struct is private, so there | |
270 | * are accessor apis that support enqueue and dequeue. | |
271 | */ | |
25779064 | 272 | TAILQ_HEAD(dplane_ctx_q, zebra_dplane_ctx); |
7cdb1a84 | 273 | |
5917df09 MS |
274 | /* Declare a type for (optional) extended interface info objects. */ |
275 | TAILQ_HEAD(dplane_intf_extra_q, dplane_intf_extra); | |
276 | ||
593e4eb1 MS |
277 | /* Allocate a context object */ |
278 | struct zebra_dplane_ctx *dplane_ctx_alloc(void); | |
279 | ||
f73a8467 MS |
280 | /* |
281 | * Reset an allocated context object for re-use. All internal allocations are | |
282 | * freed. | |
283 | */ | |
284 | void dplane_ctx_reset(struct zebra_dplane_ctx *ctx); | |
285 | ||
aa21da07 MS |
286 | /* |
287 | * Allow zebra code to walk the queue of pending contexts, evaluate each one | |
288 | * using a callback function. The caller can supply an optional void* arg also. | |
289 | * If the function returns 'true', the context will be dequeued and freed | |
290 | * without being processed. | |
291 | */ | |
292 | int dplane_clean_ctx_queue(bool (*context_cb)(struct zebra_dplane_ctx *ctx, | |
293 | void *arg), void *val); | |
294 | ||
7cdb1a84 MS |
295 | /* Return a dataplane results context block after use; the caller's pointer will |
296 | * be cleared. | |
297 | */ | |
25779064 | 298 | void dplane_ctx_fini(struct zebra_dplane_ctx **pctx); |
7cdb1a84 | 299 | |
14b0bc8e | 300 | /* Enqueue a context block to caller's tailq. This exists so that the |
7cdb1a84 MS |
301 | * context struct can remain opaque. |
302 | */ | |
25779064 MS |
303 | void dplane_ctx_enqueue_tail(struct dplane_ctx_q *q, |
304 | const struct zebra_dplane_ctx *ctx); | |
7cdb1a84 | 305 | |
c831033f MS |
306 | /* Append a list of context blocks to another list - again, just keeping |
307 | * the context struct opaque. | |
308 | */ | |
309 | void dplane_ctx_list_append(struct dplane_ctx_q *to_list, | |
310 | struct dplane_ctx_q *from_list); | |
311 | ||
7cdb1a84 | 312 | /* Dequeue a context block from the head of caller's tailq */ |
68b375e0 | 313 | struct zebra_dplane_ctx *dplane_ctx_dequeue(struct dplane_ctx_q *q); |
c8453cd7 | 314 | struct zebra_dplane_ctx *dplane_ctx_get_head(struct dplane_ctx_q *q); |
7cdb1a84 MS |
315 | |
316 | /* | |
317 | * Accessors for information from the context object | |
318 | */ | |
25779064 MS |
319 | enum zebra_dplane_result dplane_ctx_get_status( |
320 | const struct zebra_dplane_ctx *ctx); | |
c831033f MS |
321 | void dplane_ctx_set_status(struct zebra_dplane_ctx *ctx, |
322 | enum zebra_dplane_result status); | |
f183e380 | 323 | const char *dplane_res2str(enum zebra_dplane_result res); |
7cdb1a84 | 324 | |
25779064 | 325 | enum dplane_op_e dplane_ctx_get_op(const struct zebra_dplane_ctx *ctx); |
593e4eb1 | 326 | void dplane_ctx_set_op(struct zebra_dplane_ctx *ctx, enum dplane_op_e op); |
5709131c | 327 | const char *dplane_op2str(enum dplane_op_e op); |
7cdb1a84 | 328 | |
25779064 | 329 | const struct prefix *dplane_ctx_get_dest(const struct zebra_dplane_ctx *ctx); |
593e4eb1 MS |
330 | void dplane_ctx_set_dest(struct zebra_dplane_ctx *ctx, |
331 | const struct prefix *dest); | |
7c7ef4a8 | 332 | const char *dplane_ctx_get_ifname(const struct zebra_dplane_ctx *ctx); |
fd563cc7 | 333 | void dplane_ctx_set_ifname(struct zebra_dplane_ctx *ctx, const char *ifname); |
7c7ef4a8 | 334 | ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx); |
971bad84 | 335 | void dplane_ctx_set_ifindex(struct zebra_dplane_ctx *ctx, ifindex_t ifindex); |
7cdb1a84 | 336 | |
c831033f MS |
337 | /* Retrieve last/current provider id */ |
338 | uint32_t dplane_ctx_get_provider(const struct zebra_dplane_ctx *ctx); | |
339 | ||
340 | /* Providers running before the kernel can control whether a kernel | |
341 | * update should be done. | |
342 | */ | |
343 | void dplane_ctx_set_skip_kernel(struct zebra_dplane_ctx *ctx); | |
344 | bool dplane_ctx_is_skip_kernel(const struct zebra_dplane_ctx *ctx); | |
345 | ||
5709131c MS |
346 | /* Source prefix is a little special - use convention to return NULL |
347 | * to mean "no src prefix" | |
7cdb1a84 | 348 | */ |
25779064 | 349 | const struct prefix *dplane_ctx_get_src(const struct zebra_dplane_ctx *ctx); |
593e4eb1 | 350 | void dplane_ctx_set_src(struct zebra_dplane_ctx *ctx, const struct prefix *src); |
25779064 MS |
351 | |
352 | bool dplane_ctx_is_update(const struct zebra_dplane_ctx *ctx); | |
353 | uint32_t dplane_ctx_get_seq(const struct zebra_dplane_ctx *ctx); | |
354 | uint32_t dplane_ctx_get_old_seq(const struct zebra_dplane_ctx *ctx); | |
593e4eb1 | 355 | void dplane_ctx_set_vrf(struct zebra_dplane_ctx *ctx, vrf_id_t vrf); |
25779064 | 356 | vrf_id_t dplane_ctx_get_vrf(const struct zebra_dplane_ctx *ctx); |
0f461727 | 357 | |
971bad84 MS |
358 | /* In some paths we have only a namespace id */ |
359 | void dplane_ctx_set_ns_id(struct zebra_dplane_ctx *ctx, ns_id_t nsid); | |
360 | ns_id_t dplane_ctx_get_ns_id(const struct zebra_dplane_ctx *ctx); | |
361 | ||
0024a559 | 362 | bool dplane_ctx_is_from_notif(const struct zebra_dplane_ctx *ctx); |
9651af61 MS |
363 | void dplane_ctx_set_notif_provider(struct zebra_dplane_ctx *ctx, |
364 | uint32_t id); | |
0024a559 MS |
365 | uint32_t dplane_ctx_get_notif_provider(const struct zebra_dplane_ctx *ctx); |
366 | ||
0f461727 | 367 | /* Accessors for route update information */ |
593e4eb1 | 368 | void dplane_ctx_set_type(struct zebra_dplane_ctx *ctx, int type); |
25779064 MS |
369 | int dplane_ctx_get_type(const struct zebra_dplane_ctx *ctx); |
370 | int dplane_ctx_get_old_type(const struct zebra_dplane_ctx *ctx); | |
593e4eb1 | 371 | void dplane_ctx_set_afi(struct zebra_dplane_ctx *ctx, afi_t afi); |
25779064 | 372 | afi_t dplane_ctx_get_afi(const struct zebra_dplane_ctx *ctx); |
593e4eb1 | 373 | void dplane_ctx_set_safi(struct zebra_dplane_ctx *ctx, safi_t safi); |
25779064 | 374 | safi_t dplane_ctx_get_safi(const struct zebra_dplane_ctx *ctx); |
593e4eb1 | 375 | void dplane_ctx_set_table(struct zebra_dplane_ctx *ctx, uint32_t table); |
25779064 MS |
376 | uint32_t dplane_ctx_get_table(const struct zebra_dplane_ctx *ctx); |
377 | route_tag_t dplane_ctx_get_tag(const struct zebra_dplane_ctx *ctx); | |
6a91ae98 | 378 | void dplane_ctx_set_tag(struct zebra_dplane_ctx *ctx, route_tag_t tag); |
25779064 MS |
379 | route_tag_t dplane_ctx_get_old_tag(const struct zebra_dplane_ctx *ctx); |
380 | uint16_t dplane_ctx_get_instance(const struct zebra_dplane_ctx *ctx); | |
6a91ae98 | 381 | void dplane_ctx_set_instance(struct zebra_dplane_ctx *ctx, uint16_t instance); |
25779064 | 382 | uint16_t dplane_ctx_get_old_instance(const struct zebra_dplane_ctx *ctx); |
10388e99 DS |
383 | uint32_t dplane_ctx_get_flags(const struct zebra_dplane_ctx *ctx); |
384 | void dplane_ctx_set_flags(struct zebra_dplane_ctx *ctx, uint32_t flags); | |
25779064 MS |
385 | uint32_t dplane_ctx_get_metric(const struct zebra_dplane_ctx *ctx); |
386 | uint32_t dplane_ctx_get_old_metric(const struct zebra_dplane_ctx *ctx); | |
387 | uint32_t dplane_ctx_get_mtu(const struct zebra_dplane_ctx *ctx); | |
388 | uint32_t dplane_ctx_get_nh_mtu(const struct zebra_dplane_ctx *ctx); | |
389 | uint8_t dplane_ctx_get_distance(const struct zebra_dplane_ctx *ctx); | |
6a91ae98 | 390 | void dplane_ctx_set_distance(struct zebra_dplane_ctx *ctx, uint8_t distance); |
25779064 MS |
391 | uint8_t dplane_ctx_get_old_distance(const struct zebra_dplane_ctx *ctx); |
392 | ||
449a30ed | 393 | /* Accessors for traffic control context */ |
c317d3f2 SY |
394 | int dplane_ctx_tc_qdisc_get_kind(const struct zebra_dplane_ctx *ctx); |
395 | const char * | |
396 | dplane_ctx_tc_qdisc_get_kind_str(const struct zebra_dplane_ctx *ctx); | |
397 | ||
398 | uint32_t dplane_ctx_tc_class_get_handle(const struct zebra_dplane_ctx *ctx); | |
399 | int dplane_ctx_tc_class_get_kind(const struct zebra_dplane_ctx *ctx); | |
400 | const char * | |
401 | dplane_ctx_tc_class_get_kind_str(const struct zebra_dplane_ctx *ctx); | |
402 | uint64_t dplane_ctx_tc_class_get_rate(const struct zebra_dplane_ctx *ctx); | |
403 | uint64_t dplane_ctx_tc_class_get_ceil(const struct zebra_dplane_ctx *ctx); | |
404 | ||
405 | int dplane_ctx_tc_filter_get_kind(const struct zebra_dplane_ctx *ctx); | |
406 | const char * | |
407 | dplane_ctx_tc_filter_get_kind_str(const struct zebra_dplane_ctx *ctx); | |
408 | uint32_t dplane_ctx_tc_filter_get_priority(const struct zebra_dplane_ctx *ctx); | |
409 | uint32_t dplane_ctx_tc_filter_get_handle(const struct zebra_dplane_ctx *ctx); | |
410 | uint16_t dplane_ctx_tc_filter_get_minor(const struct zebra_dplane_ctx *ctx); | |
411 | uint16_t dplane_ctx_tc_filter_get_eth_proto(const struct zebra_dplane_ctx *ctx); | |
412 | uint32_t dplane_ctx_tc_filter_get_filter_bm(const struct zebra_dplane_ctx *ctx); | |
449a30ed | 413 | const struct prefix * |
c317d3f2 SY |
414 | dplane_ctx_tc_filter_get_src_ip(const struct zebra_dplane_ctx *ctx); |
415 | uint16_t | |
416 | dplane_ctx_tc_filter_get_src_port_min(const struct zebra_dplane_ctx *ctx); | |
417 | uint16_t | |
418 | dplane_ctx_tc_filter_get_src_port_max(const struct zebra_dplane_ctx *ctx); | |
449a30ed | 419 | const struct prefix * |
c317d3f2 SY |
420 | dplane_ctx_tc_filter_get_dst_ip(const struct zebra_dplane_ctx *ctx); |
421 | uint16_t | |
422 | dplane_ctx_tc_filter_get_dst_port_min(const struct zebra_dplane_ctx *ctx); | |
423 | uint16_t | |
424 | dplane_ctx_tc_filter_get_dst_port_max(const struct zebra_dplane_ctx *ctx); | |
425 | uint8_t dplane_ctx_tc_filter_get_ip_proto(const struct zebra_dplane_ctx *ctx); | |
426 | uint8_t dplane_ctx_tc_filter_get_dsfield(const struct zebra_dplane_ctx *ctx); | |
427 | uint8_t | |
428 | dplane_ctx_tc_filter_get_dsfield_mask(const struct zebra_dplane_ctx *ctx); | |
429 | uint32_t dplane_ctx_tc_filter_get_classid(const struct zebra_dplane_ctx *ctx); | |
449a30ed | 430 | |
593e4eb1 | 431 | void dplane_ctx_set_nexthops(struct zebra_dplane_ctx *ctx, struct nexthop *nh); |
928f94a9 MS |
432 | void dplane_ctx_set_backup_nhg(struct zebra_dplane_ctx *ctx, |
433 | const struct nexthop_group *nhg); | |
1d48702e MS |
434 | |
435 | uint32_t dplane_ctx_get_nhg_id(const struct zebra_dplane_ctx *ctx); | |
25779064 MS |
436 | const struct nexthop_group *dplane_ctx_get_ng( |
437 | const struct zebra_dplane_ctx *ctx); | |
438 | const struct nexthop_group *dplane_ctx_get_old_ng( | |
439 | const struct zebra_dplane_ctx *ctx); | |
440 | ||
5917df09 MS |
441 | /* Optional extra info about interfaces in nexthops - a plugin must enable |
442 | * this extra info. | |
443 | */ | |
444 | const struct dplane_intf_extra * | |
445 | dplane_ctx_get_intf_extra(const struct zebra_dplane_ctx *ctx); | |
446 | ||
447 | const struct dplane_intf_extra * | |
448 | dplane_ctx_intf_extra_next(const struct zebra_dplane_ctx *ctx, | |
449 | const struct dplane_intf_extra *ptr); | |
450 | ||
451 | vrf_id_t dplane_intf_extra_get_vrfid(const struct dplane_intf_extra *ptr); | |
452 | uint32_t dplane_intf_extra_get_ifindex(const struct dplane_intf_extra *ptr); | |
453 | uint32_t dplane_intf_extra_get_flags(const struct dplane_intf_extra *ptr); | |
454 | uint32_t dplane_intf_extra_get_status(const struct dplane_intf_extra *ptr); | |
455 | ||
1d48702e MS |
456 | /* Backup nexthop information (list of nexthops) if present. */ |
457 | const struct nexthop_group * | |
458 | dplane_ctx_get_backup_ng(const struct zebra_dplane_ctx *ctx); | |
459 | const struct nexthop_group * | |
460 | dplane_ctx_get_old_backup_ng(const struct zebra_dplane_ctx *ctx); | |
461 | ||
f820d025 | 462 | /* Accessors for nexthop information */ |
0c8215cb | 463 | uint32_t dplane_ctx_get_nhe_id(const struct zebra_dplane_ctx *ctx); |
df3cef24 | 464 | uint32_t dplane_ctx_get_old_nhe_id(const struct zebra_dplane_ctx *ctx); |
0c8215cb SW |
465 | afi_t dplane_ctx_get_nhe_afi(const struct zebra_dplane_ctx *ctx); |
466 | vrf_id_t dplane_ctx_get_nhe_vrf_id(const struct zebra_dplane_ctx *ctx); | |
38e40db1 | 467 | int dplane_ctx_get_nhe_type(const struct zebra_dplane_ctx *ctx); |
0c8215cb SW |
468 | const struct nexthop_group * |
469 | dplane_ctx_get_nhe_ng(const struct zebra_dplane_ctx *ctx); | |
e22e8001 SW |
470 | const struct nh_grp * |
471 | dplane_ctx_get_nhe_nh_grp(const struct zebra_dplane_ctx *ctx); | |
472 | uint8_t dplane_ctx_get_nhe_nh_grp_count(const struct zebra_dplane_ctx *ctx); | |
f820d025 | 473 | |
0f461727 | 474 | /* Accessors for LSP information */ |
65f264cf MS |
475 | |
476 | /* Init the internal LSP data struct - necessary before adding to it. | |
477 | * If 'lsp' is non-NULL, info will be copied from it to the internal | |
478 | * context data area. | |
479 | */ | |
480 | int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op, | |
8f74a383 | 481 | struct zebra_lsp *lsp); |
65f264cf | 482 | |
0f461727 | 483 | mpls_label_t dplane_ctx_get_in_label(const struct zebra_dplane_ctx *ctx); |
3ab54059 MS |
484 | void dplane_ctx_set_in_label(struct zebra_dplane_ctx *ctx, |
485 | mpls_label_t label); | |
0f461727 | 486 | uint8_t dplane_ctx_get_addr_family(const struct zebra_dplane_ctx *ctx); |
3ab54059 MS |
487 | void dplane_ctx_set_addr_family(struct zebra_dplane_ctx *ctx, |
488 | uint8_t family); | |
0f461727 | 489 | uint32_t dplane_ctx_get_lsp_flags(const struct zebra_dplane_ctx *ctx); |
3ab54059 MS |
490 | void dplane_ctx_set_lsp_flags(struct zebra_dplane_ctx *ctx, |
491 | uint32_t flags); | |
ee70f629 MS |
492 | const struct nhlfe_list_head *dplane_ctx_get_nhlfe_list( |
493 | const struct zebra_dplane_ctx *ctx); | |
cd4bb96f MS |
494 | const struct nhlfe_list_head *dplane_ctx_get_backup_nhlfe_list( |
495 | const struct zebra_dplane_ctx *ctx); | |
496 | ||
f2595bd5 DS |
497 | struct zebra_nhlfe *dplane_ctx_add_nhlfe(struct zebra_dplane_ctx *ctx, |
498 | enum lsp_types_t lsp_type, | |
499 | enum nexthop_types_t nh_type, | |
500 | const union g_addr *gate, | |
501 | ifindex_t ifindex, uint8_t num_labels, | |
502 | mpls_label_t *out_labels); | |
503 | ||
504 | struct zebra_nhlfe *dplane_ctx_add_backup_nhlfe( | |
505 | struct zebra_dplane_ctx *ctx, enum lsp_types_t lsp_type, | |
506 | enum nexthop_types_t nh_type, const union g_addr *gate, | |
507 | ifindex_t ifindex, uint8_t num_labels, mpls_label_t *out_labels); | |
508 | ||
509 | const struct zebra_nhlfe * | |
510 | dplane_ctx_get_best_nhlfe(const struct zebra_dplane_ctx *ctx); | |
511 | const struct zebra_nhlfe * | |
512 | dplane_ctx_set_best_nhlfe(struct zebra_dplane_ctx *ctx, | |
513 | struct zebra_nhlfe *nhlfe); | |
0f461727 MS |
514 | uint32_t dplane_ctx_get_lsp_num_ecmp(const struct zebra_dplane_ctx *ctx); |
515 | ||
d613b8e1 | 516 | /* Accessors for pseudowire information */ |
d613b8e1 MS |
517 | mpls_label_t dplane_ctx_get_pw_local_label(const struct zebra_dplane_ctx *ctx); |
518 | mpls_label_t dplane_ctx_get_pw_remote_label(const struct zebra_dplane_ctx *ctx); | |
519 | int dplane_ctx_get_pw_type(const struct zebra_dplane_ctx *ctx); | |
520 | int dplane_ctx_get_pw_af(const struct zebra_dplane_ctx *ctx); | |
521 | uint32_t dplane_ctx_get_pw_flags(const struct zebra_dplane_ctx *ctx); | |
522 | int dplane_ctx_get_pw_status(const struct zebra_dplane_ctx *ctx); | |
fd563cc7 | 523 | void dplane_ctx_set_pw_status(struct zebra_dplane_ctx *ctx, int status); |
16d69787 | 524 | const union g_addr *dplane_ctx_get_pw_dest( |
d613b8e1 MS |
525 | const struct zebra_dplane_ctx *ctx); |
526 | const union pw_protocol_fields *dplane_ctx_get_pw_proto( | |
527 | const struct zebra_dplane_ctx *ctx); | |
09cd307c MS |
528 | const struct nexthop_group *dplane_ctx_get_pw_nhg( |
529 | const struct zebra_dplane_ctx *ctx); | |
072b487b MS |
530 | const struct nexthop_group * |
531 | dplane_ctx_get_pw_primary_nhg(const struct zebra_dplane_ctx *ctx); | |
532 | const struct nexthop_group * | |
533 | dplane_ctx_get_pw_backup_nhg(const struct zebra_dplane_ctx *ctx); | |
d613b8e1 | 534 | |
a4a4802a | 535 | /* Accessors for interface information */ |
a4a4802a | 536 | uint32_t dplane_ctx_get_intf_metric(const struct zebra_dplane_ctx *ctx); |
971bad84 | 537 | void dplane_ctx_set_intf_metric(struct zebra_dplane_ctx *ctx, uint32_t metric); |
ab465d24 SW |
538 | uint32_t dplane_ctx_get_intf_pd_reason_val(const struct zebra_dplane_ctx *ctx); |
539 | void dplane_ctx_set_intf_pd_reason_val(struct zebra_dplane_ctx *ctx, bool val); | |
5d414138 | 540 | bool dplane_ctx_intf_is_protodown(const struct zebra_dplane_ctx *ctx); |
a4a4802a MS |
541 | /* Is interface addr p2p? */ |
542 | bool dplane_ctx_intf_is_connected(const struct zebra_dplane_ctx *ctx); | |
971bad84 | 543 | void dplane_ctx_intf_set_connected(struct zebra_dplane_ctx *ctx); |
a4a4802a | 544 | bool dplane_ctx_intf_is_secondary(const struct zebra_dplane_ctx *ctx); |
971bad84 | 545 | void dplane_ctx_intf_set_secondary(struct zebra_dplane_ctx *ctx); |
990b0d09 | 546 | bool dplane_ctx_intf_is_broadcast(const struct zebra_dplane_ctx *ctx); |
971bad84 | 547 | void dplane_ctx_intf_set_broadcast(struct zebra_dplane_ctx *ctx); |
a4a4802a MS |
548 | const struct prefix *dplane_ctx_get_intf_addr( |
549 | const struct zebra_dplane_ctx *ctx); | |
971bad84 MS |
550 | void dplane_ctx_set_intf_addr(struct zebra_dplane_ctx *ctx, |
551 | const struct prefix *p); | |
a4a4802a MS |
552 | bool dplane_ctx_intf_has_dest(const struct zebra_dplane_ctx *ctx); |
553 | const struct prefix *dplane_ctx_get_intf_dest( | |
554 | const struct zebra_dplane_ctx *ctx); | |
971bad84 MS |
555 | void dplane_ctx_set_intf_dest(struct zebra_dplane_ctx *ctx, |
556 | const struct prefix *p); | |
a4a4802a MS |
557 | bool dplane_ctx_intf_has_label(const struct zebra_dplane_ctx *ctx); |
558 | const char *dplane_ctx_get_intf_label(const struct zebra_dplane_ctx *ctx); | |
971bad84 | 559 | void dplane_ctx_set_intf_label(struct zebra_dplane_ctx *ctx, const char *label); |
a4a4802a | 560 | |
7597ac7b MS |
561 | /* Accessors for MAC information */ |
562 | vlanid_t dplane_ctx_mac_get_vlan(const struct zebra_dplane_ctx *ctx); | |
563 | bool dplane_ctx_mac_is_sticky(const struct zebra_dplane_ctx *ctx); | |
f188e68e | 564 | uint32_t dplane_ctx_mac_get_update_flags(const struct zebra_dplane_ctx *ctx); |
506efd37 | 565 | uint32_t dplane_ctx_mac_get_nhg_id(const struct zebra_dplane_ctx *ctx); |
7597ac7b MS |
566 | const struct ethaddr *dplane_ctx_mac_get_addr( |
567 | const struct zebra_dplane_ctx *ctx); | |
568 | const struct in_addr *dplane_ctx_mac_get_vtep_ip( | |
569 | const struct zebra_dplane_ctx *ctx); | |
478566d6 | 570 | ifindex_t dplane_ctx_mac_get_br_ifindex(const struct zebra_dplane_ctx *ctx); |
7597ac7b | 571 | |
931fa60c MS |
572 | /* Accessors for neighbor information */ |
573 | const struct ipaddr *dplane_ctx_neigh_get_ipaddr( | |
574 | const struct zebra_dplane_ctx *ctx); | |
575 | const struct ethaddr *dplane_ctx_neigh_get_mac( | |
576 | const struct zebra_dplane_ctx *ctx); | |
0a27a2fe PG |
577 | const struct ipaddr * |
578 | dplane_ctx_neigh_get_link_ip(const struct zebra_dplane_ctx *ctx); | |
931fa60c MS |
579 | uint32_t dplane_ctx_neigh_get_flags(const struct zebra_dplane_ctx *ctx); |
580 | uint16_t dplane_ctx_neigh_get_state(const struct zebra_dplane_ctx *ctx); | |
f188e68e | 581 | uint32_t dplane_ctx_neigh_get_update_flags(const struct zebra_dplane_ctx *ctx); |
931fa60c | 582 | |
60d8d43b JU |
583 | /* Accessors for policy based routing rule information */ |
584 | int dplane_ctx_rule_get_sock(const struct zebra_dplane_ctx *ctx); | |
585 | int dplane_ctx_rule_get_unique(const struct zebra_dplane_ctx *ctx); | |
586 | int dplane_ctx_rule_get_seq(const struct zebra_dplane_ctx *ctx); | |
58a1d249 | 587 | const char *dplane_ctx_rule_get_ifname(const struct zebra_dplane_ctx *ctx); |
60d8d43b JU |
588 | uint32_t dplane_ctx_rule_get_priority(const struct zebra_dplane_ctx *ctx); |
589 | uint32_t dplane_ctx_rule_get_old_priority(const struct zebra_dplane_ctx *ctx); | |
590 | uint32_t dplane_ctx_rule_get_table(const struct zebra_dplane_ctx *ctx); | |
591 | uint32_t dplane_ctx_rule_get_old_table(const struct zebra_dplane_ctx *ctx); | |
592 | uint32_t dplane_ctx_rule_get_filter_bm(const struct zebra_dplane_ctx *ctx); | |
593 | uint32_t dplane_ctx_rule_get_old_filter_bm(const struct zebra_dplane_ctx *ctx); | |
594 | uint32_t dplane_ctx_rule_get_fwmark(const struct zebra_dplane_ctx *ctx); | |
595 | uint32_t dplane_ctx_rule_get_old_fwmark(const struct zebra_dplane_ctx *ctx); | |
01f23aff WC |
596 | uint8_t dplane_ctx_rule_get_dsfield(const struct zebra_dplane_ctx *ctx); |
597 | uint8_t dplane_ctx_rule_get_old_dsfield(const struct zebra_dplane_ctx *ctx); | |
8ccbc778 DS |
598 | uint8_t dplane_ctx_rule_get_ipproto(const struct zebra_dplane_ctx *ctx); |
599 | uint8_t dplane_ctx_rule_get_old_ipproto(const struct zebra_dplane_ctx *ctx); | |
9898473f AK |
600 | uint16_t dplane_ctx_rule_get_src_port(const struct zebra_dplane_ctx *ctx); |
601 | uint16_t dplane_ctx_rule_get_old_src_port(const struct zebra_dplane_ctx *ctx); | |
602 | uint16_t dplane_ctx_rule_get_dst_port(const struct zebra_dplane_ctx *ctx); | |
603 | uint16_t dplane_ctx_rule_get_old_dst_port(const struct zebra_dplane_ctx *ctx); | |
60d8d43b JU |
604 | const struct prefix * |
605 | dplane_ctx_rule_get_src_ip(const struct zebra_dplane_ctx *ctx); | |
606 | const struct prefix * | |
607 | dplane_ctx_rule_get_old_src_ip(const struct zebra_dplane_ctx *ctx); | |
608 | const struct prefix * | |
609 | dplane_ctx_rule_get_dst_ip(const struct zebra_dplane_ctx *ctx); | |
610 | const struct prefix * | |
611 | dplane_ctx_rule_get_old_dst_ip(const struct zebra_dplane_ctx *ctx); | |
9898473f AK |
612 | const struct ethaddr * |
613 | dplane_ctx_rule_get_smac(const struct zebra_dplane_ctx *ctx); | |
614 | const struct ethaddr * | |
615 | dplane_ctx_rule_get_dmac(const struct zebra_dplane_ctx *ctx); | |
616 | int dplane_ctx_rule_get_out_ifindex(const struct zebra_dplane_ctx *ctx); | |
617 | intptr_t dplane_ctx_rule_get_dp_flow_ptr(const struct zebra_dplane_ctx *ctx); | |
618 | intptr_t | |
619 | dplane_ctx_rule_get_old_dp_flow_ptr(const struct zebra_dplane_ctx *ctx); | |
620 | void dplane_ctx_rule_set_dp_flow_ptr(struct zebra_dplane_ctx *ctx, | |
621 | intptr_t dp_flow_ptr); | |
5162e000 PG |
622 | /* Accessors for policy based routing iptable information */ |
623 | struct zebra_pbr_iptable; | |
8d78e148 DS |
624 | void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx, |
625 | struct zebra_pbr_iptable *table); | |
ef524230 | 626 | struct zebra_pbr_ipset; |
8249f96a DS |
627 | void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx, |
628 | struct zebra_pbr_ipset *ipset); | |
ef524230 | 629 | struct zebra_pbr_ipset_entry; |
f284c132 DS |
630 | void dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx, |
631 | struct zebra_pbr_ipset_entry *entry); | |
c60522f7 AK |
632 | /* Accessors for bridge port information */ |
633 | uint32_t dplane_ctx_get_br_port_flags(const struct zebra_dplane_ctx *ctx); | |
634 | uint32_t | |
635 | dplane_ctx_get_br_port_sph_filter_cnt(const struct zebra_dplane_ctx *ctx); | |
636 | const struct in_addr * | |
637 | dplane_ctx_get_br_port_sph_filters(const struct zebra_dplane_ctx *ctx); | |
638 | uint32_t | |
639 | dplane_ctx_get_br_port_backup_nhg_id(const struct zebra_dplane_ctx *ctx); | |
640 | ||
e18747a9 PG |
641 | /* Accessors for neighbor table information */ |
642 | uint8_t dplane_ctx_neightable_get_family(const struct zebra_dplane_ctx *ctx); | |
643 | uint32_t | |
644 | dplane_ctx_neightable_get_app_probes(const struct zebra_dplane_ctx *ctx); | |
645 | uint32_t | |
646 | dplane_ctx_neightable_get_mcast_probes(const struct zebra_dplane_ctx *ctx); | |
647 | uint32_t | |
648 | dplane_ctx_neightable_get_ucast_probes(const struct zebra_dplane_ctx *ctx); | |
649 | ||
62b4b7e4 PG |
650 | /* Accessor for GRE set */ |
651 | uint32_t | |
652 | dplane_ctx_gre_get_link_ifindex(const struct zebra_dplane_ctx *ctx); | |
db51f0cd PG |
653 | unsigned int |
654 | dplane_ctx_gre_get_mtu(const struct zebra_dplane_ctx *ctx); | |
e3d3fa06 PG |
655 | const struct zebra_l2info_gre * |
656 | dplane_ctx_gre_get_info(const struct zebra_dplane_ctx *ctx); | |
62b4b7e4 | 657 | |
728f2017 | 658 | /* Interface netconf info */ |
728f2017 MS |
659 | enum dplane_netconf_status_e |
660 | dplane_ctx_get_netconf_mpls(const struct zebra_dplane_ctx *ctx); | |
661 | enum dplane_netconf_status_e | |
662 | dplane_ctx_get_netconf_mcast(const struct zebra_dplane_ctx *ctx); | |
3689905d DS |
663 | enum dplane_netconf_status_e |
664 | dplane_ctx_get_netconf_linkdown(const struct zebra_dplane_ctx *ctx); | |
665 | ||
728f2017 MS |
666 | void dplane_ctx_set_netconf_mpls(struct zebra_dplane_ctx *ctx, |
667 | enum dplane_netconf_status_e val); | |
668 | void dplane_ctx_set_netconf_mcast(struct zebra_dplane_ctx *ctx, | |
669 | enum dplane_netconf_status_e val); | |
3689905d DS |
670 | void dplane_ctx_set_netconf_linkdown(struct zebra_dplane_ctx *ctx, |
671 | enum dplane_netconf_status_e val); | |
728f2017 | 672 | |
d4000d7b | 673 | /* Namespace fd info - esp. for netlink communication */ |
25779064 MS |
674 | const struct zebra_dplane_info *dplane_ctx_get_ns( |
675 | const struct zebra_dplane_ctx *ctx); | |
d4000d7b | 676 | int dplane_ctx_get_ns_sock(const struct zebra_dplane_ctx *ctx); |
7cdb1a84 | 677 | |
4dfd7a02 MS |
678 | /* Indicates zebra shutdown/exit is in progress. Some operations may be |
679 | * simplified or skipped during shutdown processing. | |
680 | */ | |
681 | bool dplane_is_in_shutdown(void); | |
682 | ||
7cdb1a84 MS |
683 | /* |
684 | * Enqueue route change operations for the dataplane. | |
685 | */ | |
655d681a MS |
686 | enum zebra_dplane_result dplane_route_add(struct route_node *rn, |
687 | struct route_entry *re); | |
7cdb1a84 | 688 | |
655d681a MS |
689 | enum zebra_dplane_result dplane_route_update(struct route_node *rn, |
690 | struct route_entry *re, | |
691 | struct route_entry *old_re); | |
7cdb1a84 | 692 | |
655d681a MS |
693 | enum zebra_dplane_result dplane_route_delete(struct route_node *rn, |
694 | struct route_entry *re); | |
7cdb1a84 | 695 | |
cf363e1b MS |
696 | /* Notify the dplane when system/connected routes change */ |
697 | enum zebra_dplane_result dplane_sys_route_add(struct route_node *rn, | |
698 | struct route_entry *re); | |
699 | enum zebra_dplane_result dplane_sys_route_del(struct route_node *rn, | |
700 | struct route_entry *re); | |
701 | ||
188a00e0 MS |
702 | /* Update from an async notification, to bring other fibs up-to-date */ |
703 | enum zebra_dplane_result dplane_route_notif_update( | |
704 | struct route_node *rn, | |
705 | struct route_entry *re, | |
706 | enum dplane_op_e op, | |
707 | struct zebra_dplane_ctx *ctx); | |
708 | ||
c60522f7 AK |
709 | /* |
710 | * Enqueue bridge port changes for the dataplane. | |
711 | */ | |
712 | enum zebra_dplane_result dplane_br_port_update( | |
713 | const struct interface *ifp, bool non_df, uint32_t sph_filter_cnt, | |
714 | const struct in_addr *sph_filters, uint32_t backup_nhg_id); | |
f820d025 SW |
715 | |
716 | /* Forward ref of nhg_hash_entry */ | |
717 | struct nhg_hash_entry; | |
718 | /* | |
719 | * Enqueue a nexthop change operation for the dataplane. | |
720 | */ | |
721 | enum zebra_dplane_result dplane_nexthop_add(struct nhg_hash_entry *nhe); | |
722 | enum zebra_dplane_result dplane_nexthop_update(struct nhg_hash_entry *nhe); | |
723 | enum zebra_dplane_result dplane_nexthop_delete(struct nhg_hash_entry *nhe); | |
724 | ||
16c628de MS |
725 | /* |
726 | * Enqueue LSP change operations for the dataplane. | |
727 | */ | |
8f74a383 DS |
728 | enum zebra_dplane_result dplane_lsp_add(struct zebra_lsp *lsp); |
729 | enum zebra_dplane_result dplane_lsp_update(struct zebra_lsp *lsp); | |
730 | enum zebra_dplane_result dplane_lsp_delete(struct zebra_lsp *lsp); | |
16c628de | 731 | |
188a00e0 | 732 | /* Update or un-install resulting from an async notification */ |
8f74a383 | 733 | enum zebra_dplane_result dplane_lsp_notif_update(struct zebra_lsp *lsp, |
188a00e0 MS |
734 | enum dplane_op_e op, |
735 | struct zebra_dplane_ctx *ctx); | |
736 | ||
97d8d05a MS |
737 | /* |
738 | * Enqueue pseudowire operations for the dataplane. | |
739 | */ | |
740 | enum zebra_dplane_result dplane_pw_install(struct zebra_pw *pw); | |
741 | enum zebra_dplane_result dplane_pw_uninstall(struct zebra_pw *pw); | |
742 | ||
39ffa8e8 DS |
743 | enum zebra_dplane_result |
744 | dplane_intf_mpls_modify_state(const struct interface *ifp, const bool set); | |
a4a4802a MS |
745 | /* |
746 | * Enqueue interface address changes for the dataplane. | |
747 | */ | |
748 | enum zebra_dplane_result dplane_intf_addr_set(const struct interface *ifp, | |
749 | const struct connected *ifc); | |
750 | enum zebra_dplane_result dplane_intf_addr_unset(const struct interface *ifp, | |
751 | const struct connected *ifc); | |
752 | ||
5d414138 SW |
753 | /* |
754 | * Enqueue interface link changes for the dataplane. | |
755 | */ | |
756 | enum zebra_dplane_result dplane_intf_add(const struct interface *ifp); | |
757 | enum zebra_dplane_result dplane_intf_update(const struct interface *ifp); | |
758 | enum zebra_dplane_result dplane_intf_delete(const struct interface *ifp); | |
759 | ||
449a30ed | 760 | /* |
c317d3f2 | 761 | * Enqueue tc link changes for the dataplane. |
449a30ed | 762 | */ |
c317d3f2 SY |
763 | |
764 | struct zebra_tc_qdisc; | |
765 | struct zebra_tc_class; | |
766 | struct zebra_tc_filter; | |
767 | enum zebra_dplane_result dplane_tc_qdisc_install(struct zebra_tc_qdisc *qdisc); | |
768 | enum zebra_dplane_result | |
769 | dplane_tc_qdisc_uninstall(struct zebra_tc_qdisc *qdisc); | |
770 | enum zebra_dplane_result dplane_tc_class_add(struct zebra_tc_class *class); | |
771 | enum zebra_dplane_result dplane_tc_class_delete(struct zebra_tc_class *class); | |
772 | enum zebra_dplane_result dplane_tc_class_update(struct zebra_tc_class *class); | |
773 | enum zebra_dplane_result dplane_tc_filter_add(struct zebra_tc_filter *filter); | |
774 | enum zebra_dplane_result | |
775 | dplane_tc_filter_delete(struct zebra_tc_filter *filter); | |
776 | enum zebra_dplane_result | |
777 | dplane_tc_filter_update(struct zebra_tc_filter *filter); | |
449a30ed | 778 | |
0a27a2fe PG |
779 | /* |
780 | * Link layer operations for the dataplane. | |
781 | */ | |
782 | enum zebra_dplane_result dplane_neigh_ip_update(enum dplane_op_e op, | |
783 | const struct interface *ifp, | |
784 | struct ipaddr *link_ip, | |
785 | struct ipaddr *ip, | |
d603c077 PG |
786 | uint32_t ndm_state, |
787 | int protocol); | |
0a27a2fe | 788 | |
7597ac7b MS |
789 | /* |
790 | * Enqueue evpn mac operations for the dataplane. | |
791 | */ | |
f188e68e | 792 | enum zebra_dplane_result dplane_rem_mac_add(const struct interface *ifp, |
478566d6 | 793 | const struct interface *bridge_ifp, |
7597ac7b MS |
794 | vlanid_t vid, |
795 | const struct ethaddr *mac, | |
796 | struct in_addr vtep_ip, | |
506efd37 | 797 | bool sticky, |
f188e68e AK |
798 | uint32_t nhg_id, |
799 | bool was_static); | |
7597ac7b | 800 | |
f188e68e AK |
801 | enum zebra_dplane_result dplane_local_mac_add(const struct interface *ifp, |
802 | const struct interface *bridge_ifp, | |
803 | vlanid_t vid, | |
804 | const struct ethaddr *mac, | |
805 | bool sticky, | |
806 | uint32_t set_static, | |
807 | uint32_t set_inactive); | |
808 | ||
00a7710c AK |
809 | enum zebra_dplane_result |
810 | dplane_local_mac_del(const struct interface *ifp, | |
811 | const struct interface *bridge_ifp, vlanid_t vid, | |
812 | const struct ethaddr *mac); | |
813 | ||
f188e68e | 814 | enum zebra_dplane_result dplane_rem_mac_del(const struct interface *ifp, |
478566d6 | 815 | const struct interface *bridge_ifp, |
7597ac7b MS |
816 | vlanid_t vid, |
817 | const struct ethaddr *mac, | |
818 | struct in_addr vtep_ip); | |
a4a4802a | 819 | |
f73a8467 MS |
820 | /* Helper api to init an empty or new context for a MAC update */ |
821 | void dplane_mac_init(struct zebra_dplane_ctx *ctx, | |
822 | const struct interface *ifp, | |
823 | const struct interface *br_ifp, | |
824 | vlanid_t vid, | |
825 | const struct ethaddr *mac, | |
826 | struct in_addr vtep_ip, | |
f188e68e | 827 | bool sticky, |
b169fd6f | 828 | uint32_t nhg_id, uint32_t update_flags); |
f73a8467 | 829 | |
f2412b2d MS |
830 | /* |
831 | * Enqueue evpn neighbor updates for the dataplane. | |
832 | */ | |
f188e68e AK |
833 | enum zebra_dplane_result dplane_rem_neigh_add(const struct interface *ifp, |
834 | const struct ipaddr *ip, | |
835 | const struct ethaddr *mac, | |
836 | uint32_t flags, bool was_static); | |
837 | enum zebra_dplane_result dplane_local_neigh_add(const struct interface *ifp, | |
f2412b2d MS |
838 | const struct ipaddr *ip, |
839 | const struct ethaddr *mac, | |
f188e68e AK |
840 | bool set_router, bool set_static, |
841 | bool set_inactive); | |
f188e68e | 842 | enum zebra_dplane_result dplane_rem_neigh_delete(const struct interface *ifp, |
931fa60c | 843 | const struct ipaddr *ip); |
f2412b2d | 844 | |
0bbd4ff4 MS |
845 | /* |
846 | * Enqueue evpn VTEP updates for the dataplane. | |
847 | */ | |
848 | enum zebra_dplane_result dplane_vtep_add(const struct interface *ifp, | |
849 | const struct in_addr *ip, | |
850 | vni_t vni); | |
851 | enum zebra_dplane_result dplane_vtep_delete(const struct interface *ifp, | |
852 | const struct in_addr *ip, | |
853 | vni_t vni); | |
854 | ||
d68e74b4 JU |
855 | /* |
856 | * Enqueue a neighbour discovery request for the dataplane. | |
857 | */ | |
858 | enum zebra_dplane_result dplane_neigh_discover(const struct interface *ifp, | |
859 | const struct ipaddr *ip); | |
860 | ||
e18747a9 PG |
861 | /* |
862 | * Enqueue a neighbor table parameter set | |
863 | */ | |
864 | enum zebra_dplane_result dplane_neigh_table_update(const struct interface *ifp, | |
865 | const uint8_t family, | |
866 | const uint32_t app_probes, | |
867 | const uint32_t ucast_probes, | |
868 | const uint32_t mcast_probes); | |
869 | ||
62b4b7e4 PG |
870 | /* |
871 | * Enqueue a GRE set | |
872 | */ | |
873 | enum zebra_dplane_result | |
db51f0cd | 874 | dplane_gre_set(struct interface *ifp, struct interface *ifp_link, |
e3d3fa06 | 875 | unsigned int mtu, const struct zebra_l2info_gre *gre_info); |
62b4b7e4 | 876 | |
f62e5480 JU |
877 | /* Forward ref of zebra_pbr_rule */ |
878 | struct zebra_pbr_rule; | |
879 | ||
880 | /* | |
881 | * Enqueue policy based routing rule for the dataplane. | |
882 | * It is possible that the user-defined sequence number and the one in the | |
883 | * forwarding plane may not coincide, hence the API requires a separate | |
884 | * rule priority - maps to preference/FRA_PRIORITY on Linux. | |
885 | */ | |
886 | enum zebra_dplane_result dplane_pbr_rule_add(struct zebra_pbr_rule *rule); | |
887 | enum zebra_dplane_result dplane_pbr_rule_delete(struct zebra_pbr_rule *rule); | |
888 | enum zebra_dplane_result | |
889 | dplane_pbr_rule_update(struct zebra_pbr_rule *old_rule, | |
890 | struct zebra_pbr_rule *new_rule); | |
5162e000 PG |
891 | /* iptable */ |
892 | enum zebra_dplane_result | |
893 | dplane_pbr_iptable_add(struct zebra_pbr_iptable *iptable); | |
894 | enum zebra_dplane_result | |
895 | dplane_pbr_iptable_delete(struct zebra_pbr_iptable *iptable); | |
f62e5480 | 896 | |
ef524230 PG |
897 | /* ipset */ |
898 | struct zebra_pbr_ipset; | |
899 | enum zebra_dplane_result dplane_pbr_ipset_add(struct zebra_pbr_ipset *ipset); | |
900 | enum zebra_dplane_result dplane_pbr_ipset_delete(struct zebra_pbr_ipset *ipset); | |
901 | ||
902 | /* ipset entry */ | |
903 | struct zebra_pbr_ipset_entry; | |
904 | enum zebra_dplane_result | |
905 | dplane_pbr_ipset_entry_add(struct zebra_pbr_ipset_entry *ipset); | |
906 | enum zebra_dplane_result | |
907 | dplane_pbr_ipset_entry_delete(struct zebra_pbr_ipset_entry *ipset); | |
908 | ||
018e77bc RZ |
909 | /* Encode route information into data plane context. */ |
910 | int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op, | |
911 | struct route_node *rn, struct route_entry *re); | |
0bbd4ff4 | 912 | |
f935122e DS |
913 | int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx, |
914 | enum dplane_op_e op, struct route_entry *re, | |
915 | const struct prefix *p, | |
a0e11736 | 916 | const struct prefix_ipv6 *src_p, afi_t afi, |
f935122e DS |
917 | safi_t safi); |
918 | ||
981ca597 | 919 | /* Encode next hop information into data plane context. */ |
a2072e71 | 920 | int dplane_ctx_nexthop_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op, |
981ca597 RZ |
921 | struct nhg_hash_entry *nhe); |
922 | ||
5d414138 SW |
923 | /* Encode interface information into data plane context. */ |
924 | int dplane_ctx_intf_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op, | |
925 | const struct interface *ifp); | |
926 | ||
449a30ed SY |
927 | /* Encode traffic control information into data plane context. */ |
928 | int dplane_ctx_tc_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op); | |
929 | ||
91f16812 MS |
930 | /* Retrieve the limit on the number of pending, unprocessed updates. */ |
931 | uint32_t dplane_get_in_queue_limit(void); | |
932 | ||
933 | /* Configure limit on the number of pending, queued updates. If 'unset', reset | |
934 | * to default value. | |
935 | */ | |
936 | void dplane_set_in_queue_limit(uint32_t limit, bool set); | |
937 | ||
938 | /* Retrieve the current queue depth of incoming, unprocessed updates */ | |
939 | uint32_t dplane_get_in_queue_len(void); | |
940 | ||
1d11b21f MS |
941 | /* |
942 | * Vty/cli apis | |
943 | */ | |
944 | int dplane_show_helper(struct vty *vty, bool detailed); | |
945 | int dplane_show_provs_helper(struct vty *vty, bool detailed); | |
f26730e1 | 946 | int dplane_config_write_helper(struct vty *vty); |
1d11b21f | 947 | |
1d11b21f | 948 | /* |
c831033f | 949 | * Dataplane providers: modules that process or consume dataplane events. |
1d11b21f MS |
950 | */ |
951 | ||
c831033f MS |
952 | struct zebra_dplane_provider; |
953 | ||
fe2c53d4 | 954 | /* Support string name for a dataplane provider */ |
7cdb1a84 MS |
955 | #define DPLANE_PROVIDER_NAMELEN 64 |
956 | ||
957 | /* Priority or ordering values for providers. The idea is that there may be | |
958 | * some pre-processing, followed by an external or remote dataplane, | |
959 | * followed by the kernel, followed by some post-processing step (such as | |
960 | * the fpm output stream.) | |
961 | */ | |
c831033f | 962 | enum dplane_provider_prio { |
7cdb1a84 MS |
963 | DPLANE_PRIO_NONE = 0, |
964 | DPLANE_PRIO_PREPROCESS, | |
965 | DPLANE_PRIO_PRE_KERNEL, | |
966 | DPLANE_PRIO_KERNEL, | |
967 | DPLANE_PRIO_POSTPROCESS, | |
b8e0423d | 968 | DPLANE_PRIO_LAST |
5709131c | 969 | }; |
7cdb1a84 | 970 | |
c831033f MS |
971 | /* Flags values used during provider registration. */ |
972 | #define DPLANE_PROV_FLAGS_DEFAULT 0x0 | |
973 | ||
974 | /* Provider will be spawning its own worker thread */ | |
975 | #define DPLANE_PROV_FLAG_THREADED 0x1 | |
7cdb1a84 | 976 | |
c831033f | 977 | /* Provider registration: ordering or priority value, callbacks, and optional |
1ff8a248 MS |
978 | * opaque data value. If 'prov_p', return the newly-allocated provider object |
979 | * on success. | |
c831033f | 980 | */ |
4c206c8f MS |
981 | |
982 | /* Providers offer an entry-point for incoming work, called in the context of | |
983 | * the dataplane pthread. The dataplane pthread enqueues any new work to the | |
984 | * provider's 'inbound' queue, then calls the callback. The dataplane | |
985 | * then checks the provider's outbound queue for completed work. | |
986 | */ | |
987 | ||
1dd4ea8a MS |
988 | /* |
989 | * Providers can offer a 'start' callback; if present, the dataplane will | |
990 | * call it when it is starting - when its pthread and event-scheduling | |
991 | * thread_master are available. | |
992 | */ | |
993 | ||
994 | /* Providers can offer an entry-point for shutdown and cleanup. This is called | |
4c206c8f MS |
995 | * with 'early' during shutdown, to indicate that the dataplane subsystem |
996 | * is allowing work to move through the providers and finish. | |
997 | * When called without 'early', the provider should release | |
998 | * all resources (if it has any allocated). | |
999 | */ | |
7cdb1a84 | 1000 | int dplane_provider_register(const char *name, |
c831033f MS |
1001 | enum dplane_provider_prio prio, |
1002 | int flags, | |
1dd4ea8a | 1003 | int (*start_fp)(struct zebra_dplane_provider *), |
4c206c8f MS |
1004 | int (*fp)(struct zebra_dplane_provider *), |
1005 | int (*fini_fp)(struct zebra_dplane_provider *, | |
1006 | bool early), | |
1ff8a248 MS |
1007 | void *data, |
1008 | struct zebra_dplane_provider **prov_p); | |
7cdb1a84 | 1009 | |
c831033f MS |
1010 | /* Accessors for provider attributes */ |
1011 | const char *dplane_provider_get_name(const struct zebra_dplane_provider *prov); | |
1012 | uint32_t dplane_provider_get_id(const struct zebra_dplane_provider *prov); | |
1013 | void *dplane_provider_get_data(const struct zebra_dplane_provider *prov); | |
1014 | bool dplane_provider_is_threaded(const struct zebra_dplane_provider *prov); | |
1015 | ||
ad6aad4d MS |
1016 | /* Lock/unlock a provider's mutex - iff the provider was registered with |
1017 | * the THREADED flag. | |
1018 | */ | |
1019 | void dplane_provider_lock(struct zebra_dplane_provider *prov); | |
1020 | void dplane_provider_unlock(struct zebra_dplane_provider *prov); | |
1021 | ||
1022 | /* Obtain thread_master for dataplane thread */ | |
1023 | struct thread_master *dplane_get_thread_master(void); | |
1024 | ||
1025 | /* Providers should (generally) limit number of updates per work cycle */ | |
c831033f MS |
1026 | int dplane_provider_get_work_limit(const struct zebra_dplane_provider *prov); |
1027 | ||
1028 | /* Provider api to signal that work/events are available | |
1029 | * for the dataplane pthread. | |
7cdb1a84 | 1030 | */ |
c831033f MS |
1031 | int dplane_provider_work_ready(void); |
1032 | ||
1033 | /* Dequeue, maintain associated counter and locking */ | |
1034 | struct zebra_dplane_ctx *dplane_provider_dequeue_in_ctx( | |
1035 | struct zebra_dplane_provider *prov); | |
1036 | ||
1037 | /* Dequeue work to a list, maintain counter and locking, return count */ | |
1038 | int dplane_provider_dequeue_in_list(struct zebra_dplane_provider *prov, | |
1039 | struct dplane_ctx_q *listp); | |
1040 | ||
53706b4e DE |
1041 | /* Current completed work queue length */ |
1042 | uint32_t dplane_provider_out_ctx_queue_len(struct zebra_dplane_provider *prov); | |
1043 | ||
593e4eb1 | 1044 | /* Enqueue completed work, maintain associated counter and locking */ |
c831033f MS |
1045 | void dplane_provider_enqueue_out_ctx(struct zebra_dplane_provider *prov, |
1046 | struct zebra_dplane_ctx *ctx); | |
7cdb1a84 | 1047 | |
593e4eb1 MS |
1048 | /* Enqueue a context directly to zebra main. */ |
1049 | void dplane_provider_enqueue_to_zebra(struct zebra_dplane_ctx *ctx); | |
1050 | ||
5917df09 MS |
1051 | /* Enable collection of extra info about interfaces in route updates; |
1052 | * this allows a provider/plugin to see some extra info in route update | |
1053 | * context objects. | |
1054 | */ | |
1055 | void dplane_enable_intf_extra_info(void); | |
1056 | ||
7cdb1a84 | 1057 | /* |
1d11b21f | 1058 | * Initialize the dataplane modules at zebra startup. This is currently called |
4c206c8f MS |
1059 | * by the rib module. Zebra registers a results callback with the dataplane. |
1060 | * The callback is called in the dataplane pthread context, | |
1061 | * so the expectation is that the contexts are queued for the zebra | |
1062 | * main pthread. | |
7cdb1a84 | 1063 | */ |
4c206c8f | 1064 | void zebra_dplane_init(int (*) (struct dplane_ctx_q *)); |
7cdb1a84 | 1065 | |
e5a60d82 MS |
1066 | /* |
1067 | * Start the dataplane pthread. This step needs to be run later than the | |
1068 | * 'init' step, in case zebra has fork-ed. | |
1069 | */ | |
1070 | void zebra_dplane_start(void); | |
1071 | ||
4dfd7a02 MS |
1072 | /* Finalize/cleanup apis, one called early as shutdown is starting, |
1073 | * one called late at the end of zebra shutdown, and then one called | |
c831033f MS |
1074 | * from the zebra main pthread to stop the dplane pthread and |
1075 | * free all resources. | |
4dfd7a02 | 1076 | * |
1d11b21f MS |
1077 | * Zebra expects to try to clean up all vrfs and all routes during |
1078 | * shutdown, so the dplane must be available until very late. | |
1079 | */ | |
4dfd7a02 | 1080 | void zebra_dplane_pre_finish(void); |
1d11b21f | 1081 | void zebra_dplane_finish(void); |
4dfd7a02 | 1082 | void zebra_dplane_shutdown(void); |
1d11b21f | 1083 | |
45f0a10b DS |
1084 | /* |
1085 | * decision point for sending a routing update through the old | |
1086 | * straight to zebra master pthread or through the dplane to | |
1087 | * the master pthread for handling | |
1088 | */ | |
1089 | void dplane_rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, | |
1090 | struct prefix_ipv6 *src_p, struct route_entry *re, | |
1091 | struct nexthop_group *ng, int startup, | |
1092 | struct zebra_dplane_ctx *ctx); | |
1093 | ||
51e94aa7 EDP |
1094 | #ifdef __cplusplus |
1095 | } | |
1096 | #endif | |
1097 | ||
ea1c14f6 | 1098 | #endif /* _ZEBRA_DPLANE_H */ |