编程Linux网络驱动程序以支持关闭TCP校验和卸载

时间:2013-03-12 21:17:44

标签: linux tcp linux-device-driver

我正在编写一个linux网络驱动程序。它差不多完成了。当我在2台PC之间ping时,一切都很完美。然后我尝试使用一些TCP / UDP协议,接收器永远不会回复。我使用wireshark来查看那里发生了什么,我发现所有TCP数据包都有不正确的校验和。据说错误的校验和是由TCP校验和卸载引起的。我尝试用ethtool将其关闭。当我使用sudo ethtool -K uwn0 tx off时,它会回复我

Cannot get device rx-checksumming settings: Operation not supported
Cannot get device tx-checksumming settings: Operation not supported
Cannot get device scatter-gather settings: Operation not supported
Cannot get device tcp-segmentation-offload settings: Operation not supported
Cannot get device udp-fragmentation-offload settings: Operation not supported
Cannot get device generic-segmentation-offload settings: Operation not supported
Cannot get device generic-receive-offload settings: Operation not supported
Cannot get device flags: Operation not supported

有没有办法让我的驱动程序支持tcp校验和卸载?或者只是在软件中计算校验和? 感谢

1 个答案:

答案 0 :(得分:1)

在驱动程序中设置设备的界面时,应取消NETIF_F_HW_CSUM中的标记netdev->hw_features以强制TCP在软件中计算校验和。

有关设置硬件功能标志的示例,请查看
lxr.free-electrons.com/source/drivers/net/ethernet/intel/e1000e/netdev.c