{"id":818595,"url":"http://patchwork.ozlabs.org/api/patches/818595/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170926115843.12013-3-fw@strlen.de/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170926115843.12013-3-fw@strlen.de>","list_archive_url":null,"date":"2017-09-26T11:58:41","name":"[net-next,v4,2/4] rtnetlink: add helpers to dump vf information","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"8f8975a0b00a9e84b793a71e7ce0b894e8de5858","submitter":{"id":1025,"url":"http://patchwork.ozlabs.org/api/people/1025/?format=json","name":"Florian Westphal","email":"fw@strlen.de"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170926115843.12013-3-fw@strlen.de/mbox/","series":[{"id":5115,"url":"http://patchwork.ozlabs.org/api/series/5115/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=5115","date":"2017-09-26T11:58:39","name":"rtnetlink: preparation patches for further rtnl lock pushdown/removal","version":4,"mbox":"http://patchwork.ozlabs.org/series/5115/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818595/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818595/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y1fcD0nHZz9t67\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 26 Sep 2017 21:58:36 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S937200AbdIZL6e (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 26 Sep 2017 07:58:34 -0400","from Chamillionaire.breakpoint.cc ([146.0.238.67]:58790 \"EHLO\n\tChamillionaire.breakpoint.cc\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S936361AbdIZL6d (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 26 Sep 2017 07:58:33 -0400","from fw by Chamillionaire.breakpoint.cc with local (Exim 4.84_2)\n\t(envelope-from <fw@breakpoint.cc>)\n\tid 1dwoS8-0007Az-QL; Tue, 26 Sep 2017 13:55:04 +0200"],"From":"Florian Westphal <fw@strlen.de>","To":"<netdev@vger.kernel.org>","Cc":"Florian Westphal <fw@strlen.de>","Subject":"[PATCH net-next v4 2/4] rtnetlink: add helpers to dump vf\n\tinformation","Date":"Tue, 26 Sep 2017 13:58:41 +0200","Message-Id":"<20170926115843.12013-3-fw@strlen.de>","X-Mailer":"git-send-email 2.13.5","In-Reply-To":"<20170926115843.12013-1-fw@strlen.de>","References":"<20170926115843.12013-1-fw@strlen.de>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"similar to earlier patches, split out more parts of this function to\nbetter see what is happening and where we assume rtnl is locked.\n\nReviewed-by: David Ahern <dsahern@gmail.com>\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n No changes in v4.\n\n net/core/rtnetlink.c | 50 +++++++++++++++++++++++++++++++-------------------\n 1 file changed, 31 insertions(+), 19 deletions(-)","diff":"diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c\nindex c801212ee40e..d504e78cd01f 100644\n--- a/net/core/rtnetlink.c\n+++ b/net/core/rtnetlink.c\n@@ -1211,6 +1211,36 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,\n \treturn -EMSGSIZE;\n }\n \n+static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,\n+\t\t\t\t\t   struct net_device *dev,\n+\t\t\t\t\t   u32 ext_filter_mask)\n+{\n+\tstruct nlattr *vfinfo;\n+\tint i, num_vfs;\n+\n+\tif (!dev->dev.parent || ((ext_filter_mask & RTEXT_FILTER_VF) == 0))\n+\t\treturn 0;\n+\n+\tnum_vfs = dev_num_vf(dev->dev.parent);\n+\tif (nla_put_u32(skb, IFLA_NUM_VF, num_vfs))\n+\t\treturn -EMSGSIZE;\n+\n+\tif (!dev->netdev_ops->ndo_get_vf_config)\n+\t\treturn 0;\n+\n+\tvfinfo = nla_nest_start(skb, IFLA_VFINFO_LIST);\n+\tif (!vfinfo)\n+\t\treturn -EMSGSIZE;\n+\n+\tfor (i = 0; i < num_vfs; i++) {\n+\t\tif (rtnl_fill_vfinfo(skb, dev, i, vfinfo))\n+\t\t\treturn -EMSGSIZE;\n+\t}\n+\n+\tnla_nest_end(skb, vfinfo);\n+\treturn 0;\n+}\n+\n static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)\n {\n \tstruct rtnl_link_ifmap map;\n@@ -1407,27 +1437,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,\n \tif (rtnl_fill_stats(skb, dev))\n \t\tgoto nla_put_failure;\n \n-\tif (dev->dev.parent && (ext_filter_mask & RTEXT_FILTER_VF) &&\n-\t    nla_put_u32(skb, IFLA_NUM_VF, dev_num_vf(dev->dev.parent)))\n+\tif (rtnl_fill_vf(skb, dev, ext_filter_mask))\n \t\tgoto nla_put_failure;\n \n-\tif (dev->netdev_ops->ndo_get_vf_config && dev->dev.parent &&\n-\t    ext_filter_mask & RTEXT_FILTER_VF) {\n-\t\tint i;\n-\t\tstruct nlattr *vfinfo;\n-\t\tint num_vfs = dev_num_vf(dev->dev.parent);\n-\n-\t\tvfinfo = nla_nest_start(skb, IFLA_VFINFO_LIST);\n-\t\tif (!vfinfo)\n-\t\t\tgoto nla_put_failure;\n-\t\tfor (i = 0; i < num_vfs; i++) {\n-\t\t\tif (rtnl_fill_vfinfo(skb, dev, i, vfinfo))\n-\t\t\t\tgoto nla_put_failure;\n-\t\t}\n-\n-\t\tnla_nest_end(skb, vfinfo);\n-\t}\n-\n \tif (rtnl_port_fill(skb, dev, ext_filter_mask))\n \t\tgoto nla_put_failure;\n \n","prefixes":["net-next","v4","2/4"]}