Assign sequential priorities to filters

- Also remove a redundant 0x prefix from a table number.

Signed-off-by: Tom Eastep <teastep@shorewall.net
This commit is contained in:
Tom Eastep 2012-09-13 09:30:11 -07:00
parent 14073e8943
commit e0f85edab3
2 changed files with 15 additions and 4 deletions

View File

@ -1239,7 +1239,7 @@ sub in_hex2( $ ) {
}
sub in_hex3( $ ) {
sprintf '0x%03x', $_[0];
sprintf '%03x', $_[0];
}
sub in_hex4( $ ) {

View File

@ -983,6 +983,7 @@ sub validate_tc_device( ) {
mtu => $mtu,
mpu => $mpu,
tsize => $tsize,
filterpri => 1,
} ,
push @tcdevices, $device;
@ -1408,9 +1409,7 @@ sub process_tc_filter() {
fatal_error "Invalid INTERFACE:CLASS ($devclass)" if defined $rest || ! ($device && $class );
my ( $ip, $ip32, $prio , $lo ) = $family == F_IPV4 ? ('ip', 'ip', 10, 2 ) : ('ipv6', 'ip6', 11 , 4 );
$prio = validate_filter_priority( $priority, 'filter' ) unless $priority eq '-';
my ( $ip, $ip32, $lo ) = $family == F_IPV4 ? ('ip', 'ip', 2 ) : ('ipv6', 'ip6', 4 );
my $devref;
@ -1420,6 +1419,18 @@ sub process_tc_filter() {
( $device , $devref ) = dev_by_number( $device );
}
my ( $prio, $filterpri ) = ( undef, $devref->{filterpri} );
if ( $priority eq '-' ) {
$prio = $filterpri++;
fatal_error "Filter priority overflow" if $prio > 65535;
} else {
$prio = validate_filter_priority( $priority, 'filter' );
$filterpri = $prio + 1 if $prio >= $filterpri;
}
$devref->{filterpri} = $filterpri;
my $devnum = in_hexp $devref->{number};
my $tcref = $tcclasses{$device};