back to topotato report
topotato coverage report
Current view: top level - zebra - zebra_dplane.h (source / functions) Hit Total Coverage
Test: test_pim6_bootstrap.py::PIM6Bootstrap Lines: 8 8 100.0 %
Date: 2023-02-16 02:07:22 Functions: 0 0 -

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

Generated by: LCOV version v1.16-topotato