summaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/tcp')
-rw-r--r--src/vnet/tcp/tcp.c6
-rw-r--r--src/vnet/tcp/tcp.h3
-rw-r--r--src/vnet/tcp/tcp_output.c36
3 files changed, 20 insertions, 25 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 86729011f8f..baa5c0daa61 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -705,6 +705,9 @@ tcp_init_snd_vars (tcp_connection_t * tc)
tc->snd_nxt = tc->iss + 1;
tc->snd_una_max = tc->snd_nxt;
tc->srtt = 100; /* 100 ms */
+
+ if (!tcp_cfg.csum_offload)
+ tc->cfg_flags |= TCP_CFG_F_NO_CSUM_OFFLOAD;
}
void
@@ -1656,6 +1659,7 @@ tcp_configuration_init (void)
tcp_cfg.initial_cwnd_multiplier = 0;
tcp_cfg.enable_tx_pacing = 1;
tcp_cfg.allow_tso = 0;
+ tcp_cfg.csum_offload = 1;
tcp_cfg.cc_algo = TCP_CC_NEWRENO;
tcp_cfg.rwnd_min_update_ack = 1;
@@ -1797,6 +1801,8 @@ tcp_config_fn (vlib_main_t * vm, unformat_input_t * input)
tcp_cfg.enable_tx_pacing = 0;
else if (unformat (input, "tso"))
tcp_cfg.allow_tso = 1;
+ else if (unformat (input, "no-csum-offload"))
+ tcp_cfg.csum_offload = 0;
else if (unformat (input, "cc-algo %U", unformat_tcp_cc_algo,
&tcp_cfg.cc_algo))
;
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index e9247eb86b2..299e76de5a7 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -558,6 +558,9 @@ typedef struct tcp_configuration_
/** Allow use of TSO whenever available */
u8 allow_tso;
+ /** Set if csum offloading is enabled */
+ u8 csum_offload;
+
/** Default congestion control algorithm type */
tcp_cc_algorithm_type_e cc_algo;
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index c06bbf19ef4..d6e1adc9600 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -896,26 +896,15 @@ static void
tcp_push_ip_hdr (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
vlib_buffer_t * b)
{
- tcp_header_t *th = vlib_buffer_get_current (b);
- vlib_main_t *vm = wrk->vm;
if (tc->c_is_ip4)
{
- ip4_header_t *ih;
- ih = vlib_buffer_push_ip4 (vm, b, &tc->c_lcl_ip4,
- &tc->c_rmt_ip4, IP_PROTOCOL_TCP,
- tcp_csum_offload (tc));
- th->checksum = ip4_tcp_udp_compute_checksum (vm, b, ih);
+ vlib_buffer_push_ip4 (wrk->vm, b, &tc->c_lcl_ip4, &tc->c_rmt_ip4,
+ IP_PROTOCOL_TCP, tcp_csum_offload (tc));
}
else
{
- ip6_header_t *ih;
- int bogus = ~0;
-
- ih = vlib_buffer_push_ip6_custom (vm, b, &tc->c_lcl_ip6,
- &tc->c_rmt_ip6, IP_PROTOCOL_TCP,
- tc->ipv6_flow_label);
- th->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ih, &bogus);
- ASSERT (!bogus);
+ vlib_buffer_push_ip6_custom (wrk->vm, b, &tc->c_lcl_ip6, &tc->c_rmt_ip6,
+ IP_PROTOCOL_TCP, tc->ipv6_flow_label);
}
}
@@ -2270,19 +2259,16 @@ always_inline void
tcp_output_push_ip (vlib_main_t * vm, vlib_buffer_t * b0,
tcp_connection_t * tc0, u8 is_ip4)
{
- u8 __clib_unused *ih0;
- tcp_header_t __clib_unused *th0 = vlib_buffer_get_current (b0);
-
- TCP_EVT (TCP_EVT_OUTPUT, tc0, th0->flags, b0->current_length);
+ TCP_EVT (TCP_EVT_OUTPUT, tc0,
+ ((tcp_header_t *) vlib_buffer_get_current (b0))->flags,
+ b0->current_length);
if (is_ip4)
- ih0 = vlib_buffer_push_ip4 (vm, b0, &tc0->c_lcl_ip4, &tc0->c_rmt_ip4,
- IP_PROTOCOL_TCP, tcp_csum_offload (tc0));
+ vlib_buffer_push_ip4 (vm, b0, &tc0->c_lcl_ip4, &tc0->c_rmt_ip4,
+ IP_PROTOCOL_TCP, tcp_csum_offload (tc0));
else
- ih0 =
- vlib_buffer_push_ip6_custom (vm, b0, &tc0->c_lcl_ip6, &tc0->c_rmt_ip6,
- IP_PROTOCOL_TCP, tc0->ipv6_flow_label);
-
+ vlib_buffer_push_ip6_custom (vm, b0, &tc0->c_lcl_ip6, &tc0->c_rmt_ip6,
+ IP_PROTOCOL_TCP, tc0->ipv6_flow_label);
}
always_inline void