diff options
author | Luiz Souza <luiz@netgate.com> | 2017-10-26 18:47:59 -0200 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2017-10-26 18:50:57 -0200 |
commit | 3c6a128b6700303ad1f58256378e939a8bad4e25 (patch) | |
tree | 94038656cab8cbdf0fda3b4bf7b35d37b5d108e9 | |
parent | 77888d7b7a68791802a54935853610225f25bcb5 (diff) | |
download | FreeBSD-src-3c6a128b6700303ad1f58256378e939a8bad4e25.zip FreeBSD-src-3c6a128b6700303ad1f58256378e939a8bad4e25.tar.gz |
Make the bandwidth internal storage an unsigned int in IPFW dummynet.
This allows the maximum value of 4294967295 (~4Gb/s) instead of previous value of 2147483647 (~2Gb/s).
Ticket #7979
(cherry picked from commit e626f15967f568082f91c7caa2c76f262e34d8cb)
-rw-r--r-- | sbin/ipfw/dummynet.c | 9 | ||||
-rw-r--r-- | sys/netinet/ip_dummynet.h | 4 | ||||
-rw-r--r-- | sys/netpfil/ipfw/ip_dn_glue.c | 4 | ||||
-rw-r--r-- | sys/netpfil/ipfw/ip_dn_io.c | 3 |
4 files changed, 11 insertions, 9 deletions
diff --git a/sbin/ipfw/dummynet.c b/sbin/ipfw/dummynet.c index cd00411..44e2b71 100644 --- a/sbin/ipfw/dummynet.c +++ b/sbin/ipfw/dummynet.c @@ -23,6 +23,7 @@ */ #define NEW_AQM +#include <sys/limits.h> #include <sys/types.h> #include <sys/socket.h> /* XXX there are several sysctl leftover here */ @@ -794,7 +795,7 @@ is_valid_number(const char *s) * set clocking interface or bandwidth value */ static void -read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) +read_bandwidth(char *arg, uint32_t *bandwidth, char *if_name, int namelen) { if (*bandwidth != -1) warnx("duplicate token, override bandwidth value!"); @@ -811,7 +812,7 @@ read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) if_name[namelen] = '\0'; *bandwidth = 0; } else { /* read bandwidth value */ - int bw; + uint64_t bw; char *end = NULL; bw = strtoul(arg, &end, 0); @@ -830,10 +831,10 @@ read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) _substrcmp2(end, "by", "bytes") == 0) bw *= 8; - if (bw < 0) + if (bw > UINT_MAX) errx(EX_DATAERR, "bandwidth too large"); - *bandwidth = bw; + *bandwidth = (uint32_t)bw; if (if_name) if_name[0] = '\0'; } diff --git a/sys/netinet/ip_dummynet.h b/sys/netinet/ip_dummynet.h index 377b5b0..0d5efa6 100644 --- a/sys/netinet/ip_dummynet.h +++ b/sys/netinet/ip_dummynet.h @@ -129,7 +129,7 @@ struct dn_link { * XXX what about burst ? */ int32_t link_nr; - int bandwidth; /* bit/s or bits/tick. */ + uint32_t bandwidth; /* bit/s or bits/tick. */ int delay; /* ms and ticks */ uint64_t burst; /* scaled. bits*Hz XXX */ }; @@ -214,7 +214,7 @@ struct dn_profile { char name[ED_MAX_NAME_LEN]; int link_nr; int loss_level; - int bandwidth; // XXX use link bandwidth? + uint32_t bandwidth; // XXX use link bandwidth? int samples_no; /* actual len of samples[] */ int samples[ED_MAX_SAMPLES_NO]; /* may be shorter */ }; diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index 4c4659a..7686155 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -164,7 +164,7 @@ struct dn_pipe7 { /* a pipe */ SLIST_ENTRY(dn_pipe7) next; /* linked list in a hash slot */ int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ + uint32_t bandwidth; /* really, bytes/tick. */ int delay ; /* really, ticks */ struct mbuf *head, *tail ; /* packets in delay line */ @@ -230,7 +230,7 @@ struct dn_pipe8 { /* a pipe */ SLIST_ENTRY(dn_pipe8) next; /* linked list in a hash slot */ int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ + uint32_t bandwidth; /* really, bytes/tick. */ int delay ; /* really, ticks */ struct mbuf *head, *tail ; /* packets in delay line */ diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 6509006..4a8843f 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -618,7 +618,8 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) struct dn_schk *s = si->sched; struct mbuf *m = NULL; int delay_line_idle = (si->dline.mq.head == NULL); - int done, bw; + int done; + uint32_t bw; if (q == NULL) { q = &def_q; |