36 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 43 #define foreach_session_api_msg \ 44 _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \ 45 _(APPLICATION_ATTACH, application_attach) \ 46 _(APPLICATION_DETACH, application_detach) \ 47 _(BIND_URI, bind_uri) \ 48 _(UNBIND_URI, unbind_uri) \ 49 _(CONNECT_URI, connect_uri) \ 50 _(DISCONNECT_SESSION, disconnect_session) \ 51 _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \ 52 _(BIND_SOCK, bind_sock) \ 53 _(UNBIND_SOCK, unbind_sock) \ 54 _(CONNECT_SOCK, connect_sock) \ 55 _(SESSION_ENABLE_DISABLE, session_enable_disable) \ 56 _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \ 57 _(SESSION_RULE_ADD_DEL, session_rule_add_del) \ 58 _(SESSION_RULES_DUMP, session_rules_dump) \ 59 _(APPLICATION_TLS_CERT_ADD, application_tls_cert_add) \ 60 _(APPLICATION_TLS_KEY_ADD, application_tls_key_add) \ 61 _(APP_WORKER_ADD_DEL, app_worker_add_del) \ 94 clib_warning (
"no api registration for client: %u", api_client_index);
108 fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
115 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT);
145 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_UNMAP_SEGMENT);
180 session_event_t *evt;
217 mp->
port = tc->rmt_port;
231 mp->
port = ct->c_rmt_port;
247 session_event_t *evt;
254 evt->event_type = evt_type;
273 for (i = 0; i < f->n_subscribers; i++)
317 session_event_t *evt;
368 mp->
is_ip4 = cct->c_is_ip4;
382 clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0;
397 session_event_t *evt;
460 vl_api_session_enable_disable_reply_t *rmp;
484 rv = VNET_API_ERROR_FEATURE_DISABLED;
490 "Out of options, fix api message definition");
498 rv = VNET_API_ERROR_INVALID_VALUE;
520 fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
521 fds[n_fds] = evt_q_segment->
fd;
527 fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
528 fds[n_fds] = a->segment->fd;
533 fd_flags |= SESSION_FD_F_MQ_EVENTFD;
545 rmp->
app_index = clib_host_to_net_u32 (a->app_index);
568 vl_api_application_detach_reply_t *rmp;
569 int rv = VNET_API_ERROR_INVALID_VALUE_2;
575 rv = VNET_API_ERROR_FEATURE_DISABLED;
594 vl_api_bind_uri_reply_t *rmp;
602 rv = VNET_API_ERROR_FEATURE_DISABLED;
610 a->uri = (
char *) mp->
uri;
616 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
634 vl_api_unbind_uri_reply_t *rmp;
641 rv = VNET_API_ERROR_FEATURE_DISABLED;
648 a->uri = (
char *) mp->
uri;
654 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
664 vl_api_connect_uri_reply_t *rmp;
671 rv = VNET_API_ERROR_FEATURE_DISABLED;
679 a->uri = (
char *) mp->
uri;
687 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
712 rv = VNET_API_ERROR_FEATURE_DISABLED;
725 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
767 vl_api_bind_sock_reply_t *rmp;
770 ip46_address_t *ip46;
775 rv = VNET_API_ERROR_FEATURE_DISABLED;
782 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
786 ip46 = (ip46_address_t *) mp->
ip;
788 a->sep.is_ip4 = mp->
is_ip4;
790 a->sep.port = mp->
port;
791 a->sep.fib_index = mp->
vrf;
793 a->sep.transport_proto = mp->
proto;
815 vl_api_unbind_sock_reply_t *rmp;
823 rv = VNET_API_ERROR_FEATURE_DISABLED;
846 session_event_t *evt;
872 vl_api_connect_sock_reply_t *rmp;
879 rv = VNET_API_ERROR_FEATURE_DISABLED;
887 ip46_address_t *ip46 = (ip46_address_t *) mp->
ip;
892 a->sep.is_ip4 = mp->
is_ip4;
894 a->sep.port = mp->
port;
895 a->sep.transport_proto = mp->
proto;
896 a->sep.peer.fib_index = mp->
vrf;
913 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
942 rv = VNET_API_ERROR_FEATURE_DISABLED;
953 rv = VNET_API_ERROR_INVALID_VALUE;
959 .wrk_map_index = clib_net_to_host_u32 (mp->
wrk_index),
976 fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
977 fds[n_fds] = args.segment->fd;
982 fd_flags |= SESSION_FD_F_MQ_EVENTFD;
991 rmp->
wrk_index = clib_host_to_net_u32 (args.wrk_map_index);
995 if (
vec_len (args.segment->name))
1016 u32 appns_index = 0;
1021 rv = VNET_API_ERROR_FEATURE_DISABLED;
1027 rv = VNET_API_ERROR_INVALID_VALUE;
1035 .secret = clib_net_to_host_u64 (mp->
secret),
1036 .sw_if_index = clib_net_to_host_u32 (mp->
sw_if_index),
1037 .ip4_fib_id = clib_net_to_host_u32 (mp->
ip4_fib_id),
1038 .ip6_fib_id = clib_net_to_host_u32 (mp->
ip6_fib_id),
1048 rv = VNET_API_ERROR_UNSPECIFIED;
1057 rmp->
appns_index = clib_host_to_net_u32 (appns_index);
1065 vl_api_session_rule_add_del_reply_t *rmp;
1074 table_args->lcl.fp_len = mp->
lcl_plen;
1075 table_args->lcl.fp_proto = fib_proto;
1076 table_args->rmt.fp_len = mp->
rmt_plen;
1077 table_args->rmt.fp_proto = fib_proto;
1078 table_args->lcl_port = mp->
lcl_port;
1079 table_args->rmt_port = mp->
rmt_port;
1080 table_args->action_index = clib_net_to_host_u32 (mp->
action_index);
1081 table_args->is_add = mp->
is_add;
1082 mp->
tag[
sizeof (mp->
tag) - 1] = 0;
1083 table_args->tag =
format (0,
"%s", mp->
tag);
1084 args.appns_index = clib_net_to_host_u32 (mp->
appns_index);
1085 args.scope = mp->
scope;
1088 clib_memset (&table_args->lcl.fp_addr, 0, sizeof (table_args->lcl.fp_addr));
1089 clib_memset (&table_args->rmt.fp_addr, 0, sizeof (table_args->rmt.fp_addr));
1101 u8 transport_proto,
u32 appns_index,
u8 * tag,
1105 session_mask_or_match_4_t *match =
1106 (session_mask_or_match_4_t *) & rule->match;
1107 session_mask_or_match_4_t *mask =
1108 (session_mask_or_match_4_t *) & rule->mask;
1112 rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
1122 rmp->
action_index = clib_host_to_net_u32 (rule->action_index);
1126 rmp->
appns_index = clib_host_to_net_u32 (appns_index);
1138 u8 transport_proto,
u32 appns_index,
u8 * tag,
1142 session_mask_or_match_6_t *match =
1143 (session_mask_or_match_6_t *) & rule->match;
1144 session_mask_or_match_6_t *mask =
1145 (session_mask_or_match_6_t *) & rule->mask;
1149 rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
1159 rmp->
action_index = clib_host_to_net_u32 (rule->action_index);
1163 rmp->
appns_index = clib_host_to_net_u32 (appns_index);
1175 u8 tp,
u8 is_local,
u32 appns_index,
1178 mma_rule_16_t *rule16;
1179 mma_rule_40_t *rule40;
1180 mma_rules_table_16_t *srt16;
1181 mma_rules_table_40_t *srt40;
1188 srt16 = &srt->session_rules_tables_16;
1190 ri = mma_rules_table_rule_index_16 (srt16, rule16);
1191 tag = session_rules_table_rule_tag (srt, ri, 1);
1192 send_session_rule_details4 (rule16, is_local, tp, appns_index, tag,
1201 srt40 = &srt->session_rules_tables_40;
1203 ri = mma_rules_table_rule_index_40 (srt40, rule40);
1204 tag = session_rules_table_rule_tag (srt, ri, 1);
1205 send_session_rule_details6 (rule40, is_local, tp, appns_index, tag,
1228 st->active_fib_proto, tp,
1229 st->is_local, st->appns_index, reg,
1248 rv = VNET_API_ERROR_FEATURE_DISABLED;
1253 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1258 cert_len = clib_net_to_host_u16 (mp->
cert_len);
1259 if (cert_len > 10000)
1261 rv = VNET_API_ERROR_INVALID_VALUE;
1273 REPLY_MACRO (VL_API_APPLICATION_TLS_CERT_ADD_REPLY);
1288 rv = VNET_API_ERROR_FEATURE_DISABLED;
1293 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
1298 key_len = clib_net_to_host_u16 (mp->
key_len);
1299 if (key_len > 10000)
1301 rv = VNET_API_ERROR_INVALID_VALUE;
1313 REPLY_MACRO (VL_API_APPLICATION_TLS_KEY_ADD_REPLY);
1324 a->api_client_index = client_index;
1332 #define vl_msg_name_crc_list 1334 #undef vl_msg_name_crc_list 1339 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 1340 foreach_vl_msg_name_crc_session;
1357 vl_msg_api_set_handlers(VL_API_##N, #n, \ 1358 vl_api_##n##_t_handler, \ 1360 vl_api_##n##_t_endian, \ 1361 vl_api_##n##_t_print, \ 1362 sizeof(vl_api_##n##_t), 1);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void vl_api_disconnect_session_reply_t_handler(vl_api_disconnect_session_reply_t *mp)
u32 al_index
App listener index in app's listener pool if a listener.
struct _vnet_app_worker_add_del_args vnet_app_worker_add_del_args_t
u32 connection_index
Index of the transport connection associated to the session.
#define ENDPOINT_INVALID_INDEX
#define APP_NAMESPACE_INVALID_INDEX
static clib_error_t * session_api_hookup(vlib_main_t *vm)
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
session_type_t session_type
Type built from transport and network protocol types.
static int send_del_segment_callback(u32 api_client_index, u64 segment_handle)
static void mq_notify_close_subscribers(u32 app_index, session_handle_t sh, svm_fifo_t *f, session_evt_type_t evt_type)
VL_MSG_API_REAPER_FUNCTION(application_reaper_cb)
struct _session_rules_table_t session_rules_table_t
struct _vnet_connect_args vnet_connect_args_t
struct _vnet_unlisten_args_t vnet_unlisten_args_t
static void vl_api_app_namespace_add_del_t_handler(vl_api_app_namespace_add_del_t *mp)
int vnet_app_namespace_add_del(vnet_app_namespace_add_del_args_t *a)
transport_connection_t * listen_session_get_transport(session_t *s)
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
uword vpp_event_queue_address
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
svm_fifo_segment_private_t * segment_manager_get_segment_w_handle(u64 segment_handle)
#define clib_memcpy_fast(a, b, c)
static void mq_send_session_close_evt(app_worker_t *app_wrk, session_handle_t sh, session_evt_type_t evt_type)
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
transport_connection_t * session_get_transport(session_t *s)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
u8 * message_bounce
Don't automatically free message buffer vetor.
static void vl_api_map_another_segment_reply_t_handler(vl_api_map_another_segment_reply_t *mp)
Bind to an ip:port pair for a given transport protocol.
static int svm_msg_q_get_producer_eventfd(svm_msg_q_t *mq)
static transport_proto_t session_get_transport_proto(session_t *s)
struct _vnet_app_namespace_add_del_args vnet_app_namespace_add_del_args_t
static int mq_send_session_bound_cb(u32 app_wrk_index, u32 api_context, session_handle_t handle, int rv)
application_t * application_lookup(u32 api_client_index)
app_listener_t * app_listener_get(application_t *app, u32 app_listener_index)
session_handle_t app_listener_handle(app_listener_t *al)
Request for map server summary status.
static void vl_api_unbind_sock_t_handler(vl_api_unbind_sock_t *mp)
int vnet_unlisten(vnet_unlisten_args_t *a)
#define foreach_session_api_msg
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
void * vl_msg_api_alloc(int nbytes)
u64 app_event_queue_address
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
app_worker_t * application_get_worker(application_t *app, u32 wrk_map_index)
application_t * application_get_if_valid(u32 app_index)
struct _vnet_bind_args_t vnet_listen_args_t
static session_handle_t session_handle(session_t *s)
struct _svm_fifo svm_fifo_t
int svm_msg_q_lock_and_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index, u8 noblock, svm_msg_q_msg_t *msg)
Lock message queue and allocate message buffer on ring.
Reply for app worker add/del.
#define SESSION_INVALID_INDEX
int application_is_proxy(application_t *app)
static void vl_api_connect_uri_t_handler(vl_api_connect_uri_t *mp)
static void mq_send_session_reset_cb(session_t *s)
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
struct _vnet_disconnect_args_t vnet_disconnect_args_t
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
add/del application namespace
static void vl_api_application_tls_cert_add_t_handler(vl_api_application_tls_cert_add_t *mp)
static void send_session_rule_details4(mma_rule_16_t *rule, u8 is_local, u8 transport_proto, u32 appns_index, u8 *tag, vl_api_registration_t *reg, u32 context)
u32 app_namespace_index_from_id(const u8 *ns_id)
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
static void vl_api_app_worker_add_del_t_handler(vl_api_app_worker_add_del_t *mp)
vpp->client unmap shared memory segment
static void vl_api_session_rules_dump_t_handler(vl_api_one_map_server_dump_t *mp)
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
session_t * app_listener_get_local_session(app_listener_t *al)
#define VL_API_INVALID_FI
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
session_t * app_listener_get_session(app_listener_t *al)
struct _session_rule_add_del_args session_rule_add_del_args_t
client->vpp, attach application to session layer
u8 hostname[hostname_len]
static void vl_api_disconnect_session_t_handler(vl_api_disconnect_session_t *mp)
static int session_send_fds(vl_api_registration_t *reg, int fds[], int n_fds)
int vnet_session_rule_add_del(session_rule_add_del_args_t *args)
static clib_error_t * application_reaper_cb(u32 client_index)
u32 wrk_index
Worker index in global worker pool.
uword vpp_event_queue_address
u64 session_segment_handle(session_t *s)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
static u64 listen_session_get_handle(session_t *s)
u32 ip6_mask_to_preflen(ip6_address_t *mask)
API main structure, used by both vpp and binary API clients.
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
static int mq_try_lock_and_alloc_msg(svm_msg_q_t *app_mq, svm_msg_q_msg_t *msg)
An API client registration, only in vpp/vlib.
static transport_connection_t * transport_get_connection(transport_proto_t tp, u32 conn_index, u8 thread_index)
session_t * app_worker_first_listener(app_worker_t *app, u8 fib_proto, u8 transport_proto)
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
struct _stream_session_cb_vft session_cb_vft_t
struct _transport_connection transport_connection_t
static void mq_send_session_disconnected_cb(session_t *s)
u32 ip4_mask_to_preflen(ip4_address_t *mask)
static void send_session_rules_table_details(session_rules_table_t *srt, u8 fib_proto, u8 tp, u8 is_local, u32 appns_index, vl_api_registration_t *reg, u32 context)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Application attach reply.
static clib_error_t * vl_api_send_fd_msg(vl_api_registration_t *reg, int fds[], int n_fds)
static u32 vl_api_registration_file_index(vl_api_registration_t *reg)
application_t * application_get(u32 app_index)
int vnet_unbind_uri(vnet_unlisten_args_t *a)
static void send_session_rule_details6(mma_rule_40_t *rule, u8 is_local, u8 transport_proto, u32 appns_index, u8 *tag, vl_api_registration_t *reg, u32 context)
app_listener_t * app_listener_get_w_handle(session_handle_t handle)
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
enable/disable session layer
static void vl_api_connect_sock_t_handler(vl_api_connect_sock_t *mp)
session_t * ct_session_get_peer(session_t *s)
Reply for app namespace add/del.
u64 app_event_queue_address
client->vpp, attach application to session layer
int vnet_listen(vnet_listen_args_t *a)
static fib_protocol_t session_get_fib_proto(session_t *s)
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
static void vl_api_bind_sock_t_handler(vl_api_bind_sock_t *mp)
vpp->client, please map an additional shared memory segment
#define clib_error_report(e)
static int mq_send_session_accepted_cb(session_t *s)
struct _vnet_app_detach_args_t vnet_app_detach_args_t
static uword pointer_to_uword(const void *p)
int vnet_connect(vnet_connect_args_t *a)
Connect to a remote peer.
static vlib_main_t * vlib_get_main(void)
u8 thread_index
Index of the thread that allocated the session.
static void vl_api_application_attach_t_handler(vl_api_application_attach_t *mp)
static void setup_message_id_table(api_main_t *am)
u32 app_index
App index in app pool.
static u8 session_type_is_ip4(session_type_t st)
bidirectional disconnect API
static session_cb_vft_t session_mq_cb_vft
add/del application worker
app_worker_t * app_worker_get(u32 wrk_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define STATIC_ASSERT(truth,...)
static void vl_api_application_tls_key_add_t_handler(vl_api_application_tls_key_add_t *mp)
int vnet_bind_uri(vnet_listen_args_t *a)
ssvm_private_t * session_main_get_evt_q_segment(void)
#define clib_error_get_code(err)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
VLIB_API_INIT_FUNCTION(session_api_hookup)
struct _session_lookup_table session_table_t
int vnet_app_worker_add_del(vnet_app_worker_add_del_args_t *a)
struct _svm_queue svm_queue_t
void * vl_mem_api_alloc_as_if_client_w_reg(vl_api_registration_t *reg, int nbytes)
static void vl_api_application_detach_t_handler(vl_api_application_detach_t *mp)
static u8 session_has_transport(session_t *s)
struct _session_rules_table_add_del_args session_rule_table_add_del_args_t
u32 app_index
Index of owning app.
static u8 svm_fifo_n_subscribers(svm_fifo_t *f)
#define session_table_foreach(VAR, BODY)
Application add TLS certificate.
static int send_add_segment_callback(u32 api_client_index, u64 segment_handle)
u32 app_wrk_index
Index of the app worker that owns the session.
static void vl_api_session_rule_add_del_t_handler(vl_api_session_rule_add_del_t *mp)
bidirectional disconnect reply API
u32 api_client_index
API index for the worker.
int vnet_connect_uri(vnet_connect_args_t *a)
segment_manager_properties_t * application_segment_manager_properties(application_t *app)
svm_msg_q_t * event_queue
Application listens for events on this svm queue.
static transport_service_type_t session_transport_service_type(session_t *s)
static int mq_send_session_connected_cb(u32 app_wrk_index, u32 api_context, session_t *s, u8 is_fail)
static void vl_api_bind_uri_t_handler(vl_api_bind_uri_t *mp)
static session_t * listen_session_get(u32 ls_index)
non-blocking call - works with both condvar and eventfd signaling
u32 listener_index
Parent listener session index if the result of an accept.
static u8 session_main_is_enabled()
static void vl_api_unbind_uri_t_handler(vl_api_unbind_uri_t *mp)
ssvm_segment_type_t ssvm_type(const ssvm_private_t *ssvm)