Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jun 2010 23:01:43 +0100
From:      =?ISO-8859-1?Q?Ermal_Lu=E7i?= <eri@freebsd.org>
To:        Luigi Rizzo <luigi@freebsd.org>
Cc:        freebsd-net <freebsd-net@freebsd.org>
Subject:   [PATCH] ipfw pipe bandwidth parameter parser.
Message-ID:  <AANLkTina6_2EoZOVPWD3pPcJ4FbeDi8eahcHXp-KL-XN@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hello,

on FreeBSD-STABLE at least ipfw wrongly interprets dummynet
configurations of the type:

pipe 10 config bw 1.5Mb
                           ^^^

as being 1bit/s configuration. Which is quite wrong in real production usage.
This simple patch fixes it http://tinyurl.com/33j6odw.

I am not sure if this should be included before 8.1 release or not.

Here is the inline version.
Index: sbin/ipfw/dummynet.c
===================================================================
RCS file: /home/ncvs/src/sbin/ipfw/dummynet.c,v
retrieving revision 1.9.2.4
diff -u -r1.9.2.4 dummynet.c
--- sbin/ipfw/dummynet.c        23 Mar 2010 09:58:59 -0000      1.9.2.4
+++ sbin/ipfw/dummynet.c        14 Jun 2010 21:49:38 -0000
@@ -528,10 +528,10 @@
                if_name[namelen] = '\0';
                *bandwidth = 0;
        } else {        /* read bandwidth value */
-               int bw;
+               double bw;
                char *end = NULL;

-               bw = strtoul(arg, &end, 0);
+               bw = strtod(arg, &end);
                if (*end == 'K' || *end == 'k') {
                        end++;
                        bw *= 1000;
@@ -547,7 +547,7 @@
                if (bw < 0)
                        errx(EX_DATAERR, "bandwidth too large");

-               *bandwidth = bw;
+               *bandwidth = (int)bw;
                if (if_name)
                        if_name[0] = '\0';
        }


Regards,
-- 
Ermal



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTina6_2EoZOVPWD3pPcJ4FbeDi8eahcHXp-KL-XN>