Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: 4183221 propagate socket errors #276

Open
wants to merge 1 commit into
base: release_3_40
Choose a base branch
from

Conversation

tomerdbz
Copy link
Collaborator

@tomerdbz tomerdbz commented Dec 10, 2024

In case we got an ECQE - set the socket in a closing state. Effectively this sends a TCP-RST.

Description

Currently, in case we got an ECQE - we don't notify our callers we got to an invalid state.
The callers will keep trying to transmit TX segments, unaware of any issues.
This causes callers to not be able to identify and overcome error states, causing issues like 4183221.

What

Propagates the pcb to sq_wqe_prop, so when getting an ECQE - we could notify the TCP/IP stack.

Why ?

Justification for the PR. If there is existing issue/bug please reference.

How ?
  1. Tested sockperf gets correct error + errno
  2. Tested xlio_socket_api.c test gets correct error

Change type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

Check list

  • Code follows the style de facto guidelines of this project
  • Comments have been inserted in hard to understand places
  • Documentation has been updated (if necessary)
  • Test has been added (if possible)

@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch from fa87745 to 519b192 Compare December 10, 2024 12:25
@tomerdbz
Copy link
Collaborator Author

Tested with sockperf

@AlexanderGrissik
Copy link
Collaborator

BTW, maybe instead of propagating errors to socket and handling socket deletion cases, we can mark some bit on the mem_buf_desc/pbuf, and on the next rexmit attempt lwip/socket will check the bit and fail it.

@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch from 519b192 to 4b913e2 Compare December 12, 2024 12:44
@tomerdbz
Copy link
Collaborator Author

ZC API tester yielded:
XLIO WARNING: cq_mgr_tx[0x5602d17e5920]:256:log_cqe_error() cqe: syndrome=0x4 vendor=0x52 hw=0x84 (type=0x0) wqe_opcode_qpn=0xa0014c2 wqe_counter=0x4
XLIO WARNING: cq_mgr_tx[0x5602d17e5920]:226:poll_and_process_element_tx() triggering low-level interface error on sockinfo=0x5602d17ecac0
Event callback: event=4 value=104 (sock=deadc0de).

@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch 2 times, most recently from 9dfc5b1 to e78f6dd Compare December 16, 2024 13:47
@tomerdbz
Copy link
Collaborator Author

TODO - squash

@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch from 9620582 to 8b7a5b4 Compare December 17, 2024 10:34
@tomerdbz
Copy link
Collaborator Author

Following the split concern @AlexanderGrissik - validated tcp_seg_move_flags duplicates flags before it is set by ip_output.
Flow:

  1. ECQE found - mem_buf_desc gets signaled
  2. split happens on lwip segment REXMIT
  3. ip_output called for 1st segment
  4. mem_buf_desc noticed - RST gets initiated
  5. ip_output called for 2nd segment
  6. no anomaly in mem_buf_desc
  7. gets sent
  8. another ECQE generated

@tomerdbz
Copy link
Collaborator Author

bot:retest

@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch 2 times, most recently from ea28c28 to 7c9b9a2 Compare December 18, 2024 09:04
@AlexanderGrissik
Copy link
Collaborator

Do we want this to vNext?

src/core/dev/cq_mgr_tx.cpp Show resolved Hide resolved
src/core/dev/cq_mgr_tx.cpp Show resolved Hide resolved
CLONED = 0x01,
ZCOPY = 0x02,
INVALID = 0x04,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do another scan and check we do not use other values than these for flags.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified

@@ -1372,6 +1372,17 @@ 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))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this method to a separate inline method. Lets make sure that possible splits will not break it.

@@ -1372,6 +1387,10 @@ 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_socket_in_error_state(p, (struct tcp_pcb *)v_p_conn, flags))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe is_buffer_in_error_state

@@ -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(flags & XLIO_TX_PACKET_REXMIT)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would move this check to sockinfo_tcp::ip_output because now we have 2 ifs

TYPICAL = 0,
CLONED = 0x01,
ZCOPY = 0x02,
INVALID = 0x04,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename it to something more specific than just invalid. Maybe: HAD_CQE_ERROR

@@ -1372,6 +1384,13 @@ 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(flags & XLIO_TX_PACKET_REXMIT)) {
const mem_buf_desc_t *mem_buf_desc = (const mem_buf_desc_t *)p;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider cpp style cast

@@ -1372,6 +1384,13 @@ 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(flags & XLIO_TX_PACKET_REXMIT)) {
const mem_buf_desc_t *mem_buf_desc = (const mem_buf_desc_t *)p;
if (unlikely(is_socket_in_error_state(mem_buf_desc, (struct tcp_pcb *)v_p_conn))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making this method a member and doing:
p_si_tcp->is_socket_in_error_state()
Also the name is_socket_in_error_state is a bit confusing because it suggests some read only check but in fact it sets flags. Maybe check_previous_buffer_failure?

@@ -5096,8 +5118,9 @@ int sockinfo_tcp::rx_wait_helper(int &poll_count, bool blocking)
// It can be too expansive for the application to get nothing just because of lock contention.
// In this case it will be better to have a lock() version of poll_and_process_element_rx.
// And then we should continue polling untill we have ready packets or we drained the CQ.
bool all_drained = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these are here?

@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch 4 times, most recently from 6b5b2bc to c174be4 Compare December 25, 2024 16:15
@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch from c174be4 to 489c0bc Compare December 25, 2024 16:33
In case we got an ECQE - set the socket in a error state.
Effectively this sends a TCP-RST.

Signed-off-by: Tomer Cabouly <[email protected]>
@tomerdbz tomerdbz force-pushed the propagate_4183221_to_release_3_40 branch from 489c0bc to 780d15e Compare January 5, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants