diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2021-11-26 17:04:07 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-11-30 21:24:48 +0000 |
commit | 376c2106cec344d65bffd322d261cefaf4f6e67c (patch) | |
tree | f16d9b3cfbdeb1c14611b4177a145bddf623fc97 /src/vnet/interface_output.h | |
parent | bfcd23968246086b5b884f7df1e78adb1a059724 (diff) |
interface: add support for outer header checksums
Type: improvement
Change-Id: I7c341dc4a99898dd1f865ac2ebd99de9898bb0bd
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/interface_output.h')
-rw-r--r-- | src/vnet/interface_output.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vnet/interface_output.h b/src/vnet/interface_output.h index 15b0a1d3ccc..786b0ff8e21 100644 --- a/src/vnet/interface_output.h +++ b/src/vnet/interface_output.h @@ -114,6 +114,36 @@ vnet_calc_checksums_inline (vlib_main_t * vm, vlib_buffer_t * b, VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)); } +static_always_inline void +vnet_calc_outer_checksums_inline (vlib_main_t *vm, vlib_buffer_t *b) +{ + + if (!(b->flags & VNET_BUFFER_F_OFFLOAD)) + return; + + vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags; + if (oflags & VNET_BUFFER_OFFLOAD_F_OUTER_IP_CKSUM) + { + ip4_header_t *ip4; + ip4 = (ip4_header_t *) (b->data + vnet_buffer2 (b)->outer_l3_hdr_offset); + ip4->checksum = ip4_header_checksum (ip4); + vnet_buffer_offload_flags_clear (b, + VNET_BUFFER_OFFLOAD_F_OUTER_IP_CKSUM); + } + else if (oflags & VNET_BUFFER_OFFLOAD_F_OUTER_UDP_CKSUM) + { + int bogus; + ip6_header_t *ip6; + udp_header_t *uh; + + ip6 = (ip6_header_t *) (b->data + vnet_buffer2 (b)->outer_l3_hdr_offset); + uh = (udp_header_t *) (b->data + vnet_buffer2 (b)->outer_l4_hdr_offset); + uh->checksum = 0; + uh->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus); + vnet_buffer_offload_flags_clear (b, + VNET_BUFFER_OFFLOAD_F_OUTER_UDP_CKSUM); + } +} #endif /* |