aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-07-27 19:51:27 +0200
committerFlorin Coras <florin.coras@gmail.com>2021-07-27 19:27:09 +0000
commit9218c60c2bd3bffa5bd79adfe64f048d2976a080 (patch)
tree815349ac1971dd16daeaa0ff7deca350402ae8c7
parent7743d6bde8fc674187835f4858f198454c162dd6 (diff)
vppinfra: fix sock init netns
Type: fix Change-Id: I0ce8183ded601bdab031c9689ca361414fed165f Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
-rw-r--r--src/vppinfra/socket.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c
index 26427d98fa1..2921e008018 100644
--- a/src/vppinfra/socket.c
+++ b/src/vppinfra/socket.c
@@ -560,7 +560,7 @@ clib_socket_init_netns (clib_socket_t *s, u8 *namespace)
return clib_socket_init (s);
clib_error_t *error;
- int old_netns_fd, nfd;
+ int old_netns_fd, nfd = -1;
old_netns_fd = clib_netns_open (NULL /* self */);
if ((nfd = clib_netns_open (namespace)) == -1)
@@ -580,8 +580,12 @@ clib_socket_init_netns (clib_socket_t *s, u8 *namespace)
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;
}