vlib: add missing file template descriptions 01/24601/6
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Tue, 28 Jan 2020 19:47:17 +0000 (14:47 -0500)
committerNeale Ranns <nranns@cisco.com>
Mon, 28 Dec 2020 09:45:41 +0000 (09:45 +0000)
Add descriptions to clib_file_t template structures so that
sockets can be identified via the 'show unix file' cli command.

Type: fix

Change-Id: Ibf82d55aa6c7b1126bd252b76d0dc8b7076f5046
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
extras/deprecated/netmap/netmap.c
src/vlib/unix/mc_socket.c
src/vlibmemory/socket_api.c
src/vnet/devices/virtio/vhost_user.c
src/vnet/ip/punt.c
src/vnet/unix/tuntap.c

index 03d9621..7cab6bb 100644 (file)
@@ -194,6 +194,7 @@ netmap_create_if (vlib_main_t * vm, u8 * if_name, u8 * hw_addr_set,
     template.read_function = netmap_fd_read_ready;
     template.file_descriptor = nif->fd;
     template.private_data = nif->if_index;
+    template.description = format (0, "netmap socket");
     nif->clib_file_index = clib_file_add (&file_main, &template);
   }
 
index 86ee436..9800b1e 100644 (file)
@@ -95,7 +95,7 @@ sendmsg_helper (mc_socket_main_t * msm,
   n_bytes = append_buffer_index_to_iovec (vm, buffer_index, &msm->iovecs);
   ASSERT (n_bytes <= msm->mc_main.transport.max_packet_size);
   if (n_bytes > msm->mc_main.transport.max_packet_size)
-    clib_error ("sending packet larger than interace MTU %d bytes", n_bytes);
+    clib_error ("sending packet larger than interface MTU %d bytes", n_bytes);
 
   h.msg_iov = msm->iovecs;
   h.msg_iovlen = vec_len (msm->iovecs);
@@ -616,6 +616,7 @@ catchup_listen_read_ready (clib_file_t * uf)
   template.write_function = catchup_server_write_ready;
   template.error_function = catchup_socket_error_ready;
   template.file_descriptor = c->socket;
+  template.description = format (0, "multicast catchup socket");
   template.private_data = pointer_to_uword (msm);
   c->clib_file_index = clib_file_add (&file_main, &template);
   hash_set (msm->catchup_index_by_file_descriptor, c->socket,
@@ -786,6 +787,7 @@ socket_setup (mc_socket_main_t * msm)
     template.file_descriptor =
       msm->multicast_sockets[MC_TRANSPORT_USER_REQUEST_TO_RELAY].socket;
     template.private_data = (uword) msm;
+    template.description = format (0, "multicast to_relay socket");
     clib_file_add (&file_main, &template);
 
     /* epoll setup for multicast from_relay socket */
@@ -793,24 +795,28 @@ socket_setup (mc_socket_main_t * msm)
     template.file_descriptor =
       msm->multicast_sockets[MC_TRANSPORT_USER_REQUEST_FROM_RELAY].socket;
     template.private_data = (uword) msm;
+    template.description = format (0, "multicast from_relay socket");
     clib_file_add (&file_main, &template);
 
     template.read_function = join_socket_read_ready;
     template.file_descriptor =
       msm->multicast_sockets[MC_TRANSPORT_JOIN].socket;
     template.private_data = (uword) msm;
+    template.description = format (0, "multicast join socket");
     clib_file_add (&file_main, &template);
 
     /* epoll setup for ack rx socket */
     template.read_function = ack_socket_read_ready;
     template.file_descriptor = msm->ack_socket;
     template.private_data = (uword) msm;
+    template.description = format (0, "multicast ack rx socket");
     clib_file_add (&file_main, &template);
 
     /* epoll setup for TCP catchup server */
     template.read_function = catchup_listen_read_ready;
     template.file_descriptor = msm->catchup_server_socket;
     template.private_data = (uword) msm;
+    template.description = format (0, "multicast tcp catchup socket");
     clib_file_add (&file_main, &template);
   }
 
@@ -903,6 +909,7 @@ catchup_request_fun (void *transport_main,
     template.error_function = catchup_socket_error_ready;
     template.file_descriptor = c->socket;
     template.private_data = (uword) msm;
+    template.description = format (0, "multicast socket");
     c->clib_file_index = clib_file_add (um, &template);
 
     hash_set (msm->catchup_index_by_file_descriptor, c->socket,
index a5fb86b..546791b 100644 (file)
@@ -410,6 +410,7 @@ socksvr_file_add (clib_file_main_t * fm, int fd)
   template.write_function = vl_socket_write_ready;
   template.error_function = vl_socket_error_ready;
   template.file_descriptor = fd;
+  template.description = format (0, "socksrv");
   template.private_data = rp - socket_main.registration_pool;
 
   rp->registration_type = REGISTRATION_TYPE_SOCKET_SERVER;
@@ -767,6 +768,7 @@ vl_sock_api_init (vlib_main_t * vm)
   template.read_function = socksvr_accept_ready;
   template.write_function = socksvr_bogus_write;
   template.file_descriptor = sock->fd;
+  template.description = format (0, "socksvr %s", sock->config);
   template.private_data = rp - sm->registration_pool;
 
   rp->clib_file_index = clib_file_add (fm, &template);
index 5c5d23f..573d657 100644 (file)
@@ -746,6 +746,7 @@ vhost_user_socket_read (clib_file_t * uf)
          template.file_descriptor = fds[0];
          template.private_data =
            ((vui - vhost_user_main.vhost_user_interfaces) << 8) + q;
+         template.description = format (0, "vhost user");
          vui->vrings[q].callfd_idx = clib_file_add (&file_main, &template);
        }
       else
@@ -1098,6 +1099,7 @@ vhost_user_socksvr_accept_ready (clib_file_t * uf)
   template.error_function = vhost_user_socket_error;
   template.file_descriptor = client_fd;
   template.private_data = vui - vhost_user_main.vhost_user_interfaces;
+  template.description = format (0, "vhost interface %d", vui->sw_if_index);
   vui->clib_file_index = clib_file_add (&file_main, &template);
   vui->num_qid = 2;
   return 0;
@@ -1251,6 +1253,7 @@ vhost_user_process (vlib_main_t * vm,
   sun.sun_family = AF_UNIX;
   template.read_function = vhost_user_socket_read;
   template.error_function = vhost_user_socket_error;
+  template.description = format (0, "vhost user process");
 
   while (1)
     {
@@ -1577,6 +1580,7 @@ vhost_user_vui_init (vnet_main_t * vnm,
       template.read_function = vhost_user_socksvr_accept_ready;
       template.file_descriptor = server_sock_fd;
       template.private_data = vui - vum->vhost_user_interfaces;        //hw index
+      template.description = format (0, "vhost user %d", sw);
       vui->unix_server_index = clib_file_add (&file_main, &template);
     }
   else
index ffe0b83..7cdb5fc 100644 (file)
@@ -869,7 +869,7 @@ punt_config (vlib_main_t * vm, unformat_input_t * input)
   clib_file_t template = { 0 };
   template.read_function = punt_socket_read_ready;
   template.file_descriptor = pm->socket_fd;
-  template.description = format (0, "%s", socket_path);
+  template.description = format (0, "punt socket %s", socket_path);
   pm->clib_file_index = clib_file_add (fm, &template);
 
   pm->is_configured = true;
index 6834ee8..50f02df 100644 (file)
@@ -665,6 +665,7 @@ tuntap_config (vlib_main_t * vm, unformat_input_t * input)
     clib_file_t template = { 0 };
     template.read_function = tuntap_read_ready;
     template.file_descriptor = tm->dev_net_tun_fd;
+    template.description = format (0, "vnet tuntap");
     tm->clib_file_index = clib_file_add (&file_main, &template);
   }