naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone
Blob Blame History Raw
From f2794eafcfaa6dacb1bdcf5cfc11bf9d173cad28 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon, 26 Aug 2013 08:41:19 -0700
Subject: [PATCH] tc: fix for qdiscs without options

This is a combination of 2 commits which fix tc for adding a qdisc which does
not support options, like e.g. pfifo_fast. A simple test-case is:

tc qdisc replace dev eth0 root pfifo_fast

Without this patch applied, the above command fails with the following message:

qdisc 'pfifo_fast' does not support option parsing

commit e9e78b0db0e023035e346ba67de838be851eb665
Author: Stephen Hemminger <stephen@networkplumber.org>
Date:   Mon Aug 26 08:41:19 2013 -0700

    tc: allow qdisc without options

    Pfifo_fast needs no options. So don't force it to have parsing code.

commit 0a502b21e30be835dcad8d9c6023a41da8709eb1
Author: Stephen Hemminger <stephen@networkplumber.org>
Date:   Sun Oct 27 12:26:47 2013 -0700

    Fix handling of qdis without options

    Some qdisc like htb want the parse_qopt to be called even if no options
    present. Fixes regression caused by:

    e9e78b0db0e023035e346ba67de838be851eb665 is the first bad commit
    commit e9e78b0db0e023035e346ba67de838be851eb665
    Author: Stephen Hemminger <stephen@networkplumber.org>
    Date:   Mon Aug 26 08:41:19 2013 -0700

        tc: allow qdisc without options
---
 tc/tc_qdisc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
index f3bf5b5..e304858 100644
--- a/tc/tc_qdisc.c
+++ b/tc/tc_qdisc.c
@@ -138,12 +138,13 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
 		addattr_l(&req.n, sizeof(req), TCA_RATE, &est, sizeof(est));
 
 	if (q) {
-		if (!q->parse_qopt) {
+		if (q->parse_qopt) {
+			if (q->parse_qopt(q, argc, argv, &req.n))
+				return 1;
+		} else if (argc) {
 			fprintf(stderr, "qdisc '%s' does not support option parsing\n", k);
 			return -1;
 		}
-		if (q->parse_qopt(q, argc, argv, &req.n))
-			return 1;
 	} else {
 		if (argc) {
 			if (matches(*argv, "help") == 0)
-- 
1.8.3.1