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