Bug 1269000 - virNetLinkCommand receives truncated netlink response while parsing vf config
Summary: virNetLinkCommand receives truncated netlink response while parsing vf config
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-10-05 21:42 UTC by A R Karthick
Modified: 2016-05-02 15:14 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-02 15:14:45 UTC
Embargoed:


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

Description A R Karthick 2015-10-05 21:42:04 UTC
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 22:36:47 UTC
Thanks for the patch. Can you make send it to libvir-list and CC laine, and reference this bug.

Comment 2 Laine Stump 2016-05-02 15:14:45 UTC
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.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.