Bug 1269000 - virNetLinkCommand receives truncated netlink response while parsing vf config
virNetLinkCommand receives truncated netlink response while parsing vf config
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
All All
unspecified Severity medium
: ---
: ---
Assigned To: Libvirt Maintainers
Depends On:
  Show dependency treegraph
Reported: 2015-10-05 17:42 EDT by A R Karthick
Modified: 2016-05-02 11:14 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-05-02 11:14:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to increase netlink socket msg buffer size. (1020 bytes, patch)
2015-10-05 17:42 EDT, A R Karthick
no flags Details | Diff

  None (edit)
Description A R Karthick 2015-10-05 17:42:04 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.
Comment 1 Cole Robinson 2016-04-10 18:36:47 EDT
Thanks for the patch. Can you make send it to libvir-list@redhat.com and CC laine@laine.org, and reference this bug.
Comment 2 Laine Stump 2016-05-02 11:14:45 EDT
A patch went in to address this "once and for all" in January. It was in libvirt-1.3.2:

commit 8c70d04bab7278c96390a913fa949a17cd3124f9
Author: Leno Hou <houqy@linux.vnet.ibm.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
    space available":
    * 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
    have caused.

Note You need to log in before you can comment on or make changes to this bug.