From 0c3d467df4c5651df03895d06444f6e830e9688c Mon Sep 17 00:00:00 2001 From: Andrew Yourtchenko Date: Tue, 3 Jan 2017 16:52:22 +0000 Subject: VPP-574: fix VPP hang during security group configuration on a suspended VM The unix connect() in vhost-user driver in VPP is blocking, and a non-expedient accept() on the other side causes the entire VPP to hang. Solution: set the nonblocking flag for the socket fd before calling connect(), and set the socket back to blocking after the accept() succeeds. Change-Id: Ia5ee782037eeffabdad71db8241f476a048a4f6f Signed-off-by: Andrew Yourtchenko --- src/vnet/devices/virtio/vhost-user.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/vnet') diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index f9bbae4f90f..3fbcee90752 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -2325,9 +2325,13 @@ vhost_user_process (vlib_main_t * vm, strncpy (sun.sun_path, (char *) vui->sock_filename, sizeof (sun.sun_path) - 1); + /* Avoid hanging VPP if the other end does not accept */ + fcntl(sockfd, F_SETFL, O_NONBLOCK); if (connect (sockfd, (struct sockaddr *) &sun, sizeof (struct sockaddr_un)) == 0) { + /* Set the socket to blocking as it was before */ + fcntl(sockfd, F_SETFL, 0); vui->sock_errno = 0; template.file_descriptor = sockfd; template.private_data = -- cgit 1.2.3-korg