summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/socket.c49
-rw-r--r--src/vppinfra/socket.h3
2 files changed, 11 insertions, 41 deletions
diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c
index 40374d736c5..ef0eaaee0a3 100644
--- a/src/vppinfra/socket.c
+++ b/src/vppinfra/socket.c
@@ -374,6 +374,16 @@ clib_socket_prefix_is_valid (char *s)
return 0;
}
+__clib_export int
+clib_socket_prefix_get_type (char *s)
+{
+ for (typeof (clib_socket_type_data[0]) *d = clib_socket_type_data;
+ d - clib_socket_type_data < ARRAY_LEN (clib_socket_type_data); d++)
+ if (strncmp (s, d->prefix, strlen (d->prefix)) == 0)
+ return d->type;
+ return 0;
+}
+
__clib_export clib_error_t *
clib_socket_init (clib_socket_t *s)
{
@@ -731,45 +741,6 @@ done:
}
__clib_export clib_error_t *
-clib_socket_init_netns (clib_socket_t *s, u8 *namespace)
-{
- if (namespace == NULL || namespace[0] == 0)
- return clib_socket_init (s);
-
- clib_error_t *error;
- int old_netns_fd, nfd = -1;
-
- old_netns_fd = clib_netns_open (NULL /* self */);
- if (old_netns_fd < 0)
- return clib_error_return_unix (0, "get current netns failed");
-
- if ((nfd = clib_netns_open (namespace)) == -1)
- {
- error = clib_error_return_unix (0, "clib_netns_open '%s'", namespace);
- goto done;
- }
-
- if (clib_setns (nfd) == -1)
- {
- error = clib_error_return_unix (0, "setns '%s'", namespace);
- goto done;
- }
-
- error = clib_socket_init (s);
-
-done:
- if (clib_setns (old_netns_fd) == -1)
- clib_warning ("Cannot set old ns");
-
- close (old_netns_fd);
-
- if (-1 != nfd)
- close (nfd);
-
- return error;
-}
-
-__clib_export clib_error_t *
clib_socket_accept (clib_socket_t * server, clib_socket_t * client)
{
clib_error_t *err = 0;
diff --git a/src/vppinfra/socket.h b/src/vppinfra/socket.h
index 132e89f2871..13e09e66a91 100644
--- a/src/vppinfra/socket.h
+++ b/src/vppinfra/socket.h
@@ -118,12 +118,11 @@ typedef struct _socket_t
from IPPORT_USERRESERVED (5000). */
clib_error_t *clib_socket_init (clib_socket_t * socket);
-clib_error_t *clib_socket_init_netns (clib_socket_t *socket, u8 *namespace);
-
clib_error_t *clib_socket_accept (clib_socket_t * server,
clib_socket_t * client);
int clib_socket_prefix_is_valid (char *s);
+int clib_socket_prefix_get_type (char *s);
always_inline uword
clib_socket_is_server (clib_socket_t * sock)