Network Driver Problem Solved
I ported STAR 9100 network driver without a documentation, I just blindly use the old driver and modify it to fit with all of the changes in the networking stuff since kernel 2.4.27. The driver claims to support scatter/gather I/O, but there is no implementation of scatter gather I/O in the hard_start_xmit function. I don’t know whether this device supports it or not, so I just change this line:
dev->features |= NETIF_F_SG|NETIF_F_IP_CSUM
to this:
dev->features |= NETIF_F_IP_CSUM
http://tinyhack.com/agestar/patch-2.6.25.4-for-agestar-20080622.bz2
And now the sendfile function works (although it would be faster if the driver supports scatter/gather IO).
I have concluded the source of failure for many applications is that the sendfile syscall on my port doesn’t work. To be precise, sendfile sends garbage data to the other side. I have an USB to Ethernet adapter, and using that adapter, the problem disappears. So the conclusion is that my network driver is buggy.