diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 6836c21c..7e977a67 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -1175,16 +1175,16 @@ int rtnl_listen(struct rtnl_handle *rtnl, char buf[16384]; char cmsgbuf[BUFSIZ]; - if (rtnl->flags & RTNL_HANDLE_F_LISTEN_ALL_NSID) { - msg.msg_control = &cmsgbuf; - msg.msg_controllen = sizeof(cmsgbuf); - } - iov.iov_base = buf; while (1) { struct rtnl_ctrl_data ctrl; struct cmsghdr *cmsg; + if (rtnl->flags & RTNL_HANDLE_F_LISTEN_ALL_NSID) { + msg.msg_control = &cmsgbuf; + msg.msg_controllen = sizeof(cmsgbuf); + } + iov.iov_len = sizeof(buf); status = recvmsg(rtnl->fd, &msg, 0);