[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#623059: Data corruption when sendfile is used on atl1c Atheros NIC.



Package: linux-2.6
Version: 2.6.32-33
Severity: grave
File: /lib/modules/2.6.32-5-686-bigmem/kernel/drivers/net/atl1c/atl1c.ko

Hello,
As far as I can tell it there is the bug occuring when combination of
sendfile(2) and module atl1c is used. The result of the bug is data
corruption. Examples of data corruption are in attached files:
 - orig.txt - the original file, output of command
              seq 1 600 | xargs printf '%04d\n'
 - apache.dat - result of wget http://the.server/orig.txt -O apache.dat
 - sendfile.dat - file sent from the same server using attached program
                  and netcat

The mentioned server has a multiple interfaces and this problem appears
only on Atheros interface. After spotting the problem on Apache first
I finally nailed it to sendfile function. The problem appears only for files
longer than some specific value. For Apache it was 2600 bytes (I suppose it's
because of headers added by webserver). For my test program the minimal size
of file where the problem appears is 2896 bytes.

I also found a similar problem on Ubuntu:
https://bugs.launchpad.net/ubuntu/+source/slide-webdavclient/+bug/651004
The common factor is Atheros AR8131.

Best regards
	Artur

-- Package-specific info:
** Version:
Linux version 2.6.32-5-686-bigmem (Debian 2.6.32-33) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Apr 4 22:36:24 UTC 2011

** Command line:
BOOT_IMAGE=/vmlinuz-2.6.32-5-686-bigmem root=UUID=88e830fa-51a6-4d5f-bac5-26e00210b525 ro quiet

** Not tainted

** Kernel log:
[    1.109796] uhci_hcd 0000:00:1d.3: UHCI Host Controller
[    1.109803] uhci_hcd 0000:00:1d.3: new USB bus registered, assigned bus number 5
[    1.109828] uhci_hcd 0000:00:1d.3: irq 16, io base 0x0000fb00
[    1.109850] usb usb5: New USB device found, idVendor=1d6b, idProduct=0001
[    1.109853] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.109855] usb usb5: Product: UHCI Host Controller
[    1.109856] usb usb5: Manufacturer: Linux 2.6.32-5-686-bigmem uhci_hcd
[    1.109858] usb usb5: SerialNumber: 0000:00:1d.3
[    1.109903] usb usb5: configuration #1 chosen from 1 choice
[    1.109924] hub 5-0:1.0: USB hub found
[    1.109929] hub 5-0:1.0: 2 ports detected
[    1.110627] libata version 3.00 loaded.
[    1.112917] ata_piix 0000:00:1f.2: version 2.13
[    1.112934] ata_piix 0000:00:1f.2: PCI INT B -> GSI 19 (level, low) -> IRQ 19
[    1.112938] ata_piix 0000:00:1f.2: MAP [ P0 P2 IDE IDE ]
[    1.112973] ata_piix 0000:00:1f.2: setting latency timer to 64
[    1.113039] scsi0 : ata_piix
[    1.113148] scsi1 : ata_piix
[    1.113687] ata1: SATA max UDMA/133 cmd 0x1f0 ctl 0x3f6 bmdma 0xf800 irq 14
[    1.113689] ata2: PATA max UDMA/100 cmd 0x170 ctl 0x376 bmdma 0xf808 irq 15
[    1.172748] atl1c 0000:02:00.0: version 1.0.0.2-NAPI
[    1.279888] ata1.00: HPA detected: current 976771055, native 976773168
[    1.279894] ata1.00: ATA-8: WDC WD5002AALX-00J37A0, 15.01H15, max UDMA/133
[    1.279897] ata1.00: 976771055 sectors, multi 16: LBA48 NCQ (depth 0/32)
[    1.292662] ata1.00: configured for UDMA/133
[    1.292765] scsi 0:0:0:0: Direct-Access     ATA      WDC WD5002AALX-0 15.0 PQ: 0 ANSI: 5
[    1.298826] sd 0:0:0:0: [sda] 976771055 512-byte logical blocks: (500 GB/465 GiB)
[    1.298887] sd 0:0:0:0: [sda] Write Protect is off
[    1.298890] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.298912] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.299039]  sda: sda1 sda2 sda3 sda4
[    1.317839] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.570230] device-mapper: uevent: version 1.0.3
[    1.570459] device-mapper: ioctl: 4.15.0-ioctl (2009-04-01) initialised: dm-devel@redhat.com
[    1.592994] kjournald starting.  Commit interval 5 seconds
[    1.592998] EXT3-fs: mounted filesystem with ordered data mode.
[    2.002170] udev[405]: starting version 164
[    2.082367] ACPI: SSDT 7f5ed720 0022A (v01  PmRef  Cpu0Ist 00003000 INTL 20040311)
[    2.082589] processor LNXCPU:00: registered as cooling_device0
[    2.082764] ACPI: SSDT 7f5edbe0 00152 (v01  PmRef  Cpu1Ist 00003000 INTL 20040311)
[    2.082964] processor LNXCPU:01: registered as cooling_device1
[    2.083163] ACPI: SSDT 7f5edd40 00152 (v01  PmRef  Cpu2Ist 00003000 INTL 20040311)
[    2.083407] processor LNXCPU:02: registered as cooling_device2
[    2.083716] ACPI: SSDT 7f5edea0 00152 (v01  PmRef  Cpu3Ist 00003000 INTL 20040311)
[    2.083981] processor LNXCPU:03: registered as cooling_device3
[    2.113596] input: PC Speaker as /devices/platform/pcspkr/input/input1
[    2.149526] udev[430]: renamed network interface eth2 to eth2-eth0
[    2.184981] input: Power Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input2
[    2.185019] ACPI: Power Button [PWRB]
[    2.185079] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input3
[    2.185099] ACPI: Power Button [PWRF]
[    2.186831] udev[418]: renamed network interface eth1 to eth2
[    2.189064] udev[413]: renamed network interface eth0 to eth1
[    2.200237] udev[430]: renamed network interface eth2-eth0 to eth0
[    2.254195] Error: Driver 'pcspkr' is already registered, aborting...
[    2.324469] intel_rng: FWH not detected
[    2.326809] HDA Intel 0000:00:1b.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
[    2.326831] HDA Intel 0000:00:1b.0: setting latency timer to 64
[    2.363089] [drm] Initialized drm 1.1.0 20060810
[    2.487388] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/input/input4
[    2.489806] parport_pc 00:08: reported by Plug and Play ACPI
[    2.489865] parport0: PC-style at 0x378 (0x778), irq 7 [PCSPP,TRISTATE]
[    2.490152] i801_smbus 0000:00:1f.3: PCI INT B -> GSI 19 (level, low) -> IRQ 19
[    2.519740] pci 0000:00:02.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
[    2.519744] pci 0000:00:02.0: setting latency timer to 64
[    2.524472] pci 0000:00:02.0: irq 26 for MSI/MSI-X
[    2.524524] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0
[    2.896081] Adding 3906548k swap on /dev/sda3.  Priority:-1 extents:1 across:3906548k 
[    3.008745] EXT3 FS on sda2, internal journal
[    3.760283] kjournald starting.  Commit interval 5 seconds
[    3.760484] EXT3 FS on sda1, internal journal
[    3.760488] EXT3-fs: mounted filesystem with ordered data mode.
[    3.804446] SGI XFS with ACLs, security attributes, realtime, large block/inode numbers, no debug enabled
[    3.805627] SGI XFS Quota Management subsystem
[    3.852739] XFS mounting filesystem dm-0
[    4.201137] Ending clean XFS mount for filesystem: dm-0
[    4.238906] XFS mounting filesystem dm-1
[    4.586343] Ending clean XFS mount for filesystem: dm-1
[    4.625152] XFS mounting filesystem dm-2
[    5.014185] Ending clean XFS mount for filesystem: dm-2
[    5.069654] XFS mounting filesystem dm-3
[    5.167090] Ending clean XFS mount for filesystem: dm-3
[    5.200389] XFS mounting filesystem dm-4
[    5.586592] Ending clean XFS mount for filesystem: dm-4
[    5.643924] XFS mounting filesystem dm-5
[    5.767336] Ending clean XFS mount for filesystem: dm-5
[    6.468485] atl1c 0000:02:00.0: irq 27 for MSI/MSI-X
[    6.468580] atl1c 0000:02:00.0: atl1c: eth0 NIC Link is Up<100 Mbps Full Duplex>
[    6.516923] eth1: link up, 100Mbps, full-duplex, lpa 0x45E1
[    6.536775] eth2: link up, 100Mbps, full-duplex, lpa 0x45E1
[    6.640195] nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
[    6.640404] CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Please use
[    6.640406] nf_conntrack.acct=1 kernel parameter, acct=1 nf_conntrack module option or
[    6.640407] sysctl net.netfilter.nf_conntrack_acct=1 to enable it.
[    6.707746] ip_tables: (C) 2000-2006 Netfilter Core Team
[    9.604141] tun: Universal TUN/TAP device driver, 1.6
[    9.604144] tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
[   16.617059] eth0: no IPv6 routers present
[   16.634816] eth2: no IPv6 routers present
[   17.221507] eth1: no IPv6 routers present

