diff options
11 files changed, 120 insertions, 57 deletions
diff --git a/debian/rules b/debian/rules index b02c352..5c52b5d 100755 --- a/debian/rules +++ b/debian/rules @@ -88,7 +88,11 @@ binary-indep: build install dh_compress dh_fixperms dh_installdeb - dh_gencontrol + if [ -f "../.VYATTA_DEV_BUILD" ]; then \ + dh_gencontrol -- -v999.dev; \ + else \ + dh_gencontrol; \ + fi dh_md5sums dh_builddeb diff --git a/lib/Vyatta/Qos/TrafficLimiter.pm b/lib/Vyatta/Qos/TrafficLimiter.pm index 8564e87..03b3021 100644 --- a/lib/Vyatta/Qos/TrafficLimiter.pm +++ b/lib/Vyatta/Qos/TrafficLimiter.pm @@ -27,6 +27,7 @@ my %fields = ( id => undef, priority => undef, + burst => undef, rate => undef, _match => undef, ); @@ -50,8 +51,11 @@ my @matches = (); my $rate = $config->returnValue("bandwidth"); - defined $rate or die "bandwidth must be defined for $level\n"; $self->{rate} = getRate($rate); + defined $rate or die "bandwidth must be defined for $level\n"; + + $self->{burst} = $config->returnValue("burst"); + defined $self->{burst} or die "burst must be defined for $level\n"; $self->{priority} = $config->returnValue("priority"); @@ -133,13 +137,10 @@ sub commands { printf {$out} "qdisc add dev %s handle %x: ingress\n", $dev, $parent; foreach my $class (@$classes) { - my $id = $class->{id}; - my $rate = $class->{rate}; - my $priority = $class->{priority}; - foreach my $match ( $class->matchRules() ) { - $match->filter( $out, $dev, $parent, $priority ); - printf {$out} " police avrate %s drop flowid :%x\n", $rate, $id; + $match->filter( $out, $dev, $parent, $class->{priority} ); + printf {$out} " police rate %s burst %s drop flowid :%x\n", + $class->{rate}, $class->{burst}, $class->{id}; } } } diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl index 3437b1b..9b1253e 100755 --- a/scripts/vyatta-qos.pl +++ b/scripts/vyatta-qos.pl @@ -160,18 +160,66 @@ sub update_interface { } sub using_policy { - my ($config, $name, $interface) = @_; + my ($config, $name, $path) = @_; my @inuse = (); - foreach my $dir ( $config->listNodes("$interface qos-policy") ) { - my $policy = $config->returnValue("$interface qos-policy $dir"); + foreach my $dir ( $config->listNodes("$path qos-policy") ) { + my $policy = $config->returnValue("$path qos-policy $dir"); if ($policy eq $name) { - push @inuse, "$interface $dir"; + push @inuse, "$path $dir"; } } return @inuse; } +sub ether_vif_using { + my ($config, $name, $type, $interface) = @_; + my @affected = (); + + foreach my $vif ( $config->listNodes("$type $interface vif") ) { + my $path = "$type $interface vif $vif"; + push @affected, using_policy($config, $name, $path); + } + return @affected; +} + +sub adsl_vif_using { + my ($config, $name, $type, $interface) = @_; + my @affected = (); + + foreach my $pvc ( $config->listNodes("$type $interface pvc") ) { + foreach my $pvctype ( $config->listNodes("$type $interface pvc $pvc") ) { + foreach my $vc ( $config->listNodes("$type $interface pvc $pvc $pvctype") ) { + my $path = "$type $interface pvc $pvc $pvctype $vc"; + push @affected, using_policy($config, $name, $path); + } + } + } + return @affected; +} + +sub serial_vif_using { + my ($config, $name, $type, $interface) = @_; + my @affected = (); + + foreach my $encap (qw/cisco-hdlc frame-relay ppp/) { + foreach my $vif ( $config->listNodes("$type $interface vif") ) { + push @affected, + using_policy($config, $name, "$type $interface $encap vif $vif"); + } + } + + return @affected; +} + + +my %interfaceVifUsing = ( + 'ethernet' => \ðer_vif_using, + 'bonding' => \ðer_vif_using, + 'serial' => \&serial_vif_using, + 'adsl' => \&adsl_vif_using, +); + sub interfaces_using { my ($name) = @_; my $config = new VyattaConfig; @@ -181,22 +229,10 @@ sub interfaces_using { foreach my $type ( $config->listNodes() ) { foreach my $interface ( $config->listNodes($type) ) { push @affected, using_policy($config, $name, "$type $interface"); - - if ($type eq 'ethernet') { - foreach my $vif ( $config->listNodes("$type $interface vif") ) { - push @affected, using_policy($config, $name, "$type $interface vif $vif"); - } - } - - if ($type eq 'adsl') { - foreach my $pvc ( $config->listNodes("adsl $interface pvc") ) { - foreach my $pvctype ( $config->listNodes("adsl $interface pvc $pvc") ) { - foreach my $vc ( $config->listNodes("adsl $interface pvc $pvc $pvctype") ) { - push @affected, using_policy($config, $name, - "adsl $interface pvc $pvc $pvctype $vc"); - } - } - } + + my $vif_check = $interfaceVifUsing{$type}; + if ($vif_check) { + push @affected, $vif_check->($config, $name, $type, $interface); } } } @@ -205,34 +241,44 @@ sub interfaces_using { } sub etherName { - my $eth = shift; + my ($eth, $vif, $id) = @_; - if ($_ =~ /vif/) { - shift; - $eth .= $_; + if ($vif eq 'vif') { + return "$eth.$id"; + } else { + return $eth; } - return $eth; } sub serialName { - my $wan = shift; - # XXX add vif - return $wan; + my ($wan, $encap, $type, $id) = @_; + + if ($encap && $type eq 'vif') { + return "$wan.$id"; + } else { + return $wan; + } } sub adslName { # adsl-name pvc pvc-num ppp-type id - my (undef, undef, undef, $type, $id) = @_; - - return $type . $id; + my ($name, undef, undef, $type, $id) = @_; + + if ($id) { + return "$name.$id"; + } else { + return $name; + } } -# Handle mapping of interface types to device names +# Handle mapping of interface types to device names with vif's +# This is because of differences in config layout my %interfaceTypes = ( 'ethernet' => \ðerName, + 'bonding' => \ðerName, 'serial' => \&serialName, 'adsl' => \&adslName, - ); +); sub delete_policy { my ($name) = @_; @@ -279,6 +325,7 @@ sub apply_changes { if ($shaper->isChanged($name)) { foreach my $cfgpath (interfaces_using($name)) { + # ethernet ethX vif 1 out my @elements = split / /, $cfgpath; my $direction = pop @elements; # out, in, ... my $type = shift @elements; # ethernet, serial, ... @@ -330,10 +377,10 @@ if ( $applyChanges ) { print <<EOF; usage: vyatta-qos.pl --check vyatta-qos.pl --list-policy + vyatta-qos.pl --apply-changes vyatta-qos.pl --create-policy policy-type policy-name vyatta-qos.pl --delete-policy policy-name - vyatta-qos.pl --apply-changes policy-type policy-name vyatta-qos.pl --update-interface interface direction policy-name vyatta-qos.pl --delete-interface interface direction diff --git a/templates/interfaces/bonding/node.tag/qos-policy/out/node.def b/templates/interfaces/bonding/node.tag/qos-policy/out/node.def index ec96f0f..c7d6ad2 100644 --- a/templates/interfaces/bonding/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/bonding/node.tag/qos-policy/out/node.def @@ -1,6 +1,6 @@ type: txt help: Set output QOS policy for specified bonding interface allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl --update-interface $VAR(../../@) $VAR(.) $VAR(@) +update: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl --update-interface $VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-interface $VAR(../../@) $VAR(.) diff --git a/templates/interfaces/bonding/node.tag/vif/node.tag/qos-policy/out/node.def b/templates/interfaces/bonding/node.tag/vif/node.tag/qos-policy/out/node.def index df0ea43..729fa7c 100644 --- a/templates/interfaces/bonding/node.tag/vif/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/bonding/node.tag/vif/node.tag/qos-policy/out/node.def @@ -1,8 +1,8 @@ type: txt help: Set outbound QOS policy allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl \ +update: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl \ --update-interface $VAR(../../../@).$VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl \ --delete-interface $VAR(../../../@).$VAR(../../@) $VAR(.) diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/qos-policy/out/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/qos-policy/out/node.def index df0ea43..548cc8c 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/qos-policy/out/node.def @@ -1,9 +1,9 @@ type: txt help: Set outbound QOS policy allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl \ - --update-interface $VAR(../../../@).$VAR(../../@) $VAR(.) $VAR(@) +update: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl \ + --update-interface $VAR(../../../@).$VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl \ --delete-interface $VAR(../../../@).$VAR(../../@) $VAR(.) sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 0 diff --git a/templates/interfaces/serial/node.tag/cisco-hdlc/vif/node.tag/qos-policy/out/node.def b/templates/interfaces/serial/node.tag/cisco-hdlc/vif/node.tag/qos-policy/out/node.def index f4b7221..2f92a3b 100644 --- a/templates/interfaces/serial/node.tag/cisco-hdlc/vif/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/serial/node.tag/cisco-hdlc/vif/node.tag/qos-policy/out/node.def @@ -1,9 +1,10 @@ type: txt help: Set outbound QOS policy allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl \ +update: sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl \ --update-interface $VAR(../../../../@).$VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl \ --delete-interface $VAR(../../../../@).$VAR(../../@) $VAR(.) + sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 0 diff --git a/templates/interfaces/serial/node.tag/frame-relay/vif/node.tag/qos-policy/out/node.def b/templates/interfaces/serial/node.tag/frame-relay/vif/node.tag/qos-policy/out/node.def index 905c3b5..67482aa 100644 --- a/templates/interfaces/serial/node.tag/frame-relay/vif/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/serial/node.tag/frame-relay/vif/node.tag/qos-policy/out/node.def @@ -1,8 +1,9 @@ type: txt help: Set outbound QOS policy allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl \ +update: sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl \ --update-interface $VAR(../../../../@).$VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl \ --delete-interface $VAR(../../../../@).$VAR(../../@) $VAR(.) + sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 0 diff --git a/templates/interfaces/serial/node.tag/ppp/vif/node.tag/qos-policy/out/node.def b/templates/interfaces/serial/node.tag/ppp/vif/node.tag/qos-policy/out/node.def index 905c3b5..67482aa 100644 --- a/templates/interfaces/serial/node.tag/ppp/vif/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/serial/node.tag/ppp/vif/node.tag/qos-policy/out/node.def @@ -1,8 +1,9 @@ type: txt help: Set outbound QOS policy allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl \ +update: sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl \ --update-interface $VAR(../../../../@).$VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl \ --delete-interface $VAR(../../../../@).$VAR(../../@) $VAR(.) + sudo ip link set dev $VAR(../../../../@).$VAR(../../@) txqueuelen 0 diff --git a/templates/interfaces/tunnel/node.tag/qos-policy/out/node.def b/templates/interfaces/tunnel/node.tag/qos-policy/out/node.def index 063fe58..13c78af 100644 --- a/templates/interfaces/tunnel/node.tag/qos-policy/out/node.def +++ b/templates/interfaces/tunnel/node.tag/qos-policy/out/node.def @@ -1,6 +1,7 @@ type: txt help: Set the tunnel QoS policy allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out -create: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 -update: /opt/vyatta/sbin/vyatta-qos.pl --update-interface $VAR(../../@) $VAR(.) $VAR(@) +update: sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 100 + /opt/vyatta/sbin/vyatta-qos.pl --update-interface $VAR(../../@) $VAR(.) $VAR(@) delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-interface $VAR(../../@) $VAR(.) + sudo ip link set dev $VAR(../../../@).$VAR(../../@) txqueuelen 0 diff --git a/templates/qos-policy/traffic-limiter/node.tag/class/node.tag/burst/node.def b/templates/qos-policy/traffic-limiter/node.tag/class/node.tag/burst/node.def new file mode 100644 index 0000000..54ae4f3 --- /dev/null +++ b/templates/qos-policy/traffic-limiter/node.tag/class/node.tag/burst/node.def @@ -0,0 +1,7 @@ +type: txt +help: Set the burst size for this class (default: 15kb) +default: "15k" +syntax:expression: exec "/opt/vyatta/sbin/vyatta-qos-util.pl --burst \"$VAR(@)\"" +comp_help: Allowed values: + <number> Burst size in bytes + <number><suffix> Size with scaling suffix (kb, mb, gb) |