-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
problem with implementation of sock_set_flag #19191
Comments
I quickly went through the code and it was not clear to me where the issue is. Only place that I noticed setting ctx->user_data was in Could you elaborate what kind of issues you were seeing? |
My scenario is as following:
|
Yep, got the issue, thanks for the analysis. I will investigate how to solve it. |
@eyuval can you try the proposed PR? It worked in my tests but I would like to get confirmation from you too. |
Do not try to re-use net_context.user_data field as in many places (like in accept) it is expected to contain pointer to net_context. Storing the socket flags will corrupt the value. To simplify and make things less error prone, use socket specific field in net_context to store the socket flags. Fixes zephyrproject-rtos#19191 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
I tested the patch and for me it fixes the issue. Thanks. |
Do not try to re-use net_context.user_data field as in many places (like in accept) it is expected to contain pointer to net_context. Storing the socket flags will corrupt the value. To simplify and make things less error prone, use socket specific field in net_context to store the socket flags. Fixes #19191 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Do not try to re-use net_context.user_data field as in many places (like in accept) it is expected to contain pointer to net_context. Storing the socket flags will corrupt the value. To simplify and make things less error prone, use socket specific field in net_context to store the socket flags. Fixes zephyrproject-rtos#19191 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Do not try to re-use net_context.user_data field as in many places (like in accept) it is expected to contain pointer to net_context. Storing the socket flags will corrupt the value. To simplify and make things less error prone, use socket specific field in net_context to store the socket flags. Fixes #19191 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
I am using sockets in non-blocking mode, i.e. I set O_NONBLOCK flag for my listening socket and for all newly accepted sockets. The sock_set_flag function in subsys/net/lib/sockets/sockets_internal.h uses the low bits of the net_context user_data pointer to store the SOCK_EOF/SOCK_NONBLOCK flags. I encounter problems, e.g. in zsock_accepted_cb, because the user_data pointer is used without discarding the flag bits, resulting in a pointer, which is off from the true pointer by some bytes, dependent on the flags.
I am working in the native posix system:
CONFIG_BOARD="native_posix_64"
CONFIG_BOARD_NATIVE_POSIX_64BIT=y
The text was updated successfully, but these errors were encountered: