[Edited Message Follows]

Hi experts,

I am confusing about the L4 checksum behavior in VPP. I noticed the code was 
there for a very long time(more than 3 years) so I open this topic to see if 
anybody knows the history and why.

* The first problem is in DPDK plugin and was introduced in commit d81566ff92: 
Disable for-us udp/tcp checksum validation by default

in Current DPDK plugin, the code clears flags 
VNET_BUFFER_F_L4_CHECKSUM_COMPUTED and VNET_BUFFER_F_L4_CHECKSUM_CORRECT when 
"enable-tcp-udp-checksum" option is enabled. While these two flags are used to 
identify if the L4 checksum is checked and correct, respectively. So I think 
this is a wrong behavior - *are we doing the opposite* ?
The current DPDK plugin assumes all the packets from DPDK are correct but in 
fact we should check per packet and set the corresponding bits. I've pushed a 
patch to fix this issue and Dave invited experts to help to review - Thanks 
Dave :-)

* Another problem in the IP4 graph node. The following mechanism was first 
introduced in commit 96be8e88109b3e1 and got refactored in commit 1b25552eb.

#define ip4_local_csum_is_offloaded(_b) \
_b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM \
|| _b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM

#define ip4_local_need_csum_check(is_tcp_udp, _b) \
(is_tcp_udp && !(_b->flags & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED \
|| ip4_local_csum_is_offloaded (_b)))

#define ip4_local_csum_is_valid(_b) \
(_b->flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT \
|| (ip4_local_csum_is_offloaded (_b))) != 0

In my understanding, the Marcos ip4_local_need_csum_check and 
ip4_local_csum_is_valid are used to check if the L4 checksum is computed and 
checked before ip4-local node. While the Macro ip4_local_csum_is_offloaded is 
to check if the L4 checksum can be offloaded to NIC on the *TX side*. *I am not 
very clear why do we need to check the tx offload capability in the RX path* - 
maybe we are expecting the NIC can help to re-calculate the checksum before 
sending out?  Think about if an APP(local APP running upon TCP/UDP stack or a 
tunnel like VxLAN/GTPU/etc...) is running on L4, it would get invalid checksum 
packets(Considering the DPDK plugin marked all the packets are COMPUTED and 
CORRECT as I described in the first problem).

see in:
commit 96be8e88109b3e166b76f58e552dbe438d73bb73
Author: Jakub Grajciar <jakub.grajc...@pantheon.tech>
Date:   Mon Oct 30 14:56:17 2017 +0100

vnet: ip4/6_local->don't drop packet if marked for TCP/UDP offload cksum 
calculation
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16053): https://lists.fd.io/g/vpp-dev/message/16053
Mute This Topic: https://lists.fd.io/mt/72982275/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to