2 * Copyright (c) 2019 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vlib/vlib.h>
18 #include <netlink/route/link.h>
19 #include <netlink/route/route.h>
20 #include <netlink/route/neighbour.h>
21 #include <netlink/route/addr.h>
23 typedef void (*nl_rt_link_cb_t) (struct rtnl_link *rl, void *ctx);
24 typedef void (*nl_rt_link_sync_cb_t) (void);
25 typedef void (*nl_rt_addr_cb_t) (struct rtnl_addr *ra);
26 typedef void (*nl_rt_addr_sync_cb_t) (void);
27 typedef void (*nl_rt_neigh_cb_t) (struct rtnl_neigh *rr);
28 typedef void (*nl_rt_neigh_sync_cb_t) (void);
29 typedef void (*nl_rt_route_cb_t) (struct rtnl_route *rn);
30 typedef void (*nl_rt_route_sync_cb_t) (void);
32 #define NL_RT_COMMON uword is_mp_safe
34 typedef struct nl_rt_link_t_
41 typedef struct nl_rt_link_sync_t_
45 nl_rt_link_sync_cb_t cb;
48 typedef struct nl_rt_addr_t_
55 typedef struct nl_rt_addr_sync_t_
59 nl_rt_addr_sync_cb_t cb;
62 typedef struct nl_rt_neigh_t_
69 typedef struct nl_rt_neigh_sync_t_
73 nl_rt_neigh_sync_cb_t cb;
76 typedef struct nl_rt_route_t_
83 typedef struct nl_rt_route_sync_t_
87 nl_rt_route_sync_cb_t cb;
92 typedef struct nl_vft_t_
94 nl_rt_link_t nvl_rt_link_add;
95 nl_rt_link_t nvl_rt_link_del;
96 nl_rt_link_sync_t nvl_rt_link_sync_begin;
97 nl_rt_link_sync_t nvl_rt_link_sync_end;
98 nl_rt_addr_t nvl_rt_addr_add;
99 nl_rt_addr_t nvl_rt_addr_del;
100 nl_rt_addr_sync_t nvl_rt_addr_sync_begin;
101 nl_rt_addr_sync_t nvl_rt_addr_sync_end;
102 nl_rt_neigh_t nvl_rt_neigh_add;
103 nl_rt_neigh_t nvl_rt_neigh_del;
104 nl_rt_neigh_sync_t nvl_rt_neigh_sync_begin;
105 nl_rt_neigh_sync_t nvl_rt_neigh_sync_end;
106 nl_rt_route_t nvl_rt_route_add;
107 nl_rt_route_t nvl_rt_route_del;
108 nl_rt_route_sync_t nvl_rt_route_sync_begin;
109 nl_rt_route_sync_t nvl_rt_route_sync_end;
112 extern void nl_register_vft (const nl_vft_t *nv);
114 typedef enum lcp_nl_obj_t_
122 /* struct type to hold context on the netlink message being processed.
124 * At creation of a pair, a tap/tun is created and configured to match its
125 * corresponding hardware interface (MAC address, link state, MTU). Netlink
126 * messages are sent announcing the creation and subsequent configuration.
127 * We do not need to (and should not) act on those messages since applying
128 * those same configurations again is unnecessary and can be disruptive. So
129 * a timestamp for a message is stored and can be compared against the time
130 * the interface came under linux-cp management in order to figure out
131 * whether we should apply any configuration.
133 typedef struct nl_msg_info
139 #define LCP_NL_N_OBJS (LCP_NL_ROUTE + 1)
141 extern struct nl_cache *lcp_nl_get_cache (lcp_nl_obj_t t);
142 extern int lcp_nl_drain_messages (void);
143 extern void lcp_nl_set_buffer_size (u32 buf_size);
144 extern void lcp_nl_set_batch_size (u32 batch_size);
145 extern void lcp_nl_set_batch_delay (u32 batch_delay_ms);
148 * fd.io coding-style-patch-verification: ON
151 * eval: (c-set-style "gnu")