FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
udp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #include <vnet/udp/udp.h>
17 #include <vnet/session/session.h>
18 #include <vnet/dpo/load_balance.h>
19 #include <vnet/ip/ip4_inlines.h>
20 #include <vnet/ip/ip6_inlines.h>
21 #include <vppinfra/sparse_vec.h>
22 
24 
25 static void
27 {
28  udp_main_t *um = &udp_main;
30  u16 *n;
31 
32  pi = udp_get_dst_port_info (um, lcl_port, is_ip4);
33  if (!pi)
34  {
35  udp_add_dst_port (um, lcl_port, 0, is_ip4);
36  pi = udp_get_dst_port_info (um, lcl_port, is_ip4);
37  pi->n_connections = 1;
38  }
39  else
40  {
41  pi->n_connections += 1;
42  /* Do not return. The fact that the pi is valid does not mean
43  * it's up to date */
44  }
45 
46  pi->node_index = is_ip4 ? udp4_input_node.index : udp6_input_node.index;
47  pi->next_index = um->local_to_input_edge[is_ip4];
48 
49  /* Setup udp protocol -> next index sparse vector mapping. */
50  if (is_ip4)
52  clib_host_to_net_u16 (lcl_port));
53  else
55  clib_host_to_net_u16 (lcl_port));
56 
57  n[0] = pi->next_index;
58 }
59 
60 static void
62 {
63  udp_main_t *um = &udp_main;
65 
66  pi = udp_get_dst_port_info (um, lcl_port, is_ip4);
67  if (!pi)
68  return;
69 
70  if (!pi->n_connections)
71  {
72  clib_warning ("no connections using port %u", lcl_port);
73  return;
74  }
75 
76  if (!clib_atomic_sub_fetch (&pi->n_connections, 1))
77  udp_unregister_dst_port (0, lcl_port, is_ip4);
78 }
79 
80 void
81 udp_connection_share_port (u16 lcl_port, u8 is_ip4)
82 {
83  udp_main_t *um = &udp_main;
85 
86  /* Done without a lock but the operation is atomic. Writers to pi hash
87  * table and vector should be guarded by a barrier sync */
88  pi = udp_get_dst_port_info (um, lcl_port, is_ip4);
90 }
91 
94 {
95  udp_main_t *um = &udp_main;
96  udp_connection_t *uc;
97  u32 will_expand = 0;
100 
101  if (PREDICT_FALSE (will_expand))
102  {
104  [thread_index]);
108  [thread_index]);
109  }
110  else
111  {
114  }
115  clib_memset (uc, 0, sizeof (*uc));
116  uc->c_c_index = uc - um->connections[thread_index];
117  uc->c_thread_index = thread_index;
118  uc->c_proto = TRANSPORT_PROTO_UDP;
119  return uc;
120 }
121 
122 void
124 {
125  u32 thread_index = uc->c_thread_index;
127  if (CLIB_DEBUG)
128  clib_memset (uc, 0xFA, sizeof (*uc));
130 }
131 
132 static void
134 {
135  transport_endpoint_cleanup (TRANSPORT_PROTO_UDP, &uc->c_lcl_ip,
136  uc->c_lcl_port);
137  udp_connection_unregister_port (clib_net_to_host_u16 (uc->c_lcl_port),
138  uc->c_is_ip4);
139  udp_connection_free (uc);
140 }
141 
142 void
144 {
147 }
148 
149 static u8
151 {
152  udp_main_t *um = vnet_get_udp_main ();
154 
155  pi = udp_get_dst_port_info (um, lcl_port, is_ip4);
156  return (pi && !pi->n_connections
157  && udp_is_valid_dst_port (lcl_port, is_ip4));
158 }
159 
160 static u16
162 {
163  u16 ip_hlen = is_ip4 ? sizeof (ip4_header_t) : sizeof (ip6_header_t);
164  return (um->default_mtu - sizeof (udp_header_t) - ip_hlen);
165 }
166 
167 static u32
169 {
170  udp_main_t *um = vnet_get_udp_main ();
172  transport_endpoint_cfg_t *lcl_ext;
174  u16 lcl_port_ho;
175  void *iface_ip;
176 
177  lcl_port_ho = clib_net_to_host_u16 (lcl->port);
178 
179  if (udp_connection_port_used_extern (lcl_port_ho, lcl->is_ip4))
180  {
181  clib_warning ("port already used");
182  return SESSION_E_PORTINUSE;
183  }
184 
186  clib_memset (listener, 0, sizeof (udp_connection_t));
187 
188  listener->c_lcl_port = lcl->port;
189  listener->c_c_index = listener - um->listener_pool;
190 
191  /* If we are provided a sw_if_index, bind using one of its ips */
192  if (ip_is_zero (&lcl->ip, 1) && lcl->sw_if_index != ENDPOINT_INVALID_INDEX)
193  {
194  if ((iface_ip = ip_interface_get_first_ip (lcl->sw_if_index,
195  lcl->is_ip4)))
196  ip_set (&lcl->ip, iface_ip, lcl->is_ip4);
197  }
198  ip_copy (&listener->c_lcl_ip, &lcl->ip, lcl->is_ip4);
199  listener->c_is_ip4 = lcl->is_ip4;
200  listener->c_proto = TRANSPORT_PROTO_UDP;
201  listener->c_s_index = session_index;
202  listener->c_fib_index = lcl->fib_index;
203  listener->mss = udp_default_mtu (um, listener->c_is_ip4);
204  listener->flags |= UDP_CONN_F_OWNS_PORT | UDP_CONN_F_LISTEN;
205  lcl_ext = (transport_endpoint_cfg_t *) lcl;
206  if (lcl_ext->transport_flags & TRANSPORT_CFG_F_CONNECTED)
207  listener->flags |= UDP_CONN_F_CONNECTED;
208  else
210  clib_spinlock_init (&listener->rx_lock);
211 
212  udp_connection_register_port (vm, lcl_port_ho, lcl->is_ip4);
213  return listener->c_c_index;
214 }
215 
216 static u32
217 udp_session_unbind (u32 listener_index)
218 {
219  udp_main_t *um = &udp_main;
221 
222  listener = udp_listener_get (listener_index);
223  udp_connection_unregister_port (clib_net_to_host_u16 (listener->c_lcl_port),
224  listener->c_is_ip4);
225  clib_spinlock_free (&listener->rx_lock);
227  return 0;
228 }
229 
230 static transport_connection_t *
232 {
233  udp_connection_t *us;
234 
235  us = udp_listener_get (listener_index);
236  return &us->connection;
237 }
238 
239 static u32
241 {
242  udp_connection_t *uc;
244 
246 
247  vlib_buffer_push_udp (b, uc->c_lcl_port, uc->c_rmt_port, 1);
248  if (tc->is_ip4)
249  vlib_buffer_push_ip4_custom (vm, b, &uc->c_lcl_ip4, &uc->c_rmt_ip4,
250  IP_PROTOCOL_UDP, 1 /* csum offload */ ,
251  0 /* is_df */ );
252  else
253  vlib_buffer_push_ip6 (vm, b, &uc->c_lcl_ip6, &uc->c_rmt_ip6,
254  IP_PROTOCOL_UDP);
255  vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
256  vnet_buffer (b)->sw_if_index[VLIB_TX] = uc->c_fib_index;
257  b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
258 
259  if (PREDICT_FALSE (uc->flags & UDP_CONN_F_CLOSING))
260  {
263  }
264 
265  return 0;
266 }
267 
268 static transport_connection_t *
269 udp_session_get (u32 connection_index, u32 thread_index)
270 {
271  udp_connection_t *uc;
272  uc = udp_connection_get (connection_index, thread_index);
273  if (uc)
274  return &uc->connection;
275  return 0;
276 }
277 
278 static void
280 {
281  udp_connection_t *uc;
282 
283  uc = udp_connection_get (connection_index, thread_index);
284  if (!uc)
285  return;
286 
289  else
290  uc->flags |= UDP_CONN_F_CLOSING;
291 }
292 
293 static void
295 {
296  udp_connection_t *uc;
297  uc = udp_connection_get (connection_index, thread_index);
298  if (!uc)
299  return;
300  if (uc->flags & UDP_CONN_F_MIGRATED)
301  udp_connection_free (uc);
302  else
304 }
305 
306 static int
309 {
310  udp_connection_t *uc;
311 
312  uc = udp_connection_from_transport (tconn);
313 
314  /* No constraint on TX window */
315  sp->snd_space = ~0;
316  /* TODO figure out MTU of output interface */
317  sp->snd_mss = uc->mss;
318  sp->tx_offset = 0;
319  sp->flags = 0;
320  return 0;
321 }
322 
323 static int
325 {
328  udp_main_t *um = &udp_main;
329  ip46_address_t lcl_addr;
330  udp_connection_t *uc;
331  u16 lcl_port;
332  int rv;
333 
334  rv = transport_alloc_local_endpoint (TRANSPORT_PROTO_UDP, rmt, &lcl_addr,
335  &lcl_port);
336  if (rv)
337  {
338  if (rv != SESSION_E_PORTINUSE)
339  return rv;
340 
341  if (udp_connection_port_used_extern (lcl_port, rmt->is_ip4))
342  return SESSION_E_PORTINUSE;
343 
344  /* If port in use, check if 5-tuple is also in use */
345  if (session_lookup_connection (rmt->fib_index, &lcl_addr, &rmt->ip,
346  lcl_port, rmt->port, TRANSPORT_PROTO_UDP,
347  rmt->is_ip4))
348  return SESSION_E_PORTINUSE;
349 
350  /* 5-tuple is available so increase lcl endpoint refcount and proceed
351  * with connection allocation */
352  transport_share_local_endpoint (TRANSPORT_PROTO_UDP, &lcl_addr,
353  lcl_port);
354  goto conn_alloc;
355  }
356 
357  if (udp_is_valid_dst_port (lcl_port, rmt->is_ip4))
358  {
359  /* If specific source port was requested abort */
360  if (rmt->peer.port)
361  return SESSION_E_PORTINUSE;
362 
363  /* Try to find a port that's not used */
364  while (udp_is_valid_dst_port (lcl_port, rmt->is_ip4))
365  {
366  lcl_port = transport_alloc_local_port (TRANSPORT_PROTO_UDP,
367  &lcl_addr);
368  if (lcl_port < 1)
369  return SESSION_E_PORTINUSE;
370  }
371  }
372 
373 conn_alloc:
374 
375  udp_connection_register_port (vm, lcl_port, rmt->is_ip4);
376 
377  /* We don't poll main thread if we have workers */
379 
381  ip_copy (&uc->c_rmt_ip, &rmt->ip, rmt->is_ip4);
382  ip_copy (&uc->c_lcl_ip, &lcl_addr, rmt->is_ip4);
383  uc->c_rmt_port = rmt->port;
384  uc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
385  uc->c_is_ip4 = rmt->is_ip4;
386  uc->c_proto = TRANSPORT_PROTO_UDP;
387  uc->c_fib_index = rmt->fib_index;
388  uc->mss = rmt->mss ? rmt->mss : udp_default_mtu (um, uc->c_is_ip4);
389  uc->flags |= UDP_CONN_F_OWNS_PORT;
390  if (rmt->transport_flags & TRANSPORT_CFG_F_CONNECTED)
391  {
392  uc->flags |= UDP_CONN_F_CONNECTED;
393  }
394  else
395  {
397  uc->c_flags |= TRANSPORT_CONNECTION_F_CLESS;
398  }
399 
400  return uc->c_c_index;
401 }
402 
403 static transport_connection_t *
405 {
406  udp_connection_t *uc;
408 
409  /* We don't poll main thread if we have workers */
411  uc = udp_connection_get (conn_index, thread_index);
412  if (!uc)
413  return 0;
414  return &uc->connection;
415 }
416 
417 static u8 *
418 format_udp_session (u8 * s, va_list * args)
419 {
420  u32 uci = va_arg (*args, u32);
421  u32 thread_index = va_arg (*args, u32);
422  u32 verbose = va_arg (*args, u32);
423  udp_connection_t *uc;
424 
425  uc = udp_connection_get (uci, thread_index);
426  return format (s, "%U", format_udp_connection, uc, verbose);
427 }
428 
429 static u8 *
430 format_udp_half_open_session (u8 * s, va_list * args)
431 {
432  u32 __clib_unused tci = va_arg (*args, u32);
433  u32 __clib_unused thread_index = va_arg (*args, u32);
434  clib_warning ("BUG");
435  return 0;
436 }
437 
438 static u8 *
439 format_udp_listener_session (u8 * s, va_list * args)
440 {
441  u32 tci = va_arg (*args, u32);
442  u32 __clib_unused thread_index = va_arg (*args, u32);
443  u32 verbose = va_arg (*args, u32);
445  return format (s, "%U", format_udp_connection, uc, verbose);
446 }
447 
448 /* *INDENT-OFF* */
450  .start_listen = udp_session_bind,
451  .connect = udp_open_connection,
452  .stop_listen = udp_session_unbind,
453  .push_header = udp_push_header,
454  .get_connection = udp_session_get,
455  .get_listener = udp_session_get_listener,
456  .get_half_open = udp_session_get_half_open,
457  .close = udp_session_close,
458  .cleanup = udp_session_cleanup,
459  .send_params = udp_session_send_params,
460  .format_connection = format_udp_session,
461  .format_half_open = format_udp_half_open_session,
462  .format_listener = format_udp_listener_session,
463  .transport_options = {
464  .name = "udp",
465  .short_name = "U",
466  .tx_type = TRANSPORT_TX_DGRAM,
467  .service_type = TRANSPORT_SERVICE_CL,
468  },
469 };
470 /* *INDENT-ON* */
471 
472 static clib_error_t *
474 {
475  udp_main_t *um = vnet_get_udp_main ();
476  ip_main_t *im = &ip_main;
478  u32 num_threads;
479  ip_protocol_info_t *pi;
480  int i;
481 
482  /*
483  * Registrations
484  */
485 
486  /* IP registration */
487  pi = ip_get_protocol_info (im, IP_PROTOCOL_UDP);
488  if (pi == 0)
489  return clib_error_return (0, "UDP protocol info AWOL");
492 
493  /* Register as transport with URI */
494  transport_register_protocol (TRANSPORT_PROTO_UDP, &udp_proto,
496  transport_register_protocol (TRANSPORT_PROTO_UDP, &udp_proto,
498 
499  /*
500  * Initialize data structures
501  */
502 
503  num_threads = 1 /* main thread */ + tm->n_threads;
504  vec_validate (um->connections, num_threads - 1);
505  vec_validate (um->connection_peekers, num_threads - 1);
506  vec_validate (um->peekers_readers_locks, num_threads - 1);
507  vec_validate (um->peekers_write_locks, num_threads - 1);
508 
509  if (num_threads > 1)
510  for (i = 0; i < num_threads; i++)
511  {
514  }
515 
520 
521  um->default_mtu = 1500;
522  return 0;
523 }
524 
525 /* *INDENT-OFF* */
527 {
528  .runs_after = VLIB_INITS("ip_main_init", "ip4_lookup_init",
529  "ip6_lookup_init"),
530 };
531 /* *INDENT-ON* */
532 
533 /*
534  * fd.io coding-style-patch-verification: ON
535  *
536  * Local Variables:
537  * eval: (c-set-style "gnu")
538  * End:
539  */
load_balance.h
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
ip4_lookup_node
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
Definition: ip4_forward.c:105
im
vnet_interface_main_t * im
Definition: interface_output.c:415
transport_alloc_local_endpoint
int transport_alloc_local_endpoint(u8 proto, transport_endpoint_cfg_t *rmt_cfg, ip46_address_t *lcl_addr, u16 *lcl_port)
Definition: transport.c:583
udp_connection_t::flags
u8 flags
connection flags
Definition: udp.h:65
ip_set
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
Definition: ip.c:95
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
udp_listener_get
static udp_connection_t * udp_listener_get(u32 conn_index)
Definition: udp.h:148
udp_dst_port_info_t
Definition: udp.h:69
udp6_local_node
vlib_node_registration_t udp6_local_node
(constructor) VLIB_REGISTER_NODE (udp6_local_node)
Definition: udp_local.c:388
udp_push_header
static u32 udp_push_header(transport_connection_t *tc, vlib_buffer_t *b)
Definition: udp.c:240
vlib_node_add_next
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
vlib_buffer_push_udp
static void * vlib_buffer_push_udp(vlib_buffer_t *b, u16 sp, u16 dp, u8 offload_csum)
Definition: udp_inlines.h:26
clib_spinlock_lock_if_init
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:106
format_udp_listener_session
static u8 * format_udp_listener_session(u8 *s, va_list *args)
Definition: udp.c:439
udp_add_dst_port
void udp_add_dst_port(udp_main_t *um, udp_dst_port_t dst_port, char *dst_port_name, u8 is_ip4)
Definition: udp_local.c:411
udp_default_mtu
static u16 udp_default_mtu(udp_main_t *um, u8 is_ip4)
Definition: udp.c:161
udp_session_get
static transport_connection_t * udp_session_get(u32 connection_index, u32 thread_index)
Definition: udp.c:269
udp_connection_free
void udp_connection_free(udp_connection_t *uc)
Definition: udp.c:123
ip4_inlines.h
vlib_buffer_push_ip6
static void * vlib_buffer_push_ip6(vlib_main_t *vm, vlib_buffer_t *b, ip6_address_t *src, ip6_address_t *dst, int proto)
Push IPv6 header to buffer.
Definition: ip6_inlines.h:255
udp_session_close
static void udp_session_close(u32 connection_index, u32 thread_index)
Definition: udp.c:279
pool_get_aligned
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:249
ip_main
ip_main_t ip_main
Definition: ip_init.c:42
ip_get_protocol_info
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
Definition: ip.h:134
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
ip_protocol_info_t::format_header
format_function_t * format_header
Definition: ip.h:79
udp_init
static clib_error_t * udp_init(vlib_main_t *vm)
Definition: udp.c:473
transport_proto_vft_t
struct _transport_proto_vft transport_proto_vft_t
udp_connection_unregister_port
static void udp_connection_unregister_port(u16 lcl_port, u8 is_ip4)
Definition: udp.c:61
u16
unsigned short u16
Definition: types.h:57
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
udp4_input_node
vlib_node_registration_t udp4_input_node
(constructor) VLIB_REGISTER_NODE (udp4_input_node)
Definition: udp_input.c:346
transport_alloc_local_port
int transport_alloc_local_port(u8 proto, ip46_address_t *ip)
Allocate local port and add if successful add entry to local endpoint table to mark the pair as used.
Definition: transport.c:493
udp_main_t::local_to_input_edge
u32 local_to_input_edge[N_UDP_AF]
Definition: udp.h:113
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
listener
Definition: test_stats.cpp:7
transport_send_params_::snd_mss
u16 snd_mss
Definition: transport.h:54
udp_session_get_listener
static transport_connection_t * udp_session_get_listener(u32 listener_index)
Definition: udp.c:231
transport_connection_t
struct _transport_connection transport_connection_t
udp_session_get_half_open
static transport_connection_t * udp_session_get_half_open(u32 conn_index)
Definition: udp.c:404
udp_connection_t
Definition: udp.h:59
udp4_local_node
vlib_node_registration_t udp4_local_node
(constructor) VLIB_REGISTER_NODE (udp4_local_node)
Definition: udp_local.c:366
transport_endpoint_pair_
Definition: transport_types.h:216
ip6_lookup_node
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
Definition: ip6_forward.c:739
udp_header_t
Definition: udp_packet.h:45
udp_main_t::peekers_readers_locks
clib_spinlock_t * peekers_readers_locks
Definition: udp.h:120
ip4_header_t
Definition: ip4_packet.h:87
udp_main_t::next_by_dst_port4
u16 * next_by_dst_port4
Definition: udp.h:107
udp_session_bind
static u32 udp_session_bind(u32 session_index, transport_endpoint_t *lcl)
Definition: udp.c:168
format_udp_header
format_function_t format_udp_header
Definition: format.h:100
pool_get_aligned_will_expand
#define pool_get_aligned_will_expand(P, YESNO, A)
See if pool_get will expand the pool or not.
Definition: pool.h:261
udp_connection_share_port
void udp_connection_share_port(u16 lcl_port, u8 is_ip4)
Definition: udp.c:81
udp_dst_port_info_t::node_index
u32 node_index
Definition: udp.h:78
UDP_IP4
@ UDP_IP4
Definition: udp.h:93
udp_connection_cleanup
static void udp_connection_cleanup(udp_connection_t *uc)
Definition: udp.c:133
udp_dst_port_info_t::n_connections
u32 n_connections
Definition: udp.h:84
TRANSPORT_CONNECTION_F_CLESS
@ TRANSPORT_CONNECTION_F_CLESS
Connection is "connection less".
Definition: transport_types.h:62
ip_interface_get_first_ip
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
Definition: ip_interface.c:174
udp_connection_get
static udp_connection_t * udp_connection_get(u32 conn_index, u32 thread_index)
Definition: udp.h:140
sparse_vec_validate
#define sparse_vec_validate(v, i)
Definition: sparse_vec.h:231
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
ENDPOINT_INVALID_INDEX
#define ENDPOINT_INVALID_INDEX
Definition: transport_types.h:293
transport_send_params_::tx_offset
u32 tx_offset
Definition: transport.h:53
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
unformat_pg_udp_header
unformat_function_t unformat_pg_udp_header
Definition: format.h:102
udp_main_t::listener_pool
udp_connection_t * listener_pool
Definition: udp.h:122
udp_proto
static const transport_proto_vft_t udp_proto
Definition: udp.c:449
sparse_vec.h
transport_max_tx_dequeue
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
Definition: session.h:544
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
transport_cl_thread
static u32 transport_cl_thread(void)
Definition: session.h:613
clib_spinlock_free
static void clib_spinlock_free(clib_spinlock_t *p)
Definition: lock.h:72
TRANSPORT_CFG_F_CONNECTED
@ TRANSPORT_CFG_F_CONNECTED
Definition: transport_types.h:202
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:469
udp_session_send_params
static int udp_session_send_params(transport_connection_t *tconn, transport_send_params_t *sp)
Definition: udp.c:307
transport_register_protocol
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
Definition: transport.c:246
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
udp_is_valid_dst_port
u8 udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp_local.c:492
session_lookup_connection
transport_connection_t * session_lookup_connection(u32 fib_index, ip46_address_t *lcl, ip46_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u8 is_ip4)
Definition: session_lookup.c:1304
UDP_IP6
@ UDP_IP6
Definition: udp.h:92
format_udp_half_open_session
static u8 * format_udp_half_open_session(u8 *s, va_list *args)
Definition: udp.c:430
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
udp_session_unbind
static u32 udp_session_unbind(u32 listener_index)
Definition: udp.c:217
clib_atomic_fetch_add_rel
#define clib_atomic_fetch_add_rel(a, b)
Definition: atomics.h:60
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
ip6_inlines.h
transport_send_params_::snd_space
u32 snd_space
Definition: transport.h:52
session_transport_delete_notify
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
Definition: session.c:1084
udp_connection_delete
void udp_connection_delete(udp_connection_t *uc)
Definition: udp.c:143
clib_atomic_sub_fetch
#define clib_atomic_sub_fetch(a, b)
Definition: atomics.h:31
udp_connection_t::mss
u16 mss
connection mss
Definition: udp.h:66
transport_send_params_
Definition: transport.h:45
transport_share_local_endpoint
void transport_share_local_endpoint(u8 proto, ip46_address_t *lcl_ip, u16 port)
Definition: transport.c:474
format_udp_connection
format_function_t format_udp_connection
Definition: udp.h:239
udp_main_t::next_by_dst_port6
u16 * next_by_dst_port6
Definition: udp.h:108
TRANSPORT_TX_DGRAM
@ TRANSPORT_TX_DGRAM
datagram mode
Definition: transport_types.h:33
format
description fragment has unexpected format
Definition: map.api:433
udp_main
udp_main_t udp_main
Definition: udp.c:23
vlib_thread_main_t::n_threads
u32 n_threads
Definition: threads.h:271
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
ip_copy
void ip_copy(ip46_address_t *dst, ip46_address_t *src, u8 is_ip4)
Definition: ip.c:83
transport_endpoint_
Definition: transport_types.h:193
udp6_input_node
vlib_node_registration_t udp6_input_node
(constructor) VLIB_REGISTER_NODE (udp6_input_node)
Definition: udp_input.c:372
ip_protocol_info_t
Definition: ip.h:70
vlib_thread_main_t
Definition: threads.h:243
udp_dst_port_info_t::next_index
u32 next_index
Definition: udp.h:81
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
udp_connection_register_port
static void udp_connection_register_port(vlib_main_t *vm, u16 lcl_port, u8 is_ip4)
Definition: udp.c:26
udp.h
ip6_header_t
Definition: ip6_packet.h:294
TRANSPORT_SERVICE_CL
@ TRANSPORT_SERVICE_CL
connectionless service
Definition: transport_types.h:40
transport_endpoint_cleanup
void transport_endpoint_cleanup(u8 proto, ip46_address_t *lcl_ip, u16 port)
Definition: transport.c:439
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:231
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
udp_connection_alloc
udp_connection_t * udp_connection_alloc(u32 thread_index)
Definition: udp.c:93
udp_main_t
Definition: udp.h:97
udp_session_cleanup
static void udp_session_cleanup(u32 connection_index, u32 thread_index)
Definition: udp.c:294
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
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
udp_main_t::connection_peekers
u32 * connection_peekers
Definition: udp.h:119
udp_connection_port_used_extern
static u8 udp_connection_port_used_extern(u16 lcl_port, u8 is_ip4)
Definition: udp.c:150
session.h
i
int i
Definition: flowhash_template.h:376
udp_connection_t::rx_lock
clib_spinlock_t rx_lock
rx fifo lock
Definition: udp.h:64
udp_main_t::default_mtu
u16 default_mtu
Definition: udp.h:124
udp_open_connection
static int udp_open_connection(transport_endpoint_cfg_t *rmt)
Definition: udp.c:324
transport_send_params_::flags
transport_snd_flags_t flags
Definition: transport.h:62
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
udp_connection_t::connection
transport_connection_t connection
must be first
Definition: udp.h:63
rv
int __clib_unused rv
Definition: application.c:491
ip_main_t
Definition: ip.h:107
vlib_buffer_push_ip4_custom
static void * vlib_buffer_push_ip4_custom(vlib_main_t *vm, vlib_buffer_t *b, ip4_address_t *src, ip4_address_t *dst, int proto, u8 csum_offload, u8 is_df)
Definition: ip4_inlines.h:101
clib_spinlock_unlock_if_init
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:129
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
ip_protocol_info_t::unformat_pg_edit
unformat_function_t * unformat_pg_edit
Definition: ip.h:88
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
udp_main_t::connections
udp_connection_t ** connections
Definition: udp.h:118
udp_main_t::peekers_write_locks
clib_spinlock_t * peekers_write_locks
Definition: udp.h:121
format_udp_session
static u8 * format_udp_session(u8 *s, va_list *args)
Definition: udp.c:418
vnet_get_udp_main
static udp_main_t * vnet_get_udp_main()
Definition: udp.h:154
udp_connection_from_transport
static udp_connection_t * udp_connection_from_transport(transport_connection_t *tc)
Definition: udp.h:160
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
ip_is_zero
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
Definition: ip.c:22