From patchwork Mon Mar 20 23:32:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 741290 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vnCC22X5pz9s3l for ; Tue, 21 Mar 2017 10:41:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754187AbdCTXl3 (ORCPT ); Mon, 20 Mar 2017 19:41:29 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34403 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753258AbdCTXl2 (ORCPT ); Mon, 20 Mar 2017 19:41:28 -0400 Received: by mail-pg0-f66.google.com with SMTP id b5so22437433pgg.1 for ; Mon, 20 Mar 2017 16:40:18 -0700 (PDT) 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=LJhvonww402Ko7mdUfE6ZhQ85JJ58zVU8JbR57jL8Uk=; b=Hmg6+arxCvYGY232pSp+IneJkAHqki0WsbxHRYm2an/bY/qPAIm6021a3YNcKvw0dA 9Ldi8/o18zAM+3Besu7yVkiNoTgQafraaE69QZ4y89J+FhnyuFLWg3sIUUeN2V4g7Lue fJM+Wf2nFmjq9oXCgsS/Z3TR5y5PIhdkG1RTl4EaIo1Bmg0+ALOg56IyRnNdydmd6aDK 6paaWZc6UwHF3imxgrdz4+iMQBsygPoOGusBqMOZ85t9SbQVzZQMUkKJrZE/t2kfvcoH /kJxz6w1/lvnzb+eKKu2KuR0DfysGsvgOlG9R7nfPAgh79VLKo3v5/+Fs+q1AmbFtPOj k1hA== X-Gm-Message-State: AFeK/H1Y8dpklUKEB564Bz8VXRva4ZMPStACK+bHTaOOk3wbnGH6x2z71Y+YL2mR+F6JqQ== X-Received: by 10.98.142.1 with SMTP id k1mr35003735pfe.98.1490052772742; Mon, 20 Mar 2017 16:32:52 -0700 (PDT) Received: from ubuntu.localdomain ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id s4sm35206701pfi.74.2017.03.20.16.32.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 16:32:52 -0700 (PDT) From: Andy Zhou To: netdev@vger.kernel.org Cc: joe@ovn.org, pshelar@ovn.org, Andy Zhou Subject: [net-next sample action optimization v4 1/4] openvswitch: Deferred fifo API change. Date: Mon, 20 Mar 2017 16:32:27 -0700 Message-Id: <1490052750-60187-2-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490052750-60187-1-git-send-email-azhou@ovn.org> References: <1490052750-60187-1-git-send-email-azhou@ovn.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org add_deferred_actions() API currently requires actions to be passed in as a fully encoded netlink message. So far both 'sample' and 'recirc' actions happens to carry actions as fully encoded netlink messages. However, this requirement is more restrictive than necessary, future patch will need to pass in action lists that are not fully encoded by themselves. Signed-off-by: Andy Zhou Acked-by: Joe Stringer Acked-by: Pravin B Shelar --- net/openvswitch/actions.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index c82301c..75182e9 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -51,6 +51,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, struct deferred_action { struct sk_buff *skb; const struct nlattr *actions; + int actions_len; /* Store pkt_key clone when creating deferred action. */ struct sw_flow_key pkt_key; @@ -119,8 +120,9 @@ static struct deferred_action *action_fifo_put(struct action_fifo *fifo) /* Return true if fifo is not full */ static struct deferred_action *add_deferred_actions(struct sk_buff *skb, - const struct sw_flow_key *key, - const struct nlattr *attr) + const struct sw_flow_key *key, + const struct nlattr *actions, + const int actions_len) { struct action_fifo *fifo; struct deferred_action *da; @@ -129,7 +131,8 @@ static struct deferred_action *add_deferred_actions(struct sk_buff *skb, da = action_fifo_put(fifo); if (da) { da->skb = skb; - da->actions = attr; + da->actions = actions; + da->actions_len = actions_len; da->pkt_key = *key; } @@ -966,7 +969,8 @@ static int sample(struct datapath *dp, struct sk_buff *skb, /* Skip the sample action when out of memory. */ return 0; - if (!add_deferred_actions(skb, key, a)) { + if (!add_deferred_actions(skb, key, nla_data(acts_list), + nla_len(acts_list))) { if (net_ratelimit()) pr_warn("%s: deferred actions limit reached, dropping sample action\n", ovs_dp_name(dp)); @@ -1123,7 +1127,7 @@ static int execute_recirc(struct datapath *dp, struct sk_buff *skb, return 0; } - da = add_deferred_actions(skb, key, NULL); + da = add_deferred_actions(skb, key, NULL, 0); if (da) { da->pkt_key.recirc_id = nla_get_u32(a); } else { @@ -1278,10 +1282,10 @@ static void process_deferred_actions(struct datapath *dp) struct sk_buff *skb = da->skb; struct sw_flow_key *key = &da->pkt_key; const struct nlattr *actions = da->actions; + int actions_len = da->actions_len; if (actions) - do_execute_actions(dp, skb, key, actions, - nla_len(actions)); + do_execute_actions(dp, skb, key, actions, actions_len); else ovs_dp_process_packet(skb, key); } while (!action_fifo_is_empty(fifo));