[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200415143936.18924-2-odin@ugedal.com>
Date: Wed, 15 Apr 2020 16:39:34 +0200
From: Odin Ugedal <odin@...dal.com>
To: toke@...hat.com, netdev@...r.kernel.org
Cc: Odin Ugedal <odin@...dal.com>
Subject: [PATCH 1/3] q_cake: Make fwmark uint instead of int
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@...dal.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
Powered by blists - more mailing lists