diff --git a/src/core/sock/sockinfo_tcp.cpp b/src/core/sock/sockinfo_tcp.cpp index 572a3c11f..2c1b77438 100644 --- a/src/core/sock/sockinfo_tcp.cpp +++ b/src/core/sock/sockinfo_tcp.cpp @@ -1347,6 +1347,21 @@ ssize_t sockinfo_tcp::tcp_tx_slow_path(xlio_tx_call_attr_t &tx_arg) return tcp_tx_handle_done_and_unlock(total_tx, errno_tmp, is_dummy, is_send_zerocopy); } +static bool is_socket_in_error_state(const struct pbuf *p, struct tcp_pcb * pcb, uint16_t flags) +{ + if (unlikely(is_set(flags, XLIO_TX_PACKET_REXMIT))) { + // this means a retransmit happened - let's check the error_state we'll put if we got error + // cqe + const mem_buf_desc_t * mem_buf_desc = (const mem_buf_desc_t *)p; + if (mem_buf_desc->m_flags & mem_buf_desc_t::INVALID) { + TCP_EVENT_ERR(pcb->errf, pcb->my_container, ERR_RST); + return true; + } + } + + return false; +} + /* * TODO Remove 'p' from the interface and use 'seg'. * There are multiple places where ip_output() is used without allocating @@ -1372,15 +1387,8 @@ err_t sockinfo_tcp::ip_output(struct pbuf *p, struct tcp_seg *seg, void *v_p_con int count = 0; void *cur_end; - if (unlikely(is_set(attr.flags, XLIO_TX_PACKET_REXMIT))) { - // this means a retransmit happened - let's check the error_state we'll put if we got error - // cqe - const auto mem_buf_desc = (mem_buf_desc_t *)p; - if (mem_buf_desc->m_flags & mem_buf_desc_t::INVALID) { - const auto pcb = (struct tcp_pcb *)v_p_conn; - TCP_EVENT_ERR(pcb->errf, pcb->my_container, ERR_RST); - return ERR_RST; - } + if (unlikely(is_socket_in_error_state(p, (struct tcp_pcb *)v_p_conn, flags))) { + return ERR_RST; } int rc = p_si_tcp->m_ops->postrouting(p, seg, attr);