FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
wireguard_if.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Cisco and/or its affiliates.
3  * Copyright (c) 2020 Doc.ai and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <vnet/adj/adj_midchain.h>
18 #include <vnet/udp/udp.h>
19 
21 #include <wireguard/wireguard_if.h>
22 #include <wireguard/wireguard.h>
24 
25 /* pool of interfaces */
27 
28 /* bitmap of Allocated WG_ITF instances */
30 
31 /* vector of interfaces key'd on their sw_if_index */
33 
34 /* vector of interfaces key'd on their UDP port (in network order) */
36 
37 static u8 *
38 format_wg_if_name (u8 * s, va_list * args)
39 {
40  u32 dev_instance = va_arg (*args, u32);
41  return format (s, "wg%d", dev_instance);
42 }
43 
44 u8 *
45 format_wg_if (u8 * s, va_list * args)
46 {
47  index_t wgii = va_arg (*args, u32);
48  wg_if_t *wgi = wg_if_get (wgii);
49  noise_local_t *local = noise_local_get (wgi->local_idx);
51 
52 
53  s = format (s, "[%d] %U src:%U port:%d",
54  wgii,
56  wgi->sw_if_index, format_ip_address, &wgi->src_ip, wgi->port);
57 
59 
60  s = format (s, " private-key:%s", key);
61  s =
62  format (s, " %U", format_hex_bytes, local->l_private,
64 
66 
67  s = format (s, " public-key:%s", key);
68 
69  s =
70  format (s, " %U", format_hex_bytes, local->l_public,
72 
73  s = format (s, " mac-key: %U", format_hex_bytes,
75 
76  return (s);
77 }
78 
79 index_t
81 {
83  return INDEX_INVALID;
85  if (ti == ~0)
86  return INDEX_INVALID;
87 
88  return (ti);
89 }
90 
91 static walk_rc_t
93 {
94  uint8_t *public = data;
95  wg_peer_t *peer = wg_peer_get (peeri);
96 
97  if (!memcmp (peer->remote.r_public, public, NOISE_PUBLIC_KEY_LEN))
98  return (WALK_STOP);
99  return (WALK_CONTINUE);
100 }
101 
102 static noise_remote_t *
103 wg_remote_get (const uint8_t public[NOISE_PUBLIC_KEY_LEN])
104 {
105  index_t peeri;
106 
107  peeri = wg_peer_walk (wg_if_find_peer_by_public_key, (void *) public);
108 
109  if (INDEX_INVALID != peeri)
110  return &wg_peer_get (peeri)->remote;
111 
112  return NULL;
113 }
114 
115 static uint32_t
117 {
118  wg_main_t *wmp = &wg_main;
119  u32 rnd_seed = (u32) (vlib_time_now (wmp->vlib_main) * 1e6);
120  u32 ret =
121  wg_index_table_add (&wmp->index_table, remote->r_peer_idx, rnd_seed);
122  return ret;
123 }
124 
125 static void
126 wg_index_drop (uint32_t key)
127 {
128  wg_main_t *wmp = &wg_main;
130 }
131 
132 static clib_error_t *
134 {
136  index_t wgii;
137  u32 hw_flags;
138 
139  hi = vnet_get_hw_interface (vnm, hw_if_index);
140  hw_flags = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP ?
142  vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
143 
144  wgii = wg_if_find_by_sw_if_index (hi->sw_if_index);
145 
147 
148  return (NULL);
149 }
150 
151 void
153 {
154  /* The peers manage the adjacencies */
155 }
156 
157 
158 /* *INDENT-OFF* */
159 VNET_DEVICE_CLASS (wg_if_device_class) = {
160  .name = "Wireguard Tunnel",
161  .format_device_name = format_wg_if_name,
162  .admin_up_down_function = wg_if_admin_up_down,
163 };
164 
165 VNET_HW_INTERFACE_CLASS(wg_hw_interface_class) = {
166  .name = "Wireguard",
167  .update_adjacency = wg_if_update_adj,
169 };
170 /* *INDENT-ON* */
171 
172 /*
173  * Maintain a bitmap of allocated wg_if instance numbers.
174  */
175 #define WG_ITF_MAX_INSTANCE (16 * 1024)
176 
177 static u32
179 {
180  /*
181  * Check for dynamically allocated instance number.
182  */
183  if (~0 == want)
184  {
185  u32 bit;
186 
188  if (bit >= WG_ITF_MAX_INSTANCE)
189  {
190  return ~0;
191  }
193  return bit;
194  }
195 
196  /*
197  * In range?
198  */
199  if (want >= WG_ITF_MAX_INSTANCE)
200  {
201  return ~0;
202  }
203 
204  /*
205  * Already in use?
206  */
207  if (clib_bitmap_get (wg_if_instances, want))
208  {
209  return ~0;
210  }
211 
212  /*
213  * Grant allocation request.
214  */
216 
217  return want;
218 }
219 
220 static int
222 {
224  {
225  return -1;
226  }
227 
229  {
230  return -1;
231  }
232 
234  return 0;
235 }
236 
237 
238 int
239 wg_if_create (u32 user_instance,
241  u16 port, const ip_address_t * src_ip, u32 * sw_if_indexp)
242 {
243  vnet_main_t *vnm = vnet_get_main ();
244  u32 instance, hw_if_index;
246  wg_if_t *wg_if;
247  noise_local_t *local;
248 
249  ASSERT (sw_if_indexp);
250 
251  *sw_if_indexp = (u32) ~ 0;
252 
253  /*
254  * Check if the required port is already in use
255  */
257  if (pi)
258  return VNET_API_ERROR_UDP_PORT_TAKEN;
259 
260  /*
261  * Allocate a wg_if instance. Either select on dynamically
262  * or try to use the desired user_instance number.
263  */
264  instance = wg_if_instance_alloc (user_instance);
265  if (instance == ~0)
266  return VNET_API_ERROR_INVALID_REGISTRATION;
267 
268  /* *INDENT-OFF* */
269  struct noise_upcall upcall = {
270  .u_remote_get = wg_remote_get,
271  .u_index_set = wg_index_set,
272  .u_index_drop = wg_index_drop,
273  };
274  /* *INDENT-ON* */
275 
276  pool_get (noise_local_pool, local);
277 
278  noise_local_init (local, &upcall);
279  if (!noise_local_set_private (local, private_key))
280  {
281  pool_put (noise_local_pool, local);
283  return VNET_API_ERROR_INVALID_REGISTRATION;
284  }
285 
286  pool_get (wg_if_pool, wg_if);
287 
288  /* tunnel index (or instance) */
289  u32 t_idx = wg_if - wg_if_pool;
290 
291  wg_if->user_instance = instance;
292  if (~0 == wg_if->user_instance)
293  wg_if->user_instance = t_idx;
294 
296 
299 
300  wg_if->port = port;
301  wg_if->local_idx = local - noise_local_pool;
303 
304  hw_if_index = vnet_register_interface (vnm,
305  wg_if_device_class.index,
306  t_idx,
307  wg_hw_interface_class.index, t_idx);
308 
309  hi = vnet_get_hw_interface (vnm, hw_if_index);
310 
312  INDEX_INVALID);
313  wg_if_index_by_sw_if_index[hi->sw_if_index] = t_idx;
314 
315  ip_address_copy (&wg_if->src_ip, src_ip);
316  wg_if->sw_if_index = *sw_if_indexp = hi->sw_if_index;
317 
318  return 0;
319 }
320 
321 int
323 {
324  vnet_main_t *vnm = vnet_get_main ();
325 
327  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
328 
330  if (hw == 0 || hw->dev_class_index != wg_if_device_class.index)
331  return VNET_API_ERROR_INVALID_VALUE;
332 
333  wg_if_t *wg_if;
335  if (NULL == wg_if)
336  return VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
337 
338  if (wg_if_instance_free (wg_if->user_instance) < 0)
339  return VNET_API_ERROR_INVALID_VALUE_2;
340 
345  pool_put (wg_if_pool, wg_if);
346 
347  return 0;
348 }
349 
350 void
352 {
353  hash_set (wgi->peers, peeri, peeri);
354 
355  if (1 == hash_elts (wgi->peers))
356  vnet_feature_enable_disable ("ip4-output", "wg-output-tun",
357  wgi->sw_if_index, 1, 0, 0);
358 }
359 
360 void
362 {
363  hash_unset (wgi->peers, peeri);
364 
365  if (0 == hash_elts (wgi->peers))
366  vnet_feature_enable_disable ("ip4-output", "wg-output-tun",
367  wgi->sw_if_index, 0, 0, 0);
368 }
369 
370 void
372 {
373  index_t wgii;
374 
375  /* *INDENT-OFF* */
377  {
378  if (WALK_STOP == fn(wgii, data))
379  break;
380  }
381  /* *INDENT-ON* */
382 }
383 
384 index_t
386 {
387  index_t peeri, val;
388 
389  /* *INDENT-OFF* */
390  hash_foreach (peeri, val, wgi->peers,
391  {
392  if (WALK_STOP == fn(wgi, peeri, data))
393  return peeri;
394  });
395  /* *INDENT-ON* */
396 
397  return INDEX_INVALID;
398 }
399 
400 
401 static void
403  uword opaque,
404  u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
405 {
406  wg_if_t *wg_if;
407 
409  if (NULL == wg_if)
410  return;
411 
413  .af = AF_IP4,
414  .old_fib_index = old_fib_index,
415  .new_fib_index = new_fib_index,
416  };
417 
419 }
420 
421 static void
423  uword opaque,
424  u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
425 {
426  wg_if_t *wg_if;
427 
429  if (NULL == wg_if)
430  return;
431 
433  .af = AF_IP6,
434  .old_fib_index = old_fib_index,
435  .new_fib_index = new_fib_index,
436  };
437 
439 }
440 
441 static clib_error_t *
443 {
444  {
447  };
449  }
450  {
453  };
455  }
456 
457  return (NULL);
458 }
459 
460 /* *INDENT-OFF* */
462 {
463  .runs_after = VLIB_INITS("ip_main_init"),
464 };
465 /* *INDENT-ON* */
466 
467 
468 /*
469  * fd.io coding-style-patch-verification: ON
470  *
471  * Local Variables:
472  * eval: (c-set-style "gnu")
473  * End:
474  */
ip_address
Definition: ip_types.h:79
wg_peer_if_table_change
walk_rc_t wg_peer_if_table_change(wg_if_t *wgi, index_t peeri, void *data)
Definition: wireguard_peer.c:194
im
vnet_interface_main_t * im
Definition: interface_output.c:395
adj_midchain.h
wg_index_table_add
u32 wg_index_table_add(wg_index_table_t *table, u32 peer_pool_idx, u32 rnd_seed)
Definition: wireguard_index_table.c:22
wg_if_get
static_always_inline wg_if_t * wg_if_get(index_t wgii)
Definition: wireguard_if.h:68
wg_if_pool
wg_if_t * wg_if_pool
Data-plane exposed functions.
Definition: wireguard_if.c:26
wg_if_t_::src_ip
ip_address_t src_ip
Definition: wireguard_if.h:37
udp_dst_port_info_t
Definition: udp.h:69
NOISE_KEY_LEN_BASE64
#define NOISE_KEY_LEN_BASE64
Definition: wireguard_messages.h:26
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
wg_if_create
int wg_if_create(u32 user_instance, const u8 private_key[NOISE_PUBLIC_KEY_LEN], u16 port, const ip_address_t *src_ip, u32 *sw_if_indexp)
Definition: wireguard_if.c:239
ip4_main_t::table_bind_callbacks
ip4_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
Definition: ip4.h:148
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
wg_if_instance_free
static int wg_if_instance_free(u32 instance)
Definition: wireguard_if.c:221
private_key
u8 private_key[32]
Definition: wireguard.api:35
wg_if_t_::peers
uword * peers
Definition: wireguard_if.h:40
format_hex_bytes
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
wg_main_t::index_table
wg_index_table_t index_table
Definition: wireguard.h:38
wg_if_instances
static uword * wg_if_instances
Definition: wireguard_if.c:29
u16
unsigned short u16
Definition: types.h:57
wg_peer_table_bind_ctx_t_
Definition: wireguard_peer.h:94
wg_if_table_bind_v6
static void wg_if_table_bind_v6(ip6_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
Definition: wireguard_if.c:422
VNET_SW_INTERFACE_FLAG_ADMIN_UP
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:843
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
wg_if_walk_cb_t
walk_rc_t(* wg_if_walk_cb_t)(index_t wgi, void *data)
Definition: wireguard_if.h:52
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
AF_IP4
@ AF_IP4
Definition: ip_types.h:23
VNET_HW_INTERFACE_FLAG_LINK_UP
@ VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:509
port
u16 port
Definition: lb_types.api:73
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
wg_if_instance_alloc
static u32 wg_if_instance_alloc(u32 want)
Definition: wireguard_if.c:178
wg_peer_if_admin_state_change
walk_rc_t wg_peer_if_admin_state_change(wg_if_t *wgi, index_t peeri, void *data)
Definition: wireguard_peer.c:186
wg_if_peer_remove
void wg_if_peer_remove(wg_if_t *wgi, index_t peeri)
Definition: wireguard_if.c:361
noise_local::l_private
uint8_t l_private[NOISE_PUBLIC_KEY_LEN]
Definition: wireguard_noise.h:118
wg_remote_get
static noise_remote_t * wg_remote_get(const uint8_t public[NOISE_PUBLIC_KEY_LEN])
Definition: wireguard_if.c:103
pool_put_index
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:337
clib_bitmap_first_clear
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
Definition: bitmap.h:451
format_wg_if
u8 * format_wg_if(u8 *s, va_list *args)
Definition: wireguard_if.c:45
ip6_table_bind_callback_t::function
ip6_table_bind_function_t * function
Definition: ip6.h:106
key
typedef key
Definition: ipsec_types.api:88
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
UDP_IP4
@ UDP_IP4
Definition: udp.h:93
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
wg_if_t_::port
u16 port
Definition: wireguard_if.h:32
ti
u32 ti
Definition: interface_output.c:405
wireguard_peer.h
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
clib_bitmap_get
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
Definition: bitmap.h:197
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
wg_if_t_::cookie_checker
cookie_checker_t cookie_checker
Definition: wireguard_if.h:31
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
wg_if_find_by_sw_if_index
index_t wg_if_find_by_sw_if_index(u32 sw_if_index)
Definition: wireguard_if.c:80
wg_input_node
vlib_node_registration_t wg_input_node
(constructor) VLIB_REGISTER_NODE (wg_input_node)
Definition: wireguard_input.c:452
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
peer
vl_api_address_t peer
Definition: teib.api:28
format_ip_address
u8 * format_ip_address(u8 *s, va_list *args)
Definition: ip_types.c:21
uword
u64 uword
Definition: types.h:112
vnet_delete_hw_interface
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:1052
vnet_hw_interface_t::dev_class_index
u32 dev_class_index
Definition: interface.h:659
noise_remote
Definition: wireguard_noise.h:99
wg_peer
Definition: wireguard_peer.h:48
ip6_main_t::table_bind_callbacks
ip6_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
Definition: ip6.h:151
hash_foreach
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:441
format_wg_if_name
static u8 * format_wg_if_name(u8 *s, va_list *args)
Definition: wireguard_if.c:38
udp_register_dst_port
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
Definition: udp_local.c:468
wg_if_peer_walk
index_t wg_if_peer_walk(wg_if_t *wgi, wg_if_peer_walk_cb_t fn, void *data)
Definition: wireguard_if.c:385
wg_if_peer_walk_cb_t
walk_rc_t(* wg_if_peer_walk_cb_t)(wg_if_t *wgi, index_t peeri, void *data)
Definition: wireguard_if.h:55
udp_unregister_dst_port
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp_local.c:506
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
wg_if_index_by_sw_if_index
static index_t * wg_if_index_by_sw_if_index
Definition: wireguard_if.c:32
wg_main
wg_main_t wg_main
Definition: wireguard.c:26
wg_if_index_by_port
index_t * wg_if_index_by_port
Definition: wireguard_if.c:35
wg_if_delete
int wg_if_delete(u32 sw_if_index)
Definition: wireguard_if.c:322
wg_if_t_
Definition: wireguard_if.h:23
clib_bitmap_set
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap.
Definition: bitmap.h:167
VNET_HW_INTERFACE_CLASS
VNET_HW_INTERFACE_CLASS(wg_hw_interface_class)
wg_if_walk
void wg_if_walk(wg_if_walk_cb_t fn, void *data)
Definition: wireguard_if.c:371
ip6_table_bind_callback_t
Definition: ip6.h:104
vnet_interface_main_t::sw_interfaces
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:1014
ip4_table_bind_callback_t
Definition: ip4.h:92
noise_local_pool
noise_local_t * noise_local_pool
Definition: wireguard_noise.c:29
wireguard_messages.h
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2787
data
u8 data[128]
Definition: ipsec_types.api:92
wg_if_t_::user_instance
int user_instance
Definition: wireguard_if.h:25
hash_elts
static uword hash_elts(void *v)
Definition: hash.h:118
wg_if_module_init
static clib_error_t * wg_if_module_init(vlib_main_t *vm)
Definition: wireguard_if.c:442
wg_main_t::vlib_main
vlib_main_t * vlib_main
Definition: wireguard.h:34
wg_main_t
Definition: wireguard.h:31
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
key_to_base64
bool key_to_base64(const u8 *src, size_t src_len, u8 *out)
Definition: wireguard_key.c:104
cookie_checker::cc_mac1_key
uint8_t cc_mac1_key[COOKIE_KEY_SIZE]
Definition: wireguard_cookie.h:75
wg_if_admin_up_down
static clib_error_t * wg_if_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: wireguard_if.c:133
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:576
noise_local_get
static_always_inline noise_local_t * noise_local_get(uint32_t locali)
Definition: wireguard_noise.h:134
wg_index_set
static uint32_t wg_index_set(noise_remote_t *remote)
Definition: wireguard_if.c:116
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:455
udp_main
udp_main_t udp_main
Definition: udp.c:23
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
noise_local
Definition: wireguard_noise.h:115
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
NOISE_PUBLIC_KEY_LEN
#define NOISE_PUBLIC_KEY_LEN
Definition: wireguard_noise.h:26
VNET_DEVICE_CLASS
VNET_DEVICE_CLASS(wg_if_device_class)
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vnet_get_sup_hw_interface
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:92
wg_peer::remote
noise_remote_t remote
Definition: wireguard_peer.h:50
wg_if_update_adj
void wg_if_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: wireguard_if.c:152
wg_index_drop
static void wg_index_drop(uint32_t key)
Definition: wireguard_if.c:126
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
instance
u32 instance
Definition: gre.api:51
AF_IP6
@ AF_IP6
Definition: ip_types.h:24
ip4_table_bind_callback_t::function
ip4_table_bind_function_t * function
Definition: ip4.h:94
udp.h
noise_remote::r_peer_idx
uint32_t r_peer_idx
Definition: wireguard_noise.h:101
src_ip
vl_api_address_t src_ip
Definition: wireguard.api:38
wg_if_table_bind_v4
static void wg_if_table_bind_v4(ip4_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
Definition: wireguard_if.c:402
wg_if_find_peer_by_public_key
static walk_rc_t wg_if_find_peer_by_public_key(index_t peeri, void *data)
Definition: wireguard_if.c:92
ip6_main_t
Definition: ip6.h:110
vnet_feature_enable_disable
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: pnat_test_stubs.h:50
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
udp_get_dst_port_info
static udp_dst_port_info_t * udp_get_dst_port_info(udp_main_t *um, udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp.h:228
vlib_main_t
Definition: main.h:102
VLIB_INITS
#define VLIB_INITS(...)
Definition: init.h:352
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vnet_hw_interface_set_flags
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:513
wireguard.h
noise_local::l_public
uint8_t l_public[NOISE_PUBLIC_KEY_LEN]
Definition: wireguard_noise.h:117
noise_local_init
void noise_local_init(noise_local_t *l, struct noise_upcall *upcall)
Definition: wireguard_noise.c:74
WG_ITF_MAX_INSTANCE
#define WG_ITF_MAX_INSTANCE
Definition: wireguard_if.c:175
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
wg_peer_get
static wg_peer_t * wg_peer_get(index_t peeri)
Definition: wireguard_peer.h:125
wg_index_table_del
void wg_index_table_del(wg_index_table_t *table, u32 key)
Definition: wireguard_index_table.c:39
vnet_hw_interface_t::hw_if_index
u32 hw_if_index
Definition: interface.h:667
wireguard_if.h
wg_if_t_::sw_if_index
u32 sw_if_index
Definition: wireguard_if.h:26
noise_local_set_private
bool noise_local_set_private(noise_local_t *l, const uint8_t private[NOISE_PUBLIC_KEY_LEN])
Definition: wireguard_noise.c:81
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
VNET_HW_INTERFACE_CLASS_FLAG_NBMA
@ VNET_HW_INTERFACE_CLASS_FLAG_NBMA
a non-broadcast multiple access interface
Definition: interface.h:398
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
ip_address_copy
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
Definition: ip_types.c:133
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
wg_if_peer_add
void wg_if_peer_add(wg_if_t *wgi, index_t peeri)
Definition: wireguard_if.c:351
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
wg_if_t_::local_idx
u32 local_idx
Definition: wireguard_if.h:30
WALK_STOP
@ WALK_STOP
Definition: interface_funcs.h:173
vnet_register_interface
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
Definition: interface.c:812
vnet_main_t::interface_main
vnet_interface_main_t interface_main
Definition: vnet.h:81
wg_peer_walk
index_t wg_peer_walk(wg_peer_walk_cb_t fn, void *data)
Definition: wireguard_peer.c:361
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105