Skip to content

fix: [ee/tcpip] wire _libcglue_fdman_inet_ops in _ps2sdk_ps2ipee_init#835

Merged
uyjulian merged 1 commit intops2dev:masterfrom
fjtrujy:fix/ee-tcpip-wire-inet-ops
May 7, 2026
Merged

fix: [ee/tcpip] wire _libcglue_fdman_inet_ops in _ps2sdk_ps2ipee_init#835
uyjulian merged 1 commit intops2dev:masterfrom
fjtrujy:fix/ee-tcpip-wire-inet-ops

Conversation

@fjtrujy
Copy link
Copy Markdown
Member

@fjtrujy fjtrujy commented May 7, 2026

Summary

_ps2sdk_ps2ipee_init (the EE-side init that hooks the lwIP/ps2sdk stack into libcglue) wired _libcglue_fdman_socket_ops but forgot to wire _libcglue_fdman_inet_ops. The inet ops table (__ps2ipee_fdman_inet_ops, populated with ipaddr_addr / ip4addr_ntoa / ip4addr_aton) was filled in, but the global pointer it backs stayed NULL.

libcglue's inet_addr / inet_ntoa / inet_aton wrappers each check the pointer before dispatching and silently return 0 / NULL when it's NULL, so on the EE-side path:

inet_addr("192.168.31.233") => 0

Any code that resolved a literal IP string for outbound traffic (UDP sendto, TCP connect by IP) ended up addressed to 0.0.0.0. lwIP classifies that as broadcast and emits the frame with destination MAC ff:ff:ff:ff:ff:ff — the host's IP stack drops it because the unicast destination IP doesn't match its own.

The fix

Wire _libcglue_fdman_inet_ops symmetrically with the existing socket-ops registration. Single 10-line addition in _ps2sdk_ps2ipee_init.

Test plan

  • EE-side UDP echo client (ps2_drivers/samples/udp_echo_server_ee) — 100/100 round trips sustained on real hardware. Pre-fix: every iter times out; tcpdump on the host shows the packet emitted as a broadcast for IP destination 0.0.0.0.
  • EE-side TCP burst client (tcp_burst_client_ee) — ok=20 fail=0 against a host TCP echo server. Pre-fix: same broadcast-to-0.0.0.0 symptom.
  • No regression in select_test_ee / tcp_echo_test_ee.

🤖 Generated with Claude Code

_ps2sdk_ps2ipee_init only wired _libcglue_fdman_socket_ops; the inet ops
table (__ps2ipee_fdman_inet_ops, populated with ipaddr_addr / ip4addr_ntoa
/ ip4addr_aton) was filled in but the global pointer it backs was left
NULL. libcglue's inet_addr / inet_ntoa / inet_aton wrappers all check
the pointer before dispatching and silently return 0 / NULL when it is
NULL, so on the EE-side path:

    inet_addr("192.168.31.233") => 0

Anything that resolved a literal IP string for outbound traffic (UDP
sendto, TCP connect by IP) ended up addressed to 0.0.0.0, which lwIP
classifies as broadcast and emits with dst MAC ff:ff:ff:ff:ff:ff —
the host's IP stack drops the frame because the unicast IP doesn't
match its own.

Wire and restore _libcglue_fdman_inet_ops symmetrically with the
existing socket-ops registration. Validated with an EE-side UDP echo
client (ps2_drivers/samples/udp_echo_server_ee) sustaining 100/100
round trips on real hardware after the fix; pre-fix every iter timed
out and tcpdump showed the packet on the wire as a broadcast for an
IP destination of 0.0.0.0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fjtrujy fjtrujy changed the title fix: [ee/tcpip] wire _libcglue_fdman_inet_ops in _ps2sdk_ps2ipee_init fix: [ee/tcpip] wire _libcglue_fdman_inet_ops in _ps2sdk_ps2ipee_init May 7, 2026
@fjtrujy fjtrujy requested a review from uyjulian May 7, 2026 22:29
@fjtrujy fjtrujy marked this pull request as ready for review May 7, 2026 22:29
Copy link
Copy Markdown
Member

@uyjulian uyjulian left a comment

Choose a reason for hiding this comment

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

lgtm

@uyjulian uyjulian merged commit 0391dd8 into ps2dev:master May 7, 2026
3 checks passed
@fjtrujy fjtrujy mentioned this pull request May 8, 2026
2 tasks
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