Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Apr 2016 18:37:41 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r297984 - head/sbin/pfctl
Message-ID:  <201604141837.u3EIbfjT092038@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Thu Apr 14 18:37:40 2016
New Revision: 297984
URL: https://svnweb.freebsd.org/changeset/base/297984

Log:
  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)

Modified:
  head/sbin/pfctl/parse.y

Modified: head/sbin/pfctl/parse.y
==============================================================================
--- head/sbin/pfctl/parse.y	Thu Apr 14 18:31:45 2016	(r297983)
+++ head/sbin/pfctl/parse.y	Thu Apr 14 18:37:40 2016	(r297984)
@@ -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) {



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