[pve-devel] [PATCH v1 pve-common 2/5] add out/in-rate parameter to tap_plug sub, keep version with just rate param
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Apr 29 16:57:58 CEST 2021
On 11.09.20 12:08, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
> src/PVE/Network.pm | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
> index 3e7a1c1..3b09cec 100644
> --- a/src/PVE/Network.pm
> +++ b/src/PVE/Network.pm
> @@ -389,6 +389,11 @@ my $cleanup_firewall_bridge = sub {
>
> sub tap_plug {
> my ($iface, $bridge, $tag, $firewall, $trunks, $rate) = @_;
> + tap_plug($iface, $bridge, $tag, $firewall, $trunks, $rate, $rate);
> +}
> +
> +sub tap_plug {
> + my ($iface, $bridge, $tag, $firewall, $trunks, $inrate, $outrate) = @_;
FYI: This really cannot work, perl has no such overloading.
In theory you could pass the $in/out as array ref or even hash and check for that.
Something like the following (not tested):
my ($iface, $bridge, $tag, $firewall, $trunks, $rate) = @_;
my ($inrate, $outrate);
if (defined($rate) && ref($rate) eq 'HASH) {
($inrate, $outrate) = $rate->@{'in', 'out'};
} else {
$inrate = $outrate = $rate;
}
>
> #cleanup old port config from any openvswitch bridge
> eval {run_command("/usr/bin/ovs-vsctl del-port $iface", outfunc => sub {}, errfunc => sub {}) };
> @@ -422,7 +427,7 @@ sub tap_plug {
> }
> }
>
> - tap_rate_limit($iface, $rate);
> + tap_rate_limit($iface, $outrate, $inrate);
> }
>
> sub tap_unplug {
>
More information about the pve-devel
mailing list