rtnetlink: Compute and store minimum ifinfo dump size
The message size allocated for rtnl ifinfo dumps was limited to a single page. This is not enough for additional interface info available with devices that support SR-IOV and caused a bug in which VF info would not be displayed if more than approximately 40 VFs were created per interface. Implement a new function pointer for the rtnl_register service that will calculate the amount of data required for the ifinfo dump and allocate enough data to satisfy the request. Signed-off-by: Greg Rose <gregory.v.rose@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
@@ -1659,13 +1659,10 @@ static int netlink_dump(struct sock *sk)
|
||||
{
|
||||
struct netlink_sock *nlk = nlk_sk(sk);
|
||||
struct netlink_callback *cb;
|
||||
struct sk_buff *skb;
|
||||
struct sk_buff *skb = NULL;
|
||||
struct nlmsghdr *nlh;
|
||||
int len, err = -ENOBUFS;
|
||||
|
||||
skb = sock_rmalloc(sk, NLMSG_GOODSIZE, 0, GFP_KERNEL);
|
||||
if (!skb)
|
||||
goto errout;
|
||||
int alloc_size;
|
||||
|
||||
mutex_lock(nlk->cb_mutex);
|
||||
|
||||
@@ -1675,6 +1672,12 @@ static int netlink_dump(struct sock *sk)
|
||||
goto errout_skb;
|
||||
}
|
||||
|
||||
alloc_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
|
||||
|
||||
skb = sock_rmalloc(sk, alloc_size, 0, GFP_KERNEL);
|
||||
if (!skb)
|
||||
goto errout;
|
||||
|
||||
len = cb->dump(skb, cb);
|
||||
|
||||
if (len > 0) {
|
||||
@@ -1721,7 +1724,8 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
|
||||
const struct nlmsghdr *nlh,
|
||||
int (*dump)(struct sk_buff *skb,
|
||||
struct netlink_callback *),
|
||||
int (*done)(struct netlink_callback *))
|
||||
int (*done)(struct netlink_callback *),
|
||||
u16 min_dump_alloc)
|
||||
{
|
||||
struct netlink_callback *cb;
|
||||
struct sock *sk;
|
||||
@@ -1735,6 +1739,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
|
||||
cb->dump = dump;
|
||||
cb->done = done;
|
||||
cb->nlh = nlh;
|
||||
cb->min_dump_alloc = min_dump_alloc;
|
||||
atomic_inc(&skb->users);
|
||||
cb->skb = skb;
|
||||
|
||||
|
Reference in New Issue
Block a user