From patchwork Fri Feb 14 08:36:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 320326 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 DF0662C00AF for ; Fri, 14 Feb 2014 19:36:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149AbaBNIg3 (ORCPT ); Fri, 14 Feb 2014 03:36:29 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:58744 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbaBNIg1 (ORCPT ); Fri, 14 Feb 2014 03:36:27 -0500 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BPU42824; Fri, 14 Feb 2014 16:36:18 +0800 (CST) Received: from SZXEML456-HUB.china.huawei.com (10.82.67.199) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 14 Feb 2014 16:36:15 +0800 Received: from localhost (10.177.18.231) by szxeml456-hub.china.huawei.com (10.82.67.199) with Microsoft SMTP Server id 14.3.158.1; Fri, 14 Feb 2014 16:36:15 +0800 From: Yang Yingliang To: CC: , Subject: [PATCH net-next 4/7] sch_netem: clear old correlation when old qdisc's replaced Date: Fri, 14 Feb 2014 16:36:07 +0800 Message-ID: <1392366970-11592-5-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 correlation option, while we use "#tc qdisc replace ..." that without correlation option to replace the old qdisc, the old correlation is still there. We need clear old correlation after qdisc's replaced. Signed-off-by: Yang Yingliang --- net/sched/sch_netem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index bb06dd8..33e7cef 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -703,6 +703,13 @@ static void get_correlation(struct netem_sched_data *q, const struct nlattr *att init_crandom(&q->dup_cor, c->dup_corr); } +static void correlation_reset(struct netem_sched_data *q) +{ + memset(&q->delay_cor, 0, sizeof(struct crndstate)); + memset(&q->loss_cor, 0, sizeof(struct crndstate)); + memset(&q->dup_cor, 0, sizeof(struct crndstate)); +} + static void get_reorder(struct netem_sched_data *q, const struct nlattr *attr) { const struct tc_netem_reorder *r = nla_data(attr); @@ -890,6 +897,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt) if (tb[TCA_NETEM_CORR]) get_correlation(q, tb[TCA_NETEM_CORR]); + else + correlation_reset(q); if (tb[TCA_NETEM_REORDER]) get_reorder(q, tb[TCA_NETEM_REORDER]);