Skip to content

Fix NetX I/O porting layer - #11287

Open
embhorn wants to merge 3 commits into
wolfSSL:masterfrom
embhorn:zd22372
Open

Fix NetX I/O porting layer#11287
embhorn wants to merge 3 commits into
wolfSSL:masterfrom
embhorn:zd22372

Conversation

@embhorn

@embhorn embhorn commented Aug 26, 2026

Copy link
Copy Markdown
Member

Description

The native NetX callbacks mapped every non-NX_SUCCESS status to WOLFSSL_CBIO_ERR_GENERAL, which the TLS layer treats as fatal. Non-blocking operation (nxWait set to NX_NO_WAIT or any expiring wait option) was therefore impossible: a "no data yet" from the stack killed the connection.

Adds NetX_TranslateReturnCode() and uses it in NetX_Receive, NetX_Send, NetX_ReceiveFrom, and NetX_SendTo:

  • NX_NO_PACKET, NX_WINDOW_OVERFLOW, NX_TX_QUEUE_DEPTH -> WANT_READ/WANT_WRITE
  • NX_WAIT_ABORTED -> ERR_ISR
  • NX_NOT_CONNECTED -> ERR_CONN_CLOSE
  • everything else -> ERR_GENERAL, unchanged

Also fixes the HAVE_NETX SOCKET_E* aliases in wolfssl/wolfio.h, which all mapped to NX_NOT_CONNECTED, and enables DTLS in the ThreadX CI job so the NetX Duo UDP callbacks get compile coverage.

Blocking users (NX_WAIT_FOREVER) see no behavior change.

Also fix build error with DTLS / IPv4-only config.

Fixes

  • zd22372
  • zd22378

Testing

Compiled locally, customer confirmed

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@embhorn embhorn self-assigned this Aug 26, 2026
@embhorn
embhorn requested review from wolfSSL-Fenrir-bot and a lite review from Copilot August 26, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves the ThreadX NetX/NetX Duo I/O porting layer so non-blocking and expiring-wait configurations don’t get treated as fatal TLS I/O errors, enabling correct retry behavior for transient network conditions.

Changes:

  • Adds NetX_TranslateReturnCode() and uses it across NetX TCP/UDP send/receive callbacks to return WANT_READ/WANT_WRITE (and other appropriate CBIO errors) instead of always ERR_GENERAL.
  • Fixes NetX SOCKET_E* aliases in wolfssl/wolfio.h to better reflect “would block” and “interrupted” conditions.
  • Fixes DTLS NetX Duo IPv4-only build issues by guarding NXD_ADDRESS union access and using nxd_udp_socket_send() without direct union member access.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
wolfssl/wolfio.h Corrects NetX SOCKET_E* mappings to align with NetX status codes for non-blocking / interrupted behavior.
src/wolfio.c Introduces NetX status-to-CBIO translation and updates NetX TCP/UDP callbacks; hardens DTLS peer address handling for IPv4-only/IPv6 builds.
doc/dox_comments/header_files/wolfio.h Updates doxygen guidance to describe NX_NO_WAIT / expiring-wait retry semantics for NetX callbacks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread doc/dox_comments/header_files/wolfio.h

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11287

Scan targets checked: wolfcrypt-rs-bugs, wolfssl-bugs, wolfssl-src

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

@wolfSSL wolfSSL deleted a comment from wolfSSL-Bot Sep 2, 2026
@embhorn

embhorn commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

retest this please

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.

3 participants