** Model information
not available

** Loaded modules:
Module                  Size  Used by
tun                     8772  2 
ipt_REJECT              1517  1 
xt_tcpudp               1743  19 
iptable_mangle          2325  0 
iptable_nat             3551  1 
iptable_filter          1790  1 
ip_tables               7706  3 iptable_mangle,iptable_nat,iptable_filter
x_tables                8327  4 ipt_REJECT,xt_tcpudp,iptable_nat,ip_tables
nf_nat_ftp              1519  0 
nf_nat                 10568  2 iptable_nat,nf_nat_ftp
nf_conntrack_ipv4       7597  3 iptable_nat,nf_nat
nf_defrag_ipv4           779  1 nf_conntrack_ipv4
nf_conntrack_ftp        4272  1 nf_nat_ftp
nf_conntrack           38083  5 iptable_nat,nf_nat_ftp,nf_nat,nf_conntrack_ipv4,nf_conntrack_ftp
xfs                   415435  6 
exportfs                2618  1 xfs
i915                  223214  0 
parport_pc             15871  0 
snd_hda_codec_realtek   163294  1 
drm_kms_helper         18309  1 i915
parport                22554  1 parport_pc
drm                   112720  2 i915,drm_kms_helper
i2c_i801                6466  0 
i2c_algo_bit            3497  1 i915
snd_hda_intel          16907  0 
i2c_core               12787  5 i915,drm_kms_helper,drm,i2c_i801,i2c_algo_bit
rng_core                2178  0 
snd_hda_codec          46002  2 snd_hda_codec_realtek,snd_hda_intel
snd_hwdep               4054  1 snd_hda_codec
snd_pcm                47386  2 snd_hda_intel,snd_hda_codec
video                  14605  1 i915
output                  1204  1 video
snd_timer              12258  1 snd_pcm
button                  3598  1 i915
evdev                   5609  0 
snd                    34375  6 snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
soundcore               3450  1 snd
snd_page_alloc          5113  2 snd_hda_intel,snd_pcm
pcspkr                  1207  0 
processor              26335  0 
ext3                   94320  2 
jbd                    32169  1 ext3
mbcache                 3762  1 ext3
dm_mod                 46046  18 
sd_mod                 26005  5 
crc_t10dif              1012  1 sd_mod
ata_generic             2067  0 
ata_piix               17784  4 
libata                116065  2 ata_generic,ata_piix
uhci_hcd               16141  0 
8139too                15109  0 
8139cp                 13622  0 
mii                     2714  2 8139too,8139cp
ehci_hcd               29053  0 
atl1c                  24244  0 
scsi_mod              104857  2 sd_mod,libata
usbcore                99081  3 uhci_hcd,ehci_hcd
nls_base                4541  1 usbcore
thermal                 9206  0 
thermal_sys             9378  3 video,processor,thermal

** Network interface configuration:

auto lo
iface lo inet loopback

auto eth0 eth1 eth2

iface eth0 inet static
        address 46.
        netmask 255.255.255.248
        network 46.
        broadcast 46.
        gateway 46.

iface eth1 inet static
	address 192.168.2.1
	netmask 255.255.255.0
	network 192.168.2.0
	broadcast 192.168.2.255

iface eth2 inet static
	address 192.168.3.1
	netmask 255.255.255.0
	network 192.168.3.0
	broadcast 192.168.3.255


** Network status:
*** IP interfaces and addresses:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:1f:1f:90:52:2e brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.1/24 brd 192.168.2.255 scope global eth1
    inet6 fe80::21f:1fff:fe90:522e/64 scope link 
       valid_lft forever preferred_lft forever
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0a:cd:08:a7:04 brd ff:ff:ff:ff:ff:ff
    inet 192.168.3.1/24 brd 192.168.3.255 scope global eth2
    inet6 fe80::20a:cdff:fe08:a704/64 scope link 
       valid_lft forever preferred_lft forever
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 6c:f0:49:cf:7f:51 brd ff:ff:ff:ff:ff:ff
    inet 46./29 brd 46. scope global eth0
    inet6 fe80::6ef0:49ff:fecf:7f51/64 scope link 
       valid_lft forever preferred_lft forever
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
    link/none 
    inet 10.8.0.1 peer 10.8.0.2/32 scope global tun0

