> On 10/8/2020 7:12 PM, Simon Matter wrote:
>>> On 10/8/20 3:19 AM, Simon Matter wrote:
>>>> Hi,
>>>>
>>>> It happened recently to me when moving a firewall to a new location...
>>>>
>>>> Before moving I adapted VLAN config and Shorewall configuration. The
>>>> TC
>>>> config was blindly modified by me to use 'gbit' units.
>>>>
>>>> In the new location nothing seemed to work - you can think of headless
>>>> firewall and headless admin - and I had a hard time to find out that
>>>> changing the TC config from 'mbit' to 'gbit' didn't work. :(
>>>>
>>>> Attached patch against 5.2.8 is my proposal to add support for
>>>> g,gb,gbit
>>>> and gbps.
>>>>
>>>> From what I saw on my systems is that not all 'tc' versions support
>>>> 'gbit'
>>>> but AFAIK Shorewall always converts the units to 'kbit' for
>>>> compatibility.
>>>>
>>>> Am I right assuming so?
>>>>
>>>> As always, feedback an testing is appreciated.
>>>>
>>>
>>> Thanks, Simon.
>>>
>>> Note that in the Shorewall/code git repository
>>> (https://gitlab.com/shorewall/code), there are no .annotabed sample
>>> files. Those files are created during the build process by combining
>>> each plain config file with its associated manpage.
>>>
>>> Also, the manpages are generated from .xml files; so when modifying a
>>> manpage, the patch must be against the XML file and not the resulting
>>> manpage.
>>>
>>> So you only need to provide patches for Tc.pm, tcinterfaces.xml,
>>> tcdevices.xml and tcclasses.xml.
>>
>> Thanks Tom, now that you say it I remember there were XLM doc files :-)
>>
>> I'll redo the patch tomorrow.
>>
>
> The clone command for the code repository is at (1).
>
> Sending the patches formatted with 'git format-patch' is best but 'git
> diff' will also do it! :)

Since I'm not really a developer and never used git please allow me to
send a pure diff against master.

@Tom, hope I got it right with the XLM files this time.

Regards,
Simon
diff -Naupr a/Shorewall/manpages/shorewall-tcclasses.xml b/Shorewall/manpages/shorewall-tcclasses.xml
--- a/Shorewall/manpages/shorewall-tcclasses.xml	2020-09-17 23:47:53.000000000 +0200
+++ b/Shorewall/manpages/shorewall-tcclasses.xml	2020-10-09 08:02:22.696699360 +0200
@@ -55,6 +55,14 @@
           </varlistentry>
 
           <varlistentry>
+            <term><emphasis role="bold">gbps</emphasis></term>
+
+            <listitem>
+              <para>Gigabytes per second.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
             <term><emphasis role="bold">kbit</emphasis></term>
 
             <listitem>
@@ -70,6 +78,14 @@
             </listitem>
           </varlistentry>
 
+          <varlistentry>
+            <term><emphasis role="bold">gbit</emphasis></term>
+
+            <listitem>
+              <para>Gigabits per second.</para>
+            </listitem>
+          </varlistentry>
+
           <varlistentry>
             <term><emphasis role="bold">bps</emphasis> or <emphasis
             role="bold">number</emphasis></term>
diff -Naupr a/Shorewall/manpages/shorewall-tcdevices.xml b/Shorewall/manpages/shorewall-tcdevices.xml
--- a/Shorewall/manpages/shorewall-tcdevices.xml	2020-09-17 23:47:53.000000000 +0200
+++ b/Shorewall/manpages/shorewall-tcdevices.xml	2020-10-09 08:02:47.559814154 +0200
@@ -62,6 +62,14 @@
           </varlistentry>
 
           <varlistentry>
+            <term><emphasis role="bold">gbps</emphasis></term>
+
+            <listitem>
+              <para>Gigabytes per second.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
             <term><emphasis role="bold">kbit</emphasis></term>
 
             <listitem>
@@ -77,6 +85,14 @@
             </listitem>
           </varlistentry>
 
+          <varlistentry>
+            <term><emphasis role="bold">gbit</emphasis></term>
+
+            <listitem>
+              <para>Gigabits per second.</para>
+            </listitem>
+          </varlistentry>
+
           <varlistentry>
             <term><emphasis role="bold">bps</emphasis> or <emphasis
             role="bold">number</emphasis></term>
diff -Naupr a/Shorewall/manpages/shorewall-tcinterfaces.xml b/Shorewall/manpages/shorewall-tcinterfaces.xml
--- a/Shorewall/manpages/shorewall-tcinterfaces.xml	2020-09-17 23:47:53.000000000 +0200
+++ b/Shorewall/manpages/shorewall-tcinterfaces.xml	2020-10-09 08:04:06.827180117 +0200
@@ -60,6 +60,14 @@
           </varlistentry>
 
           <varlistentry>
