Add DSCP target support.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-02-19 17:04:16 -08:00
parent 75d5957020
commit b1272e8835

View File

@ -86,6 +86,30 @@ use constant { NOMARK => 0 ,
HIGHMARK => 2 HIGHMARK => 2
}; };
my %dscpmap = ( CS0 => 0x00,
CS1 => 0x08,
CS2 => 0x10,
CS3 => 0x18,
CS4 => 0x20,
CS5 => 0x28,
CS6 => 0x30,
CS7 => 0x38,
BE => 0x00,
AF11 => 0x0a,
AF12 => 0x0c,
AF13 => 0x0e,
AF21 => 0x12,
AF22 => 0x14,
AF23 => 0x16,
AF31 => 0x1a,
AF32 => 0x1c,
AF33 => 0x1e,
AF41 => 0x22,
AF42 => 0x24,
AF43 => 0x26,
EF => 0x2e,
);
my %flow_keys = ( 'src' => 1, my %flow_keys = ( 'src' => 1,
'dst' => 1, 'dst' => 1,
'proto' => 1, 'proto' => 1,
@ -464,6 +488,12 @@ sub process_tc_rule( ) {
assert( $cmd =~ /^IMQ\((\d+)\)$/ ); assert( $cmd =~ /^IMQ\((\d+)\)$/ );
require_capability 'IMQ_TARGET', 'IMQ', 's'; require_capability 'IMQ_TARGET', 'IMQ', 's';
$target .= " --todev $1"; $target .= " --todev $1";
} elsif ( $target eq 'DSCP' ) {
assert( $cmd =~ /^DSCP\((\w+)\)$/ );
my $dscp = numeric_value( $1);
$dscp = $dscpmap{$1} unless defined $dscp;
fatal_error( "Invalid DSCP ($1)" ) unless defined $dscp && $dscp < 0x2f && ! ( $dscp & 1 );
$target .= ' --set-dscp ' . in_hex( $dscp );
} }
if ( $rest ) { if ( $rest ) {
@ -1991,6 +2021,12 @@ sub setup_tc() {
mask => '', mask => '',
connmark => 0 connmark => 0
}, },
{ match => sub( $ ) { $_[0] =~ /^DSCP\(\w+\)$/ },
target => 'DSCP',
mark => NOMARK,
mask => '',
connmark => 0
},
); );
if ( my $fn = open_file 'tcrules' ) { if ( my $fn = open_file 'tcrules' ) {