summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-07-13 09:39:11 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-07-13 09:39:11 -0700
commitbc475f21c4f7a157a0b0657748ce334ce347d3de (patch)
tree40f2c10afcaab6c10acd2bcb90886c5ac98b30e3
parent66c1789e80f6fe0da15a876eb84aa36ad0290767 (diff)
downloadvyatta-cfg-qos-kenwood.tar.gz
vyatta-cfg-qos-kenwood.zip
Add firewall mark match optionkenwood
Backport 'traffic-shaper XXX class CCC match MMM mark N' from larkspur
-rw-r--r--lib/Vyatta/Qos/Match.pm39
-rw-r--r--templates/qos-policy/traffic-shaper/node.tag/class/node.tag/match/node.tag/mark/node.def2
2 files changed, 35 insertions, 6 deletions
diff --git a/lib/Vyatta/Qos/Match.pm b/lib/Vyatta/Qos/Match.pm
index c2f00a3..42d0bb6 100644
--- a/lib/Vyatta/Qos/Match.pm
+++ b/lib/Vyatta/Qos/Match.pm
@@ -24,16 +24,13 @@ sub new {
my ( $that, $config ) = @_;
my $self = {};
my $class = ref($that) || $that;
+ my $ptype;
bless $self, $class;
foreach my $proto (qw(ip ipv6 ether)) {
next unless $config->exists($proto);
- foreach my $t (qw(vif dev)) {
- die "can not match on $proto and $t\n" if $config->exists($t);
- }
-
my %fields;
if ( $proto eq 'ether' ) {
@@ -54,10 +51,29 @@ sub new {
}
$self->{$proto} = \%fields;
+ my $other = $ptype;
+ die "Can not match on both $proto and $other protocol in same match\n"
+ if $other;
+ $ptype = $other;
}
- $self->{_vif} = $config->returnValue("vif");
- $self->{_indev} = getIfIndex( $config->returnValue("interface") );
+ my $vif = $config->returnValue("vif");
+ $self->{_vif} = $vif;
+
+ my $iif = $config->returnValue("interface");
+ $self->{_indev} = getIfIndex($iif);
+
+ my $fwmark = $config->returnValue("mark");
+ $self->{_fwmark} = $fwmark;
+
+ if ($ptype) {
+ die "Can not combine protocol and firewall mark match\n"
+ if ($fwmark);
+ die "Can not combine protocol and vlan tag match\n"
+ if ($vif);
+ die "Can not combine protocol and interface match\n"
+ if ($iif);
+ }
return $self;
}
@@ -128,8 +144,10 @@ sub filter {
}
print " $police" if $police;
printf " flowid %x:%x\n", $parent, $classid;
+ return;
}
+ my $fwmark = $self->{_fwmark};
my $indev = $self->{_indev};
my $vif = $self->{_vif};
if ( defined($vif) || defined($indev) ) {
@@ -137,7 +155,16 @@ sub filter {
print " protocol all basic";
print " match meta\(rt_iif eq $indev\)" if $indev;
print " match meta\(vlan mask 0xfff eq $vif\)" if $vif;
+ print " match meta\(fwmark eq $fwmark\)" if $fwmark;
+
+ print " $police" if $police;
+ printf " flowid %x:%x\n", $parent, $classid;
+ } elsif ( $fwmark ) {
+ printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio;
+ printf " protocol all handle %d fw", $fwmark;
print " $police" if $police;
printf " flowid %x:%x\n", $parent, $classid;
}
}
+
+1;
diff --git a/templates/qos-policy/traffic-shaper/node.tag/class/node.tag/match/node.tag/mark/node.def b/templates/qos-policy/traffic-shaper/node.tag/class/node.tag/match/node.tag/mark/node.def
new file mode 100644
index 0000000..a3a805e
--- /dev/null
+++ b/templates/qos-policy/traffic-shaper/node.tag/class/node.tag/match/node.tag/mark/node.def
@@ -0,0 +1,2 @@
+type: u32
+help: Match on mark applied by firewall