+            <term><emphasis role="bold">gbps</emphasis></term>
+
+            <listitem>
+              <para>Gigabytes per second.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
             <term><emphasis role="bold">kbit</emphasis></term>
 
             <listitem>
@@ -76,6 +84,14 @@
           </varlistentry>
 
           <varlistentry>
+            <term><emphasis role="bold">gbit</emphasis></term>
+
+            <listitem>
+              <para>Gigabits per second.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
             <term><emphasis role="bold">bps</emphasis> or <emphasis
             role="bold">number</emphasis></term>
 
@@ -88,7 +104,7 @@
             <term>k or kb</term>
 
             <listitem>
-              <para>Kilo bytes.</para>
+              <para>Kilobytes.</para>
             </listitem>
           </varlistentry>
 
@@ -99,6 +115,14 @@
               <para>Megabytes.</para>
             </listitem>
           </varlistentry>
+
+          <varlistentry>
+            <term>g or gb</term>
+
+            <listitem>
+              <para>Gigabytes.</para>
+            </listitem>
+          </varlistentry>
         </variablelist>
       </listitem>
 
diff -Naupr a/Shorewall/Perl/Shorewall/Tc.pm b/Shorewall/Perl/Shorewall/Tc.pm
--- a/Shorewall/Perl/Shorewall/Tc.pm	2020-09-17 23:47:53.000000000 +0200
+++ b/Shorewall/Perl/Shorewall/Tc.pm	2020-10-09 07:56:54.114181996 +0200
@@ -139,12 +139,14 @@ sub initialize( $ ) {
 sub rate_to_kbit( $ ) {
     my $rate = $_[0];
 
-    return 0           if $rate eq '-';
-    return $1          if $rate =~ /^((\d+)(\.\d+)?)kbit$/i;
-    return $1 * 1000   if $rate =~ /^((\d+)(\.\d+)?)mbit$/i;
-    return $1 * 8000   if $rate =~ /^((\d+)(\.\d+)?)mbps$/i;
-    return $1 * 8      if $rate =~ /^((\d+)(\.\d+)?)kbps$/i;
-    return ($1/125)    if $rate =~ /^((\d+)(\.\d+)?)(bps)?$/;
+    return 0              if $rate eq '-';
+    return $1             if $rate =~ /^((\d+)(\.\d+)?)kbit$/i;
+    return $1 * 1000      if $rate =~ /^((\d+)(\.\d+)?)mbit$/i;
+    return $1 * 1000000   if $rate =~ /^((\d+)(\.\d+)?)gbit$/i;
+    return $1 * 8000000   if $rate =~ /^((\d+)(\.\d+)?)gbps$/i;
+    return $1 * 8000      if $rate =~ /^((\d+)(\.\d+)?)mbps$/i;
+    return $1 * 8         if $rate =~ /^((\d+)(\.\d+)?)kbps$/i;
+    return ($1/125)       if $rate =~ /^((\d+)(\.\d+)?)(bps)?$/;
     fatal_error "Invalid Rate ($rate)";
 }
 
@@ -202,7 +204,7 @@ sub process_in_bandwidth( $ ) {
     } else {
 	if ( $in_band =~ /:/ ) {
 	    ( $in_band, $burst ) = split /:/, $in_rate, 2;
-	    fatal_error "Invalid burst ($burst)" unless $burst  =~ /^\d+(k|kb|m|mb|mbit|kbit|b)?$/;
+	    fatal_error "Invalid burst ($burst)" unless $burst  =~ /^\d+(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
 	    $in_burst = $burst;
 	}
 
@@ -314,7 +316,7 @@ sub process_simple_device() {
 	my $command = "run_tc qdisc add dev $physical root handle $number: tbf rate ${out_bandwidth}kbit";
 
 	if ( supplied $burst ) {
-	    fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|mbit|kbit|b)?$/;
+	    fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
 	    $command .= " burst $burst";
 	} else {
 	    $command .= ' burst 10kb';
@@ -330,12 +332,12 @@ sub process_simple_device() {
 	$command .= ' mpu 64'; #Assume Ethernet
 
 	if ( supplied $peak ) {
-	    fatal_error "Invalid peak ($peak)" unless $peak =~ /^\d+(?:\.\d+)?(k|kb|m|mb|mbit|kbit|b)?$/;
+	    fatal_error "Invalid peak ($peak)" unless $peak =~ /^\d+(?:\.\d+)?(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
 	    $command .= " peakrate $peak";
 	}
 
 	if ( supplied $minburst ) {
-	    fatal_error "Invalid minburst ($minburst)" unless $minburst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|mbit|kbit|b)?$/;
+	    fatal_error "Invalid minburst ($minburst)" unless $minburst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
 	    $command .= " minburst $minburst";
 	}
 
_______________________________________________
Shorewall-devel mailing list
Shorewall-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to