Bug 24832 - SO_NO_CHECK only affects the first fragment of an UDP packet
Summary: SO_NO_CHECK only affects the first fragment of an UDP packet
Status: RESOLVED CODE_FIX
Alias: None
Product: Networking
Classification: Unclassified
Component: IPV4 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-13 12:10 UTC by Timo Lindfors
Modified: 2012-08-14 14:40 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.32
Subsystem:
Regression: No
Bisected commit-id:


Attachments
test program to reproduce the issue (7.23 KB, text/x-csrc)
2010-12-13 12:10 UTC, Timo Lindfors
Details
this patch works for me but somebody else should verify it (874 bytes, patch)
2010-12-13 12:47 UTC, Timo Lindfors
Details | Diff

Description Timo Lindfors 2010-12-13 12:10:24 UTC
Created attachment 39992 [details]
test program to reproduce the issue

Steps to reproduce:
1) dd if=/dev/zero of=source.img bs=1M count=1
2) make sure 10.99.0.1 can receive udp packets on port 1234 (e.g. run netcat -lp1234 -u > /dev/zero there)
2) gcc -g -O2 -Wall -o sendfileudp_test sendfileudp_test.c
3) perf record -g -- ./sendfileudp_test -fsource.img -l10737418240 10.99.0.1 1234 -s60000 -msend-sendfile -g
4) perf report -g

Expected results:
4) since the SO_NO_CHECK option is used the kernel does not calculate checksums for the UDP payload

Actual results:
4) A lot of time is spent calculating checksums:

46.81%  sendfileudp_tes  [kernel]                   [k] csum_partial

 5.30%  sendfileudp_tes  [kernel]                   [k] _spin_lock
            |          
                       |          
                       |--99.95%-- sendfile64
                        --0.05%-- [...]

 4.61%  sendfileudp_tes  [kernel]                   [k] ip_append_page

 3.68%  sendfileudp_tes  [kernel]                   [k] ip_fragment

 2.04%  sendfileudp_tes  [kernel]                   [k] _local_bh_enable_ip

 1.84%  sendfileudp_tes  [kernel]                   [k] ip_finish_output2


More info:
1) If I use packets that are smaller than my MTU (9000) the kernel does not calculate checksums. It seems that SO_NO_CHECK works if no fragmentation occurs:

$ perf record -g -- ./sendfileudp_test -fsource.img -l10737418240 10.99.0.1 1234 -s8192 -msend-sendfile -g
$ perf report -g

6.93%  sendfileudp_tes  [kernel]                   [k] _spin_lock

5.25%  sendfileudp_tes  [kernel]                   [k] ip_append_page

3.21%  sendfileudp_tes  [kernel]                   [k] _spin_lock_bh
           |          
           |--99.95%-- sendfile64
            --0.05%-- [...]

3.16%  sendfileudp_tes  [kernel]                   [k] _local_bh_enable_ip

2.97%  sendfileudp_tes  [kernel]                   [k] ip_finish_output2
Comment 1 Timo Lindfors 2010-12-13 12:47:39 UTC
Created attachment 40002 [details]
this patch works for me but somebody else should verify it
Comment 2 Andrew Morton 2010-12-13 23:45:43 UTC
Please don't send patches via bugzilla - it causes lots of problems with
our usual patch management and review processes.

Please send this patch via email as per Documentation/SubmittingPatches. 
Suitable recipients may be found via scripts/get_maintainer.pl.  netdev@vger.kernel.org will suffice.

Thanks.
Comment 3 Timo Lindfors 2010-12-14 10:47:16 UTC
Sure. It's now at

http://marc.info/?l=linux-netdev&m=129232307330696&w=2

with Message-Id: <1292313093-11973-1-git-send-email-timo.lindfors@iki.fi>
Comment 4 Timo Lindfors 2012-08-14 14:40:08 UTC
Alan, if you think that the bug has been resolved can you please point me to the commit that fixes it? To my best understanding the issue still exists.

Note You need to log in before you can comment on or make changes to this bug.