Linux checksum flag in kernel
2014-08-22 14:04
701 查看
net_device->feature
| NETIF_F_NO_CSUM: No need to use L4 checksum, it used for loopback device.
| NETIF_F_IP_CSUM: the device can compute L4 checksum in hardware, but only for TCP and UDP over IPv4.
| NETIF_F_HW_CSUM: the device can compute the L4 checksum in hardware for any protocol.
For receive path:
skb->csum may hold the L4 checksum(when skb->ip_summed == CHECKSUM_COMPLETE, this filed hold the checksum provided by hardware).
skb->ip_summed: indicate the checksum status.
CHECKSUM_NONE: the checksum in csum is not valid, this can be due to:
1. device doesn't provide hardware checksumming.
2. hardware found the packet is corrupted, in normal case, it should drop this packet and not discard this packet, but the driver may want the kernel to re-check it again,so it set this flag.
IMPORTANT: if the packet is going to be forwarded, the router should not discard it dure to wrong L4 checksum (a route is not supposed to check L4 checksum). but the receiver need to check it.
3. the checksum need be recomputed nd reverified.
CHECKSUM_HW: the NIC hs computed the checksum on the L4 header and payload. and has copied it into the skb->csum field. The software needs to add checksum on the pseduo-heder to generate the result checksum.
CHECHSUM_UNNECESSARY: the NIC has computed and verified the checksum. software doesn't need to verify the checksum again.
For TX path: skb->csum: tell hardware to put the checksum at this offset of the packet.
skb->ip_summed, CHECKSUM_NONE: the software has processed the checksum, hardware doesn't need to do anything.
CHECKSUM_HW: software computed the checksum of the pseudo-header. hardware need to adding this checksum to L4 header and payload.
refer:tcp_v4_checksum_init for rx, tcp_v4_send_check for tx in kernel code.
| NETIF_F_NO_CSUM: No need to use L4 checksum, it used for loopback device.
| NETIF_F_IP_CSUM: the device can compute L4 checksum in hardware, but only for TCP and UDP over IPv4.
| NETIF_F_HW_CSUM: the device can compute the L4 checksum in hardware for any protocol.
For receive path:
skb->csum may hold the L4 checksum(when skb->ip_summed == CHECKSUM_COMPLETE, this filed hold the checksum provided by hardware).
skb->ip_summed: indicate the checksum status.
CHECKSUM_NONE: the checksum in csum is not valid, this can be due to:
1. device doesn't provide hardware checksumming.
2. hardware found the packet is corrupted, in normal case, it should drop this packet and not discard this packet, but the driver may want the kernel to re-check it again,so it set this flag.
IMPORTANT: if the packet is going to be forwarded, the router should not discard it dure to wrong L4 checksum (a route is not supposed to check L4 checksum). but the receiver need to check it.
3. the checksum need be recomputed nd reverified.
CHECKSUM_HW: the NIC hs computed the checksum on the L4 header and payload. and has copied it into the skb->csum field. The software needs to add checksum on the pseduo-heder to generate the result checksum.
CHECHSUM_UNNECESSARY: the NIC has computed and verified the checksum. software doesn't need to verify the checksum again.
For TX path: skb->csum: tell hardware to put the checksum at this offset of the packet.
skb->ip_summed, CHECKSUM_NONE: the software has processed the checksum, hardware doesn't need to do anything.
CHECKSUM_HW: software computed the checksum of the pseudo-header. hardware need to adding this checksum to L4 header and payload.
refer:tcp_v4_checksum_init for rx, tcp_v4_send_check for tx in kernel code.
相关文章推荐
- switch off UDP checksum in kernel
- Linux Kernel Threads in Device Drivers
- Interrupt Handling Internals in Linux Kernel
- Compile Linux Kernel in Ubuntu
- Linux Kernel Threads in Device Drivers
- Init Call Mechanism in the Linux Kernel
- Feature: High Memory In The Linux Kernel
- Radix Tree in Linux Kernel
- How to burn Linux Kernel into nor flash and rootfs in USB stick at Mindspeed c1k
- circular buffer in Linux kernel
- Linux Kernel in a Nutshell
- Linux kernel in a nutshell
- Linux Kernel in a Nutshel
- [转]Init Call Mechanism in the Linux Kernel(很犀利)
- Linux 安装gcc [原]解决Metadata file does not match checksum错误
- Linux Device Drivers 3rd Edition Data Types in the Kernel
- HOWTO: Use ethtool to configure checksum offload for NICs under Linux
- [OS]Assembly in Linux Kernel
- Dynamic Debugging in Linux Kernel(1) --- How To...
- Linux 内核可用的字符串分割函数 strsep (String Split Function strsep in Linux Kernel)