*** Device statistics:
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:  908210    4052    0    0    0     0          0         0   908210    4052    0    0    0     0       0          0
  eth1: 2729245   27615    0    0    0     0          0         0 68898368   50329    0    0    0     0       0          0
  eth2:       0       0    0    0    0     0          0         0      468       6    0    0    0     0       0          0
  eth0:17916865   53042    0    0    0     0          0         0 65702302   61220    0    0    0     0       1          0
  tun0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

*** Protocol statistics:
Ip:
    84300 total packets received
    14200 forwarded
    0 incoming packets discarded
    70078 incoming packets delivered
    58802 requests sent out
    16 outgoing packets dropped
    30 reassemblies required
    15 packets reassembled ok
Icmp:
    360 ICMP messages received
    0 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 20
        echo requests: 340
    372 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 32
        echo replies: 340
IcmpMsg:
        InType3: 20
        InType8: 340
        OutType0: 340
        OutType3: 32
Tcp:
    251 active connections openings
    636 passive connection openings
    39 failed connection attempts
    78 connection resets received
    3 connections established
    65007 segments received
    37975 segments send out
    1861 segments retransmited
    7 bad segments received.
    91 resets sent
Udp:
    4698 packets received
    25 packets to unknown port received.
    0 packet receive errors
    4458 packets sent
UdpLite:
TcpExt:
    21 resets received for embryonic SYN_RECV sockets
    318 TCP sockets finished time wait in fast timer
    931 delayed acks sent
    Quick ack mode was activated 10 times
    1014 packets directly queued to recvmsg prequeue.
    99878 bytes directly received in process context from prequeue
    6745 packet headers predicted
    136 packets header predicted and directly queued to user
    20528 acknowledgments not containing data payload received
    35017 predicted acknowledgments
    40 times recovered from packet loss by selective acknowledgements
    3 congestion windows recovered without slow start by DSACK
    10 congestion windows recovered without slow start after partial ack
    5019 TCP data loss events
    TCPLostRetransmit: 3
    3 timeouts after SACK recovery
    1 timeouts in loss state
    1527 fast retransmits
    33 forward retransmits
    167 retransmits in slow start
    72 other TCP timeouts
    3 SACK retransmits failed
    11 DSACKs sent for old packets
    222 DSACKs received
    6 connections reset due to unexpected data
    51 connections reset due to early user close
    9 connections aborted due to timeout
    TCPDSACKIgnoredOld: 63
    TCPDSACKIgnoredNoUndo: 149
    TCPSackShifted: 5906
    TCPSackMerged: 5258
    TCPSackShiftFallback: 1216
