aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Rose2013-01-03 18:33:34 -0600
committerGreg Kroah-Hartman2013-01-17 10:43:58 -0600
commita0d3aa1f04a7430fc80f6f1a7aaaaf495da8d8e1 (patch)
treecd4e0a2b2a532c4c2e846c6ed29081d0d14f43da /include
parent2e3cbdeae8e4d13087657d95ed7a5be57dc9695e (diff)
downloadkernel-common-a0d3aa1f04a7430fc80f6f1a7aaaaf495da8d8e1.tar.gz
kernel-common-a0d3aa1f04a7430fc80f6f1a7aaaaf495da8d8e1.tar.xz
kernel-common-a0d3aa1f04a7430fc80f6f1a7aaaaf495da8d8e1.zip
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> Acked-by: Greg Rose <gregory.v.rose@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> [bwh: Backported to 3.0: - Adjust context - Drop the change in do_setlink() that reverts commit f18da1456581 ('net: RTNETLINK adjusting values of min_ifinfo_dump_size'), which was never applied here] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/if_link.h1
-rw-r--r--include/linux/rtnetlink.h3
-rw-r--r--include/net/rtnetlink.h2
3 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 0ee969a5593..61a48b5670d 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -137,6 +137,7 @@ enum {
137 IFLA_AF_SPEC, 137 IFLA_AF_SPEC,
138 IFLA_GROUP, /* Group the device belongs to */ 138 IFLA_GROUP, /* Group the device belongs to */
139 IFLA_NET_NS_FD, 139 IFLA_NET_NS_FD,
140 IFLA_EXT_MASK, /* Extended info mask, VFs, etc */
140 __IFLA_MAX 141 __IFLA_MAX
141}; 142};
142 143
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index bbad657a372..5415dfb2235 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -600,6 +600,9 @@ struct tcamsg {
600#define TCA_ACT_TAB 1 /* attr type must be >=1 */ 600#define TCA_ACT_TAB 1 /* attr type must be >=1 */
601#define TCAA_MAX 1 601#define TCAA_MAX 1
602 602
603/* New extended info filters for IFLA_EXT_MASK */
604#define RTEXT_FILTER_VF (1 << 0)
605
603/* End of information exported to user level */ 606/* End of information exported to user level */
604 607
605#ifdef __KERNEL__ 608#ifdef __KERNEL__
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 678f1ffaf84..37029390197 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -6,7 +6,7 @@
6 6
7typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *); 7typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *);
8typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); 8typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);
9typedef u16 (*rtnl_calcit_func)(struct sk_buff *); 9typedef u16 (*rtnl_calcit_func)(struct sk_buff *, struct nlmsghdr *);
10 10
11extern int __rtnl_register(int protocol, int msgtype, 11extern int __rtnl_register(int protocol, int msgtype,
12 rtnl_doit_func, rtnl_dumpit_func, 12 rtnl_doit_func, rtnl_dumpit_func,