cnat: Support offloaded check sums

This patch removes zero checks for new_addr, new_port
meaning sessions with zero values will rewrite the packet
with a 0 value instead of leaving it in place. This allows
to reduce branchiness in the code, and sessions are fully
resolved at creation time anyway.

This also adds support for checksum offloads:
- IP checksum offload : we always compute the checksum to
avoid issues with drivers. We'll revert this if we realize
cost gets too important.
- TCP/UDP checksum offload : we add the implementation for
pseudo header checksum computation. This is needed for the
drivers that do not re-compute this pseudo-checksum before
the packet is TX-ed (e.g. a few DPDK drivers).

Type: improvement

Change-Id: I6543f3aec8c120ec50f4219108609138283620ef
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
This commit is contained in:
Nathan Skrzypczak
2021-02-25 19:13:19 +01:00
parent 994a58997d
commit b22da9c7d1
4 changed files with 155 additions and 215 deletions

File diff suppressed because it is too large Load Diff

View File

@ -156,9 +156,9 @@ cnat_input_feature_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
}
if (AF_IP4 == ctx->af)
cnat_translation_ip4 (session, ip4, udp0);
cnat_translation_ip4 (session, ip4, udp0, vnet_buffer (b)->oflags);
else
cnat_translation_ip6 (session, ip6, udp0);
cnat_translation_ip6 (session, ip6, udp0, vnet_buffer (b)->oflags);
if (NULL != ct)
{
@ -326,9 +326,9 @@ cnat_output_feature_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
}
if (AF_IP4 == ctx->af)
cnat_translation_ip4 (session, ip4, udp0);
cnat_translation_ip4 (session, ip4, udp0, vnet_buffer (b)->oflags);
else
cnat_translation_ip6 (session, ip6, udp0);
cnat_translation_ip6 (session, ip6, udp0, vnet_buffer (b)->oflags);
trace:
if (PREDICT_FALSE (ctx->do_trace))

View File

@ -133,11 +133,10 @@ cnat_snat_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
CNAT_SESSION_FLAG_HAS_SNAT);
}
if (AF_IP4 == ctx->af)
cnat_translation_ip4 (session, ip4, udp0);
cnat_translation_ip4 (session, ip4, udp0, vnet_buffer (b)->oflags);
else
cnat_translation_ip6 (session, ip6, udp0);
cnat_translation_ip6 (session, ip6, udp0, vnet_buffer (b)->oflags);
trace:
if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))

View File

@ -176,9 +176,9 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b,
}
if (AF_IP4 == ctx->af)
cnat_translation_ip4 (session, ip4, udp0);
cnat_translation_ip4 (session, ip4, udp0, vnet_buffer (b)->oflags);
else
cnat_translation_ip6 (session, ip6, udp0);
cnat_translation_ip6 (session, ip6, udp0, vnet_buffer (b)->oflags);
if (NULL != ct)
{