From patchwork Tue May 1 09:11:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 156037 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 09ED8B6F9A for ; Tue, 1 May 2012 19:11:42 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962Ab2EAJLL (ORCPT ); Tue, 1 May 2012 05:11:11 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:33823 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752375Ab2EAJLK (ORCPT ); Tue, 1 May 2012 05:11:10 -0400 Received: by eaaq12 with SMTP id q12so861470eaa.19 for ; Tue, 01 May 2012 02:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=MQME6G7eA/ACcbSyut5SXISZ4eeaJmGSTpm041Lvttg=; b=HROOAbUbfOcROABLjkfqTW4O+bPBdPGebxA/cdze6iMw3R/QvUq0YqiRfaydYuQDY9 +tLsBzIt4y3EpELhpPmPn6xwVhmmr/gppeRclvjAJBEDGVoTB3COETxbEpZP8LOYShYy XP5Fy72oKGq+S7bts3AA3biWbDPQqqpEcpTloBmCqJhaamkz5R8o70FgbL+3tDa2fhUo NWfUnaYGPHjisWwEynM6V0P2oQDzn5LVDIcvei8Qgc3QHQdQieNODPtZLPcf3e4JuL41 u4urSIF9INmKTd8JCCobnKVBh06jVe2axjvbof9JgmH4WBLrgtNgJwwC8XfGC2HpI5eY KVoQ== Received: by 10.213.34.138 with SMTP id l10mr1682682ebd.198.1335863469252; Tue, 01 May 2012 02:11:09 -0700 (PDT) Received: from [192.168.1.37] (122.237.66.86.rev.sfr.net. [86.66.237.122]) by mx.google.com with ESMTPS id d54sm87848998eei.9.2012.05.01.02.11.07 (version=SSLv3 cipher=OTHER); Tue, 01 May 2012 02:11:08 -0700 (PDT) Subject: [PATCH net-next] netem: add ECN capability From: Eric Dumazet To: David Miller Cc: netdev , Tom Herbert , Neal Cardwell , Hagen Paul Pfeifer , Stephen Hemminger Date: Tue, 01 May 2012 11:11:05 +0200 Message-ID: <1335863465.11396.45.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet Add ECN (Explicit Congestion Notification) marking capability to netem tc qdisc add dev eth0 root netem drop 0.5 ecn Instead of dropping packets, try to ECN mark them. Signed-off-by: Eric Dumazet Cc: Neal Cardwell Cc: Tom Herbert Cc: Hagen Paul Pfeifer Cc: Stephen Hemminger Acked-by: Hagen Paul Pfeifer --- include/linux/pkt_sched.h | 1 + net/sched/sch_netem.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h index 410b33d..ffe975c 100644 --- a/include/linux/pkt_sched.h +++ b/include/linux/pkt_sched.h @@ -509,6 +509,7 @@ enum { TCA_NETEM_CORRUPT, TCA_NETEM_LOSS, TCA_NETEM_RATE, + TCA_NETEM_ECN, __TCA_NETEM_MAX, }; diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 1109731..231cd11 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -26,6 +26,7 @@ #include #include +#include #define VERSION "1.3" @@ -78,6 +79,7 @@ struct netem_sched_data { psched_tdiff_t jitter; u32 loss; + u32 ecn; u32 limit; u32 counter; u32 gap; @@ -374,9 +376,12 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++count; /* Drop packet? */ - if (loss_event(q)) - --count; - + if (loss_event(q)) { + if (q->ecn && INET_ECN_set_ce(skb)) + sch->qstats.drops++; /* mark packet */ + else + --count; + } if (count == 0) { sch->qstats.drops++; kfree_skb(skb); @@ -706,6 +711,7 @@ static const struct nla_policy netem_policy[TCA_NETEM_MAX + 1] = { [TCA_NETEM_CORRUPT] = { .len = sizeof(struct tc_netem_corrupt) }, [TCA_NETEM_RATE] = { .len = sizeof(struct tc_netem_rate) }, [TCA_NETEM_LOSS] = { .type = NLA_NESTED }, + [TCA_NETEM_ECN] = { .type = NLA_U32 }, }; static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla, @@ -776,6 +782,9 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt) if (tb[TCA_NETEM_RATE]) get_rate(sch, tb[TCA_NETEM_RATE]); + if (tb[TCA_NETEM_ECN]) + q->ecn = nla_get_u32(tb[TCA_NETEM_ECN]); + q->loss_model = CLG_RANDOM; if (tb[TCA_NETEM_LOSS]) ret = get_loss_clg(sch, tb[TCA_NETEM_LOSS]); @@ -902,6 +911,9 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb) if (nla_put(skb, TCA_NETEM_RATE, sizeof(rate), &rate)) goto nla_put_failure; + if (q->ecn && nla_put_u32(skb, TCA_NETEM_ECN, q->ecn)) + goto nla_put_failure; + if (dump_loss_model(q, skb) != 0) goto nla_put_failure;