LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2009, 12:22 PM   #1
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Rep: Reputation: 32
tc filter can't match ACK packets


Hello,
I'm trying to build some basic traffic shaper here, and I want to classify tcp packets with ACK flag set. I'm reading LARTC and I see that example there:
Code:
# tc filter add dev ppp14 parent 1:0 prio 10 u32 \
     match ip protocol 6 0xff \
     match u8 0x10 0xff at nexthdr+13 \
     flowid 1:3
Well, here is the filter I'm using and it won't assign any traffic to class 1:212:
Code:
tc filter add dev eth0 protocol ip parent 1: u32 \
match ip protocol 6 0xff \
match u8 0x10 0xff at nexthdr+13 \
classid 1:212
Flowid and classid are the same thing, right?
I'm watching the queues and I never see any traffic in 1:212.
Code:
# tc -s class show dev eth0                                                                                    
class hfsc 1: root 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 period 0 level 2 

class hfsc 1:212 parent 1:21 sc m1 0bit d 0us m2 3000Kbit ul m1 0bit d 0us m2 8000Kbit 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 period 0 level 0 

class hfsc 1:211 parent 1:21 sc m1 0bit d 0us m2 3000Kbit ul m1 0bit d 0us m2 8000Kbit 
 Sent 6583839 bytes 5738 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 2p requeues 0 
 period 3274 work 6580811 bytes rtwork 3542314 bytes level 0 

class hfsc 1:30 parent 1: sc m1 10000Kbit d 1.0s m2 1000Kbit ul m1 0bit d 0us m2 1000Kbit 
 Sent 7570 bytes 5 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 period 4 work 7570 bytes rtwork 7570 bytes level 0 

class hfsc 1:21 parent 1: sc m1 0bit d 0us m2 8000Kbit 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 period 3274 work 6580811 bytes level 1
Also I'm seeing in Wireshark there are ACK packets passing trough me.
What could I be doing wrong?
 
Old 02-10-2009, 01:29 PM   #2
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Original Poster
Rep: Reputation: 32
What happens when I put several 'match' lines in a single filter? Is it a logical AND of the results of the different matches? Also, is there a place where all matches are described and documented?
Is there an obvious reason why the following filter is not working:
Code:
tc filter add dev eth0 protocol ip parent 1: u32 match ip protocol 6 0xff \
match ip dst 192.168.0.34 \
match u8 0x05 0x0f at 0 \
match u16 0x0000 0xffc0 at 2 \
match u8 0x10 0xff at 33 \
classid 1:202
Or this:
Code:
tc filter add dev eth0 protocol ip parent 1: u32 \
match ip tos 0x50 0xff \
match ip dst 192.168.0.34/32 \
classid 1:202
Assuming there is a class with ID 202 in the qdisc of the proper device.

Last edited by ivanatora; 02-10-2009 at 01:36 PM.
 
Old 02-10-2009, 03:11 PM   #3
bzyk
Member
 
Registered: Jun 2007
Location: Poland
Distribution: Debian, Slackware
Posts: 42

Rep: Reputation: 15
Hi.

This one works for me (very fine, on several machines, more than a couple of years);

# ACK < 64bit
$tc filter add dev $EXTIF protocol ip parent 1:0 prio 1 u32 match ip protocol 6 0xff match u8
0x05 0x0f at 0 match u16 0x0000 0xffc0 at 2 match u8 0x10 0xff at 33 flowid 1:15

Please notice, that this work for ACK smaller than 64bit.
 
Old 02-10-2009, 03:27 PM   #4
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Original Poster
Rep: Reputation: 32
And what would you add to that rule if you wish to capture ACKs traveling from/to certain IP?
 
Old 02-10-2009, 03:44 PM   #5
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Original Poster
Rep: Reputation: 32
Ok, I found what is wrong - the rule insertion order. Ofcourse once the packet matches a rule it doesn't check for any rules after that. Untill now I assumed every new TC rule is appended at the end of the existing ones. And I had:
Code:
1) match ack packets to $host
2) match any other packets to $host
That order should ensure the ACK packets are matched first, and if the packet is not ACK it should fall into the second rule.
Well, it is exactly the opposite state! Every new TC rule is _inserted_ at the beginning of the rules. In that way my logic is totally busted: packets are first matched against the rule 2) and if they match the rule 1) doesn't get the chance at all.
The order of the inserted rules can be view with:
Code:
tc filter show dev eth0
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tcpdump and snort cannot filter PPPoE packets kaito Linux - Networking 8 08-16-2009 03:25 AM
Mangled incoming TCP packets confuse outgoing ACK processing Bloomberger Linux - Networking 0 08-10-2006 01:50 PM
Disntiguishing between ACK packets in a TCP connection!! vishamr2000 Linux - Networking 3 05-23-2006 01:08 AM
searching for a WLAN card which is able to capture ACK and other management packets! lackyg Linux - Wireless Networking 1 02-03-2006 09:34 PM
Forwarding ACK Packets snufferz Linux - Newbie 0 05-12-2004 02:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration