summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/tcp/tcp_output.c51
1 files changed, 12 insertions, 39 deletions
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index 5690db02ee2..82694995840 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -542,23 +542,19 @@ tcp_make_synack (tcp_connection_t * tc, vlib_buffer_t * b)
}
static void
-tcp_enqueue_to_ip_lookup (tcp_worker_ctx_t * wrk, vlib_buffer_t * b, u32 bi,
- u8 is_ip4, u32 fib_index)
+tcp_enqueue_half_open (tcp_worker_ctx_t *wrk, tcp_connection_t *tc,
+ vlib_buffer_t *b, u32 bi)
{
- tcp_main_t *tm = &tcp_main;
vlib_main_t *vm = wrk->vm;
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
b->error = 0;
- vnet_buffer (b)->sw_if_index[VLIB_TX] = fib_index;
- vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
-
session_add_pending_tx_buffer (vm->thread_index, bi,
- tm->ipl_next_node[!is_ip4]);
+ wrk->tco_next_node[!tc->c_is_ip4]);
if (vm->thread_index == 0 && vlib_num_workers ())
- session_queue_run_on_main_thread (wrk->vm);
+ session_queue_run_on_main_thread (vm);
}
static void
@@ -663,13 +659,11 @@ tcp_send_reset_w_pkt (tcp_connection_t * tc, vlib_buffer_t * pkt,
tcp_worker_ctx_t *wrk = tcp_get_worker (thread_index);
vlib_main_t *vm = wrk->vm;
vlib_buffer_t *b;
- u32 bi, sw_if_index, fib_index;
u8 tcp_hdr_len, flags = 0;
tcp_header_t *th, *pkt_th;
- u32 seq, ack;
+ u32 seq, ack, bi;
ip4_header_t *ih4, *pkt_ih4;
ip6_header_t *ih6, *pkt_ih6;
- fib_protocol_t fib_proto;
if (PREDICT_FALSE (!vlib_buffer_alloc (vm, &bi, 1)))
{
@@ -678,9 +672,6 @@ tcp_send_reset_w_pkt (tcp_connection_t * tc, vlib_buffer_t * pkt,
}
b = vlib_get_buffer (vm, bi);
- sw_if_index = vnet_buffer (pkt)->sw_if_index[VLIB_RX];
- fib_proto = is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
- fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index);
tcp_init_buffer (vm, b);
/* Make and write options */
@@ -735,7 +726,7 @@ tcp_send_reset_w_pkt (tcp_connection_t * tc, vlib_buffer_t * pkt,
ASSERT (!bogus);
}
- tcp_enqueue_to_ip_lookup (wrk, b, bi, is_ip4, fib_index);
+ tcp_enqueue_half_open (wrk, tc, b, bi);
TCP_EVT (TCP_EVT_RST_SENT, tc);
vlib_node_increment_counter (vm, tcp_node_index (output, tc->c_is_ip4),
TCP_ERROR_RST_SENT, 1);
@@ -780,28 +771,13 @@ tcp_send_reset (tcp_connection_t * tc)
TCP_ERROR_RST_SENT, 1);
}
-static void
-tcp_push_ip_hdr (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
- vlib_buffer_t * b)
-{
- if (tc->c_is_ip4)
- {
- vlib_buffer_push_ip4 (wrk->vm, b, &tc->c_lcl_ip4, &tc->c_rmt_ip4,
- IP_PROTOCOL_TCP, tcp_csum_offload (tc));
- }
- else
- {
- vlib_buffer_push_ip6_custom (wrk->vm, b, &tc->c_lcl_ip6, &tc->c_rmt_ip6,
- IP_PROTOCOL_TCP, tc->ipv6_flow_label);
- }
-}
-
/**
* Send SYN
*
- * Builds a SYN packet for a half-open connection and sends it to ipx_lookup.
- * The packet is not forwarded through tcpx_output to avoid doing lookups
- * in the half_open pool.
+ * Builds a SYN packet for a half-open connection and sends it to tcp-output.
+ * The packet is handled by main thread and because half-open and established
+ * connections use the same pool the connection can be retrieved without
+ * additional logic.
*/
void
tcp_send_syn (tcp_connection_t * tc)
@@ -835,8 +811,7 @@ tcp_send_syn (tcp_connection_t * tc)
tc->rtt_seq = tc->snd_nxt;
tc->rto_boff = 0;
- tcp_push_ip_hdr (wrk, tc, b);
- tcp_enqueue_to_ip_lookup (wrk, b, bi, tc->c_is_ip4, tc->c_fib_index);
+ tcp_enqueue_half_open (wrk, tc, b, bi);
TCP_EVT (TCP_EVT_SYN_SENT, tc);
}
@@ -1504,9 +1479,7 @@ tcp_timer_retransmit_syn_handler (tcp_connection_t * tc)
TCP_EVT (TCP_EVT_SYN_RXT, tc, 0);
- /* This goes straight to ipx_lookup */
- tcp_push_ip_hdr (wrk, tc, b);
- tcp_enqueue_to_ip_lookup (wrk, b, bi, tc->c_is_ip4, tc->c_fib_index);
+ tcp_enqueue_half_open (wrk, tc, b, bi);
tcp_timer_update (&wrk->timer_wheel, tc, TCP_TIMER_RETRANSMIT_SYN,
tc->rto * TCP_TO_TIMER_TICK);