IpExt:
    InBcastPkts: 52
    InOctets: 20403828
    OutOctets: 130885132
    InBcastOctets: 12246

*** Device features:
eth0: 0x110989
eth1: 0x829
eth2: 0x829
lo: 0x13865
tun0: 0x0

** PCI devices:
00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0] (rev 10)
	Subsystem: Giga-byte Technology Device [1458:5000]
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
	Latency: 0
	Capabilities: <access denied>
	Kernel driver in use: agpgart-intel

00:02.0 VGA compatible controller [0300]: Intel Corporation 82G33/G31 Express Integrated Graphics Controller [8086:29c2] (rev 10) (prog-if 00 [VGA controller])
	Subsystem: Giga-byte Technology Device [1458:d000]
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 26
	Region 0: Memory at fdf00000 (32-bit, non-prefetchable) [size=512K]
	Region 1: I/O ports at ff00 [size=8]
	Region 2: Memory at d0000000 (32-bit, prefetchable) [size=256M]
	Region 3: Memory at fdc00000 (32-bit, non-prefetchable) [size=1M]
	Expansion ROM at <unassigned> [disabled]
	Capabilities: <access denied>

00:1b.0 Audio device [0403]: Intel Corporation N10/ICH 7 Family High Definition Audio Controller [8086:27d8] (rev 01)
	Subsystem: Giga-byte Technology Device [1458:a002]
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 4 bytes
	Interrupt: pin A routed to IRQ 16
	Region 0: Memory at fdff8000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: <access denied>
	Kernel driver in use: HDA Intel

00:1c.0 PCI bridge [0604]: Intel Corporation N10/ICH 7 Family PCI Express Port 1 [8086:27d0] (rev 01) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 4 bytes
	Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
	I/O behind bridge: 0000c000-0000cfff
	Memory behind bridge: fd900000-fd9fffff
	Prefetchable memory behind bridge: 00000000fd800000-00000000fd8fffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: <access denied>
	Kernel driver in use: pcieport

