From patchwork Fri Feb 14 08:36:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 320329 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 2A1F62C0078 for ; Fri, 14 Feb 2014 19:36:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752191AbaBNIgi (ORCPT ); Fri, 14 Feb 2014 03:36:38 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:44708 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbaBNIgg (ORCPT ); Fri, 14 Feb 2014 03:36:36 -0500 Received: from 172.24.2.119 (EHLO szxeml209-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AKP45264; Fri, 14 Feb 2014 16:36:32 +0800 (CST) Received: from SZXEML463-HUB.china.huawei.com (10.82.67.206) by szxeml209-edg.china.huawei.com (172.24.2.184) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 14 Feb 2014 16:36:17 +0800 Received: from localhost (10.177.18.231) by szxeml463-hub.china.huawei.com (10.82.67.206) with Microsoft SMTP Server id 14.3.158.1; Fri, 14 Feb 2014 16:36:16 +0800 From: Yang Yingliang To: CC: , Subject: [PATCH net-next 6/7] sch_netem: clear old rate when old qdisc's replaced Date: Fri, 14 Feb 2014 16:36:09 +0800 Message-ID: <1392366970-11592-7-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1392366970-11592-1-git-send-email-yangyingliang@huawei.com> References: <1392366970-11592-1-git-send-email-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.231] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If we set a netem qdisc with rate option, while we use "#tc qdisc replace ..." that without rate option to replace the old qdisc, the old rate is still there. We need clear old rate after qdisc's replaced. Signed-off-by: Yang Yingliang --- net/sched/sch_netem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 2f630e9..92f6ba6 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -752,6 +752,15 @@ static void get_rate(struct netem_sched_data *q, const struct nlattr *attr) q->cell_size_reciprocal = (struct reciprocal_value) { 0 }; } +static void rate_reset(struct netem_sched_data *q) +{ + q->rate = 0; + q->packet_overhead = 0; + q->cell_size = 0; + q->cell_size_reciprocal = (struct reciprocal_value) { 0 }; + q->cell_overhead = 0; +} + static int get_loss_clg(struct netem_sched_data *q, const struct nlattr *attr) { const struct nlattr *la; @@ -918,6 +927,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt) if (tb[TCA_NETEM_RATE]) get_rate(q, tb[TCA_NETEM_RATE]); + else + rate_reset(q); if (tb[TCA_NETEM_RATE64]) q->rate = max_t(u64, q->rate,