Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/816703/?format=api
{ "id": 816703, "url": "http://patchwork.ozlabs.org/api/patches/816703/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170921064338.1282-4-jiri@resnulli.us/", "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": "<20170921064338.1282-4-jiri@resnulli.us>", "list_archive_url": null, "date": "2017-09-21T06:43:29", "name": "[net-next,03/12] ipmr: Add FIB notification access functions", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "b54d26caddecf93ff7e78b3a579202b25c3e06f7", "submitter": { "id": 15321, "url": "http://patchwork.ozlabs.org/api/people/15321/?format=api", "name": "Jiri Pirko", "email": "jiri@resnulli.us" }, "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/20170921064338.1282-4-jiri@resnulli.us/mbox/", "series": [ { "id": 4309, "url": "http://patchwork.ozlabs.org/api/series/4309/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=4309", "date": "2017-09-21T06:43:26", "name": "mlxsw: Add support for offloading IPv4 multicast routes", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/4309/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/816703/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/816703/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>)", "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=resnulli-us.20150623.gappssmtp.com\n\theader.i=@resnulli-us.20150623.gappssmtp.com\n\theader.b=\"ZKG/Qhrg\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyRtm61yqz9s7g\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 16:45:04 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751808AbdIUGoe (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 21 Sep 2017 02:44:34 -0400", "from mail-wr0-f196.google.com ([209.85.128.196]:38537 \"EHLO\n\tmail-wr0-f196.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751897AbdIUGnm (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 21 Sep 2017 02:43:42 -0400", "by mail-wr0-f196.google.com with SMTP id p37so2579987wrb.5\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 23:43:42 -0700 (PDT)", "from localhost (ip-89-177-125-82.net.upcbroadband.cz.\n\t[89.177.125.82])\n\tby smtp.gmail.com with ESMTPSA id 6sm692828wru.33.2017.09.20.23.43.41\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 20 Sep 2017 23:43:41 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=resnulli-us.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=MR4+kV0A7WW522nB6pMy8uPD/IjeHLdsC4U6C2EkGeU=;\n\tb=ZKG/QhrgGrHfYfdYbNPoSB0IO3WNZ8sUAzTLgNneSqoqi2u3ymb6VSjlQGexiDfPhP\n\t+96XCbp3lTn/7D9CTb51IwaEvqaWboHBDy01aN0RCiRtzTp1EybcGYvCwpzlxRcTCD4U\n\tyrB5jwzXPH7uxYIdiGjxb7+N94aQQTw/KiEJnZ4TtA62nJR+ZLTtZKAretNzwz+IqSem\n\tctSrbSHyfRFVfOibU/FhXNwuHustf4sZYd0ekc17XZyRvDHml+AH5rqi5yOjN12JJezy\n\ttYM8EPiT5GszB0b7eyG/PrLmeIng+0VjW2vv/uLIG1cAGPzQ7AqBqGS576dsciYU/2q4\n\t1qmA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=MR4+kV0A7WW522nB6pMy8uPD/IjeHLdsC4U6C2EkGeU=;\n\tb=BTp7gbW2t7L1tmZ6YAoMF3cBANXj91hBU2jkC1nUy4ycBmfyquNFSlQeqLDFMWh0ji\n\tDXcuAu7FPmpQupB2mFLkyYPaOCNq5UcPoPb0oW4GgD68iPJ/Sdev3Hno7sPLRTyJHT6M\n\tboxe+Kao97atv+/aLcVfRvjC/D0yMdr+vxbzruoLZpSxNPHNb/ZCeEWxFPS7GaUbqG9v\n\ta8rki0629rjtuqahZqZuG0jTFY+w7BOpe1/Mst12pu5r6yW8oEoSfeqE0WLX89fBcpPo\n\tu5LAwdoU9xnxYoQ/hjjNDeFx0WCrrT+RouQEu35P6n9TBX8vQSX1tA8/S7up6M82Ft33\n\tm6LA==", "X-Gm-Message-State": "AHPjjUhGoKCopc5FmzZcZA2zOSVe0fGIl4y9jSbT0FvTgb9J1Dwa3V+k\n\tncUAbSeGdV0JvZB4GmdZNbp8uz9o", "X-Google-Smtp-Source": "AOwi7QASIw8CmjfgUeQitU4NcBmLv9qUEZkw00KlaM/i0M+Y0niu/61rgj461+BRIVaeQpgtwM2UMw==", "X-Received": "by 10.223.168.105 with SMTP id l96mr953965wrc.248.1505976221413; \n\tWed, 20 Sep 2017 23:43:41 -0700 (PDT)", "From": "Jiri Pirko <jiri@resnulli.us>", "To": "netdev@vger.kernel.org", "Cc": "davem@davemloft.net, yotamg@mellanox.com, idosch@mellanox.com,\n\tmlxsw@mellanox.com", "Subject": "[patch net-next 03/12] ipmr: Add FIB notification access functions", "Date": "Thu, 21 Sep 2017 08:43:29 +0200", "Message-Id": "<20170921064338.1282-4-jiri@resnulli.us>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20170921064338.1282-1-jiri@resnulli.us>", "References": "<20170921064338.1282-1-jiri@resnulli.us>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "From: Yotam Gigi <yotamg@mellanox.com>\n\nMake the ipmr module register as a FIB notifier. To do that, implement both\nthe ipmr_seq_read and ipmr_dump ops.\n\nThe ipmr_seq_read op returns a sequence counter that is incremented on\nevery notification related operation done by the ipmr. To implement that,\nadd a sequence counter in the netns_ipv4 struct and increment it whenever a\nnew MFC route or VIF are added or deleted. The sequence operations are\nprotected by the RTNL lock.\n\nThe ipmr_dump iterates the list of MFC routes and the list of VIF entries\nand sends notifications about them. The entries dump is done under RCU.\n\nSigned-off-by: Yotam Gigi <yotamg@mellanox.com>\nReviewed-by: Ido Schimmel <idosch@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n include/linux/mroute.h | 15 ++++++\n include/net/netns/ipv4.h | 3 ++\n net/ipv4/ipmr.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++-\n 3 files changed, 151 insertions(+), 2 deletions(-)", "diff": "diff --git a/include/linux/mroute.h b/include/linux/mroute.h\nindex 2f88e3d..ba5a976 100644\n--- a/include/linux/mroute.h\n+++ b/include/linux/mroute.h\n@@ -5,6 +5,7 @@\n #include <linux/pim.h>\n #include <linux/rhashtable.h>\n #include <net/sock.h>\n+#include <net/fib_notifier.h>\n #include <uapi/linux/mroute.h>\n \n #ifdef CONFIG_IP_MROUTE\n@@ -58,6 +59,14 @@ struct vif_device {\n \tint\t\tlink;\t\t\t/* Physical interface index\t*/\n };\n \n+struct vif_entry_notifier_info {\n+\tstruct fib_notifier_info info;\n+\tstruct net_device *dev;\n+\tvifi_t vif_index;\n+\tunsigned short vif_flags;\n+\tu32 tb_id;\n+};\n+\n #define VIFF_STATIC 0x8000\n \n #define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)\n@@ -145,6 +154,12 @@ struct mfc_cache {\n \tstruct rcu_head\trcu;\n };\n \n+struct mfc_entry_notifier_info {\n+\tstruct fib_notifier_info info;\n+\tstruct mfc_cache *mfc;\n+\tu32 tb_id;\n+};\n+\n struct rtmsg;\n int ipmr_get_route(struct net *net, struct sk_buff *skb,\n \t\t __be32 saddr, __be32 daddr,\ndiff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h\nindex 20d061c..5921496 100644\n--- a/include/net/netns/ipv4.h\n+++ b/include/net/netns/ipv4.h\n@@ -162,6 +162,9 @@ struct netns_ipv4 {\n \tstruct fib_notifier_ops\t*notifier_ops;\n \tunsigned int\tfib_seq;\t/* protected by rtnl_mutex */\n \n+\tstruct fib_notifier_ops\t*ipmr_notifier_ops;\n+\tunsigned int\tipmr_seq;\t/* protected by rtnl_mutex */\n+\n \tatomic_t\trt_genid;\n };\n #endif\ndiff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c\nindex 86dc5f9..9d331a74 100644\n--- a/net/ipv4/ipmr.c\n+++ b/net/ipv4/ipmr.c\n@@ -264,6 +264,16 @@ static void __net_exit ipmr_rules_exit(struct net *net)\n \tfib_rules_unregister(net->ipv4.mr_rules_ops);\n \trtnl_unlock();\n }\n+\n+static int ipmr_rules_dump(struct net *net, struct notifier_block *nb)\n+{\n+\treturn fib_rules_dump(net, nb, RTNL_FAMILY_IPMR);\n+}\n+\n+static unsigned int ipmr_rules_seq_read(struct net *net)\n+{\n+\treturn fib_rules_seq_read(net, RTNL_FAMILY_IPMR);\n+}\n #else\n #define ipmr_for_each_table(mrt, net) \\\n \tfor (mrt = net->ipv4.mrt; mrt; mrt = NULL)\n@@ -298,6 +308,16 @@ static void __net_exit ipmr_rules_exit(struct net *net)\n \tnet->ipv4.mrt = NULL;\n \trtnl_unlock();\n }\n+\n+static int ipmr_rules_dump(struct net *net, struct notifier_block *nb)\n+{\n+\treturn 0;\n+}\n+\n+static unsigned int ipmr_rules_seq_read(struct net *net)\n+{\n+\treturn 0;\n+}\n #endif\n \n static inline int ipmr_hash_cmp(struct rhashtable_compare_arg *arg,\n@@ -587,6 +607,43 @@ static struct net_device *ipmr_reg_vif(struct net *net, struct mr_table *mrt)\n }\n #endif\n \n+static int call_ipmr_vif_entry_notifier(struct notifier_block *nb,\n+\t\t\t\t\tstruct net *net,\n+\t\t\t\t\tenum fib_event_type event_type,\n+\t\t\t\t\tstruct vif_device *vif,\n+\t\t\t\t\tvifi_t vif_index, u32 tb_id)\n+{\n+\tstruct vif_entry_notifier_info info = {\n+\t\t.info = {\n+\t\t\t.family = RTNL_FAMILY_IPMR,\n+\t\t\t.net = net,\n+\t\t},\n+\t\t.dev = vif->dev,\n+\t\t.vif_index = vif_index,\n+\t\t.vif_flags = vif->flags,\n+\t\t.tb_id = tb_id,\n+\t};\n+\n+\treturn call_fib_notifier(nb, net, event_type, &info.info);\n+}\n+\n+static int call_ipmr_mfc_entry_notifier(struct notifier_block *nb,\n+\t\t\t\t\tstruct net *net,\n+\t\t\t\t\tenum fib_event_type event_type,\n+\t\t\t\t\tstruct mfc_cache *mfc, u32 tb_id)\n+{\n+\tstruct mfc_entry_notifier_info info = {\n+\t\t.info = {\n+\t\t\t.family = RTNL_FAMILY_IPMR,\n+\t\t\t.net = net,\n+\t\t},\n+\t\t.mfc = mfc,\n+\t\t.tb_id = tb_id\n+\t};\n+\n+\treturn call_fib_notifier(nb, net, event_type, &info.info);\n+}\n+\n /**\n *\tvif_delete - Delete a VIF entry\n *\t@notify: Set to 1, if the caller is a notifier_call\n@@ -3050,14 +3107,85 @@ static const struct net_protocol pim_protocol = {\n };\n #endif\n \n+static unsigned int ipmr_seq_read(struct net *net)\n+{\n+\tASSERT_RTNL();\n+\n+\treturn net->ipv4.ipmr_seq + ipmr_rules_seq_read(net);\n+}\n+\n+static int ipmr_dump(struct net *net, struct notifier_block *nb)\n+{\n+\tstruct mr_table *mrt;\n+\tint err;\n+\n+\terr = ipmr_rules_dump(net, nb);\n+\tif (err)\n+\t\treturn err;\n+\n+\tipmr_for_each_table(mrt, net) {\n+\t\tstruct vif_device *v = &mrt->vif_table[0];\n+\t\tstruct mfc_cache *mfc;\n+\t\tint vifi;\n+\n+\t\t/* Notifiy on table VIF entries */\n+\t\tfor (vifi = 0; vifi < mrt->maxvif; vifi++, v++) {\n+\t\t\tif (!v->dev)\n+\t\t\t\tcontinue;\n+\n+\t\t\tcall_ipmr_vif_entry_notifier(nb, net, FIB_EVENT_VIF_ADD,\n+\t\t\t\t\t\t v, vifi, mrt->id);\n+\t\t}\n+\n+\t\t/* Notify on table MFC entries */\n+\t\tlist_for_each_entry_rcu(mfc, &mrt->mfc_cache_list, list)\n+\t\t\tcall_ipmr_mfc_entry_notifier(nb, net,\n+\t\t\t\t\t\t FIB_EVENT_ENTRY_ADD, mfc,\n+\t\t\t\t\t\t mrt->id);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static const struct fib_notifier_ops ipmr_notifier_ops_template = {\n+\t.family\t\t= RTNL_FAMILY_IPMR,\n+\t.fib_seq_read\t= ipmr_seq_read,\n+\t.fib_dump\t= ipmr_dump,\n+\t.owner\t\t= THIS_MODULE,\n+};\n+\n+int __net_init ipmr_notifier_init(struct net *net)\n+{\n+\tstruct fib_notifier_ops *ops;\n+\n+\tnet->ipv4.ipmr_seq = 0;\n+\n+\tops = fib_notifier_ops_register(&ipmr_notifier_ops_template, net);\n+\tif (IS_ERR(ops))\n+\t\treturn PTR_ERR(ops);\n+\tnet->ipv4.ipmr_notifier_ops = ops;\n+\n+\treturn 0;\n+}\n+\n+static void __net_exit ipmr_notifier_exit(struct net *net)\n+{\n+\tfib_notifier_ops_unregister(net->ipv4.ipmr_notifier_ops);\n+\tnet->ipv4.ipmr_notifier_ops = NULL;\n+}\n+\n /* Setup for IP multicast routing */\n static int __net_init ipmr_net_init(struct net *net)\n {\n \tint err;\n \n+\terr = ipmr_notifier_init(net);\n+\tif (err)\n+\t\tgoto ipmr_notifier_fail;\n+\n \terr = ipmr_rules_init(net);\n \tif (err < 0)\n-\t\tgoto fail;\n+\t\tgoto ipmr_rules_fail;\n \n #ifdef CONFIG_PROC_FS\n \terr = -ENOMEM;\n@@ -3074,7 +3202,9 @@ static int __net_init ipmr_net_init(struct net *net)\n proc_vif_fail:\n \tipmr_rules_exit(net);\n #endif\n-fail:\n+ipmr_rules_fail:\n+\tipmr_notifier_exit(net);\n+ipmr_notifier_fail:\n \treturn err;\n }\n \n@@ -3084,6 +3214,7 @@ static void __net_exit ipmr_net_exit(struct net *net)\n \tremove_proc_entry(\"ip_mr_cache\", net->proc_net);\n \tremove_proc_entry(\"ip_mr_vif\", net->proc_net);\n #endif\n+\tipmr_notifier_exit(net);\n \tipmr_rules_exit(net);\n }\n \n", "prefixes": [ "net-next", "03/12" ] }