From patchwork Tue Sep 1 12:26:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1354934 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=PZS/uFqo; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Bgmw30N16z9sTd for ; Tue, 1 Sep 2020 22:43:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728014AbgIAMnf (ORCPT ); Tue, 1 Sep 2020 08:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgIAM3M (ORCPT ); Tue, 1 Sep 2020 08:29:12 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B053AC061246 for ; Tue, 1 Sep 2020 05:29:11 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id j10so380516qvk.11 for ; Tue, 01 Sep 2020 05:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IL4ANcGHFnhV074FMDrZQCU2Et6LC8FqWy2nOG6SQFo=; b=PZS/uFqozEDUNpBsHiobSKvrehQCGvRvjdh53/nzkQFkK1fJ8HZMHHs5axuxBnnH7G V0AGy42Fx97PyFunpgw6iVjSvRSQoh8lTL8F+OV3woYA4TMqUHi7DMBaML2tX5eX0vOi 6o0VjF7HozvR8rALl+phck91q7ZhD4TmTJkTDoUa1Vc8cj0WinWgOrkxoDQiTg5+RqnB tYb6mZQ8K8/Wv5AB+e87GF1Jz1w8OAIWgyPtqOdl3NJ4l4EupajS6wFj//gCT2i1kkWG l8ABB27sjxl1iBIQ5AQvks6/xNkHnQAY54ajJu8v55g10hkzg/2yJH1nZyNODWP4e/sM Yo/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IL4ANcGHFnhV074FMDrZQCU2Et6LC8FqWy2nOG6SQFo=; b=g51zaKZ+5V4gS3StbZAStbIfEEyvb2oaj5BYajq46tFOzBY6zEfpxBFkSWlfZ6tjBd O4BFbJVNGpMi7iXkMMGadWxi97pB3wGVAAGbPiVNsJQfXe8K+JBv1Mcwu6Vr/M8Hk1J0 P2sm6MgvfCUWS40mLQOXid4s3I/mixqtfs8pFq+xXEsyk/kgJK9Q4ZB24SXpPjS0rXez TzknjCNS6EEh7UQXcqfbTWqtTwbv34Px3yY1YhDYpQuvyX0JeNCCRPct7s1p5uCPTRo4 /l6YYKdClAVfS7ke1haDLPBe6768dEhClMmWK4l14hEI4TEVlgzGzY/6RyYOI8VcABUR ligA== X-Gm-Message-State: AOAM531qa5BAi6K8KXk3pdD35/z2Bo5DE6tQ8e3Ils1XzLkzRKJWXd44 NQBnUZMmuR/5xexwKcGsrgY= X-Google-Smtp-Source: ABdhPJwep+f4fCC1IUQ3PXaesp4mFUlpph7eolw3L2l0Yl8hG/xvUz+/4HnrBNyzIW4qWX40NLW/vA== X-Received: by 2002:a0c:b51c:: with SMTP id d28mr1679576qve.71.1598963350903; Tue, 01 Sep 2020 05:29:10 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id q35sm1174220qtd.75.2020.09.01.05.29.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 05:29:10 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: sbrivio@redhat.com, davem@davemloft.net, pshelar@ovn.org, xiyou.wangcong@gmail.com Cc: dev@openvswitch.org, netdev@vger.kernel.org, Tonghao Zhang Subject: [PATCH net-next v4 1/3] net: openvswitch: improve the coding style Date: Tue, 1 Sep 2020 20:26:12 +0800 Message-Id: <20200901122614.73464-2-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200901122614.73464-1-xiangxia.m.yue@gmail.com> References: <20200901122614.73464-1-xiangxia.m.yue@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang Not change the logic, just improve the coding style. Cc: Pravin B Shelar Signed-off-by: Tonghao Zhang Acked-by: Pravin B Shelar --- v4: improve the codes suggested by Stefano http://patchwork.ozlabs.org/project/netdev/patch/20200825050636.14153-2-xiangxia.m.yue@gmail.com --- net/openvswitch/actions.c | 5 ++-- net/openvswitch/datapath.c | 38 ++++++++++++++++------------- net/openvswitch/flow_table.c | 46 ++++++++++++++++++++---------------- net/openvswitch/vport.c | 7 +++--- 4 files changed, 55 insertions(+), 41 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 2611657f40ca..573b9ad97e7d 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -742,7 +742,8 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key, return 0; } -static int ovs_vport_output(struct net *net, struct sock *sk, struct sk_buff *skb) +static int ovs_vport_output(struct net *net, struct sock *sk, + struct sk_buff *skb) { struct ovs_frag_data *data = this_cpu_ptr(&ovs_frag_data_storage); struct vport *vport = data->vport; @@ -925,7 +926,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb, upcall.mru = OVS_CB(skb)->mru; for (a = nla_data(attr), rem = nla_len(attr); rem > 0; - a = nla_next(a, &rem)) { + a = nla_next(a, &rem)) { switch (nla_type(a)) { case OVS_USERSPACE_ATTR_USERDATA: upcall.userdata = a; diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 6e47ef7ef036..bf701b7a394b 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -182,7 +182,7 @@ struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no) head = vport_hash_bucket(dp, port_no); hlist_for_each_entry_rcu(vport, head, dp_hash_node, - lockdep_ovsl_is_held()) { + lockdep_ovsl_is_held()) { if (vport->port_no == port_no) return vport; } @@ -254,7 +254,7 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key) error = ovs_execute_actions(dp, skb, sf_acts, key); if (unlikely(error)) net_dbg_ratelimited("ovs: action execution error on datapath %s: %d\n", - ovs_dp_name(dp), error); + ovs_dp_name(dp), error); stats_counter = &stats->n_hit; @@ -302,7 +302,7 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb, static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key, const struct dp_upcall_info *upcall_info, - uint32_t cutlen) + uint32_t cutlen) { unsigned int gso_type = skb_shinfo(skb)->gso_type; struct sw_flow_key later_key; @@ -1080,11 +1080,12 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info) } /* Factor out action copy to avoid "Wframe-larger-than=1024" warning. */ -static noinline_for_stack struct sw_flow_actions *get_flow_actions(struct net *net, - const struct nlattr *a, - const struct sw_flow_key *key, - const struct sw_flow_mask *mask, - bool log) +static noinline_for_stack +struct sw_flow_actions *get_flow_actions(struct net *net, + const struct nlattr *a, + const struct sw_flow_key *key, + const struct sw_flow_mask *mask, + bool log) { struct sw_flow_actions *acts; struct sw_flow_key masked_key; @@ -1383,7 +1384,8 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) ovs_notify(&dp_flow_genl_family, reply, info); } else { - netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 0, PTR_ERR(reply)); + netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 0, + PTR_ERR(reply)); } } @@ -1513,7 +1515,7 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, int err; ovs_header = genlmsg_put(skb, portid, seq, &dp_datapath_genl_family, - flags, cmd); + flags, cmd); if (!ovs_header) goto error; @@ -1572,11 +1574,13 @@ static struct datapath *lookup_datapath(struct net *net, return dp ? dp : ERR_PTR(-ENODEV); } -static void ovs_dp_reset_user_features(struct sk_buff *skb, struct genl_info *info) +static void ovs_dp_reset_user_features(struct sk_buff *skb, + struct genl_info *info) { struct datapath *dp; - dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs); + dp = lookup_datapath(sock_net(skb->sk), info->userhdr, + info->attrs); if (IS_ERR(dp)) return; @@ -2075,7 +2079,7 @@ static unsigned int ovs_get_max_headroom(struct datapath *dp) for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) { hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node, - lockdep_ovsl_is_held()) { + lockdep_ovsl_is_held()) { dev = vport->dev; dev_headroom = netdev_get_fwd_headroom(dev); if (dev_headroom > max_headroom) @@ -2093,10 +2097,11 @@ static void ovs_update_headroom(struct datapath *dp, unsigned int new_headroom) int i; dp->max_headroom = new_headroom; - for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) + for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) { hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node, - lockdep_ovsl_is_held()) + lockdep_ovsl_is_held()) netdev_set_rx_headroom(vport->dev, new_headroom); + } } static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) @@ -2551,7 +2556,8 @@ static int __init dp_init(void) { int err; - BUILD_BUG_ON(sizeof(struct ovs_skb_cb) > sizeof_field(struct sk_buff, cb)); + BUILD_BUG_ON(sizeof(struct ovs_skb_cb) > + sizeof_field(struct sk_buff, cb)); pr_info("Open vSwitch switching datapath\n"); diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index e2235849a57e..441f68cf8a13 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c @@ -111,12 +111,16 @@ static void flow_free(struct sw_flow *flow) if (ovs_identifier_is_key(&flow->id)) kfree(flow->id.unmasked_key); if (flow->sf_acts) - ovs_nla_free_flow_actions((struct sw_flow_actions __force *)flow->sf_acts); + ovs_nla_free_flow_actions((struct sw_flow_actions __force *) + flow->sf_acts); /* We open code this to make sure cpu 0 is always considered */ - for (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, &flow->cpu_used_mask)) + for (cpu = 0; cpu < nr_cpu_ids; + cpu = cpumask_next(cpu, &flow->cpu_used_mask)) { if (flow->stats[cpu]) kmem_cache_free(flow_stats_cache, (struct sw_flow_stats __force *)flow->stats[cpu]); + } + kmem_cache_free(flow_cache, flow); } @@ -192,7 +196,7 @@ static void tbl_mask_array_reset_counters(struct mask_array *ma) * zero based counter we store the value at reset, and subtract it * later when processing. */ - for (i = 0; i < ma->max; i++) { + for (i = 0; i < ma->max; i++) { ma->masks_usage_zero_cntr[i] = 0; for_each_possible_cpu(cpu) { @@ -273,7 +277,7 @@ static int tbl_mask_array_add_mask(struct flow_table *tbl, if (ma_count >= ma->max) { err = tbl_mask_array_realloc(tbl, ma->max + - MASK_ARRAY_SIZE_MIN); + MASK_ARRAY_SIZE_MIN); if (err) return err; @@ -288,7 +292,7 @@ static int tbl_mask_array_add_mask(struct flow_table *tbl, BUG_ON(ovsl_dereference(ma->masks[ma_count])); rcu_assign_pointer(ma->masks[ma_count], new); - WRITE_ONCE(ma->count, ma_count +1); + WRITE_ONCE(ma->count, ma_count + 1); return 0; } @@ -309,10 +313,10 @@ static void tbl_mask_array_del_mask(struct flow_table *tbl, return; found: - WRITE_ONCE(ma->count, ma_count -1); + WRITE_ONCE(ma->count, ma_count - 1); - rcu_assign_pointer(ma->masks[i], ma->masks[ma_count -1]); - RCU_INIT_POINTER(ma->masks[ma_count -1], NULL); + rcu_assign_pointer(ma->masks[i], ma->masks[ma_count - 1]); + RCU_INIT_POINTER(ma->masks[ma_count - 1], NULL); kfree_rcu(mask, rcu); @@ -448,16 +452,17 @@ int ovs_flow_tbl_init(struct flow_table *table) static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu) { - struct table_instance *ti = container_of(rcu, struct table_instance, rcu); + struct table_instance *ti; + ti = container_of(rcu, struct table_instance, rcu); __table_instance_destroy(ti); } static void table_instance_flow_free(struct flow_table *table, - struct table_instance *ti, - struct table_instance *ufid_ti, - struct sw_flow *flow, - bool count) + struct table_instance *ti, + struct table_instance *ufid_ti, + struct sw_flow *flow, + bool count) { hlist_del_rcu(&flow->flow_table.node[ti->node_ver]); if (count) @@ -484,9 +489,9 @@ void table_instance_flow_flush(struct flow_table *table, return; for (i = 0; i < ti->n_buckets; i++) { - struct sw_flow *flow; struct hlist_head *head = &ti->buckets[i]; struct hlist_node *n; + struct sw_flow *flow; hlist_for_each_entry_safe(flow, n, head, flow_table.node[ti->node_ver]) { @@ -661,7 +666,7 @@ static int flow_key_start(const struct sw_flow_key *key) return 0; else return rounddown(offsetof(struct sw_flow_key, phy), - sizeof(long)); + sizeof(long)); } static bool cmp_key(const struct sw_flow_key *key1, @@ -673,7 +678,7 @@ static bool cmp_key(const struct sw_flow_key *key1, long diffs = 0; int i; - for (i = key_start; i < key_end; i += sizeof(long)) + for (i = key_start; i < key_end; i += sizeof(long)) diffs |= *cp1++ ^ *cp2++; return diffs == 0; @@ -713,7 +718,7 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, (*n_mask_hit)++; hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver], - lockdep_ovsl_is_held()) { + lockdep_ovsl_is_held()) { if (flow->mask == mask && flow->flow_table.hash == hash && flow_cmp_masked_key(flow, &masked_key, &mask->range)) return flow; @@ -897,7 +902,8 @@ static bool ovs_flow_cmp_ufid(const struct sw_flow *flow, return !memcmp(flow->id.ufid, sfid->ufid, sfid->ufid_len); } -bool ovs_flow_cmp(const struct sw_flow *flow, const struct sw_flow_match *match) +bool ovs_flow_cmp(const struct sw_flow *flow, + const struct sw_flow_match *match) { if (ovs_identifier_is_ufid(&flow->id)) return flow_cmp_masked_key(flow, match->key, &match->range); @@ -916,7 +922,7 @@ struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *tbl, hash = ufid_hash(ufid); head = find_bucket(ti, hash); hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver], - lockdep_ovsl_is_held()) { + lockdep_ovsl_is_held()) { if (flow->ufid_table.hash == hash && ovs_flow_cmp_ufid(flow, ufid)) return flow; @@ -1107,7 +1113,7 @@ void ovs_flow_masks_rebalance(struct flow_table *table) if (!masks_and_count) return; - for (i = 0; i < ma->max; i++) { + for (i = 0; i < ma->max; i++) { struct sw_flow_mask *mask; unsigned int start; int cpu; diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index 0d44c5c013fa..82d801f063b7 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c @@ -98,7 +98,7 @@ struct vport *ovs_vport_locate(const struct net *net, const char *name) struct vport *vport; hlist_for_each_entry_rcu(vport, bucket, hash_node, - lockdep_ovsl_is_held()) + lockdep_ovsl_is_held()) if (!strcmp(name, ovs_vport_name(vport)) && net_eq(ovs_dp_get_net(vport->dp), net)) return vport; @@ -118,7 +118,7 @@ struct vport *ovs_vport_locate(const struct net *net, const char *name) * vport_free(). */ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, - const struct vport_parms *parms) + const struct vport_parms *parms) { struct vport *vport; size_t alloc_size; @@ -397,7 +397,8 @@ int ovs_vport_get_upcall_portids(const struct vport *vport, * * Returns the portid of the target socket. Must be called with rcu_read_lock. */ -u32 ovs_vport_find_upcall_portid(const struct vport *vport, struct sk_buff *skb) +u32 ovs_vport_find_upcall_portid(const struct vport *vport, + struct sk_buff *skb) { struct vport_portids *ids; u32 ids_index; From patchwork Tue Sep 1 12:26:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1354933 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=TbBohfPR; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Bgmvs0dyPz9sTN for ; Tue, 1 Sep 2020 22:43:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728064AbgIAMnR (ORCPT ); Tue, 1 Sep 2020 08:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbgIAM3P (ORCPT ); Tue, 1 Sep 2020 08:29:15 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD14C061247 for ; Tue, 1 Sep 2020 05:29:15 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id b13so386809qvl.2 for ; Tue, 01 Sep 2020 05:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DFLtCp2O15rju9BR/oL6lxBkSxtDKRT0NnIXl1QlTg0=; b=TbBohfPROTk4wUyrL3iHsMKzIOl7yaPBz3xMDVoZHZxQ219PKFdx51eN/U4ai2jesL REQ45TQjAcpEA3se+7KCLBwI8C3ViW8LHPJRMX1gyVzqELNg6FSXUPQMsmBWul6qRiFq x2WmHQz8+Sya9l335do2x5STsXgLc2bDNXzwxdNujsA6LGK83pCfNsx2yWRRaeVjJ1r0 pfp1c4C/rE/4zBt3awYFNS65FXmRJ1N6fB1aVTkCAhavaWzgMP7TNwW3rHzQWgM3aOwC abjyOEIjy0qV0qW3xrmpiQkh4YZdiW+hu8DXeY0jd5HkS62RM2LeohfqGHpJbjXIwwYt 25IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DFLtCp2O15rju9BR/oL6lxBkSxtDKRT0NnIXl1QlTg0=; b=D881vK3L0rKmmZzNk6MxJv82DtW6O8AW516D9mjDHCbTzVROk7ofcWvUhpLh+dHQUr RL0BzoaZlekLl2YHze+yyObz0D9f0Bijhj6xqaJrZjhTtOUZfdkGWfaHK76CPk2BWrbK lJLY5dcmCUZ0z0N5bpEyO1Ll+AZmCtCcnKorMafN5Blzea8lvhhPvP8XoFJXa+3VWnrB mblsveCOcpSYYQcK+dQYJDII6tAeOmVV4uj3pT7g80nzrWJSKAFN3U8gywpaW/FjOqYf VQmaPr6ZGKGA7hAO65lo+y3XzZ5GL8h4D2i0u4sFpTFXuTHzzw6p5HCx19avPZZDyNCJ sGdg== X-Gm-Message-State: AOAM533Zm4Z8R3XT9+F7QCyVnekU53r4T2ZvkH1QNxbWmF95FCoJYSEy fXLyRLIZA3gHGqxRvKXry4Y= X-Google-Smtp-Source: ABdhPJyYHjTiHpoz0QHFglzLLpdN6cUx2co0mVrMelDQv9H5GdcaCScxUID/uFa4RbSnaZ5tY4+H7w== X-Received: by 2002:a05:6214:1045:: with SMTP id l5mr1575263qvr.110.1598963354418; Tue, 01 Sep 2020 05:29:14 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id q35sm1174220qtd.75.2020.09.01.05.29.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 05:29:13 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: sbrivio@redhat.com, davem@davemloft.net, pshelar@ovn.org, xiyou.wangcong@gmail.com Cc: dev@openvswitch.org, netdev@vger.kernel.org, Tonghao Zhang Subject: [PATCH net-next v4 2/3] net: openvswitch: refactor flow free function Date: Tue, 1 Sep 2020 20:26:13 +0800 Message-Id: <20200901122614.73464-3-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200901122614.73464-1-xiangxia.m.yue@gmail.com> References: <20200901122614.73464-1-xiangxia.m.yue@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang Decrease table->count and ufid_count unconditionally, because we only don't use count or ufid_count to count when flushing the flows. To simplify the codes, we remove the "count" argument of table_instance_flow_free. To avoid a bug when deleting flows in the future, add WARN_ON in flush flows function. Cc: Pravin B Shelar Signed-off-by: Tonghao Zhang Acked-by: Pravin B Shelar --- net/openvswitch/flow_table.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 441f68cf8a13..80849bdf45d2 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c @@ -461,18 +461,14 @@ static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu) static void table_instance_flow_free(struct flow_table *table, struct table_instance *ti, struct table_instance *ufid_ti, - struct sw_flow *flow, - bool count) + struct sw_flow *flow) { hlist_del_rcu(&flow->flow_table.node[ti->node_ver]); - if (count) - table->count--; + table->count--; if (ovs_identifier_is_ufid(&flow->id)) { hlist_del_rcu(&flow->ufid_table.node[ufid_ti->node_ver]); - - if (count) - table->ufid_count--; + table->ufid_count--; } flow_mask_remove(table, flow->mask); @@ -497,10 +493,16 @@ void table_instance_flow_flush(struct flow_table *table, flow_table.node[ti->node_ver]) { table_instance_flow_free(table, ti, ufid_ti, - flow, false); + flow); ovs_flow_free(flow, true); } } + + if (WARN_ON(table->count != 0 || + table->ufid_count != 0)) { + table->count = 0; + table->ufid_count = 0; + } } static void table_instance_destroy(struct table_instance *ti, @@ -637,8 +639,6 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table) rcu_assign_pointer(flow_table->ti, new_ti); rcu_assign_pointer(flow_table->ufid_ti, new_ufid_ti); flow_table->last_rehash = jiffies; - flow_table->count = 0; - flow_table->ufid_count = 0; table_instance_flow_flush(flow_table, old_ti, old_ufid_ti); table_instance_destroy(old_ti, old_ufid_ti); @@ -956,7 +956,7 @@ void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow) struct table_instance *ufid_ti = ovsl_dereference(table->ufid_ti); BUG_ON(table->count == 0); - table_instance_flow_free(table, ti, ufid_ti, flow, true); + table_instance_flow_free(table, ti, ufid_ti, flow); } static struct sw_flow_mask *mask_alloc(void) From patchwork Tue Sep 1 12:26:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1354932 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pn4Kv3Sz; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Bgmsf6bWnz9sTM for ; Tue, 1 Sep 2020 22:41:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728222AbgIAMle (ORCPT ); Tue, 1 Sep 2020 08:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgIAM3U (ORCPT ); Tue, 1 Sep 2020 08:29:20 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D69C061249 for ; Tue, 1 Sep 2020 05:29:19 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id cy2so392511qvb.0 for ; Tue, 01 Sep 2020 05:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QVdwJ+FE/ogrH2MCBk57HD52dDvLWyfsL/EvW07drLg=; b=pn4Kv3SzFmYS3R8PJ3Hugg4a5VSY9AWGCLWB4joFhIKmi0m9TOki4lLXEg23kh67xu OA1Twl8inc8ELF35YJCYfzTcnh58mSrKDpAxXEya9TAseYy/Ai7YPoDNsWmoB7Ehd0Hj c3sNVbgeEDOPZQjRZ8oxDnqj9TMRTUjhFnQpmaBAMjBui/SQi2itaO6XpyPNWiT3IJjn OZrhePct5WvXkZxPeDcN/4PnHavE9+xyvT5F9BDUs38Q+5P2Y9dhJ7frpSi16cUTLKBP 4zTXI4ZORN4SI9h+fd2nDwjKp7UIocqnOxVR2zalAllkzCGdQdgcmN2pLzwRhz6Gn4Ib VENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QVdwJ+FE/ogrH2MCBk57HD52dDvLWyfsL/EvW07drLg=; b=GMfiNBi+crGVBZLuepLsiDFqsEapOeT+cl1ajXlbbRjH+PL3t3XxEPIRhBNN/Kffzy qWv4szuujvviMfmAERhmn5OeQy/EjvjKoUIAQkcH2mOzy7636Y/wqggGsOrtZ55MtdS4 ko1fFSr8O/ZmwXJcbNib4ciQwtDxgzMdexj0CTLLC48cyI6ZRUqYgaIPpvFmf7b82BrY dCO6TUcIjWGiPgNwVygM6fQ+85ApduAQyMRPcCN4nuyHnrwzcjB58dZZ7uOkuFq35oZu E/+JEOGcUZboy6duOMWno1gp36SJKkGdlG2z2FuLIf/syaqvFd0HBIGTi4c3JRv+KbRr B00g== X-Gm-Message-State: AOAM5316mtxNclYVxjC94kn1qGE0h1iw451HqbViIbgd6uVGvVgoGy7n 6poxQygadWT0Sx8EYhonfiA= X-Google-Smtp-Source: ABdhPJwYiJqaMQ+GcUyKLRHiXGSSqeqEv1HgBy/ts/9jMBwHczV9GTkHAq4i+LjIfcHnpSzgWTQo5g== X-Received: by 2002:a0c:f584:: with SMTP id k4mr1706056qvm.6.1598963358391; Tue, 01 Sep 2020 05:29:18 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id q35sm1174220qtd.75.2020.09.01.05.29.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 05:29:17 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: sbrivio@redhat.com, davem@davemloft.net, pshelar@ovn.org, xiyou.wangcong@gmail.com Cc: dev@openvswitch.org, netdev@vger.kernel.org, Tonghao Zhang Subject: [PATCH net-next v4 3/3] net: openvswitch: remove unused keep_flows Date: Tue, 1 Sep 2020 20:26:14 +0800 Message-Id: <20200901122614.73464-4-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200901122614.73464-1-xiangxia.m.yue@gmail.com> References: <20200901122614.73464-1-xiangxia.m.yue@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang keep_flows was introduced by [1], which used as flag to delete flows or not. When rehashing or expanding the table instance, we will not flush the flows. Now don't use it anymore, remove it. [1] - https://github.com/openvswitch/ovs/commit/acd051f1761569205827dc9b037e15568a8d59f8 Cc: Pravin B Shelar Signed-off-by: Tonghao Zhang Acked-by: Pravin B Shelar --- net/openvswitch/flow_table.c | 6 ------ net/openvswitch/flow_table.h | 1 - 2 files changed, 7 deletions(-) diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 80849bdf45d2..87c286ad660e 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c @@ -168,7 +168,6 @@ static struct table_instance *table_instance_alloc(int new_size) ti->n_buckets = new_size; ti->node_ver = 0; - ti->keep_flows = false; get_random_bytes(&ti->hash_seed, sizeof(u32)); return ti; @@ -481,9 +480,6 @@ void table_instance_flow_flush(struct flow_table *table, { int i; - if (ti->keep_flows) - return; - for (i = 0; i < ti->n_buckets; i++) { struct hlist_head *head = &ti->buckets[i]; struct hlist_node *n; @@ -603,8 +599,6 @@ static void flow_table_copy_flows(struct table_instance *old, lockdep_ovsl_is_held()) table_instance_insert(new, flow); } - - old->keep_flows = true; } static struct table_instance *table_instance_rehash(struct table_instance *ti, diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h index 6e7d4ac59353..d8fb7a3a3dfd 100644 --- a/net/openvswitch/flow_table.h +++ b/net/openvswitch/flow_table.h @@ -53,7 +53,6 @@ struct table_instance { struct rcu_head rcu; int node_ver; u32 hash_seed; - bool keep_flows; }; struct flow_table {