Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/818594/?format=api
{ "id": 818594, "url": "http://patchwork.ozlabs.org/api/patches/818594/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170926115843.12013-2-fw@strlen.de/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "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-2-fw@strlen.de>", "list_archive_url": null, "date": "2017-09-26T11:58:40", "name": "[net-next,v4,1/4] rtnetlink: add helper to put master and link ifindexes", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "4e4197d7b9fd3bde05099d7ef592d8cda5072800", "submitter": { "id": 1025, "url": "http://patchwork.ozlabs.org/api/people/1025/?format=api", "name": "Florian Westphal", "email": "fw@strlen.de" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20170926115843.12013-2-fw@strlen.de/mbox/", "series": [ { "id": 5115, "url": "http://patchwork.ozlabs.org/api/series/5115/?format=api", "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/818594/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/818594/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 3y1fc82Q1Gz9t67\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 26 Sep 2017 21:58:32 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S937196AbdIZL6a (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 26 Sep 2017 07:58:30 -0400", "from Chamillionaire.breakpoint.cc ([146.0.238.67]:58788 \"EHLO\n\tChamillionaire.breakpoint.cc\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S936361AbdIZL63 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 26 Sep 2017 07:58:29 -0400", "from fw by Chamillionaire.breakpoint.cc with local (Exim 4.84_2)\n\t(envelope-from <fw@breakpoint.cc>)\n\tid 1dwoS5-0007As-6d; Tue, 26 Sep 2017 13:55:01 +0200" ], "From": "Florian Westphal <fw@strlen.de>", "To": "<netdev@vger.kernel.org>", "Cc": "Florian Westphal <fw@strlen.de>", "Subject": "[PATCH net-next v4 1/4] rtnetlink: add helper to put master and\n\tlink ifindexes", "Date": "Tue, 26 Sep 2017 13:58:40 +0200", "Message-Id": "<20170926115843.12013-2-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": "rtnl_fill_ifinfo currently requires caller to hold the rtnl mutex.\nUnfortunately the function is quite large which makes it harder to see\nwhich spots require the lock, which spots assume it and which ones could\ndo without.\n\nAdd helpers to factor out the ifindex dumping, one can use rcu to avoid\nrtnl dependency.\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 | 32 +++++++++++++++++++++++++++-----\n 1 file changed, 27 insertions(+), 5 deletions(-)", "diff": "diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c\nindex a78fd61da0ec..c801212ee40e 100644\n--- a/net/core/rtnetlink.c\n+++ b/net/core/rtnetlink.c\n@@ -1307,6 +1307,31 @@ static u32 rtnl_get_event(unsigned long event)\n \treturn rtnl_event_type;\n }\n \n+static int put_master_ifindex(struct sk_buff *skb, struct net_device *dev)\n+{\n+\tconst struct net_device *upper_dev;\n+\tint ret = 0;\n+\n+\trcu_read_lock();\n+\n+\tupper_dev = netdev_master_upper_dev_get_rcu(dev);\n+\tif (upper_dev)\n+\t\tret = nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex);\n+\n+\trcu_read_unlock();\n+\treturn ret;\n+}\n+\n+static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev)\n+{\n+\tint ifindex = dev_get_iflink(dev);\n+\n+\tif (dev->ifindex == ifindex)\n+\t\treturn 0;\n+\n+\treturn nla_put_u32(skb, IFLA_LINK, ifindex);\n+}\n+\n static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,\n \t\t\t int type, u32 pid, u32 seq, u32 change,\n \t\t\t unsigned int flags, u32 ext_filter_mask,\n@@ -1316,7 +1341,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,\n \tstruct nlmsghdr *nlh;\n \tstruct nlattr *af_spec;\n \tstruct rtnl_af_ops *af_ops;\n-\tstruct net_device *upper_dev = netdev_master_upper_dev_get(dev);\n \n \tASSERT_RTNL();\n \tnlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);\n@@ -1345,10 +1369,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,\n #ifdef CONFIG_RPS\n \t nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||\n #endif\n-\t (dev->ifindex != dev_get_iflink(dev) &&\n-\t nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))) ||\n-\t (upper_dev &&\n-\t nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||\n+\t nla_put_iflink(skb, dev) ||\n+\t put_master_ifindex(skb, dev) ||\n \t nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||\n \t (dev->qdisc &&\n \t nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) ||\n", "prefixes": [ "net-next", "v4", "1/4" ] }