Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2 0/4] tc: four small fixes
@ 2026-11-29 23:21 Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 1/4] tc: netem: mark TCA_NETEM_CORR present for duplicate Dave Seddon
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dave Seddon @ 2026-11-29 23:21 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern, Jamal Hadi Salim

Four small, independent tc fixes. Each message has a command that shows
the problem on current main.

Patches 3 and 4 have no Fixes tag: the code dates from the initial 2004
import.

Dave Seddon (4):
  tc: netem: mark TCA_NETEM_CORR present for duplicate
  tc: sfq: reject avpkt 0
  tc: actions: fail list and flush of an unknown action kind
  tc: return after usage() for help

 tc/m_action.c  | 2 ++
 tc/q_netem.c   | 1 +
 tc/q_sfq.c     | 2 +-
 tc/tc_class.c  | 2 ++
 tc/tc_filter.c | 1 +
 tc/tc_qdisc.c  | 2 ++
 6 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH iproute2 1/4] tc: netem: mark TCA_NETEM_CORR present for duplicate
  2026-11-29 23:21 [PATCH iproute2 0/4] tc: four small fixes Dave Seddon
@ 2026-11-29 23:21 ` Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 2/4] tc: sfq: reject avpkt 0 Dave Seddon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dave Seddon @ 2026-11-29 23:21 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern, Jamal Hadi Salim

Count TCA_NETEM_CORR as present for a duplicate correlation, as the
other arms do. Without it a duplicate correlation on its own is not
sent:

  # tc qdisc add dev lo root netem duplicate 10% 25%
  # tc qdisc show dev lo

shows "duplicate 10%", not "duplicate 10% 25%".

Fixes: 40076f622e0a ("netem parameters to change command")
Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
 tc/q_netem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tc/q_netem.c b/tc/q_netem.c
index 0e47765b..f03d0d70 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -407,6 +407,7 @@ random_loss_model:
 			}
 			if (NEXT_IS_NUMBER()) {
 				NEXT_ARG();
+				++present[TCA_NETEM_CORR];
 				if (get_percent(&cor.dup_corr, *argv)) {
 					explain1("duplicate");
 					return -1;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 2/4] tc: sfq: reject avpkt 0
  2026-11-29 23:21 [PATCH iproute2 0/4] tc: four small fixes Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 1/4] tc: netem: mark TCA_NETEM_CORR present for duplicate Dave Seddon
@ 2026-11-29 23:21 ` Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 3/4] tc: actions: fail list and flush of an unknown action kind Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 4/4] tc: return after usage() for help Dave Seddon
  3 siblings, 0 replies; 5+ messages in thread
From: Dave Seddon @ 2026-11-29 23:21 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern, Jamal Hadi Salim

Treat "avpkt 0" as illegal. It is used as a divisor, so

  # tc qdisc add dev lo root sfq redflowlimit 100000 avpkt 0

dies with a floating point exception.

Fixes: 6987ecf0832d ("sfq: add optional RED on top of SFQ")
Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
 tc/q_sfq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/q_sfq.c b/tc/q_sfq.c
index 37ebd977..5ed1ad07 100644
--- a/tc/q_sfq.c
+++ b/tc/q_sfq.c
@@ -119,7 +119,7 @@ static int sfq_parse_opt(const struct qdisc_util *qu, int argc, char **argv, str
 			red++;
 		} else if (strcmp(*argv, "avpkt") == 0) {
 			NEXT_ARG();
-			if (get_size(&avpkt, *argv)) {
+			if (get_size(&avpkt, *argv) || !avpkt) {
 				fprintf(stderr, "Illegal \"avpkt\"\n");
 				return -1;
 			}
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 3/4] tc: actions: fail list and flush of an unknown action kind
  2026-11-29 23:21 [PATCH iproute2 0/4] tc: four small fixes Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 1/4] tc: netem: mark TCA_NETEM_CORR present for duplicate Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 2/4] tc: sfq: reject avpkt 0 Dave Seddon
@ 2026-11-29 23:21 ` Dave Seddon
  2026-11-29 23:21 ` [PATCH iproute2 4/4] tc: return after usage() for help Dave Seddon
  3 siblings, 0 replies; 5+ messages in thread
From: Dave Seddon @ 2026-11-29 23:21 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern, Jamal Hadi Salim

