Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2228722/?format=api
{ "id": 2228722, "url": "http://patchwork.ozlabs.org/api/patches/2228722/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20260427091153.3210301-2-amorenoz@redhat.com/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260427091153.3210301-2-amorenoz@redhat.com>", "list_archive_url": null, "date": "2026-04-27T09:11:47", "name": "[ovs-dev,net-next,v3,1/2] net: openvswitch: make flow_table an rcu pointer", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "69382cb3c1363d76325aa65904d2c0723c7906b8", "submitter": { "id": 77477, "url": "http://patchwork.ozlabs.org/api/people/77477/?format=api", "name": "Adrian Moreno", "email": "amorenoz@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20260427091153.3210301-2-amorenoz@redhat.com/mbox/", "series": [ { "id": 501610, "url": "http://patchwork.ozlabs.org/api/series/501610/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=501610", "date": "2026-04-27T09:11:46", "name": "Decouple flow operations from RTNL", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/501610/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2228722/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2228722/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "ovs-dev@lists.linuxfoundation.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=RM2nxpwF;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org)", "smtp1.osuosl.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=RM2nxpwF", "smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com", "smtp3.osuosl.org;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.a=rsa-sha256 header.s=mimecast20190719 header.b=RM2nxpwF" ], "Received": [ "from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g3yWg1nRbz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 19:12:31 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id 6A55885508;\n\tMon, 27 Apr 2026 09:12:29 +0000 (UTC)", "from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id f3A3gVjS0Ssw; Mon, 27 Apr 2026 09:12:28 +0000 (UTC)", "from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp1.osuosl.org (Postfix) with ESMTPS id 0883C854F5;\n\tMon, 27 Apr 2026 09:12:28 +0000 (UTC)", "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id E445BC04FB;\n\tMon, 27 Apr 2026 09:12:27 +0000 (UTC)", "from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 29900C04FA\n for <dev@openvswitch.org>; Mon, 27 Apr 2026 09:12:26 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n by smtp3.osuosl.org (Postfix) with ESMTP id C8B796F621\n for <dev@openvswitch.org>; Mon, 27 Apr 2026 09:12:17 +0000 (UTC)", "from smtp3.osuosl.org ([127.0.0.1])\n by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id 2iO6xxXF5jkX for <dev@openvswitch.org>;\n Mon, 27 Apr 2026 09:12:16 +0000 (UTC)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp3.osuosl.org (Postfix) with ESMTPS id 9040B6F622\n for <dev@openvswitch.org>; Mon, 27 Apr 2026 09:12:16 +0000 (UTC)", "from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-4CMJYahiPxGhoJrHyWcyrQ-1; Mon,\n 27 Apr 2026 05:12:11 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 38B78195605A; Mon, 27 Apr 2026 09:12:10 +0000 (UTC)", "from antares.redhat.com (unknown [10.44.33.10])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id F02E11800446; Mon, 27 Apr 2026 09:12:04 +0000 (UTC)" ], "X-Virus-Scanned": [ "amavis at osuosl.org", "amavis at osuosl.org" ], "X-Comment": "SPF check N/A for local connections - client-ip=140.211.9.56;\n helo=lists.linuxfoundation.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN> ", "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0883C854F5", "OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9040B6F622" ], "Received-SPF": "Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=amorenoz@redhat.com;\n receiver=<UNKNOWN>", "DMARC-Filter": "OpenDMARC Filter v1.4.2 smtp3.osuosl.org 9040B6F622", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777281135;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=zjfHLvawIbqCLPfhB0oLblfB0S0mFOAhE4UGloe3qd4=;\n b=RM2nxpwF9rxMLQT2Ur7Li5AyfS8k4G8M+r52vf/U1mOyRqfvix4VaSpnIxZZ+/Ky86jb5g\n iaqD67t4yvqaKpiWA2Xveg61Uv7oEP+AYtGMC2kGdWjYm7kExZVlRyk2C3mdiLktRUPxQC\n XuXSGT4LyAZSXu94PNxrSu8Mr2svJM4=", "X-MC-Unique": "4CMJYahiPxGhoJrHyWcyrQ-1", "X-Mimecast-MFC-AGG-ID": "4CMJYahiPxGhoJrHyWcyrQ_1777281130", "To": "netdev@vger.kernel.org", "Date": "Mon, 27 Apr 2026 11:11:47 +0200", "Message-ID": "<20260427091153.3210301-2-amorenoz@redhat.com>", "In-Reply-To": "<20260427091153.3210301-1-amorenoz@redhat.com>", "References": "<20260427091153.3210301-1-amorenoz@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-MFC-PROC-ID": "aywbyrtoelqeuTBoV7rwwvNbsGONID518RK_FnaQf_8_1777281130", "X-Mimecast-Originator": "redhat.com", "Subject": "[ovs-dev] [PATCH net-next v3 1/2] net: openvswitch: make flow_table\n an rcu pointer", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>", "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>", "List-Post": "<mailto:ovs-dev@openvswitch.org>", "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>", "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "From": "Adrian Moreno via dev <ovs-dev@openvswitch.org>", "Reply-To": "Adrian Moreno <amorenoz@redhat.com>", "Cc": "\"open list:OPENVSWITCH\" <dev@openvswitch.org>,\n open list <linux-kernel@vger.kernel.org>, Ilya Maximets <i.maximets@ovn.org>,\n Eric Dumazet <edumazet@google.com>, Simon Horman <horms@kernel.org>,\n Jakub Kicinski <kuba@kernel.org>, pabeni@redhat.com,\n \"David S. Miller\" <davem@davemloft.net>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "ovs-dev-bounces@openvswitch.org", "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>" }, "content": "This patch turns \"flow_table\" from being embedded into \"datapath\" to\nbeing an rcu protected pointer. No functional change intended.\n\nSigned-off-by: Adrian Moreno <amorenoz@redhat.com>\n---\n net/openvswitch/datapath.c | 113 ++++++++++++++++++++++++++---------\n net/openvswitch/datapath.h | 2 +-\n net/openvswitch/flow_table.c | 23 ++++---\n net/openvswitch/flow_table.h | 5 +-\n 4 files changed, 105 insertions(+), 38 deletions(-)", "diff": "diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c\nindex e209099218b4..b2243ba866a6 100644\n--- a/net/openvswitch/datapath.c\n+++ b/net/openvswitch/datapath.c\n@@ -166,7 +166,6 @@ static void destroy_dp_rcu(struct rcu_head *rcu)\n {\n \tstruct datapath *dp = container_of(rcu, struct datapath, rcu);\n \n-\tovs_flow_tbl_destroy(&dp->table);\n \tfree_percpu(dp->stats_percpu);\n \tkfree(dp->ports);\n \tovs_meters_exit(dp);\n@@ -247,6 +246,7 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)\n \tstruct ovs_pcpu_storage *ovs_pcpu = this_cpu_ptr(ovs_pcpu_storage);\n \tconst struct vport *p = OVS_CB(skb)->input_vport;\n \tstruct datapath *dp = p->dp;\n+\tstruct flow_table *table;\n \tstruct sw_flow *flow;\n \tstruct sw_flow_actions *sf_acts;\n \tstruct dp_stats_percpu *stats;\n@@ -257,9 +257,16 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)\n \tint error;\n \n \tstats = this_cpu_ptr(dp->stats_percpu);\n+\ttable = rcu_dereference(dp->table);\n+\tif (!table) {\n+\t\tnet_dbg_ratelimited(\"ovs: no flow table on datapath %s\\n\",\n+\t\t\t\t ovs_dp_name(dp));\n+\t\tkfree_skb(skb);\n+\t\treturn;\n+\t}\n \n \t/* Look up flow. */\n-\tflow = ovs_flow_tbl_lookup_stats(&dp->table, key, skb_get_hash(skb),\n+\tflow = ovs_flow_tbl_lookup_stats(table, key, skb_get_hash(skb),\n \t\t\t\t\t &n_mask_hit, &n_cache_hit);\n \tif (unlikely(!flow)) {\n \t\tstruct dp_upcall_info upcall;\n@@ -752,12 +759,16 @@ static struct genl_family dp_packet_genl_family __ro_after_init = {\n static void get_dp_stats(const struct datapath *dp, struct ovs_dp_stats *stats,\n \t\t\t struct ovs_dp_megaflow_stats *mega_stats)\n {\n+\tstruct flow_table *table = ovsl_dereference(dp->table);\n \tint i;\n \n \tmemset(mega_stats, 0, sizeof(*mega_stats));\n+\tmemset(stats, 0, sizeof(*stats));\n \n-\tstats->n_flows = ovs_flow_tbl_count(&dp->table);\n-\tmega_stats->n_masks = ovs_flow_tbl_num_masks(&dp->table);\n+\tif (table) {\n+\t\tstats->n_flows = ovs_flow_tbl_count(table);\n+\t\tmega_stats->n_masks = ovs_flow_tbl_num_masks(table);\n+\t}\n \n \tstats->n_hit = stats->n_missed = stats->n_lost = 0;\n \n@@ -998,6 +1009,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)\n \tstruct nlattr **a = info->attrs;\n \tstruct ovs_header *ovs_header = genl_info_userhdr(info);\n \tstruct sw_flow *flow = NULL, *new_flow;\n+\tstruct flow_table *table;\n \tstruct sw_flow_mask mask;\n \tstruct sk_buff *reply;\n \tstruct datapath *dp;\n@@ -1070,17 +1082,22 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)\n \t\terror = -ENODEV;\n \t\tgoto err_unlock_ovs;\n \t}\n+\ttable = ovsl_dereference(dp->table);\n+\tif (!table) {\n+\t\terror = -ENODEV;\n+\t\tgoto err_unlock_ovs;\n+\t}\n \n \t/* Check if this is a duplicate flow */\n \tif (ovs_identifier_is_ufid(&new_flow->id))\n-\t\tflow = ovs_flow_tbl_lookup_ufid(&dp->table, &new_flow->id);\n+\t\tflow = ovs_flow_tbl_lookup_ufid(table, &new_flow->id);\n \tif (!flow)\n-\t\tflow = ovs_flow_tbl_lookup(&dp->table, key);\n+\t\tflow = ovs_flow_tbl_lookup(table, key);\n \tif (likely(!flow)) {\n \t\trcu_assign_pointer(new_flow->sf_acts, acts);\n \n \t\t/* Put flow in bucket. */\n-\t\terror = ovs_flow_tbl_insert(&dp->table, new_flow, &mask);\n+\t\terror = ovs_flow_tbl_insert(table, new_flow, &mask);\n \t\tif (unlikely(error)) {\n \t\t\tacts = NULL;\n \t\t\tgoto err_unlock_ovs;\n@@ -1115,7 +1132,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)\n \t\t */\n \t\tif (unlikely(!ovs_flow_cmp(flow, &match))) {\n \t\t\tif (ovs_identifier_is_key(&flow->id))\n-\t\t\t\tflow = ovs_flow_tbl_lookup_exact(&dp->table,\n+\t\t\t\tflow = ovs_flow_tbl_lookup_exact(table,\n \t\t\t\t\t\t\t\t &match);\n \t\t\telse /* UFID matches but key is different */\n \t\t\t\tflow = NULL;\n@@ -1244,6 +1261,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)\n \tstruct net *net = sock_net(skb->sk);\n \tstruct nlattr **a = info->attrs;\n \tstruct ovs_header *ovs_header = genl_info_userhdr(info);\n+\tstruct flow_table *table;\n \tstruct sw_flow_key key;\n \tstruct sw_flow *flow;\n \tstruct sk_buff *reply = NULL;\n@@ -1284,11 +1302,16 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)\n \t\terror = -ENODEV;\n \t\tgoto err_unlock_ovs;\n \t}\n+\ttable = ovsl_dereference(dp->table);\n+\tif (!table) {\n+\t\terror = -ENODEV;\n+\t\tgoto err_unlock_ovs;\n+\t}\n \t/* Check that the flow exists. */\n \tif (ufid_present)\n-\t\tflow = ovs_flow_tbl_lookup_ufid(&dp->table, &sfid);\n+\t\tflow = ovs_flow_tbl_lookup_ufid(table, &sfid);\n \telse\n-\t\tflow = ovs_flow_tbl_lookup_exact(&dp->table, &match);\n+\t\tflow = ovs_flow_tbl_lookup_exact(table, &match);\n \tif (unlikely(!flow)) {\n \t\terror = -ENOENT;\n \t\tgoto err_unlock_ovs;\n@@ -1346,6 +1369,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)\n \tstruct nlattr **a = info->attrs;\n \tstruct ovs_header *ovs_header = genl_info_userhdr(info);\n \tstruct net *net = sock_net(skb->sk);\n+\tstruct flow_table *table;\n \tstruct sw_flow_key key;\n \tstruct sk_buff *reply;\n \tstruct sw_flow *flow;\n@@ -1376,11 +1400,16 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)\n \t\terr = -ENODEV;\n \t\tgoto unlock;\n \t}\n+\ttable = ovsl_dereference(dp->table);\n+\tif (!table) {\n+\t\terr = -ENODEV;\n+\t\tgoto unlock;\n+\t}\n \n \tif (ufid_present)\n-\t\tflow = ovs_flow_tbl_lookup_ufid(&dp->table, &ufid);\n+\t\tflow = ovs_flow_tbl_lookup_ufid(table, &ufid);\n \telse\n-\t\tflow = ovs_flow_tbl_lookup_exact(&dp->table, &match);\n+\t\tflow = ovs_flow_tbl_lookup_exact(table, &match);\n \tif (!flow) {\n \t\terr = -ENOENT;\n \t\tgoto unlock;\n@@ -1405,6 +1434,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)\n \tstruct nlattr **a = info->attrs;\n \tstruct ovs_header *ovs_header = genl_info_userhdr(info);\n \tstruct net *net = sock_net(skb->sk);\n+\tstruct flow_table *table;\n \tstruct sw_flow_key key;\n \tstruct sk_buff *reply;\n \tstruct sw_flow *flow = NULL;\n@@ -1431,22 +1461,27 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)\n \t\terr = -ENODEV;\n \t\tgoto unlock;\n \t}\n+\ttable = ovsl_dereference(dp->table);\n+\tif (!table) {\n+\t\terr = -ENODEV;\n+\t\tgoto unlock;\n+\t}\n \n \tif (unlikely(!a[OVS_FLOW_ATTR_KEY] && !ufid_present)) {\n-\t\terr = ovs_flow_tbl_flush(&dp->table);\n+\t\terr = ovs_flow_tbl_flush(table);\n \t\tgoto unlock;\n \t}\n \n \tif (ufid_present)\n-\t\tflow = ovs_flow_tbl_lookup_ufid(&dp->table, &ufid);\n+\t\tflow = ovs_flow_tbl_lookup_ufid(table, &ufid);\n \telse\n-\t\tflow = ovs_flow_tbl_lookup_exact(&dp->table, &match);\n+\t\tflow = ovs_flow_tbl_lookup_exact(table, &match);\n \tif (unlikely(!flow)) {\n \t\terr = -ENOENT;\n \t\tgoto unlock;\n \t}\n \n-\tovs_flow_tbl_remove(&dp->table, flow);\n+\tovs_flow_tbl_remove(table, flow);\n \tovs_unlock();\n \n \treply = ovs_flow_cmd_alloc_info((const struct sw_flow_actions __force *) flow->sf_acts,\n@@ -1485,6 +1520,7 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)\n \tstruct nlattr *a[__OVS_FLOW_ATTR_MAX];\n \tstruct ovs_header *ovs_header = genlmsg_data(nlmsg_data(cb->nlh));\n \tstruct table_instance *ti;\n+\tstruct flow_table *table;\n \tstruct datapath *dp;\n \tu32 ufid_flags;\n \tint err;\n@@ -1501,8 +1537,13 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)\n \t\trcu_read_unlock();\n \t\treturn -ENODEV;\n \t}\n+\ttable = rcu_dereference_ovsl(dp->table);\n+\tif (!table) {\n+\t\trcu_read_unlock();\n+\t\treturn -ENODEV;\n+\t}\n \n-\tti = rcu_dereference(dp->table.ti);\n+\tti = rcu_dereference(table->ti);\n \tfor (;;) {\n \t\tstruct sw_flow *flow;\n \t\tu32 bucket, obj;\n@@ -1598,8 +1639,13 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,\n \tstruct ovs_dp_stats dp_stats;\n \tstruct ovs_dp_megaflow_stats dp_megaflow_stats;\n \tstruct dp_nlsk_pids *pids = ovsl_dereference(dp->upcall_portids);\n+\tstruct flow_table *table;\n \tint err, pids_len;\n \n+\ttable = ovsl_dereference(dp->table);\n+\tif (!table)\n+\t\treturn -ENODEV;\n+\n \tovs_header = genlmsg_put(skb, portid, seq, &dp_datapath_genl_family,\n \t\t\t\t flags, cmd);\n \tif (!ovs_header)\n@@ -1625,7 +1671,7 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,\n \t\tgoto nla_put_failure;\n \n \tif (nla_put_u32(skb, OVS_DP_ATTR_MASKS_CACHE_SIZE,\n-\t\t\tovs_flow_tbl_masks_cache_size(&dp->table)))\n+\t\t\tovs_flow_tbl_masks_cache_size(table)))\n \t\tgoto nla_put_failure;\n \n \tif (dp->user_features & OVS_DP_F_DISPATCH_UPCALL_PER_CPU && pids) {\n@@ -1736,6 +1782,7 @@ u32 ovs_dp_get_upcall_portid(const struct datapath *dp, uint32_t cpu_id)\n static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])\n {\n \tu32 user_features = 0, old_features = dp->user_features;\n+\tstruct flow_table *table;\n \tint err;\n \n \tif (a[OVS_DP_ATTR_USER_FEATURES]) {\n@@ -1757,8 +1804,12 @@ static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])\n \t\tint err;\n \t\tu32 cache_size;\n \n+\t\ttable = ovsl_dereference(dp->table);\n+\t\tif (!table)\n+\t\t\treturn -ENODEV;\n+\n \t\tcache_size = nla_get_u32(a[OVS_DP_ATTR_MASKS_CACHE_SIZE]);\n-\t\terr = ovs_flow_tbl_masks_cache_resize(&dp->table, cache_size);\n+\t\terr = ovs_flow_tbl_masks_cache_resize(table, cache_size);\n \t\tif (err)\n \t\t\treturn err;\n \t}\n@@ -1810,6 +1861,7 @@ static int ovs_dp_vport_init(struct datapath *dp)\n static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)\n {\n \tstruct nlattr **a = info->attrs;\n+\tstruct flow_table *table;\n \tstruct vport_parms parms;\n \tstruct sk_buff *reply;\n \tstruct datapath *dp;\n@@ -1833,9 +1885,12 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)\n \tovs_dp_set_net(dp, sock_net(skb->sk));\n \n \t/* Allocate table. */\n-\terr = ovs_flow_tbl_init(&dp->table);\n-\tif (err)\n+\ttable = ovs_flow_tbl_alloc();\n+\tif (IS_ERR(table)) {\n+\t\terr = PTR_ERR(table);\n \t\tgoto err_destroy_dp;\n+\t}\n+\trcu_assign_pointer(dp->table, table);\n \n \terr = ovs_dp_stats_init(dp);\n \tif (err)\n@@ -1905,7 +1960,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)\n err_destroy_stats:\n \tfree_percpu(dp->stats_percpu);\n err_destroy_table:\n-\tovs_flow_tbl_destroy(&dp->table);\n+\tcall_rcu(&table->rcu, ovs_flow_tbl_destroy_rcu);\n err_destroy_dp:\n \tkfree(dp);\n err_destroy_reply:\n@@ -1917,7 +1972,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)\n /* Called with ovs_mutex. */\n static void __dp_destroy(struct datapath *dp)\n {\n-\tstruct flow_table *table = &dp->table;\n+\tstruct flow_table *table = ovsl_dereference(dp->table);\n \tint i;\n \n \tif (dp->user_features & OVS_DP_F_TC_RECIRC_SHARING)\n@@ -1948,6 +2003,7 @@ static void __dp_destroy(struct datapath *dp)\n \n \t/* RCU destroy the ports, meters and flow tables. */\n \tcall_rcu(&dp->rcu, destroy_dp_rcu);\n+\tcall_rcu(&table->rcu, ovs_flow_tbl_destroy_rcu);\n }\n \n static int ovs_dp_cmd_del(struct sk_buff *skb, struct genl_info *info)\n@@ -2554,13 +2610,16 @@ static void ovs_dp_masks_rebalance(struct work_struct *work)\n {\n \tstruct ovs_net *ovs_net = container_of(work, struct ovs_net,\n \t\t\t\t\t masks_rebalance.work);\n+\tstruct flow_table *table;\n \tstruct datapath *dp;\n \n \tovs_lock();\n-\n-\tlist_for_each_entry(dp, &ovs_net->dps, list_node)\n-\t\tovs_flow_masks_rebalance(&dp->table);\n-\n+\tlist_for_each_entry(dp, &ovs_net->dps, list_node) {\n+\t\ttable = ovsl_dereference(dp->table);\n+\t\tif (!table)\n+\t\t\tcontinue;\n+\t\tovs_flow_masks_rebalance(table);\n+\t}\n \tovs_unlock();\n \n \tschedule_delayed_work(&ovs_net->masks_rebalance,\ndiff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h\nindex db0c3e69d66c..44773bf9f645 100644\n--- a/net/openvswitch/datapath.h\n+++ b/net/openvswitch/datapath.h\n@@ -90,7 +90,7 @@ struct datapath {\n \tstruct list_head list_node;\n \n \t/* Flow table. */\n-\tstruct flow_table table;\n+\tstruct flow_table __rcu *table;\n \n \t/* Switch ports. */\n \tstruct hlist_head *ports;\ndiff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c\nindex 67d5b8c0fe79..3b7518e3394d 100644\n--- a/net/openvswitch/flow_table.c\n+++ b/net/openvswitch/flow_table.c\n@@ -406,15 +406,19 @@ int ovs_flow_tbl_masks_cache_resize(struct flow_table *table, u32 size)\n \treturn 0;\n }\n \n-int ovs_flow_tbl_init(struct flow_table *table)\n+struct flow_table *ovs_flow_tbl_alloc(void)\n {\n \tstruct table_instance *ti, *ufid_ti;\n+\tstruct flow_table *table;\n \tstruct mask_cache *mc;\n \tstruct mask_array *ma;\n \n+\ttable = kzalloc_obj(*table, GFP_KERNEL);\n+\tif (!table)\n+\t\treturn ERR_PTR(-ENOMEM);\n \tmc = tbl_mask_cache_alloc(MC_DEFAULT_HASH_ENTRIES);\n \tif (!mc)\n-\t\treturn -ENOMEM;\n+\t\tgoto free_table;\n \n \tma = tbl_mask_array_alloc(MASK_ARRAY_SIZE_MIN);\n \tif (!ma)\n@@ -435,7 +439,7 @@ int ovs_flow_tbl_init(struct flow_table *table)\n \ttable->last_rehash = jiffies;\n \ttable->count = 0;\n \ttable->ufid_count = 0;\n-\treturn 0;\n+\treturn table;\n \n free_ti:\n \t__table_instance_destroy(ti);\n@@ -443,7 +447,9 @@ int ovs_flow_tbl_init(struct flow_table *table)\n \t__mask_array_destroy(ma);\n free_mask_cache:\n \t__mask_cache_destroy(mc);\n-\treturn -ENOMEM;\n+free_table:\n+\tkfree(table);\n+\treturn ERR_PTR(-ENOMEM);\n }\n \n static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu)\n@@ -505,11 +511,11 @@ static void table_instance_destroy(struct table_instance *ti,\n \tcall_rcu(&ufid_ti->rcu, flow_tbl_destroy_rcu_cb);\n }\n \n-/* No need for locking this function is called from RCU callback or\n- * error path.\n- */\n-void ovs_flow_tbl_destroy(struct flow_table *table)\n+/* No need for locking this function is called from RCU callback. */\n+void ovs_flow_tbl_destroy_rcu(struct rcu_head *rcu)\n {\n+\tstruct flow_table *table = container_of(rcu, struct flow_table, rcu);\n+\n \tstruct table_instance *ti = rcu_dereference_raw(table->ti);\n \tstruct table_instance *ufid_ti = rcu_dereference_raw(table->ufid_ti);\n \tstruct mask_cache *mc = rcu_dereference_raw(table->mask_cache);\n@@ -518,6 +524,7 @@ void ovs_flow_tbl_destroy(struct flow_table *table)\n \tcall_rcu(&mc->rcu, mask_cache_rcu_cb);\n \tcall_rcu(&ma->rcu, mask_array_rcu_cb);\n \ttable_instance_destroy(ti, ufid_ti);\n+\tkfree(table);\n }\n \n struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *ti,\ndiff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h\nindex f524dc3e4862..6211bcc72655 100644\n--- a/net/openvswitch/flow_table.h\n+++ b/net/openvswitch/flow_table.h\n@@ -60,6 +60,7 @@ struct table_instance {\n };\n \n struct flow_table {\n+\tstruct rcu_head rcu;\n \tstruct table_instance __rcu *ti;\n \tstruct table_instance __rcu *ufid_ti;\n \tstruct mask_cache __rcu *mask_cache;\n@@ -77,9 +78,9 @@ void ovs_flow_exit(void);\n struct sw_flow *ovs_flow_alloc(void);\n void ovs_flow_free(struct sw_flow *, bool deferred);\n \n-int ovs_flow_tbl_init(struct flow_table *);\n+struct flow_table *ovs_flow_tbl_alloc(void);\n+void ovs_flow_tbl_destroy_rcu(struct rcu_head *table);\n int ovs_flow_tbl_count(const struct flow_table *table);\n-void ovs_flow_tbl_destroy(struct flow_table *table);\n int ovs_flow_tbl_flush(struct flow_table *flow_table);\n \n int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,\n", "prefixes": [ "ovs-dev", "net-next", "v3", "1/2" ] }