summaryrefslogtreecommitdiffstats
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2016-04-14 18:37:40 +0000
committerloos <loos@FreeBSD.org>2016-04-14 18:37:40 +0000
commitef692c75a097aad14dfa981abac6c58348cb9a45 (patch)
tree31b4801464c70203328cb901742712f5824efead /sbin/pfctl
parentf782132f224104b62501fd7f47c7d65d1bd0da8c (diff)
downloadFreeBSD-src-ef692c75a097aad14dfa981abac6c58348cb9a45.zip
FreeBSD-src-ef692c75a097aad14dfa981abac6c58348cb9a45.tar.gz
Make pfctl(8) more flexible when parsing bandwidth values.
This is the current behaviour in OpenBSD and a similar patch exist in pfSense too. Obtained from: OpenBSD (partly - rev. 1.625) MFC after: 2 weeks Sponsored by: Rubicon Communications (Netgate)
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/parse.y15
1 files changed, 12 insertions, 3 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 9b22a6b..a03ddbc 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1605,13 +1605,22 @@ bandwidth : STRING {
bps = strtod($1, &cp);
if (cp != NULL) {
+ if (strlen(cp) > 1) {
+ char *cu = cp + 1;
+ if (!strcmp(cu, "Bit") ||
+ !strcmp(cu, "B") ||
+ !strcmp(cu, "bit") ||
+ !strcmp(cu, "b")) {
+ *cu = 0;
+ }
+ }
if (!strcmp(cp, "b"))
; /* nothing */
- else if (!strcmp(cp, "Kb"))
+ else if (!strcmp(cp, "K"))
bps *= 1000;
- else if (!strcmp(cp, "Mb"))
+ else if (!strcmp(cp, "M"))
bps *= 1000 * 1000;
- else if (!strcmp(cp, "Gb"))
+ else if (!strcmp(cp, "G"))
bps *= 1000 * 1000 * 1000;
else if (!strcmp(cp, "%")) {
if (bps < 0 || bps > 100) {
OpenPOWER on IntegriCloud