Red Hat Bugzilla – Bug 1269000
virNetLinkCommand receives truncated netlink response while parsing vf config
Last modified: 2016-05-02 11:14:45 EDT
Created attachment 1080081 [details]
Patch to increase netlink socket msg buffer size.
virNetlinkCommand function in virnetlink.c sometimes receives truncated nl_recv response while parsing vf config.
This typically happens with > 32 vfs.
libnl1 had a bug where they increased the netlink response buffer size from 1 page to 4 pages in libnl3.
if (page_size == 0)
page_size = getpagesize() * 4;
iov.iov_len = sk->s_bufsize ? : page_size;
While this addressed 64 vfs, there are some chipsets like broadcom 57810 which support 128 vfs.
4 pages would be insufficient.
But considering libnl3 introduced the nl_socket_set_msg_buf_size to set the netlink sock msg buffer size before receives (and also used above in sk->s_bufsize if set),
I presume its reasonable to also keep a safe socket buffer size from libvirt while making netlink calls.
We could do this in:
virNetlinkCommand after netlink sock alloc to set a buffer to 32kb which should suffice.
Please find the proposed patch in the attachment that increases the netlink socket msg buf size.
This should be safe while fetching the link dump from virnetdev.c before parsing vf config for > 64 vfs and while using libnl3.
Thanks for the patch. Can you make send it to email@example.com and CC firstname.lastname@example.org, and reference this bug.
A patch went in to address this "once and for all" in January. It was in libvirt-1.3.2:
Author: Leno Hou <email@example.com>
Date: Mon Jan 11 14:59:00 2016 +0800
util: increase libnl buffer size
In the following cases nl_recv() was returning the error "No buffer
* When switching CPUs to offline/online in a system more than 128 cpus
* When using virsh to destroy domain in a system with many interfaces
This patch sets the buffer size for all netlink sockets created by
libnl to 128K and turns on message peeking for nl_recv(). This
eliminates the "No buffer space available" errors seen in the cases
above, and also preempts other future errors the smaller buffers could