Set ret to -1 on the "bad action" paths of tc_act_list_or_flush(),
which exit 0 today:

  # tc actions ls action nosuch
  bad action nosuch
  # echo $?
  0

Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
 tc/m_action.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tc/m_action.c b/tc/m_action.c
index bbc8e6a6..ee6d2aac 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -791,10 +791,12 @@ static int tc_act_list_or_flush(int *argc_p, char ***argv_p, int event)
 	a = get_action_kind(k);
 	if (a == NULL) {
 		fprintf(stderr, "bad action %s\n", k);
+		ret = -1;
 		goto bad_val;
 	}
 	if (strcmp(a->id, k) != 0) {
 		fprintf(stderr, "bad action %s\n", k);
+		ret = -1;
 		goto bad_val;
 	}
 	strncpy(k, *argv, sizeof(k) - 1);
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 4/4] tc: return after usage() for help
  2026-11-29 23:21 [PATCH iproute2 0/4] tc: four small fixes Dave Seddon
                   ` (2 preceding siblings ...)
  2026-11-29 23:21 ` [PATCH iproute2 3/4] tc: actions: fail list and flush of an unknown action kind Dave Seddon
@ 2026-11-29 23:21 ` Dave Seddon
  3 siblings, 0 replies; 5+ messages in thread
From: Dave Seddon @ 2026-11-29 23:21 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern, Jamal Hadi Salim

Return after usage() for "help" in the qdisc and class add paths and in
the qdisc, class and filter show paths, as tc_filter_modify() does. Today

  # tc qdisc add dev lo root handle 1: help pfifo

prints the usage and then adds the pfifo, and

  # tc qdisc show dev lo help

prints the usage and then the qdiscs.

Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
 tc/tc_class.c  | 2 ++
 tc/tc_filter.c | 1 +
 tc/tc_qdisc.c  | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/tc/tc_class.c b/tc/tc_class.c
index 82f0f85e..7f9c961d 100644
--- a/tc/tc_class.c
+++ b/tc/tc_class.c
@@ -104,6 +104,7 @@ static int tc_class_modify(int cmd, unsigned int flags, int argc, char **argv)
 				return -1;
 		} else if (matches(*argv, "help") == 0) {
 			usage();
+			return 0;
 		} else {
 			strncpy(k, *argv, sizeof(k)-1);
 
@@ -435,6 +436,7 @@ static int tc_class_list(int argc, char **argv)
 			req.t.tcm_parent = handle;
 		} else if (matches(*argv, "help") == 0) {
 			usage();
+			return 0;
 		} else {
 			fprintf(stderr, "What is \"%s\"? Try \"tc class help\".\n", *argv);
 			return -1;
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index 7b504029..a67288e4 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -690,6 +690,7 @@ static int tc_filter_list(int cmd, int argc, char **argv)
 			filter_chain_index = chain_index;
 		} else if (matches(*argv, "help") == 0) {
 			usage();
+			return 0;
 		} else {
 			fprintf(stderr,
 				" What is \"%s\"? Try \"tc filter help\"\n",
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
index 7c3e7cb3..18818fbf 100644
--- a/tc/tc_qdisc.c
+++ b/tc/tc_qdisc.c
@@ -132,6 +132,7 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
 				invarg("invalid egress block index value", *argv);
 		} else if (matches(*argv, "help") == 0) {
 			usage();
+			return 0;
 		} else {
 			strncpy(k, *argv, sizeof(k)-1);
 
@@ -398,6 +399,7 @@ static int tc_qdisc_list(int argc, char **argv)
 			filter_handle = handle;
 		} else if (matches(*argv, "help") == 0) {
 			usage();
+			return 0;
 		} else if (strcmp(*argv, "invisible") == 0) {
 			dump_invisible = true;
 		} else {
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-29 23:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 23:21 [PATCH iproute2 0/4] tc: four small fixes Dave Seddon
2026-11-29 23:21 ` [PATCH iproute2 1/4] tc: netem: mark TCA_NETEM_CORR present for duplicate Dave Seddon
2026-11-29 23:21 ` [PATCH iproute2 2/4] tc: sfq: reject avpkt 0 Dave Seddon
2026-11-29 23:21 ` [PATCH iproute2 3/4] tc: actions: fail list and flush of an unknown action kind Dave Seddon
2026-11-29 23:21 ` [PATCH iproute2 4/4] tc: return after usage() for help Dave Seddon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox