FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
transport.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 
17 #include <vnet/session/session.h>
18 #include <vnet/fib/fib.h>
19 
20 /**
21  * Per-type vector of transport protocol virtual function tables
22  */
24 
25 /*
26  * Port allocator seed
27  */
29 
30 /*
31  * Local endpoints table
32  */
34 
35 /*
36  * Pool of local endpoints
37  */
39 
40 /*
41  * Local endpoints pool lock
42  */
44 
45 /*
46  * Period used by transport pacers. Initialized by session layer
47  */
48 static double transport_pacer_period;
49 
50 #define TRANSPORT_PACER_MIN_MSS 1460
51 #define TRANSPORT_PACER_MIN_BURST TRANSPORT_PACER_MIN_MSS
52 
53 u8 *
54 format_transport_proto (u8 * s, va_list * args)
55 {
56  u32 transport_proto = va_arg (*args, u32);
57  switch (transport_proto)
58  {
60  s = format (s, "TCP");
61  break;
63  s = format (s, "UDP");
64  break;
66  s = format (s, "SCTP");
67  break;
69  s = format (s, "UDPC");
70  break;
71  }
72  return s;
73 }
74 
75 u8 *
76 format_transport_proto_short (u8 * s, va_list * args)
77 {
78  u32 transport_proto = va_arg (*args, u32);
79  switch (transport_proto)
80  {
82  s = format (s, "T");
83  break;
85  s = format (s, "U");
86  break;
88  s = format (s, "S");
89  break;
91  s = format (s, "U");
92  break;
93  }
94  return s;
95 }
96 
97 u8 *
98 format_transport_connection (u8 * s, va_list * args)
99 {
100  u32 transport_proto = va_arg (*args, u32);
101  u32 conn_index = va_arg (*args, u32);
102  u32 thread_index = va_arg (*args, u32);
103  u32 verbose = va_arg (*args, u32);
104  transport_proto_vft_t *tp_vft;
106  u32 indent;
107 
108  tp_vft = transport_protocol_get_vft (transport_proto);
109  if (!tp_vft)
110  return s;
111 
112  s = format (s, "%U", tp_vft->format_connection, conn_index, thread_index,
113  verbose);
114  tc = tp_vft->get_connection (conn_index, thread_index);
115  if (tc && transport_connection_is_tx_paced (tc) && verbose > 1)
116  {
117  indent = format_get_indent (s) + 1;
118  s = format (s, "%Upacer: %U\n", format_white_space, indent,
119  format_transport_pacer, &tc->pacer);
120  }
121  return s;
122 }
123 
124 u8 *
126 {
127  u32 transport_proto = va_arg (*args, u32);
128  u32 listen_index = va_arg (*args, u32);
129  transport_proto_vft_t *tp_vft;
130 
131  tp_vft = transport_protocol_get_vft (transport_proto);
132  if (!tp_vft)
133  return s;
134 
135  s = format (s, "%U", tp_vft->format_listener, listen_index);
136  return s;
137 }
138 
139 u8 *
141 {
142  u32 transport_proto = va_arg (*args, u32);
143  u32 listen_index = va_arg (*args, u32);
144  transport_proto_vft_t *tp_vft;
145 
146  tp_vft = transport_protocol_get_vft (transport_proto);
147  if (!tp_vft)
148  return s;
149 
150  s = format (s, "%U", tp_vft->format_half_open, listen_index);
151  return s;
152 }
153 
154 uword
156 {
157  u32 *proto = va_arg (*args, u32 *);
158  if (unformat (input, "tcp"))
159  *proto = TRANSPORT_PROTO_TCP;
160  else if (unformat (input, "TCP"))
161  *proto = TRANSPORT_PROTO_TCP;
162  else if (unformat (input, "udp"))
163  *proto = TRANSPORT_PROTO_UDP;
164  else if (unformat (input, "UDP"))
165  *proto = TRANSPORT_PROTO_UDP;
166  else if (unformat (input, "sctp"))
167  *proto = TRANSPORT_PROTO_SCTP;
168  else if (unformat (input, "SCTP"))
169  *proto = TRANSPORT_PROTO_SCTP;
170  else if (unformat (input, "tls"))
171  *proto = TRANSPORT_PROTO_TLS;
172  else if (unformat (input, "TLS"))
173  *proto = TRANSPORT_PROTO_TLS;
174  else if (unformat (input, "udpc"))
175  *proto = TRANSPORT_PROTO_UDPC;
176  else if (unformat (input, "UDPC"))
177  *proto = TRANSPORT_PROTO_UDPC;
178  else
179  return 0;
180  return 1;
181 }
182 
183 u32
185  ip46_address_t * ip, u16 port)
186 {
188  int rv;
189 
190  kv.key[0] = ip->as_u64[0];
191  kv.key[1] = ip->as_u64[1];
192  kv.key[2] = (u64) port << 8 | (u64) proto;
193 
194  rv = clib_bihash_search_inline_24_8 (ht, &kv);
195  if (rv == 0)
196  return kv.value;
197 
198  return ENDPOINT_INVALID_INDEX;
199 }
200 
201 void
203  transport_endpoint_t * te, u32 value)
204 {
206 
207  kv.key[0] = te->ip.as_u64[0];
208  kv.key[1] = te->ip.as_u64[1];
209  kv.key[2] = (u64) te->port << 8 | (u64) proto;
210  kv.value = value;
211 
212  clib_bihash_add_del_24_8 (ht, &kv, 1);
213 }
214 
215 void
218 {
220 
221  kv.key[0] = te->ip.as_u64[0];
222  kv.key[1] = te->ip.as_u64[1];
223  kv.key[2] = (u64) te->port << 8 | (u64) proto;
224 
225  clib_bihash_add_del_24_8 (ht, &kv, 0);
226 }
227 
228 /**
229  * Register transport virtual function table.
230  *
231  * @param transport_proto - transport protocol type (i.e., TCP, UDP ..)
232  * @param vft - virtual function table for transport proto
233  * @param fib_proto - network layer protocol
234  * @param output_node - output node index that session layer will hand off
235  * buffers to, for requested fib proto
236  */
237 void
239  const transport_proto_vft_t * vft,
240  fib_protocol_t fib_proto, u32 output_node)
241 {
242  u8 is_ip4 = fib_proto == FIB_PROTOCOL_IP4;
243 
244  vec_validate (tp_vfts, transport_proto);
245  tp_vfts[transport_proto] = *vft;
246 
247  session_register_transport (transport_proto, vft, is_ip4, output_node);
248 }
249 
250 /**
251  * Get transport virtual function table
252  *
253  * @param type - session type (not protocol type)
254  */
257 {
258  if (transport_proto >= vec_len (tp_vfts))
259  return 0;
260  return &tp_vfts[transport_proto];
261 }
262 
265 {
266  return tp_vfts[tp].service_type;
267 }
268 
271 {
272  return tp_vfts[tp].tx_type;
273 }
274 
275 u8
277 {
278  return (tp_vfts[tp].service_type == TRANSPORT_SERVICE_CL);
279 }
280 
281 #define PORT_MASK ((1 << 16)- 1)
282 
283 void
285 {
286  clib_spinlock_lock_if_init (&local_endpoints_lock);
287  pool_put_index (local_endpoints, tepi);
288  clib_spinlock_unlock_if_init (&local_endpoints_lock);
289 }
290 
293 {
295  pool_get_zero (local_endpoints, tep);
296  return tep;
297 }
298 
299 void
300 transport_endpoint_cleanup (u8 proto, ip46_address_t * lcl_ip, u16 port)
301 {
302  u32 tepi;
304 
305  /* Cleanup local endpoint if this was an active connect */
306  tepi = transport_endpoint_lookup (&local_endpoints_table, proto, lcl_ip,
307  clib_net_to_host_u16 (port));
308  if (tepi != ENDPOINT_INVALID_INDEX)
309  {
310  tep = pool_elt_at_index (local_endpoints, tepi);
312  transport_endpoint_del (tepi);
313  }
314 }
315 
316 static void
317 transport_endpoint_mark_used (u8 proto, ip46_address_t * ip, u16 port)
318 {
320  clib_spinlock_lock_if_init (&local_endpoints_lock);
321  tep = transport_endpoint_new ();
322  clib_memcpy_fast (&tep->ip, ip, sizeof (*ip));
323  tep->port = port;
325  tep - local_endpoints);
326  clib_spinlock_unlock_if_init (&local_endpoints_lock);
327 }
328 
329 /**
330  * Allocate local port and add if successful add entry to local endpoint
331  * table to mark the pair as used.
332  */
333 int
334 transport_alloc_local_port (u8 proto, ip46_address_t * ip)
335 {
336  u16 min = 1024, max = 65535; /* XXX configurable ? */
337  int tries, limit;
338  u32 tei;
339 
340  limit = max - min;
341 
342  /* Only support active opens from thread 0 */
343  ASSERT (vlib_get_thread_index () == 0);
344 
345  /* Search for first free slot */
346  for (tries = 0; tries < limit; tries++)
347  {
348  u16 port = 0;
349 
350  /* Find a port in the specified range */
351  while (1)
352  {
354  if (PREDICT_TRUE (port >= min && port < max))
355  break;
356  }
357 
358  /* Look it up. If not found, we're done */
360  port);
361  if (tei == ENDPOINT_INVALID_INDEX)
362  {
363  transport_endpoint_mark_used (proto, ip, port);
364  return port;
365  }
366  }
367  return -1;
368 }
369 
370 static clib_error_t *
371 transport_get_interface_ip (u32 sw_if_index, u8 is_ip4, ip46_address_t * addr)
372 {
373  if (is_ip4)
374  {
375  ip4_address_t *ip4;
376  ip4 = ip_interface_get_first_ip (sw_if_index, 1);
377  if (!ip4)
378  return clib_error_return (0, "no routable ip4 address on %U",
380  vnet_get_main (), sw_if_index);
381  addr->ip4.as_u32 = ip4->as_u32;
382  }
383  else
384  {
385  ip6_address_t *ip6;
386  ip6 = ip_interface_get_first_ip (sw_if_index, 0);
387  if (ip6 == 0)
388  return clib_error_return (0, "no routable ip6 addresses on %U",
390  vnet_get_main (), sw_if_index);
391  clib_memcpy_fast (&addr->ip6, ip6, sizeof (*ip6));
392  }
393  return 0;
394 }
395 
396 static clib_error_t *
398  transport_endpoint_t * rmt,
399  ip46_address_t * lcl_addr)
400 {
401  fib_node_index_t fei;
403 
404  if (sw_if_index == ENDPOINT_INVALID_INDEX)
405  {
406  /* Find a FIB path to the destination */
407  clib_memcpy_fast (&prefix.fp_addr, &rmt->ip, sizeof (rmt->ip));
408  prefix.fp_proto = rmt->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
409  prefix.fp_len = rmt->is_ip4 ? 32 : 128;
410 
411  ASSERT (rmt->fib_index != ENDPOINT_INVALID_INDEX);
412  fei = fib_table_lookup (rmt->fib_index, &prefix);
413 
414  /* Couldn't find route to destination. Bail out. */
415  if (fei == FIB_NODE_INDEX_INVALID)
416  return clib_error_return (0, "no route to %U", format_ip46_address,
417  &rmt->ip, (rmt->is_ip4 == 0) + 1);
418 
419  sw_if_index = fib_entry_get_resolving_interface (fei);
420  if (sw_if_index == ENDPOINT_INVALID_INDEX)
421  return clib_error_return (0, "no resolving interface for %U",
422  format_ip46_address, &rmt->ip,
423  (rmt->is_ip4 == 0) + 1);
424  }
425 
426  clib_memset (lcl_addr, 0, sizeof (*lcl_addr));
427  return transport_get_interface_ip (sw_if_index, rmt->is_ip4, lcl_addr);
428 }
429 
430 int
432  ip46_address_t * lcl_addr, u16 * lcl_port)
433 {
434  transport_endpoint_t *rmt = (transport_endpoint_t *) rmt_cfg;
435  clib_error_t *error;
436  int port;
437  u32 tei;
438 
439  /*
440  * Find the local address
441  */
442  if (ip_is_zero (&rmt_cfg->peer.ip, rmt_cfg->peer.is_ip4))
443  {
444  error = transport_find_local_ip_for_remote (rmt_cfg->peer.sw_if_index,
445  rmt, lcl_addr);
446  if (error)
447  {
448  clib_error_report (error);
449  return -1;
450  }
451  }
452  else
453  {
454  /* Assume session layer vetted this address */
455  clib_memcpy_fast (lcl_addr, &rmt_cfg->peer.ip,
456  sizeof (rmt_cfg->peer.ip));
457  }
458 
459  /*
460  * Allocate source port
461  */
462  if (rmt_cfg->peer.port == 0)
463  {
464  port = transport_alloc_local_port (proto, lcl_addr);
465  if (port < 1)
466  {
467  clib_warning ("Failed to allocate src port");
468  return -1;
469  }
470  *lcl_port = port;
471  }
472  else
473  {
474  port = clib_net_to_host_u16 (rmt_cfg->peer.port);
476  lcl_addr, port);
477  if (tei != ENDPOINT_INVALID_INDEX)
478  return -1;
479 
480  transport_endpoint_mark_used (proto, lcl_addr, port);
481  *lcl_port = port;
482  }
483 
484  return 0;
485 }
486 
487 #define SPACER_CPU_TICKS_PER_PERIOD_SHIFT 10
488 #define SPACER_CPU_TICKS_PER_PERIOD (1 << SPACER_CPU_TICKS_PER_PERIOD_SHIFT)
489 
490 u8 *
491 format_transport_pacer (u8 * s, va_list * args)
492 {
493  spacer_t *pacer = va_arg (*args, spacer_t *);
494 
495  s = format (s, "bucket %u max_burst %u tokens/period %.3f last_update %x",
496  pacer->bucket, pacer->max_burst_size, pacer->tokens_per_period,
497  pacer->last_update);
498  return s;
499 }
500 
501 static inline u32
502 spacer_max_burst (spacer_t * pacer, u64 norm_time_now)
503 {
504  u64 n_periods = norm_time_now - pacer->last_update;
505  u64 inc;
506 
507  if (n_periods > 0 && (inc = n_periods * pacer->tokens_per_period) > 10)
508  {
509  pacer->last_update = norm_time_now;
510  pacer->bucket += inc;
511  }
512 
513  return clib_min (pacer->bucket, pacer->max_burst_size);
514 }
515 
516 static inline void
518 {
519  ASSERT (pacer->bucket >= bytes);
520  pacer->bucket -= bytes;
521 }
522 
523 static inline void
524 spacer_update_max_burst_size (spacer_t * pacer, u32 max_burst_bytes)
525 {
526  pacer->max_burst_size = clib_max (max_burst_bytes,
528 }
529 
530 static inline void
531 spacer_set_pace_rate (spacer_t * pacer, u64 rate_bytes_per_sec)
532 {
533  ASSERT (rate_bytes_per_sec != 0);
534  pacer->tokens_per_period = rate_bytes_per_sec / transport_pacer_period;
535 }
536 
537 void
539  u32 rate_bytes_per_sec,
540  u32 start_bucket, u64 time_now)
541 {
542  spacer_t *pacer = &tc->pacer;
543  f64 dispatch_period;
544  u32 burst_size;
545 
546  dispatch_period = transport_dispatch_period (tc->thread_index);
547  burst_size = rate_bytes_per_sec * dispatch_period;
548  spacer_update_max_burst_size (&tc->pacer, burst_size);
549  spacer_set_pace_rate (&tc->pacer, rate_bytes_per_sec);
550  pacer->last_update = time_now >> SPACER_CPU_TICKS_PER_PERIOD_SHIFT;
551  pacer->bucket = start_bucket;
552 }
553 
554 void
556  u32 rate_bytes_per_sec,
557  u32 initial_bucket)
558 {
561  transport_connection_tx_pacer_reset (tc, rate_bytes_per_sec,
562  initial_bucket,
564 }
565 
566 void
568  u64 bytes_per_sec)
569 {
570  f64 dispatch_period = transport_dispatch_period (tc->thread_index);
571  u32 burst_size = 1.1 * bytes_per_sec * dispatch_period;
572  spacer_set_pace_rate (&tc->pacer, bytes_per_sec);
573  spacer_update_max_burst_size (&tc->pacer, burst_size);
574 }
575 
576 u32
578  u64 time_now)
579 {
581  return spacer_max_burst (&tc->pacer, time_now);
582 }
583 
584 u32
586  u16 mss)
587 {
588  u32 snd_space, max_paced_burst;
589 
590  snd_space = tp_vfts[tc->proto].send_space (tc);
592  {
594  max_paced_burst = spacer_max_burst (&tc->pacer, time_now);
595  max_paced_burst = (max_paced_burst < mss) ? 0 : max_paced_burst;
596  snd_space = clib_min (snd_space, max_paced_burst);
597  snd_space = snd_space - snd_space % mss;
598  }
599  return snd_space;
600 }
601 
602 void
604 {
605  tc->stats.tx_bytes += bytes;
607  spacer_update_bucket (&tc->pacer, bytes);
608 }
609 
610 void
612  u32 bytes)
613 {
614  spacer_update_bucket (&tc->pacer, bytes);
615 }
616 
617 void
619 {
620  f64 cpu_freq = os_cpu_clock_frequency ();
622 }
623 
624 void
625 transport_update_time (f64 time_now, u8 thread_index)
626 {
628  vec_foreach (vft, tp_vfts)
629  {
630  if (vft->update_time)
631  (vft->update_time) (time_now, thread_index);
632  }
633 }
634 
635 void
637 {
639  vec_foreach (vft, tp_vfts)
640  {
641  if (vft->enable)
642  (vft->enable) (vm, is_en);
643  }
644 }
645 
646 void
648 {
651  u32 num_threads;
652 
653  if (smm->local_endpoints_table_buckets == 0)
654  smm->local_endpoints_table_buckets = 250000;
655  if (smm->local_endpoints_table_memory == 0)
656  smm->local_endpoints_table_memory = 512 << 20;
657 
658  /* Initialize [port-allocator] random number seed */
660 
661  clib_bihash_init_24_8 (&local_endpoints_table, "local endpoints table",
664  num_threads = 1 /* main thread */ + vtm->n_threads;
665  if (num_threads > 1)
666  clib_spinlock_init (&local_endpoints_lock);
667 }
668 
669 /*
670  * fd.io coding-style-patch-verification: ON
671  *
672  * Local Variables:
673  * eval: (c-set-style "gnu")
674  * End:
675  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:212
u8 * format_transport_connection(u8 *s, va_list *args)
Definition: transport.c:98
u32 transport_endpoint_lookup(transport_endpoint_table_t *ht, u8 proto, ip46_address_t *ip, u16 port)
Definition: transport.c:184
#define clib_min(x, y)
Definition: clib.h:295
u8 * format_transport_proto_short(u8 *s, va_list *args)
Definition: transport.c:76
static void transport_endpoint_mark_used(u8 proto, ip46_address_t *ip, u16 port)
Definition: transport.c:317
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
struct _transport_connection transport_connection_t
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
Definition: pool.h:239
void transport_endpoint_table_add(transport_endpoint_table_t *ht, u8 proto, transport_endpoint_t *te, u32 value)
Definition: transport.c:202
#define PREDICT_TRUE(x)
Definition: clib.h:112
unsigned long u64
Definition: types.h:89
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static transport_endpoint_table_t local_endpoints_table
Definition: transport.c:33
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:98
struct _transport_proto_vft transport_proto_vft_t
static u8 transport_connection_is_tx_paced(transport_connection_t *tc)
Check if transport connection is paced.
static u64 clib_cpu_time_now(void)
Definition: time.h:75
format_function_t format_ip46_address
Definition: format.h:61
static u32 format_get_indent(u8 *s)
Definition: format.h:72
transport_tx_fn_type_t transport_protocol_tx_fn_type(transport_proto_t tp)
Definition: transport.c:270
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
Definition: ip.c:134
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
clib_time_t clib_time
Definition: main.h:65
void transport_endpoint_del(u32 tepi)
Definition: transport.c:284
vhost_vring_addr_t addr
Definition: vhost_user.h:121
enum transport_service_type_ transport_service_type_t
format_function_t format_vnet_sw_if_index_name
unsigned char u8
Definition: types.h:56
u32 transport_connection_tx_pacer_burst(transport_connection_t *tc, u64 time_now)
Definition: transport.c:577
void transport_update_time(f64 time_now, u8 thread_index)
Definition: transport.c:625
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
double f64
Definition: types.h:142
connectionless service
static clib_error_t * transport_get_interface_ip(u32 sw_if_index, u8 is_ip4, ip46_address_t *addr)
Definition: transport.c:371
u32 sw_if_index
Definition: vxlan_gbp.api:37
#define always_inline
Definition: clib.h:98
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
Aggregrate type for a prefix.
Definition: fib_types.h:203
#define clib_error_return(e, args...)
Definition: error.h:99
int transport_alloc_local_endpoint(u8 proto, transport_endpoint_cfg_t *rmt_cfg, ip46_address_t *lcl_addr, u16 *lcl_port)
Definition: transport.c:431
unsigned int u32
Definition: types.h:88
#define TRANSPORT_CONNECTION_F_IS_TX_PACED
Definition: transport.h:104
u16 fp_len
The mask length.
Definition: fib_types.h:207
static clib_spinlock_t local_endpoints_lock
Definition: transport.c:43
enum transport_dequeue_type_ transport_tx_fn_type_t
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
Definition: fib_table.c:66
void transport_connection_tx_pacer_init(transport_connection_t *tc, u32 rate_bytes_per_sec, u32 initial_bucket)
Initialize tx pacer for connection.
Definition: transport.c:555
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:57
transport_proto_vft_t * transport_protocol_get_vft(transport_proto_t transport_proto)
Get transport virtual function table.
Definition: transport.c:256
static void spacer_set_pace_rate(spacer_t *pacer, u64 rate_bytes_per_sec)
Definition: transport.c:531
static session_manager_main_t * vnet_get_session_manager_main()
Definition: session.h:310
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:511
void transport_endpoint_table_del(transport_endpoint_table_t *ht, u8 proto, transport_endpoint_t *te)
Definition: transport.c:216
#define SPACER_CPU_TICKS_PER_PERIOD
Definition: transport.c:488
transport_service_type_t transport_protocol_service_type(transport_proto_t tp)
Definition: transport.c:264
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:226
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
static transport_endpoint_t * local_endpoints
Definition: transport.c:38
transport_proto_vft_t * tp_vfts
Per-type vector of transport protocol virtual function tables.
Definition: transport.c:23
void transport_connection_tx_pacer_update(transport_connection_t *tc, u64 bytes_per_sec)
Update tx pacer pacing rate.
Definition: transport.c:567
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
Definition: fib_entry.c:1451
void transport_init(void)
Definition: transport.c:647
static double transport_pacer_period
Definition: transport.c:48
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:212
vlib_main_t * vm
Definition: buffer.c:301
struct _spacer spacer_t
clib_bihash_24_8_t transport_endpoint_table_t
Definition: transport.h:151
#define TRANSPORT_PACER_MIN_BURST
Definition: transport.c:51
#define ENDPOINT_INVALID_INDEX
Definition: transport.h:153
#define clib_warning(format, args...)
Definition: error.h:59
#define PORT_MASK
Definition: transport.c:281
void transport_init_tx_pacers_period(void)
Initialize period for tx pacers.
Definition: transport.c:618
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
void transport_connection_update_tx_stats(transport_connection_t *tc, u32 bytes)
Update tx byte stats for transport connection.
Definition: transport.c:603
void transport_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: transport.c:636
u32 local_endpoints_table_buckets
Definition: session.h:284
void transport_endpoint_cleanup(u8 proto, ip46_address_t *lcl_ip, u16 port)
Definition: transport.c:300
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:238
#define SPACER_CPU_TICKS_PER_PERIOD_SHIFT
Definition: transport.c:487
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:311
#define ASSERT(truth)
u64 last_cpu_time
Definition: time.h:50
static void spacer_update_max_burst_size(spacer_t *pacer, u32 max_burst_bytes)
Definition: transport.c:524
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
Definition: transport.c:155
static transport_endpoint_t * transport_endpoint_new(void)
Definition: transport.c:292
u8 * format_transport_half_open_connection(u8 *s, va_list *args)
Definition: transport.c:140
#define clib_error_report(e)
Definition: error.h:113
u32 transport_connection_snd_space(transport_connection_t *tc, u64 time_now, u16 mss)
Get maximum tx burst allowed for transport connection.
Definition: transport.c:585
#define clib_max(x, y)
Definition: clib.h:288
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
Definition: ip.c:20
void transport_connection_tx_pacer_update_bytes(transport_connection_t *tc, u32 bytes)
Definition: transport.c:611
static u32 port_allocator_seed
Definition: transport.c:28
void transport_connection_tx_pacer_reset(transport_connection_t *tc, u32 rate_bytes_per_sec, u32 start_bucket, u64 time_now)
Definition: transport.c:538
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:31
enum _transport_proto transport_proto_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void spacer_update_bucket(spacer_t *pacer, u32 bytes)
Definition: transport.c:517
u64 uword
Definition: types.h:112
static u32 spacer_max_burst(spacer_t *pacer, u64 norm_time_now)
Definition: transport.c:502
u8 * format_transport_listen_connection(u8 *s, va_list *args)
Definition: transport.c:125
u8 * format_transport_pacer(u8 *s, va_list *args)
Definition: transport.c:491
typedef prefix
Definition: ip_types.api:35
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
#define vec_foreach(var, vec)
Vector iterator.
static clib_error_t * transport_find_local_ip_for_remote(u32 sw_if_index, transport_endpoint_t *rmt, ip46_address_t *lcl_addr)
Definition: transport.c:397
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
Definition: session.h:283
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:334
void session_register_transport(transport_proto_t transport_proto, const transport_proto_vft_t *vft, u8 is_ip4, u32 output_node)
Initialize session layer for given transport proto and ip version.
Definition: session.c:1329
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:82
u8 transport_protocol_is_cl(transport_proto_t tp)
Definition: transport.c:276
u8 * format_transport_proto(u8 *s, va_list *args)
Definition: transport.c:54
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static f64 transport_dispatch_period(u32 thread_index)
Definition: session.h:551
f64 os_cpu_clock_frequency(void)
Definition: time.c:143