Subject: Re: tcpdump "optimizer"
To: None <tech-net@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 07/26/2000 09:54:53
I believe tcpdump optimizer is not really perfect.
simpler example: it can optimize "ip and tcp", but not "tcp and ip",
somehow.
itojun
--- optimized
# tcpdump -i ep1 -d 'tcp'
(000) ldh [12]
(001) jeq #0x86dd jt 2 jf 4
(002) ldb [20]
(003) jeq #0x6 jt 7 jf 8
(004) jeq #0x800 jt 5 jf 8
(005) ldb [23]
(006) jeq #0x6 jt 7 jf 8
(007) ret #96
(008) ret #0
# tcpdump -i ep1 -d 'tcp and ip'
(000) ldh [12]
(001) jeq #0x86dd jt 6 jf 2 <--- this can be removed
(002) jeq #0x800 jt 3 jf 6
(003) ldb [23]
(004) jeq #0x6 jt 5 jf 6
(005) ret #96
(006) ret #0
# tcpdump -i ep1 -d 'ip and tcp'
(000) ldh [12]
(001) jeq #0x800 jt 2 jf 5
(002) ldb [23]
(003) jeq #0x6 jt 4 jf 5
(004) ret #96
(005) ret #0
--- non-optimized
# tcpdump -i ep1 -dO 'tcp'
(000) ldh [12]
(001) jeq #0x86dd jt 2 jf 4
(002) ldb [20]
(003) jeq #0x6 jt 8 jf 4
(004) ldh [12]
(005) jeq #0x800 jt 6 jf 9
(006) ldb [23]
(007) jeq #0x6 jt 8 jf 9
(008) ret #96
(009) ret #0
# tcpdump -i ep1 -dO 'tcp and ip'
(000) ldh [12]
(001) jeq #0x86dd jt 2 jf 4
(002) ldb [20]
(003) jeq #0x6 jt 8 jf 4
(004) ldh [12]
(005) jeq #0x800 jt 6 jf 11
(006) ldb [23]
(007) jeq #0x6 jt 8 jf 11
(008) ldh [12]
(009) jeq #0x800 jt 10 jf 11
(010) ret #96
(011) ret #0
# tcpdump -i ep1 -dO 'ip and tcp'
(000) ldh [12]
(001) jeq #0x800 jt 2 jf 11
(002) ldh [12]
(003) jeq #0x86dd jt 4 jf 6
(004) ldb [20]
(005) jeq #0x6 jt 10 jf 6
(006) ldh [12]
(007) jeq #0x800 jt 8 jf 11
(008) ldb [23]
(009) jeq #0x6 jt 10 jf 11
(010) ret #96
(011) ret #0