我已经设置了一些互连的qemu
虚拟机来测试端口转发规则。目前,我当前的阻止程序要简单得多,与端口转发无关。当我通过 Linux 操作系统从 go 程序发送 UDP 数据包时,它在tcpdump
操作系统本身的接口上被标记为具有错误的校验和(甚至在它经过任何桥接/网关/等之前)。这是预期/正常的吗?有解决办法吗?
16:37:22.899722 IP (tos 0x0, ttl 64, id 9829, offset 0, flags [DF], proto UDP ()
192.168.0.2.36793 > 22.22.22.22.20000: [bad udp cksum 0xecf9 -> 0x989f!] UD0
0x0000: 0200 0000 0202 0200 0000 0401 0800 4500
0x0010: 0026 2665 4000 4011 278c c0a8 0002 1616
0x0020: 1616 8fb9 4e20 0012 ecf9 5049 4e47 5f42
0x0030: 5954 4553
进一步来说,数据包经过的网络设备是pci
virtio
,连接到一个tap
设备。
编辑以添加输出ethtool -k
:
# ethtool -k eth1
Features for eth1:
rx-checksumming: on [fixed]
tx-checksumming: on
tx-checksum-ipv4: off [fixed]
tx-checksum-ip-generic: on
tx-checksum-ipv6: off [fixed]
tx-checksum-fcoe-crc: off [fixed]
tx-checksum-sctp: off [fixed]
scatter-gather: on
tx-scatter-gather: on
tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
tx-tcp-segmentation: on
tx-tcp-ecn-segmentation: on
tx-tcp-mangleid-segmentation: off
tx-tcp6-segmentation: on
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: off [fixed]
tx-vlan-offload: off [fixed]
ntuple-filters: off [fixed]
receive-hashing: off [fixed]
highdma: on [fixed]
rx-vlan-filter: on [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: on [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: off [fixed]
tx-gre-csum-segmentation: off [fixed]
tx-ipxip4-segmentation: off [fixed]
tx-ipxip6-segmentation: off [fixed]
tx-udp_tnl-segmentation: off [fixed]
tx-udp_tnl-csum-segmentation: off [fixed]
tx-gso-partial: off [fixed]
tx-tunnel-remcsum-segmentation: off [fixed]
tx-sctp-segmentation: off [fixed]
tx-esp-segmentation: off [fixed]
tx-udp-segmentation: off [fixed]
tx-gso-list: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: off
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off [fixed]
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: off [fixed]
rx-vlan-stag-filter: off [fixed]
l2-fwd-offload: off [fixed]
hw-tc-offload: off [fixed]
esp-hw-offload: off [fixed]
esp-tx-csum-hw-offload: off [fixed]
rx-udp_tunnel-port-offload: off [fixed]
tls-hw-tx-offload: off [fixed]
tls-hw-rx-offload: off [fixed]
rx-gro-hw: on
tls-hw-record: off [fixed]
rx-gro-list: off
macsec-hw-offload: off [fixed]
rx-udp-gro-forwarding: off
hsr-tag-ins-offload: off [fixed]
hsr-tag-rm-offload: off [fixed]
hsr-fwd-offload: off [fixed]
hsr-dup-offload: off [fixed]
答案1
这是预期的行为,因为 UDP 校验和默认是硬件卸载的,并且一旦数据包出去某个实际接口,它就会得到正确的校验和。
使用 tcpdump 您看到的是尚未到达硬件的数据包,因此它们没有分配正确的校验和。