From patchwork Fri Apr 5 04:53:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1078025 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="F6zG7XU/"; 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 44b7B0487Qz9sPS for ; Fri, 5 Apr 2019 16:08:07 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 00E3D21EE; Fri, 5 Apr 2019 05:08:04 +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 742A921E7 for ; Fri, 5 Apr 2019 05:07:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 22513FD for ; Fri, 5 Apr 2019 05:07:22 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id m10so2354350plt.10 for ; Thu, 04 Apr 2019 22:07:22 -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=2FEENFeQCwLeSGZv0yrOSMzw5ta4xITCvBFadx6S6o8=; b=F6zG7XU/QdSwqjWSSF+QdEzWrmh5efn7mPfLuWdEGulZdyIPDi/6X2CLj133oqvWdv bwGdeADUsv3wopOgQp+UsWxWGz5ZOCzPgs5jIOzNcIDXP9aay5pE7uZNwvJIi8gyS/oc m1ObVRpIbhYx4jv2r1Cb/Adh9LiO7WYe7PcVihiAT3Eq/slPTorL5q02tbuKNLm4ZSv3 bdZhWTKntzO4c3Zj7Mye7OaZU6X++61850C0isXaqhleWexxDze8yKZ/FPK08HJDOdez ySB6CwiXZMVcbxfDrSTked69suWwbfIsylGRelIRtwzBWsEm3fQR3ZKu70Wppyt+1CYq HgXQ== 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=2FEENFeQCwLeSGZv0yrOSMzw5ta4xITCvBFadx6S6o8=; b=Ex8zYDgofbppUzB8slI/yEpmq2RoPwk2OGCPo4K2ba5tZr8WF8vwCGbE7VpXFPWVV9 KRp3QHr8SphoUwjHb1HCGoKUX/OlGP/Q1xYYjc7M6O1Hb02uDOUoYuk986GCYkDAEZ2f C5OSM4hIcnrVQL9ouu/sOVrFASsKPDJI6F1CTMoZLqx/ymfd0O5nPKwmi3+qoo0KhGRw MBJCxu/KZjg9bXeNzsd5vbD4Kg+7H6AEcQYHCZhFRRaFpcvpKKAu1AgwYRCi3uf7/mr2 T+/iyWQ4Vw/ZqWLja8RbrHryBSXcGXbTMOgzTa0dw4QuEn3eQ6FifiLSh4mtMZyf3+u1 7JEg== X-Gm-Message-State: APjAAAV3IHyS6QpQuE7rWGrKC6OA26zKdowKutRpB/bLLl6TnZ4e3RSD 7nLxG2U/JcFGk6lRaMDUt2E3D3fU X-Google-Smtp-Source: APXvYqxL809Iwcj5l+j7liupuq/pTbBfm4+Nyqe1HGJQfmYJyU+OEj1mdaakNpIG3doYZVpiK9MFog== X-Received: by 2002:a17:902:e302:: with SMTP id cg2mr10216130plb.285.1554440840979; Thu, 04 Apr 2019 22:07:20 -0700 (PDT) Received: from openvirtualnetworks.com.com.com ([106.120.35.146]) by smtp.gmail.com with ESMTPSA id f71sm7253135pfc.109.2019.04.04.22.07.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 22:07:20 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: dev@openvswitch.org Date: Fri, 5 Apr 2019 00:53:39 -0400 Message-Id: <1554440019-4034-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] 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 From: Tonghao Zhang 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 configured it in openvswitch. Signed-off-by: Tonghao Zhang --- lib/netdev-linux.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index deedc69..8ea4383 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2447,7 +2447,7 @@ netdev_linux_set_policing(struct netdev *netdev_, struct netdev_linux *netdev = netdev_linux_cast(netdev_); const char *netdev_name = netdev_get_name(netdev_); int ifindex; - int error; + int error = 0; kbits_burst = (!kbits_rate ? 0 /* Force to 0 if no rate specified. */ : !kbits_burst ? 8000 /* Default to 8000 kbits if 0. */ @@ -2469,10 +2469,7 @@ netdev_linux_set_policing(struct netdev *netdev_, 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. */ if (netdev_is_flow_api_enabled()) { @@ -2484,16 +2481,20 @@ 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) { - VLOG_WARN_RL(&rl, "%s: removing policing failed: %s", - netdev_name, ovs_strerror(error)); - goto out; - } - if (kbits_rate) { + error = get_ifindex(netdev_, &ifindex); + if (error) { + goto out; + } + + /* Remove any existing ingress qdisc. */ + 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; + } + error = tc_add_del_ingress_qdisc(ifindex, true, 0); if (error) { VLOG_WARN_RL(&rl, "%s: adding policing qdisc failed: %s", @@ -2504,7 +2505,7 @@ netdev_linux_set_policing(struct netdev *netdev_, error = tc_add_policer(netdev_, kbits_rate, kbits_burst); if (error){ VLOG_WARN_RL(&rl, "%s: adding policing action failed: %s", - netdev_name, ovs_strerror(error)); + netdev_name, ovs_strerror(error)); goto out; } }