00:1c.1 PCI bridge [0604]: Intel Corporation N10/ICH 7 Family PCI Express Port 2 [8086:27d2] (rev 01) (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 4 bytes
	Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
	I/O behind bridge: 0000b000-0000bfff
	Memory behind bridge: fde00000-fdefffff
	Prefetchable memory behind bridge: 00000000fdd00000-00000000fddfffff
	Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: <access denied>
	Kernel driver in use: pcieport

00:1d.0 USB Controller [0c03]: Intel Corporation N10/ICH 7 Family USB UHCI Controller #1 [8086:27c8] (rev 01) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology Device [1458:5004]
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 23
	Region 4: I/O ports at fe00 [size=32]
	Kernel driver in use: uhci_hcd

00:1d.1 USB Controller [0c03]: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2 [8086:27c9] (rev 01) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology Device [1458:5004]
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin B routed to IRQ 19
	Region 4: I/O ports at fd00 [size=32]
	Kernel driver in use: uhci_hcd

00:1d.2 USB Controller [0c03]: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3 [8086:27ca] (rev 01) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology Device [1458:5004]
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin C routed to IRQ 18
	Region 4: I/O ports at fc00 [size=32]
	Kernel driver in use: uhci_hcd

00:1d.3 USB Controller [0c03]: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 [8086:27cb] (rev 01) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology Device [1458:5004]
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin D routed to IRQ 16
	Region 4: I/O ports at fb00 [size=32]
	Kernel driver in use: uhci_hcd

00:1d.7 USB Controller [0c03]: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller [8086:27cc] (rev 01) (prog-if 20 [EHCI])
	Subsystem: Giga-byte Technology Device [1458:5006]
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 23
	Region 0: Memory at fdfff000 (32-bit, non-prefetchable) [size=1K]
	Capabilities: <access denied>
	Kernel driver in use: ehci_hcd

00:1e.0 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev e1) (prog-if 01 [Subtractive decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Bus: primary=00, secondary=03, subordinate=03, sec-latency=32
	I/O behind bridge: 0000d000-0000dfff
	Memory behind bridge: fdb00000-fdbfffff
	Prefetchable memory behind bridge: 00000000fda00000-00000000fdafffff
	Secondary status: 66MHz- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
	BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
		PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
	Capabilities: <access denied>

00:1f.0 ISA bridge [0601]: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge [8086:27b8] (rev 01)
	Subsystem: Giga-byte Technology Device [1458:5001]
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Capabilities: <access denied>

00:1f.2 IDE interface [0101]: Intel Corporation N10/ICH7 Family SATA IDE Controller [8086:27c0] (rev 01) (prog-if 80 [Master])
	Subsystem: Giga-byte Technology Device [1458:b002]
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx+
	Latency: 0
	Interrupt: pin B routed to IRQ 19
	Region 0: I/O ports at 01f0 [size=8]
	Region 1: I/O ports at 03f4 [size=1]
	Region 2: I/O ports at 0170 [size=8]
	Region 3: I/O ports at 0374 [size=1]
	Region 4: I/O ports at f800 [size=16]
	Capabilities: <access denied>
	Kernel driver in use: ata_piix

00:1f.3 SMBus [0c05]: Intel Corporation N10/ICH 7 Family SMBus Controller [8086:27da] (rev 01)
	Subsystem: Giga-byte Technology GA-8I945PG-RH Mainboard [1458:5001]
	Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Interrupt: pin B routed to IRQ 19
	Region 4: I/O ports at 0500 [size=32]
	Kernel driver in use: i801_smbus

02:00.0 Ethernet controller [0200]: Atheros Communications AR8131 Gigabit Ethernet [1969:1063] (rev c0)
	Subsystem: Giga-byte Technology GA-G31M-ES2L Motherboard [1458:e000]
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 4 bytes
	Interrupt: pin A routed to IRQ 27
	Region 0: Memory at fdec0000 (64-bit, non-prefetchable) [size=256K]
	Region 2: I/O ports at bf00 [size=128]
	Capabilities: <access denied>
	Kernel driver in use: atl1c

03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ [10ec:8139] (rev 10)
	Subsystem: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ [10ec:8139]
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 32 (8000ns min, 16000ns max)
	Interrupt: pin A routed to IRQ 20
	Region 0: I/O ports at de00 [size=256]
	Region 1: Memory at fdbff000 (32-bit, non-prefetchable) [size=256]
	Capabilities: <access denied>
	Kernel driver in use: 8139too

03:01.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ [10ec:8139] (rev 10)
	Subsystem: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ [10ec:8139]
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 32 (8000ns min, 16000ns max)
	Interrupt: pin A routed to IRQ 19
	Region 0: I/O ports at dc00 [size=256]
	Region 1: Memory at fdbfe000 (32-bit, non-prefetchable) [size=256]
	Capabilities: <access denied>
	Kernel driver in use: 8139too


** USB devices:
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


-- System Information:
Debian Release: 6.0.1
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686-bigmem (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages linux-image-2.6.32-5-686-bigmem depends on:
ii  debconf [debconf-2.0]         1.5.36.1   Debian configuration management sy
ii  initramfs-tools [linux-initra 0.98.8     tools for generating an initramfs
ii  linux-base                    2.6.32-33  Linux image base package
ii  module-init-tools             3.12-1     tools for managing Linux kernel mo

Versions of packages linux-image-2.6.32-5-686-bigmem recommends:
ii  firmware-linux-free           2.6.32-33  Binary firmware for various driver
ii  libc6-i686                    2.11.2-10  Embedded GNU C Library: Shared lib

Versions of packages linux-image-2.6.32-5-686-bigmem suggests:
ii  grub                          0.97-64    GRand Unified Bootloader (dummy pa
pn  linux-doc-2.6.32              <none>     (no description available)

Versions of packages linux-image-2.6.32-5-686-bigmem is related to:
pn  firmware-bnx2                 <none>     (no description available)
pn  firmware-bnx2x                <none>     (no description available)
pn  firmware-ipw2x00              <none>     (no description available)
pn  firmware-ivtv                 <none>     (no description available)
pn  firmware-iwlwifi              <none>     (no description available)
pn  firmware-linux                <none>     (no description available)
pn  firmware-linux-nonfree        <none>     (no description available)
pn  firmware-qlogic               <none>     (no description available)
pn  firmware-ralink               <none>     (no description available)
pn  xen-hypervisor                <none>     (no description available)

-- debconf information:
  linux-image-2.6.32-5-686-bigmem/postinst/missing-firmware-2.6.32-5-686-bigmem:
  linux-image-2.6.32-5-686-bigmem/postinst/depmod-error-initrd-2.6.32-5-686-bigmem: false
  linux-image-2.6.32-5-686-bigmem/prerm/removing-running-kernel-2.6.32-5-686-bigmem: true
  linux-image-2.6.32-5-686-bigmem/postinst/ignoring-do-bootloader-2.6.32-5-686-bigmem:

-- 
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
057+
0578
0579

Attachment: apache.dat
Description: Netscape Proxy Auto Config

Attachment: sendfile.dat
Description: Netscape Proxy Auto Config

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <sys/sendfile.h>

#define ioCheck(exp) if((exp)<0) showError(#exp,__FILE__,__LINE__)

void showError(const char *expr, const char *file, const int line) {
    fprintf(stderr, "Error in %s:%d at %s:\n[%d] %s\n", file, line, expr, errno, strerror(errno));
    exit(1);
}

char *name;

void usage(void) {
    printf("Usage:\n"
           "\t%s port filename\n\n"
           , name);
    exit(1);
}

int openFile(const char *name) {
    int fd;

    ioCheck(fd=open(name,O_RDONLY));

    return fd;
}

int prepareSocket(int port) {
    int fd;
    long arg;
    struct linger l;
    int i = 1;
    struct sockaddr_in addr;

    ioCheck(fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP));

    ioCheck(arg = fcntl(fd, F_GETFL, NULL));
    arg &= ~O_NONBLOCK;
    ioCheck(fcntl(fd, F_SETFL, arg));

    l.l_onoff = 1;
    l.l_linger = 60 * 15;
    ioCheck(setsockopt(fd, SOL_SOCKET, SO_LINGER, &l, sizeof(l)));
    ioCheck(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR , &i, sizeof(i)));

    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = htonl(INADDR_ANY);
    addr.sin_port = htons(port);

    ioCheck(bind(fd, (struct sockaddr *)&addr, sizeof(addr)));

    ioCheck(listen(fd, 1));

    printf("Listening on port %d\n", port);

    return fd;
}

int waitForConnection(int fd) {
    int cfd;
    struct sockaddr_in addr;
    socklen_t addrlen;
    addrlen = sizeof(addr);

    ioCheck(cfd = accept(fd, (struct sockaddr *)&addr, &addrlen));
}

void closeSocket(int fd) {
    ioCheck(shutdown(fd, SHUT_RDWR));
}

void sendFile(int tfd, int sfd) {
    struct stat s;

    ioCheck(fstat(sfd,&s));

    ioCheck(sendfile(tfd, sfd, NULL, s.st_size));
}

int main(int argc, char **argv) {
    int nfd,ffd,cfd;
    int port;

    name = argv[0];

    if (argc != 3) {
        usage();
    }

    ffd=openFile(argv[2]);

    port = atoi(argv[1]);
    if(port==0) usage();

    nfd = prepareSocket(port);
    cfd = waitForConnection(nfd);

            sendFile(cfd, ffd);

    closeSocket(cfd);
    closeSocket(nfd);

    exit(0);
}

Reply to: