aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/netlink.c11
-rw-r--r--src/vnet/devices/virtio/tap.c2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/vnet/devices/netlink.c b/src/vnet/devices/netlink.c
index b2a651348a3..b05daf2674a 100644
--- a/src/vnet/devices/netlink.c
+++ b/src/vnet/devices/netlink.c
@@ -48,16 +48,16 @@ vnet_netlink_set_if_attr (int ifindex, unsigned short rta_type, void *data,
memset (&req, 0, sizeof (req));
if ((sock = socket (AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) == -1)
- {
- err = clib_error_return_unix (0, "socket(AF_NETLINK)");
- goto error;
- }
+ return clib_error_return_unix (0, "socket(AF_NETLINK)");
ra.nl_family = AF_NETLINK;
ra.nl_pid = getpid ();
if ((bind (sock, (struct sockaddr *) &ra, sizeof (ra))) == -1)
- return clib_error_return_unix (0, "bind");
+ {
+ err = clib_error_return_unix (0, "bind");
+ goto error;
+ }
req.nh.nlmsg_len = NLMSG_LENGTH (sizeof (struct ifinfomsg));
req.nh.nlmsg_flags = NLM_F_REQUEST;
@@ -75,6 +75,7 @@ vnet_netlink_set_if_attr (int ifindex, unsigned short rta_type, void *data,
err = clib_error_return_unix (0, "send");
error:
+ close (sock);
return err;
}
diff --git a/src/vnet/devices/virtio/tap.c b/src/vnet/devices/virtio/tap.c
index f6db2c90616..34339c95737 100644
--- a/src/vnet/devices/virtio/tap.c
+++ b/src/vnet/devices/virtio/tap.c
@@ -109,7 +109,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
}
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR;
- strncpy (ifr.ifr_ifrn.ifrn_name, (char *) args->name, IF_NAMESIZE);
+ strncpy (ifr.ifr_ifrn.ifrn_name, (char *) args->name, IF_NAMESIZE - 1);
_IOCTL (vif->tap_fd, TUNSETIFF, (void *) &ifr);
vif->ifindex = if_nametoindex ((char *) args->name);