rtnetlink: Fix problem with buffer allocation
authorGreg Rose <gregory.v.rose@intel.com>
Tue, 21 Feb 2012 21:54:48 +0000 (16:54 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 16 Nov 2012 16:46:52 +0000 (16:46 +0000)
commitd318a127e273716c9531fe70d497ca24db4c0bf1
tree2d143c9bcaf9697cfe60288880f74d75a5c28529
parentca9d9980c95b9cb3cbacb39408873d0f9b06fa7b
rtnetlink: Fix problem with buffer allocation

commit 115c9b81928360d769a76c632bae62d15206a94a upstream.

Implement a new netlink attribute type IFLA_EXT_MASK.  The mask
is a 32 bit value that can be used to indicate to the kernel that
certain extended ifinfo values are requested by the user application.
At this time the only mask value defined is RTEXT_FILTER_VF to
indicate that the user wants the ifinfo dump to send information
about the VFs belonging to the interface.

This patch fixes a bug in which certain applications do not have
large enough buffers to accommodate the extra information returned
by the kernel with large numbers of SR-IOV virtual functions.
Those applications will not send the new netlink attribute with
the interface info dump request netlink messages so they will
not get unexpectedly large request buffers returned by the kernel.

Modifies the rtnl_calcit function to traverse the list of net
devices and compute the minimum buffer size that can hold the
info dumps of all matching devices based upon the filter passed
in via the new netlink attribute filter mask.  If no filter
mask is sent then the buffer allocation defaults to NLMSG_GOODSIZE.

With this change it is possible to add yet to be defined netlink
attributes to the dump request which should make it fairly extensible
in the future.

Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: drop the change in do_setlink() that reverts
 commit f18da14565819ba43b8321237e2426a2914cc2ef, which we never applied]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/linux/if_link.h
include/linux/rtnetlink.h
include/net/rtnetlink.h
net/core/rtnetlink.c