-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
sockets_tls: receiving data on offloaded socket before handshake causes pollin | pollerr and failed recvfrom (SARA-R4) #35789
Comments
Thank you Emil for reporting the issue. First of all, let me shortly explain why does the SARA-R4 returns For that reason the fix implemented in So for offloaded underlying sockets, the
@emillindq Any thoughts, which sounds like a better solution for you? |
@rlubos firstly, thank you for taking a look at this! It is a juicy problem indeed. At the core of the problem is that the data is left there and nobody feeds it anywhere. Normally in the DTLS client case, no data should come until somebody has called sendto since that initiates the client handshake and it is firstly then that mbedTLS stack calls recv function. Would it be possible to check if the handshake has been started? If it has, never mind because the data will be read by mbedTLS, if it hasn't then just discard all data in the poll call and continue as usual. If that's not an option, I reckon point 2 would be the best. At long as the data is fed anywhere and discarded it should solve the problem! |
I think this should be fairly simple to implement. We have Actually, seeing it like this, I think this is the way to go with the offloaded sockets. Do you agree? |
Yes I think this is the cleanest solution! Is it perhaps possible to implement this in a way so we can revert #33474 ? It would be nice if one fix covers both offloaded and native poll Will you make a PR or should I take a look at it? |
Sorry for the delay, I'll try to propose something. |
@emillindq I've submitted a draft PR with the proposal, would you mind give it some testing? We can discuss further, but for now I've implemented the alternative solution only for offloaded sockets and left native stack as is - IMO monitoring the |
Describe the bug
This bug is a variant of #33330 but with offloaded socket behind the DTLS socket. The fix for mentioned issue doesn't apply for offloaded sockets.
The scenario is as follows:
bind()
is called with an offloaded socket behind itThe reason as to why mentioned fix doesn't work for offloaded sockets appears to be that for native sockets ioctl is implemented while sara-r4 modem's
offload_ioctl
just returns-EXDEV
onPOLL_PREPARE
request, whereby we just restore the events and go on like nothing happened (aka. patch is ignored).zephyr/subsys/net/lib/sockets/sockets_tls.c
Lines 1981 to 2022 in 8e6898e
To Reproduce
Steps to reproduce the behavior:
UUSORF
just after creating the socket to simulate, for example using a debugger.Expected behavior
poll()
on DTLS socket where handshake not complete should always return nothing.Impact
Possible network hang in rare cases when network is inited and deinited often. I guess this is not super serious, but I've seen it happen a few times during our unit tests when we stress-test it by bringing our network stack up&down to see its behavior. All special cases are not handled
Logs and console output
See above
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: