星期一 七月 31, 2006

Diag. ICMP checksum error in kernel with Dtrace

This topic talks about how to locate a kernel checksum error problem.



The problem is interesting: when enable jumbo frame to 16K Bytes, test
pairs could not ping each other with specified ping payload size(2006
Bytes in this case) on x64 platforms.



While checking netstat infor on remote side, there is "icmpInCksumErrs"
increasing with the incoming ICMP echo request. The checksum error are
from either sending or receiving side then.



Sending side calculates ICMP checksum in application. In ping.c, line 1940 - 1946

   1940 	if (family == AF_INET) {
1941 if (!use_udp)
1942 icp->icmp_cksum = in_cksum((ushort_t *)icp, cc);
1943
1944 i = sendto(send_sock, (char *)out_pkt, cc, 0, whereto,
1945 sizeof (struct sockaddr_in));
1946 }

Ethereal sniffering results shows the ICMP checksum sent by application
is correct. So the problem must be the ICMP checksum func in kernel
caused the problem.



How could we prove this? We could start by checking input IP packet contents, using below D-script:



ip_input:entry

{

        /*extern void ip_input(ill_t *, ill_rx_ring_t *, mblk_t *, size_t);

          get the mblk of input packet */

        self->ip_mp = (mblk_t *)(arg2);

        /* make self->iph point to the data header, IP header here */

        self->iph = (ipha_t *)(self->ip_mp->b_rptr);

        /* We only interest in ICMP packets here, so we need protocol */

        self->protocol = self->iph->ipha_protocol;

}

ip_cksum:entry

/self->protocol == 1/ /* ICMP only */

{

    stack(); /* just curious, no need here */

}

ip_cksum:return

{

    printf("0x%x\n", arg1); /* get the ip_cksum return value*/

}





Note, in icmp_inbound, there are two places where ICMP checksum are calculated(ip.c):



first is the LINE 1741 - 1747, which validates incoming ICMP checksum. The return value should be 0.



   1741 	/* ICMP header checksum, including checksum field, should be zero. */
1742 if (sum_valid ? (sum != 0 && sum != 0xFFFF) :
1743 IP_CSUM(mp, iph_hdr_length, 0)) {
1744 BUMP_MIB(&icmp_mib, icmpInCksumErrs);
1745 freemsg(first_mp);
1746 return;
1747 }



second is LINE 2013 - 2017, which calculates outgoing ICMP packet and should be the right ICMP checksum.

   2013 	/* Send out an ICMP packet */
2014 icmph->icmph_checksum = 0;
2015 icmph->icmph_checksum = IP_CSUM(mp, iph_hdr_length, 0);
2016 if (icmph->icmph_checksum == 0)
2017 icmph->icmph_checksum = 0xFFFF;



Let's run above D-script on a normal system, with background ping traffic, the output is below:



# dtrace -s icmp.d

dtrace: script 'icmp.d' matched 5 probes

CPU    
ID                   
FUNCTION:NAME

  0 
25208                  
ip_cksum:entry

              ip`icmp_inbound+0x120

              ip`ip_proto_input+0xa62

              ip`ip_input+0x619

              dls`i_dls_link_rx_promisc+0x213

              mac`mac_rx+0x53

              e1000g`e1000g_intr+0xc4

              unix`intr_thread+0x136



  0 
25209                 
ip_cksum:return return: 0xffff   <--- Incoming
ICMP~(0xffff) == 0, correct



  0 
25208                  
ip_cksum:entry

              ip`icmp_inbound+0x5e3

              ip`ip_proto_input+0xa62

              ip`ip_input+0x619

              dls`i_dls_link_rx_promisc+0x213

              mac`mac_rx+0x53

              e1000g`e1000g_intr+0xc4

              unix`intr_thread+0x136



  0 
25209                 
ip_cksum:return return: 0xce97  <--- Outgoing ICMP, not zero



Comparing with what we see in the bugy system:

bash-3.00# dtrace -s icmp.d

dtrace: script 'icmp.d' matched 5 probes

CPU    
ID                   
FUNCTION:NAME

  1 
23017                  
ip_cksum:entry



              ip`icmp_inbound+0x24a

              ip`ip_proto_input+0x479

              ip`ip_input+0x4ab

              dls`i_dls_link_rx+0x18c

              mac`mac_rx+0x45

              e1000g`e1000g_intr_work+0x176

              e1000g`e1000g_intr+0x3c

              unix`av_dispatch_autovect+0x78

              unix`intr_thread+0x50



  1 
23018                 
ip_cksum:return return: 0x417d   <--- should be 0xffff



...



  1 
23017                  
ip_cksum:entry

              ip`icmp_inbound+0x24a

              ip`ip_proto_input+0x479

              ip`ip_input+0x4ab

              dls`i_dls_link_rx+0x18c

              mac`mac_rx+0x45

              e1000g`e1000g_intr_work+0x176

              e1000g`e1000g_intr+0x3c

              unix`av_dispatch_autovect+0x78

              unix`intr_thread+0x50



  1 
23018                 
ip_cksum:return return: 0x60e9 <--- should be 0xffff



ip_cksum validates wrong checksum when dealing with incoming ICMP
packets. Since ip_ocsum will be called by ip_cksum when checking IP
protocol checksum, we could take a close look into ip_ocsum and learn
why this problem could happen.



ip_ocsum in Solaris are platform dependent. For example, SPARC has ip_ocsum.s while x86 has i86_subr.s.



This counts for why we see different symbols on various platforms. On SPARC, the ping problem happens with another payload size.



See following articles on the checksum code.

评论:

Something seems to go wrong in your html around: 1942 icp>icmp_cksum = in_cksum((ushort_t )icp, cc); all text from there is crossed out

发表于 Mads Toftum 在 2006年07月31日, 07:45 下午 CST #

I understand it .Thank you .

发表于 wow powerleveling 在 2008年08月04日, 05:44 下午 CST #

<A href="http://www.vipaocgold.com/" target=_blank><FONT size=4>aoc gold</FONT></A><FONT size=4>&nbsp; &nbsp;</FONT><A href="http://www.vipaocgold.com/buy-aoc-gold/" target=_blank><FONT size=4>buy aoc gold</FONT></A><FONT size=4>&nbsp;&nbsp;</FONT><A href="http://www.vipaocgold.com/aoc-news/" target=_blank><FONT size=4>cheap aoc gold</FONT></A><BR><A href="http://www.aocsale.com/" target=_blank><FONT size=4>age of conan gold</FONT></A><FONT size=4>&nbsp; &nbsp;</FONT><A href="http://www.aocsale.com/buy-aoc-gold/" target=_blank><FONT size=4>buy age of conan gold</FONT></A><FONT size=4>&nbsp; &nbsp;</FONT><A href="http://www.aocsale.com/aoc-news/" target=_blank><FONT size=4>cheap age of conan gold</FONT></A><BR><FONT size=4><A href="http://www.cheaperzone.com/" target=_blank><FONT size=4>warhammer gold</FONT></A>&nbsp; &nbsp;<A href="http://www.cheaperzone.com/Buy-WOW-Gold/WOW-Gold.Html" target=_blank>buy warhammer gold</A>&nbsp; &nbsp;<A href="http://www.cheaperzone.com/News/News.Html" target=_blank>cheap warhammer gold</A></FONT><BR><FONT size=4><A href="http://www.vipwarhammergold.com/" target=_blank><FONT size=4>warhammer gold</FONT></A>&nbsp; &nbsp;<A href="http://www.vipwarhammergold.com/" target=_blank>buy warhammer gold</A>&nbsp; &nbsp;<A href="http://www.vipwarhammergold.com/" target=_blank>cheap warhammer gold</A></FONT><BR><FONT size=4><A href="http://www.vipwargold.com/" target=_blank><FONT size=4>warhammer gold</FONT></A>&nbsp; &nbsp;<A href="http://www.vipwargold.com/" target=_blank>buy warhammer gold</A>&nbsp; &nbsp;<A href="http://www.vipwargold.com/" target=_blank>cheap warhammer gold</A></FONT><BR><FONT size=4><A href="http://www.buyfastgold.com/" target=_blank><FONT size=4>warhammer gold</FONT></A>&nbsp; &nbsp;<A href="http://www.buyfastgold.com/buy-warhammer-gold/" target=_blank>buy warhammer gold</A>&nbsp; &nbsp;<A href="http://www.buyfastgold.com/news/" target=_blank>cheap warhammer gold</A></FONT><BR><FONT size=4><A href="http://warhammer-gold.rgtrcredit.com/" target=_blank><FONT size=4>warhammer gold</FONT></A>&nbsp; &nbsp;<A href="http://warhammer-gold.rgtrcredit.com/Buy-warhammer-gold.html" target=_blank>buy warhammer gold</A>&nbsp; &nbsp;<A href="http://warhammer-gold.rgtrcredit.com/Warhammer-Gold.html" target=_blank>cheap warhammer gold</A></FONT><BR><FONT size=4><A href="http://warhammer.hellgate-pd.com/" target=_blank><FONT size=4>warhammer gold</FONT></A>&nbsp; &nbsp;<A href="http://warhammer.hellgate-pd.com/buy-warhammer-gold.html" target=_blank>buy warhammer gold</A>&nbsp; &nbsp;<A href="http://warhammer.hellgate-pd.com/cheap-warhammer-gold.html" target=_blank>cheap warhammer gold</A></FONT>

发表于 warhammer gold 在 2008年08月23日, 11:58 上午 CST #

we are a group of dedicated players who have come together to provide a service for the community so that you, our fellow player,We offer <A href="http://www.storeingame.com">wow gold</A> and <A href="http://www.storeingame.com/aoc-gold.htm">aoc gold</A>,our website is <A href="http://www.storeingame.com/wow-gold.htm">wow gold</A> Professional offered,please buy <A href="http://www.2joygame.com">lotro gold</A> in www.storeingame.com.
<A href="http://www.wzyizhou.com/jizhuangdai.htm">集装袋</A>

发表于 lvbugai 在 2008年09月04日, 08:55 上午 CST #

I support author's viewpoint, hoped that will have later also more better articles,
[url=http://c]gucci shoes[/url]
will read the first time, thank!

发表于 ptsell 在 2008年10月09日, 01:04 下午 CST #

Would like to witness the overwhelming Azshara fighting in the capital of boiling? Mmoinn for you, providing a lot of <a href="http://www.mmoinn.com"> wow money </a>, so that you can lean more to buy the equipment. So that you can pass through an eternal spring, came to the ruins of the World. You can also find <a href="http://www.mmoinn.com"> World of warcraft Gold </a> in the <a href="http://www.mmoinn.com/mmoinn_pl/"> wow power leveling </a>. As soon as possible to your adventure!w

发表于 wowgolds987 在 2008年10月26日, 03:20 下午 CST #

[url=http://www.zhongke-china.com]paper box making lines[/url]
[url=http://www.66773388.com]nike shoes[/url]
[url=http://www.66773388.com]jordan shoes[/url]
[url=http://www.66773388.com]prada shoes[/url]
[url=http://www.66773388.com]Gucci shoes[/url]
[url=http://www.66773388.com/xw_159.htm]true religion jeans [/url]

发表于 nike shoes 在 2008年10月29日, 02:28 下午 CST #

<a href=http://www.jerseysnfl.org/>jerseysnfl</a>
<a href=http://www.jerseysnfl.org/>nfl jerseys</a>
<a href=http://www.jerseysnfl.org/>official nfl jerseys</a>

发表于 jerseys 在 2009年10月28日, 03:48 下午 CST #

[url=http://www.shoppingbags1.com/louis-vuitton-c-6.html]Replica Louis Vuitton handbags[/url]
[url=http://www.shoppingbags1.com/gucci-c-40.html]Replica gucci handbags[/url]
[url=http://www.shoppingbags1.com/chanel-c-123.html]Replica chanel handbags[/url]
[url=http://www.shoppingbags1.com/hermes-c-112.html]Replica hermes handbags[/url]

[url=http://www.replicabags1.com/louis-vuitton-c-65.html]fake Louis Vuitton handbags[/url]
[url=http://www.replicabags1.com/gucci-c-101.html]fake gucci handbags[/url]
[url=http://www.replicabags1.com/chanel-c-100.html]fake chanel handbags[/url]
[url=http://www.replicabags1.com/hermes-c-102.html]fake hermes handbags[/url]

[url=http://www.cheap-replicahandbags.com/louis-vuitton-handbags-c-65.html]designer Louis Vuitton handbags[/url]
[url=http://www.cheap-replicahandbags.com/gucci-c-101.html]designer gucci handbags[/url]
[url=http://www.cheap-replicahandbags.com/chanel-c-100.html]designer chanel handbags[/url]
[url=http://www.cheap-replicahandbags.com/hermes-c-102.html]designer hermes handbags[/url]

[url=http://www.replicahandbags365.com/louis-vuitton-c-6.html]knockoff louis vuitton handbags[/url]
[url=http://www.replicahandbags365.com/gucci-c-40.html]knockoff gucci handbags[/url]
[url=http://www.replicahandbags365.com/chanel-c-123.html]knockoff chanel handbags[/url]
[url=http://www.replicahandbags365.com/hermes-c-112.html]knockoff hermes handbags[/url]

[url=http://www.i-replicahandbags.com/louis-vuitton-handbags-c-6.html]cheap louis vuitton handbags[/url]
[url=http://www.i-replicahandbags.com/gucci-handbags-c-40.html]cheap gucci handbags[/url]
[url=http://www.i-replicahandbags.com/chanel-c-123.html]cheap chanel handbags[/url]
[url=http://www.i-replicahandbags.com/hermes-birkin-handbags-c-112.html]cheap hermes handbags[/url]

[url=http://www.replicahandbags99.com/louis-vuitton-handbags-c-65.html]discount louis vuitton handbags[/url]
[url=http://www.replicahandbags99.com/gucci-handbags-c-101.html]discount gucci handbags[/url]
[url=http://www.replicahandbags99.com/chanel-handbags-c-100.html]discount chanel handbags[/url]
[url=http://www.replicahandbags99.com/hermes-handbags-c-102.html]discount Hermes Birkin handbags[/url]

[url=http://www.handbags-louisvuitton.com/louis-vuitton-c-6.html]louis vuitton outlet[/url]
[url=http://www.handbags-louisvuitton.com/gucci-c-40.html]gucci outlet[/url]
[url=http://www.handbags-louisvuitton.com/chanel-c-123.html]chanel outlet[/url]
[url=http://www.handbags-louisvuitton.com/hermes-c-112.html]Hermes birkin outlet[/url]

发表于 replica handbags 在 2009年11月06日, 11:03 下午 CST #

发表一条评论:
  • HTML语法: 禁用