48 u32 transport_proto = va_arg (*args,
u32);
49 switch (transport_proto)
51 #define _(sym, str, sstr) \ 52 case TRANSPORT_PROTO_ ## sym: \ 53 s = format (s, str); \ 67 u32 transport_proto = va_arg (*args,
u32);
68 switch (transport_proto)
70 #define _(sym, str, sstr) \ 71 case TRANSPORT_PROTO_ ## sym: \ 72 s = format (s, sstr); \ 86 u32 transport_proto = va_arg (*args,
u32);
87 u32 conn_index = va_arg (*args,
u32);
88 u32 thread_index = va_arg (*args,
u32);
89 u32 verbose = va_arg (*args,
u32);
98 s =
format (s,
"%U", tp_vft->format_connection, conn_index, thread_index,
100 tc = tp_vft->get_connection (conn_index, thread_index);
113 u32 transport_proto = va_arg (*args,
u32);
120 s = (tp_vft->format_listener) (s, args);
127 u32 transport_proto = va_arg (*args,
u32);
128 u32 listen_index = va_arg (*args,
u32);
135 s =
format (s,
"%U", tp_vft->format_half_open, listen_index);
144 if (strlen (str) >
vec_len (input->buffer) - input->index)
147 for (i = 0; i < strlen (str); i++)
149 if (input->buffer[i + input->index] != str[i])
159 u8 longest_match = 0, match;
162 #define _(sym, str, sstr) \ 163 if (unformat_transport_str_match (input, str)) \ 165 match = strlen (str); \ 166 if (match > longest_match) \ 168 *proto = TRANSPORT_PROTO_ ## sym; \ 169 longest_match = match; \ 191 kv.
key[0] = ip->as_u64[0];
192 kv.
key[1] = ip->as_u64[1];
195 rv = clib_bihash_search_inline_24_8 (ht, &kv);
208 kv.
key[0] = te->ip.as_u64[0];
209 kv.
key[1] = te->ip.as_u64[1];
213 clib_bihash_add_del_24_8 (ht, &kv, 1);
222 kv.
key[0] = te->ip.as_u64[0];
223 kv.
key[1] = te->ip.as_u64[1];
226 clib_bihash_add_del_24_8 (ht, &kv, 0);
246 tp_vfts[transport_proto] = *vft;
261 return &
tp_vfts[transport_proto];
267 return tp_vfts[tp].transport_options.half_open_has_fifos;
273 return tp_vfts[tp].transport_options.service_type;
279 return tp_vfts[tp].transport_options.tx_type;
285 tp_vfts[tp].cleanup (conn_index, thread_index);
291 return tp_vfts[tp].connect (tep);
297 tp_vfts[tp].close (conn_index, thread_index);
304 tp_vfts[tp].reset (conn_index, thread_index);
306 tp_vfts[tp].close (conn_index, thread_index);
313 return tp_vfts[tp].start_listen (session_index, tep);
319 return tp_vfts[tp].stop_listen (conn_index);
334 tep->port = tc->lcl_port;
335 tep->is_ip4 = tc->is_ip4;
340 tep->port = tc->rmt_port;
341 tep->is_ip4 = tc->is_ip4;
351 if (
tp_vfts[tp].get_transport_endpoint)
352 tp_vfts[tp].get_transport_endpoint (conn_index, thread_index, tep,
366 if (
tp_vfts[tp].get_transport_listener_endpoint)
367 tp_vfts[tp].get_transport_listener_endpoint (conn_index, tep, is_lcl);
376 #define PORT_MASK ((1 << 16)- 1) 402 clib_net_to_host_u16 (port));
420 tep - local_endpoints);
431 u16 min = 1024, max = 65535;
441 for (tries = 0; tries < limit; tries++)
476 addr->ip4.as_u32 = ip4->
as_u32;
494 ip46_address_t * lcl_addr)
504 prefix.
fp_len = rmt->is_ip4 ? 32 : 128;
512 &rmt->ip, (rmt->is_ip4 == 0) + 1);
518 (rmt->is_ip4 == 0) + 1);
527 ip46_address_t * lcl_addr,
u16 * lcl_port)
537 if (
ip_is_zero (&rmt_cfg->peer.ip, rmt_cfg->peer.is_ip4))
551 sizeof (rmt_cfg->peer.ip));
557 if (rmt_cfg->peer.port == 0)
569 port = clib_net_to_host_u16 (rmt_cfg->peer.port);
587 s =
format (s,
"%u us", t);
597 u32 thread_index = va_arg (*args,
int);
601 diff = now - pacer->last_update;
602 s =
format (s,
"rate %lu bucket %lu t/p %.3f last_update %U",
603 pacer->bytes_per_sec, pacer->bucket, pacer->tokens_per_period,
611 u64 n_periods = (time_now - pacer->last_update);
616 pacer->last_update = time_now;
622 && (inc = (
f32) n_periods * pacer->tokens_per_period) > 10)
624 pacer->last_update = time_now;
625 pacer->bucket =
clib_min (pacer->bucket + inc, pacer->bytes_per_sec);
634 ASSERT (pacer->bucket >= bytes);
635 pacer->bucket -= bytes;
641 ASSERT (rate_bytes_per_sec != 0);
642 pacer->bytes_per_sec = rate_bytes_per_sec;
649 return pacer->bytes_per_sec;
655 pacer->last_update = time_now;
656 pacer->bucket = bucket;
661 u64 rate_bytes_per_sec,
u32 start_bucket)
676 u64 rate_bytes_per_sec,
701 u32 snd_space, max_paced_burst;
703 snd_space =
tp_vfts[tc->proto].send_space (tc);
710 snd_space =
clib_min (snd_space, max_paced_burst);
711 return snd_space >= mss ? snd_space - snd_space % mss : snd_space;
742 if (vft->update_time)
743 (vft->update_time) (time_now, thread_index);
754 (vft->enable) (vm, is_en);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
fib_protocol_t fp_proto
protocol type
void transport_close(transport_proto_t tp, u32 conn_index, u8 thread_index)
#define ENDPOINT_INVALID_INDEX
u8 * format_transport_connection(u8 *s, va_list *args)
u32 transport_endpoint_lookup(transport_endpoint_table_t *ht, u8 proto, ip46_address_t *ip, u16 port)
u8 * format_transport_proto_short(u8 *s, va_list *args)
void transport_get_listener_endpoint(transport_proto_t tp, u32 conn_index, transport_endpoint_t *tep, u8 is_lcl)
static void transport_endpoint_mark_used(u8 proto, ip46_address_t *ip, u16 port)
vnet_main_t * vnet_get_main(void)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
void transport_endpoint_table_add(transport_endpoint_table_t *ht, u8 proto, transport_endpoint_t *te, u32 value)
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static transport_endpoint_table_t local_endpoints_table
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static u64 clib_cpu_time_now(void)
static void spacer_reset(spacer_t *pacer, clib_us_time_t time_now, u64 bucket)
transport_tx_fn_type_t transport_protocol_tx_fn_type(transport_proto_t tp)
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
u32 transport_start_listen(transport_proto_t tp, u32 session_index, transport_endpoint_t *tep)
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
void transport_endpoint_del(u32 tepi)
format_function_t format_vnet_sw_if_index_name
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void transport_update_time(clib_time_type_t time_now, u8 thread_index)
#define foreach_transport_proto
vl_api_interface_index_t sw_if_index
u8 transport_half_open_has_fifos(transport_proto_t tp)
static clib_error_t * transport_get_interface_ip(u32 sw_if_index, u8 is_ip4, ip46_address_t *addr)
Aggregate type for a prefix.
#define clib_error_return(e, args...)
int transport_alloc_local_endpoint(u8 proto, transport_endpoint_cfg_t *rmt_cfg, ip46_address_t *lcl_addr, u16 *lcl_port)
u16 fp_len
The mask length.
static clib_spinlock_t local_endpoints_lock
void transport_reset(transport_proto_t tp, u32 conn_index, u8 thread_index)
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.
struct _transport_proto_vft transport_proto_vft_t
static void clib_spinlock_init(clib_spinlock_t *p)
transport_proto_vft_t * transport_protocol_get_vft(transport_proto_t transport_proto)
Get transport virtual function table.
static void spacer_set_pace_rate(spacer_t *pacer, u64 rate_bytes_per_sec)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void transport_endpoint_table_del(transport_endpoint_table_t *ht, u8 proto, transport_endpoint_t *te)
transport_service_type_t transport_protocol_service_type(transport_proto_t tp)
void transport_get_endpoint(transport_proto_t tp, u32 conn_index, u32 thread_index, transport_endpoint_t *tep, u8 is_lcl)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
static transport_endpoint_t * local_endpoints
void transport_connection_tx_pacer_init(transport_connection_t *tc, u64 rate_bytes_per_sec, u32 initial_bucket)
Initialize tx pacer for connection.
enum transport_service_type_ transport_service_type_t
transport_proto_vft_t * tp_vfts
Per-type vector of transport protocol virtual function tables.
static u8 transport_connection_is_tx_paced(transport_connection_t *tc)
Check if transport connection is paced.
void transport_cleanup(transport_proto_t tp, u32 conn_index, u8 thread_index)
u32 transport_stop_listen(transport_proto_t tp, u32 conn_index)
u8 * format_clib_us_time(u8 *s, va_list *args)
void transport_connection_tx_pacer_update(transport_connection_t *tc, u64 bytes_per_sec)
Update tx pacer pacing rate.
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
void transport_init(void)
static_always_inline uword vlib_get_thread_index(void)
int transport_connect(transport_proto_t tp, transport_endpoint_cfg_t *tep)
static transport_connection_t * transport_get_connection(transport_proto_t tp, u32 conn_index, u8 thread_index)
#define clib_warning(format, args...)
static void default_get_transport_endpoint(transport_connection_t *tc, transport_endpoint_t *tep, u8 is_lcl)
struct _transport_connection transport_connection_t
u32 fib_node_index_t
A typedef of a node index.
void transport_enable_disable(vlib_main_t *vm, u8 is_en)
void transport_endpoint_cleanup(u8 proto, ip46_address_t *lcl_ip, u16 port)
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.
static clib_us_time_t transport_us_time_now(u32 thread_index)
static u64 spacer_pace_rate(spacer_t *pacer)
#define CLIB_US_TIME_PERIOD
#define pool_put_index(p, i)
Free pool element with given index.
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
#define TRANSPORT_PACER_MAX_BURST
void transport_connection_update_tx_bytes(transport_connection_t *tc, u32 bytes)
Update tx bytes for paced transport connection.
static transport_endpoint_t * transport_endpoint_new(void)
#define TRANSPORT_PACER_MIN_BURST
u8 * format_transport_half_open_connection(u8 *s, va_list *args)
enum _transport_proto transport_proto_t
#define clib_error_report(e)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
void transport_connection_tx_pacer_update_bytes(transport_connection_t *tc, u32 bytes)
static u32 port_allocator_seed
u32 local_endpoints_table_buckets
#define FIB_NODE_INDEX_INVALID
static u32 spacer_max_burst(spacer_t *pacer, clib_us_time_t time_now)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void spacer_update_bucket(spacer_t *pacer, u32 bytes)
u8 * format_transport_listen_connection(u8 *s, va_list *args)
u8 * format_transport_pacer(u8 *s, va_list *args)
void transport_connection_tx_pacer_reset_bucket(transport_connection_t *tc)
Reset tx pacer bucket.
static u32 random_u32(u32 *seed)
32-bit random number generator
static vlib_thread_main_t * vlib_get_thread_main()
#define vec_foreach(var, vec)
Vector iterator.
u32 transport_connection_snd_space(transport_connection_t *tc, u16 mss)
Get maximum tx burst allowed for transport connection.
static clib_error_t * transport_find_local_ip_for_remote(u32 sw_if_index, transport_endpoint_t *rmt, ip46_address_t *lcl_addr)
clib_bihash_24_8_t transport_endpoint_table_t
static session_main_t * vnet_get_session_main()
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...
static transport_connection_t * transport_get_listener(transport_proto_t tp, u32 conn_index)
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.
enum transport_dequeue_type_ transport_tx_fn_type_t
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
u8 transport_protocol_is_cl(transport_proto_t tp)
u8 * format_transport_proto(u8 *s, va_list *args)
void transport_connection_tx_pacer_reset(transport_connection_t *tc, u64 rate_bytes_per_sec, u32 start_bucket)
u32 transport_connection_tx_pacer_burst(transport_connection_t *tc)
Get tx pacer max burst.
u64 transport_connection_tx_pacer_rate(transport_connection_t *tc)
Get tx pacer current rate.
static u8 unformat_transport_str_match(unformat_input_t *input, const char *str)
vl_api_fib_path_nh_proto_t proto