netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Odin Ugedal <odin@ugedal.com>
To: toke@redhat.com, netdev@vger.kernel.org
Cc: Odin Ugedal <odin@ugedal.com>
Subject: [PATCH 1/3] q_cake: Make fwmark uint instead of int
Date: Wed, 15 Apr 2020 16:39:34 +0200	[thread overview]
Message-ID: <20200415143936.18924-2-odin@ugedal.com> (raw)
In-Reply-To: <20200415143936.18924-1-odin@ugedal.com>

This will help avoid overflow, since setting it to 0xffffffff would
result in -1 when converted to integer, resulting in being "-1", setting
the fwmark to 0x00.

Signed-off-by: Odin Ugedal <odin@ugedal.com>
---
 tc/q_cake.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tc/q_cake.c b/tc/q_cake.c
index 3c78b176..9ebb270c 100644
--- a/tc/q_cake.c
+++ b/tc/q_cake.c
@@ -97,6 +97,7 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 	unsigned int interval = 0;
 	unsigned int diffserv = 0;
 	unsigned int memlimit = 0;
+	unsigned int fwmark = 0;
 	unsigned int target = 0;
 	__u64 bandwidth = 0;
 	int ack_filter = -1;
@@ -107,7 +108,6 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 	int autorate = -1;
 	int ingress = -1;
 	int overhead = 0;
-	int fwmark = -1;
 	int wash = -1;
 	int nat = -1;
 	int atm = -1;
@@ -335,15 +335,12 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 				return -1;
 			}
 		} else if (strcmp(*argv, "fwmark") == 0) {
-			unsigned int fwm;
-
 			NEXT_ARG();
-			if (get_u32(&fwm, *argv, 0)) {
+			if (get_u32(&fwmark, *argv, 0)) {
 				fprintf(stderr,
 					"Illegal value for \"fwmark\": \"%s\"\n", *argv);
 				return -1;
 			}
-			fwmark = fwm;
 		} else if (strcmp(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -388,7 +385,7 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 	if (memlimit)
 		addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit,
 			  sizeof(memlimit));
-	if (fwmark != -1)
+	if (fwmark)
 		addattr_l(n, 1024, TCA_CAKE_FWMARK, &fwmark,
 			  sizeof(fwmark));
 	if (nat != -1)
-- 
2.26.1


  reply	other threads:[~2020-04-15 14:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 14:39 [PATCH 0/3] q_cake: minor fixes and cleanups Odin Ugedal
2020-04-15 14:39 ` Odin Ugedal [this message]
2020-04-16  8:47   ` [PATCH 1/3] q_cake: Make fwmark uint instead of int Toke Høiland-Jørgensen
2020-04-15 14:39 ` [PATCH 2/3] q_cake: properly print memlimit Odin Ugedal
2020-04-16  8:47   ` Toke Høiland-Jørgensen
2020-04-15 14:39 ` [PATCH 3/3] q_cake: detect overflow in get_size Odin Ugedal
2020-04-16  8:49   ` Toke Høiland-Jørgensen
2020-04-16 14:11     ` Odin Ugedal
2020-04-16 14:08 ` [PATCH v2 3/3] tc_util: " Odin Ugedal
2020-04-16 14:16   ` Toke Høiland-Jørgensen
2020-04-20 16:37 ` [PATCH 0/3] q_cake: minor fixes and cleanups Stephen Hemminger

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=20200415143936.18924-2-odin@ugedal.com \
    --to=odin@ugedal.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.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;
as well as URLs for NNTP newsgroup(s).