Skip to contentSkip to conversation

net: taprio: Fix returning EINVAL when configuring without flags

PATCH Applied Vinicius Costa Gomes 3 participants 5 messages Oct 8, 2019 – Oct 10, 2019

Subsystems (4)
lore
Share & tools
lore

Vinicius Costa Gomes

author maintainer
#0 lore raw

PATCH 1/1 net: taprio: Fix returning EINVAL when configuring without flags

When configuring a taprio instance if "flags" is not specified (or it's zero), taprio currently replies with an "Invalid argument" error.

So, set the return value to zero after we are done with all the checks.

Fixes 9c66d1564676 ("taprio: Add support for hardware offloading")
---
 net/sched/sch_taprio.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/sch_taprio.c +4 -0
index 68b543f85a96..6719a65169d4 100644
@@ -1341,6 +1341,10 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb,
 		NL_SET_ERR_MSG(extack, "Specifying a 'clockid' is mandatory");
 		goto out;
 	}
+
+	/* Everything went ok, return success. */
+	err = 0;
+
 out:
 	return err;
 }
Signature · 1 line
2.23.0
Acked-by on v1 1/1
#1 lore raw

Hi Vinicius,

Quoted 10 lines · Vinicius Costa Gomes

When configuring a taprio instance if "flags" is not specified (or it's zero), taprio currently replies with an "Invalid argument" error.

So, set the return value to zero after we are done with all the checks.

Fixes 9c66d1564676 ("taprio: Add support for hardware offloading")

---

You mean clockid, not flags, right?
Otherwise the patch looks correct, sorry for the bug. Once you fix the commit message:

Quoted 21 lines
 net/sched/sch_taprio.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/sch_taprio.c +4 -1
index 68b543f85a96..6719a65169d4 100644
@@ -1341,6 +1341,10 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb,
                NL_SET_ERR_MSG(extack, "Specifying a 'clockid' is mandatory");
                goto out;
        }
+
+       /* Everything went ok, return success. */
+       err = 0;
+
 out:
        return err;
 }
--

2.23.0

#2 lore raw
Quoted 16 lines · Vladimir Oltean

Hi Vinicius,

Quoted 10 lines · Vinicius Costa Gomes

When configuring a taprio instance if "flags" is not specified (or it's zero), taprio currently replies with an "Invalid argument" error.

So, set the return value to zero after we are done with all the checks.

Fixes 9c66d1564676 ("taprio: Add support for hardware offloading")

---

Quoted 6 lines

You mean clockid, not flags, right?
Otherwise the patch looks correct, sorry for the bug. Once you fix the commit message:

No, you are actually right to phrase it this way, but the description is still confusing. When 'flags' is zero, the driver takes a code path which is buggy and always returns a negative error code. Although I'm not really sure how much better this can be phrased. I'm fine with the description now too.

Quoted 21 lines
Quoted 21 lines
 net/sched/sch_taprio.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/sch_taprio.c +4 -1
index 68b543f85a96..6719a65169d4 100644
@@ -1341,6 +1341,10 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb,
                NL_SET_ERR_MSG(extack, "Specifying a 'clockid' is mandatory");
                goto out;
        }
+
+       /* Everything went ok, return success. */
+       err = 0;
+
 out:
        return err;
 }
--

2.23.0

author maintainer
#3 lore raw
In reply to Vladimir Oltean

Hi,

Quoted 8 lines · Vladimir Oltean

Hi Vinicius,

Quoted 4 lines · Vinicius Costa Gomes

When configuring a taprio instance if "flags" is not specified (or it's zero), taprio currently replies with an "Invalid argument" error.

Quoted 8 lines
Quoted 6 lines

So, set the return value to zero after we are done with all the checks.

Fixes 9c66d1564676 ("taprio: Add support for hardware offloading")

---

You mean clockid, not flags, right?

I do mean "flags", yeah. The case I was testing was something like this:

$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
      num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
      queues 1@0 1@1 2@2 \
      base-time $BASE_TIME \
      sched-entry S 01 300000 \
      sched-entry S 02 300000 \
      sched-entry S 04 400000 \
      clockid CLOCK_TAI

Cheers,
--
Vinicius