Data Accelerator Offload
Loading...
Searching...
No Matches
dao_netlink_route.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Marvell-MIT
2 * Copyright (c) 2023 Marvell.
3 */
4
11#ifndef _DAO_LIB_NETLINK_ROUTE_H
12#define _DAO_LIB_NETLINK_ROUTE_H
13
14#include <linux/rtnetlink.h>
15#include <netlink/cache.h>
16#include <netlink/route/addr.h>
17#include <netlink/route/link.h>
18#include <netlink/route/neighbour.h>
19#include <netlink/route/route.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
31#define DAO_NETLINK_APP_IF_COOKIE_INITIALIZER (~0u)
32
34#define dao_foreach_netlink_neigh_states \
35 _(0, INCOMPLETE) /* NUD_INCOMPLETE */ \
36 _(1, REACHABLE) /* NUD_REACHABLE */ \
37 _(2, STALE) /* NUD_STALE */ \
38 _(3, DELAY) /* NUD_DELAY */ \
39 _(4, PROBE) /* NUD_PROBE */ \
40 _(5, FAILED) /* NUD_FAILED */ \
41 _(6, NOARP) /* NUD_NOARP */ \
42 _(7, NONE) /* NUD_NONE */ \
43 _(8, PERMANENT) /* NUD_PERMANENT */
44
46#define dao_foreach_netlink_route_proto \
47 _(0, UNSPEC) /* RTPROT_UNSPEC */ \
48 _(1, REDIRECT) /* RTPROT_REDIRECT */ \
49 _(2, KERNEL) /* RTPROT_KERNEL */ \
50 _(3, BOOT) /* RTPROT_BOOT */ \
51 _(4, STATIC) /* RTPROT_STATIC */
52
54typedef enum {
55#define _(n, state) DAO_NETLINK_ROUTE_PROTO_##state = RTPROT_##state,
56
58#undef _
60
61typedef enum dao_netlink_action {
62 DAO_NETLINK_ACTION_DEL = 0, /*< Netlink notification indicates delete object */
63 DAO_NETLINK_ACTION_ADD = 1, /*< Netlink notification indicates add object */
64 DAO_NETLINK_ACTION_REPLACE = 2, /*<Netlink notification indicates replace object */
65 DAO_NETLINK_ACTION_UNKNOWN, /* Netlink notification indicates unknown action */
66} dao_netlink_action_t;
67
91
93#define dao_foreach_netlink_route_types \
94 _(0, UNSPEC) /* RTN_UNSPEC */ \
95 _(1, UNICAST) /* RTN_UNICAST */ \
96 _(2, LOCAL) /* RTN_LOCAL */ \
97 _(3, BROADCAST) /* RTN_BROADCAST */ \
98 _(4, ANYCAST) /* RTN_ANYCAST */ \
99 _(5, MULTICAST) /* RTN_MULTICAST */ \
100 _(6, BLACKHOLE) /* RTN_BLACKHOLE */ \
101 _(7, UNREACHABLE) /* RTN_UNREACHABLE */ \
102 _(8, PROHIBIT) /* RTN_PROHIBIT */ \
103 _(9, THROW) /* RTN_THROW */ \
104 _(10, NAT) /* RTN_NAT */ \
105 _(11, XRESOLVE) /* RTN_XRESOLVE */
106
108typedef enum {
109#define _(n, state) DAO_NETLINK_ROUTE_TYPES_##state = RTN_##state,
110
112#undef _
114
139
146typedef enum {
147 DAO_NETLINK_ROUTE_NH_F_DEAD = RTNH_F_DEAD, /*< Nexthop os dead */
148 DAO_NETLINK_ROUTE_NH_F_PERVASIVE = RTNH_F_PERVASIVE, /*< Recursive gateway lookup */
149 DAO_NETLINK_ROUTE_NH_F_ONLINK = RTNH_F_ONLINK, /*< Gateway is forces on link */
151
159
162
165
168
171
174 struct in6_addr dst_in6_addr; /*< Route IP address for dst */
175
176 /* If is_route_info_valid */
177 struct {
178 int is_default_route;
179 uint32_t route_flags; /*< route flags */
180 int route_table_id; /*< route table id */
181 dao_netlink_route_proto_t route_proto; /*< Route proto */
182 dao_netlink_route_types_t route_type; /*< route type */
183 };
184
185 /* If is_next_hop == 1 */
186 struct {
187 int via_addr_prefixlen;
188 struct in6_addr via_in6_addr;
191 uint8_t nh_weights; /*< If nh_attr == DAO_NETLINK_ROUTE_NH_ATTR_WEIGHT */
192 uint16_t nh_from_realms; /*< If nh_attr == DAO_NETLINK_ROUTE_NH_ATTR_REALMS */
193 uint16_t nh_to_realms; /*< If nh_attr == DAO_NETLINK_ROUTE_NH_ATTR_REALMS */
194 };
196
198typedef enum {
199#define _(n, state) DAO_NETLINK_NEIGHBOR_STATE_##state = NUD_##state,
200
202#undef _
204
205#define DAO_NETLINK_NEIGHBOR_STATE_VALID \
206 (DAO_NETLINK_NEIGHBOR_STATE_PERMANENT | DAO_NETLINK_NEIGHBOR_STATE_REACHABLE | \
207 DAO_NETLINK_NEIGHBOR_STATE_NOARP)
208
216
219
222
225
230 dao_netlink_neigh_state_t neigh_state; /*< Neigh state */
231 dao_netlink_route_types_t neigh_type;
232 struct in6_addr dst_in6_addr; /*< Peer IP address */
233 uint8_t neigh_ll_addr[RTE_ETHER_ADDR_LEN]; /*< Peer ether address */
235
253
296 int (*get_app_interface_cookie)(const char *interface_name, int linux_ifindex,
297 uint32_t *cookie);
298
311 int (*ip_local_addr_add_del)(dao_netlink_route_ip_addr_t *dao_ip_addr, int is_add);
312
325 int (*ip_neigh_add_del)(dao_netlink_route_ip_neigh_t *dao_ip_neigh, int is_add);
326
339 int (*link_add_del)(dao_netlink_route_link_t *dao_link, int is_add);
340
354 dao_netlink_action_t action);
356
357/* Function declaration */
358
367
388 const char *prefix_interface_name);
389
390#ifdef __cplusplus
391}
392#endif
393#endif