From patchwork Wed Apr 10 20:10:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1083993 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="s1eZLToC"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44g0pj60P7z9s0W for ; Thu, 11 Apr 2019 22:34:53 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8365E24F3; Thu, 11 Apr 2019 12:34:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1B9A424EB for ; Thu, 11 Apr 2019 12:34:05 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CA401F4 for ; Thu, 11 Apr 2019 12:34:04 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id g8so3473593pgf.2 for ; Thu, 11 Apr 2019 05:34:04 -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; bh=itqVoZ/zpL7FX6lJ4ooxHk8bMt0BDQ0fMtNLqI+stfw=; b=s1eZLToCRvh+GQwzWs+xWUA0qGozzHTmubhD5P6AFfKdPz4xvZKfmCpAfmXVyoe7oU NJbt1rfMOb6u0zmC2JtAYdEHi4Qn0xtMsG0PYp51QBssqK0UFb85EJgwlwuBGaDBw06B xIbXKS4ZuNbkJlAPNFjpPG1A6NBLVpjpMmK+afVGkDHWwNTBWNIIHLo0MLmM+zj94Fom OsiMBe3r2YDSwbOX2TWfUqjjY+1oe0tBHbFx9x0q/zfsM/4nKNLuG71pH3mNedwsM797 sRykyBIe0mNKodPfcW0Acwa575mOMwapSIkS1xCe8zj63XrB0QFMdy1pFJguZC++uALy PX6g== 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; bh=itqVoZ/zpL7FX6lJ4ooxHk8bMt0BDQ0fMtNLqI+stfw=; b=j2njKaB9SfTQJrtYfcZ2EjzGdCRPSVWdRJSgqhJ+rHj3H7Dg4K7inbDLXewjpjfTJ/ GbUtBn3bRReJn2pHKgf21bu1QT6HAH6DiGENScrgaNaQm4OnxAjDKHEM2bHEir0ZyuNe /+T9gkP0XspuOo01qj4YaLL29u9+x/BJsholpshagNw6++oWm+QNctgPURGS231rRyUg XlTxYb1mBYThomvwshFZQMGKWryiorBl/68OndmnK9UFkHuQ/mRs6BTmAIuWKQiZn0KT xwCgzbih67jW0/JFaefxmfQbSwK7gbYMvEP51ybfIfZrzZyyZmAbOA2qrT14iKccX78a V77w== X-Gm-Message-State: APjAAAXj1UAwNvp2VB/b/hI4tL2hSFjmtHDPxKVXm4enQGsMIDeoMval ufnZ3mPmtg/0SLf1I9ujWig9Fd01 X-Google-Smtp-Source: APXvYqxcpGQqOCKyVWZKKQp+ywY/ywz38D6dnlkJfidKC9tF4KXmN5ckW9Negrg1Gy0aSrWfHTmFvg== X-Received: by 2002:a63:ed4e:: with SMTP id m14mr47350351pgk.182.1554986044449; Thu, 11 Apr 2019 05:34:04 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id 26sm52427060pfj.93.2019.04.11.05.34.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 05:34:03 -0700 (PDT) From: Tonghao Zhang To: xiangxia.m.yue@gmail.com, blp@ovn.org Date: Wed, 10 Apr 2019 13:10:44 -0700 Message-Id: <1554927045-36902-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_12_24, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: dev@openvswitch.org, Pieter Jansen van Vuuren Subject: [ovs-dev] [PATCH v3 1/2] netdev-linux: Add coverage counters for netdev_set_policing when ingress tc-offload X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When enable tc-offload, we should add coverage counters for netdev_set_policing. Fixes: e7f6ba220e10 ("lib/tc: add ingress ratelimiting support for tc-offload") Cc: Pieter Jansen van Vuuren Signed-off-by: Tonghao Zhang Reviewed-by: Pieter Jansen van Vuuren --- lib/netdev-linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index deedc69..0fce217 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2474,6 +2474,8 @@ netdev_linux_set_policing(struct netdev *netdev_, goto out; } + COVERAGE_INC(netdev_set_policing); + /* Use matchall for policing when offloadling ovs with tc-flower. */ if (netdev_is_flow_api_enabled()) { error = tc_del_matchall_policer(netdev_); @@ -2484,7 +2486,6 @@ netdev_linux_set_policing(struct netdev *netdev_, return error; } - COVERAGE_INC(netdev_set_policing); /* Remove any existing ingress qdisc. */ error = tc_add_del_ingress_qdisc(ifindex, false, 0); if (error) { From patchwork Wed Apr 10 20:10:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1083994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="q/QPhlg0"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44g0qG73Fxz9s0W for ; Thu, 11 Apr 2019 22:35:22 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4836B24F8; Thu, 11 Apr 2019 12:34:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id EBB812412 for ; Thu, 11 Apr 2019 12:34:06 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A611F63D for ; Thu, 11 Apr 2019 12:34:06 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id y6so3334116pll.13 for ; Thu, 11 Apr 2019 05:34:06 -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=/834mxjzLPfS6hyMdeQfsp3IOxN8nN5Mi7EcdiGdrAE=; b=q/QPhlg0v1qyN3/nL+sgiJk8oDEUwDBO6SMyb647wvMzowqfA/RUzVItvEx11UB/FB vaZ0Cdi7P76gV1d77Igx40eUgbNTaL2DMX5rqzkkKaw6et9GuYuYn+Qq6fJBr3h0K6om E79JHn12+JO+g3MYGQKJhvD48MiuHip/7jajCMMmaTIBt7wtKqcH96FLjEwBahAoZrJT wVLBzROt3LA7HatevVRqvIMbftWQ1t5D/gtbiRP4DJHV5OABMsADWg66yMFvg7hyilYC TnbgUxgI0rJM+DVgRPRjR/UuRexFZjOAZoVMANBh2n9+QUSfJpUhixxub135uHpNNDqd oDQw== 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=/834mxjzLPfS6hyMdeQfsp3IOxN8nN5Mi7EcdiGdrAE=; b=itpIh0j/GI2+y/CjabguiTqwTyKYp3msZoa3mKjUOHPeohTMbFTTgaxuAybav5r1Lg 3eJx9t3DkmWS9G+UyOGFvTjYXMMiXpsxWLncpt6lcq7iPjev7EHDdxS0yMtvgd6WFiyr UJsGTAxbHQx5TPna77haBnta8qf22YycMwJRfGOsti4ojnwgITlUbRjctouKax3hacIX jApI6SkORTx/+ugbry67tWIm9JnZxG69XjT4yRfdUAcDdNA0IyJ5vUTXPfZG08J4Krza YQFqyJyBJqUW2Gcpc99YjAu9DfcgckBRnmFhf2b0xbZYarr5yU4L7Ik7GyFkRG4Dq4K/ CAtg== X-Gm-Message-State: APjAAAXpWxxUCcWu/ciJ/QjDqO4HA6jNKt2kREmGLoMTesvQtwClW0Ta xd0IUEiMtmCEan1OW3Q+PHg= X-Google-Smtp-Source: APXvYqxB8CVYhKO67JqB9HHPgNHznYt0AWSjTTHjJPkU4rSqbWrpfVZDNYbluS87hcNvIR24JhM/Sw== X-Received: by 2002:a17:902:8c89:: with SMTP id t9mr50473891plo.265.1554986046314; Thu, 11 Apr 2019 05:34:06 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id 26sm52427060pfj.93.2019.04.11.05.34.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 05:34:05 -0700 (PDT) From: Tonghao Zhang To: xiangxia.m.yue@gmail.com, blp@ovn.org Date: Wed, 10 Apr 2019 13:10:45 -0700 Message-Id: <1554927045-36902-2-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1554927045-36902-1-git-send-email-xiangxia.m.yue@gmail.com> References: <1554927045-36902-1-git-send-email-xiangxia.m.yue@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_12_24, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH v3 2/2] netdev-linux: Don't remove ingress when not configured X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org In some case, we may not use the openvswitch tc to limit the ingress police rate. And before we add the port to openvswitch bridge, we may set the ingress policer, so don't remove the ingress when we not configured it in openvswitch. Signed-off-by: Tonghao Zhang --- lib/netdev-linux.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 0fce217..ad8a244 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2448,6 +2448,7 @@ netdev_linux_set_policing(struct netdev *netdev_, const char *netdev_name = netdev_get_name(netdev_); int ifindex; int error; + bool should_cleanup_ingress = false; kbits_burst = (!kbits_rate ? 0 /* Force to 0 if no rate specified. */ : !kbits_burst ? 8000 /* Default to 8000 kbits if 0. */ @@ -2466,14 +2467,10 @@ netdev_linux_set_policing(struct netdev *netdev_, /* Assume that settings haven't changed since we last set them. */ goto out; } + should_cleanup_ingress = true; netdev->cache_valid &= ~VALID_POLICING; } - error = get_ifindex(netdev_, &ifindex); - if (error) { - goto out; - } - COVERAGE_INC(netdev_set_policing); /* Use matchall for policing when offloadling ovs with tc-flower. */ @@ -2486,14 +2483,22 @@ netdev_linux_set_policing(struct netdev *netdev_, return error; } - /* Remove any existing ingress qdisc. */ - error = tc_add_del_ingress_qdisc(ifindex, false, 0); + error = get_ifindex(netdev_, &ifindex); if (error) { - VLOG_WARN_RL(&rl, "%s: removing policing failed: %s", - netdev_name, ovs_strerror(error)); goto out; } + /* Should consider the kbits_rate/kbits_burst changed and + * the case that kbits_rate has been set in db. */ + if (should_cleanup_ingress || kbits_rate) { + error = tc_add_del_ingress_qdisc(ifindex, false, 0); + if (error) { + VLOG_WARN_RL(&rl, "%s: removing policing failed: %s", + netdev_name, ovs_strerror(error)); + goto out; + } + } + if (kbits_rate) { error = tc_add_del_ingress_qdisc(ifindex, true, 0); if (error) {