chiark / gitweb /
sd-rtnl: allow sd_rtnl_open_fd() to be used on bound sockets
authorTom Gundersen <teg@jklm.no>
Tue, 3 Feb 2015 20:33:04 +0000 (21:33 +0100)
committerTom Gundersen <teg@jklm.no>
Tue, 3 Feb 2015 21:20:38 +0000 (22:20 +0100)
src/libsystemd/sd-rtnl/sd-rtnl.c

index 45ba50a..ae49c77 100644 (file)
@@ -146,7 +146,8 @@ static int rtnl_open_fd_ap(sd_rtnl **ret, int fd, unsigned n_groups, va_list ap)
         addrlen = sizeof(rtnl->sockaddr);
 
         r = bind(fd, &rtnl->sockaddr.sa, addrlen);
-        if (r < 0)
+        /* ignore EINVAL to allow opening an already bound socket */
+        if (r < 0 && errno != EINVAL)
                 return -errno;
 
         r = getsockname(fd, &rtnl->sockaddr.sa, &addrlen);