Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: netdev <netdev@vger.kernel.org>
Subject: [PATCH iproute2] red: harddrop support and cleanups
Date: Fri, 09 Dec 2011 00:11:40 +0100	[thread overview]
Message-ID: <1323385900.2529.12.camel@edumazet-laptop> (raw)

Add harddrop support (kernel support added a long time ago), and various
cleanups.

min BYTES, max BYTES are now optional and follow Sally Floyd's
recommendations.

By the way, our default 2% probability is a bit low, Sally recommends
10%.
Not a big deal if upcoming adaptative algo is deployed.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 tc/q_red.c |   41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/tc/q_red.c b/tc/q_red.c
index 6e58d7a..90c8573 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -27,8 +27,8 @@
 
 static void explain(void)
 {
-	fprintf(stderr, "Usage: ... red limit BYTES min BYTES max BYTES avpkt BYTES burst PACKETS\n");
-	fprintf(stderr, "               probability PROBABILITY bandwidth KBPS [ ecn ]\n");
+	fprintf(stderr, "Usage: ... red limit BYTES [min BYTES] [max BYTES] avpkt BYTES [burst PACKETS]\n");
+	fprintf(stderr, "               [probability PROBABILITY] bandwidth KBPS [ecn] [harddrop]\n");
 }
 
 static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
@@ -38,7 +38,6 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
 	unsigned avpkt = 0;
 	double probability = 0.02;
 	unsigned rate = 0;
-	int ecn_ok = 0;
 	int wlog;
 	__u8 sbuf[256];
 	struct rtattr *tail;
@@ -89,7 +88,9 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
 				return -1;
 			}
 		} else if (strcmp(*argv, "ecn") == 0) {
-			ecn_ok = 1;
+			opt.flags |= TC_RED_ECN;
+		} else if (strcmp(*argv, "harddrop") == 0) {
+			opt.flags |= TC_RED_HARDDROP;
 		} else if (strcmp(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -104,14 +105,20 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
 	if (rate == 0)
 		get_rate(&rate, "10Mbit");
 
-	if (!opt.qth_min || !opt.qth_max || !opt.limit || !avpkt) {
-		fprintf(stderr, "RED: Required parameter (min, max, limit, avpkt) is missing\n");
+	if (!opt.limit || !avpkt) {
+		fprintf(stderr, "RED: Required parameter (limit, avpkt) is missing\n");
 		return -1;
 	}
-	if (!burst) {
+	/* Compute default min/max thresholds based on 
+	 * Sally Floyd's recommendations:
+	 * http://www.icir.org/floyd/REDparameters.txt
+	 */
+	if (!opt.qth_max) 
+		opt.qth_max = opt.qth_min ? opt.qth_min * 3 : opt.limit / 4;
+	if (!opt.qth_min)
+		opt.qth_min = opt.qth_max / 3;
+	if (!burst)
 		burst = (2 * opt.qth_min + opt.qth_max) / (3 * avpkt);
-		fprintf(stderr, "RED: set burst to %u\n", burst);
-	}
 	if ((wlog = tc_red_eval_ewma(opt.qth_min, burst, avpkt)) < 0) {
 		fprintf(stderr, "RED: failed to calculate EWMA constant.\n");
 		return -1;
@@ -129,14 +136,6 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
 		return -1;
 	}
 	opt.Scell_log = wlog;
-	if (ecn_ok) {
-#ifdef TC_RED_ECN
-		opt.flags |= TC_RED_ECN;
-#else
-		fprintf(stderr, "RED: ECN support is missing in this binary.\n");
-		return -1;
-#endif
-	}
 
 	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
@@ -148,7 +147,7 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
 
 static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 {
-	struct rtattr *tb[TCA_RED_STAB+1];
+	struct rtattr *tb[TCA_RED_MAX + 1];
 	struct tc_red_qopt *qopt;
 	SPRINT_BUF(b1);
 	SPRINT_BUF(b2);
@@ -157,7 +156,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	if (opt == NULL)
 		return 0;
 
-	parse_rtattr_nested(tb, TCA_RED_STAB, opt);
+	parse_rtattr_nested(tb, TCA_RED_MAX, opt);
 
 	if (tb[TCA_RED_PARMS] == NULL)
 		return -1;
@@ -168,10 +167,10 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 		sprint_size(qopt->limit, b1),
 		sprint_size(qopt->qth_min, b2),
 		sprint_size(qopt->qth_max, b3));
-#ifdef TC_RED_ECN
 	if (qopt->flags & TC_RED_ECN)
 		fprintf(f, "ecn ");
-#endif
+	if (qopt->flags & TC_RED_HARDDROP)
+		fprintf(f, "harddrop ");
 	if (show_details) {
 		fprintf(f, "ewma %u Plog %u Scell_log %u",
 			qopt->Wlog, qopt->Plog, qopt->Scell_log);

             reply	other threads:[~2011-12-08 23:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08 23:11 Eric Dumazet [this message]
2011-12-09  0:44 ` [PATCH iproute2] red: harddrop support and cleanups Stephen Hemminger
2011-12-09  4:10   ` Eric Dumazet
2011-12-09 17:33     ` Stephen Hemminger
2011-12-09 18:30       ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet
2012-01-19 22:47         ` Stephen Hemminger
2012-01-20  1:33           ` Jesse Brandeburg
2012-01-20  3:21             ` Stephen Hemminger
2012-01-20 15:10               ` [PATCH iproute2] red: fix adaptive spelling Eric Dumazet
2012-01-20  6:29             ` [PATCH iproute2] red: Add adaptative algo Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323385900.2529.12.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox