-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Deprecate NET_SOCKETS_POSIX_NAMES option #69950
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
Deprecate NET_SOCKETS_POSIX_NAMES option #69950
Conversation
0ef2c42
to
7f26700
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really really like the idea to finally clean this up.
|
||
return ret; | ||
} | ||
|
||
/** POSIX wrapper for @ref zsock_sendto */ | ||
static inline ssize_t sendto(int sock, const void *buf, size_t len, int flags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, could we remove those duplicate wrappers already, and just use the POSIX headers below in case CONFIG_NET_SOCKETS_POSIX_NAMES
is enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If one sets CONFIG_NET_SOCKETS_POSIX_NAMES=y
and CONFIG_POSIX_API=n
, then there is a compilation error if these symbols are not in socket.h
. It looks like we are stuck with these until the NET_SOCKETS_POSIX_NAMES
is removed from the Kconfig file, and then we can remove the settings.
95f1acf
to
8a8a3bb
Compare
The test expects to use various POSIX APIs so enable the config. Enabling POSIX_API requires also increase of max file descriptors. Signed-off-by: Jukka Rissanen <[email protected]>
The setting is deprecated so change the code to either use the native zsock_* API or enable POSIX_API to use the BSD socket API. Signed-off-by: Jukka Rissanen <[email protected]>
42e9249
to
2847384
Compare
Changes:
|
Change the sample applications that use network socket API to use the POSIX_API config because the NET_SOCKETS_POSIX_NAMES is deprecated. Convert also the zsock_ API calls to plain BSD socket API calls when applicable. Signed-off-by: Jukka Rissanen <[email protected]>
The library should be using internal socket API functions so that we do not need to depend on POSIX_API. Signed-off-by: Jukka Rissanen <[email protected]>
The NET_SOCKET_POSIX_NAMES is deprecated so enable POSIX_API to use the socket API. Signed-off-by: Jukka Rissanen <[email protected]>
The option is deprecated so remove it from documentation. Signed-off-by: Jukka Rissanen <[email protected]>
Add CONFIG_NET_SOCKETS_POSIX_NAMES deprecation information. Signed-off-by: Jukka Rissanen <[email protected]>
This commit fixes this error seen in CI so that things work even if CONFIG_POSIX_API is enabled. subsys/shell/backends/shell_mqtt.c:727:12: error: conflicting types for 'write'; have 'int(const struct shell_transport *, const void *, size_t, size_t *)' 727 | static int write(const struct shell_transport *transport, const void *data, size_t length) include/zephyr/posix/unistd.h:230:9: note: previous declaration of 'write' with type 'ssize_t(int, const void *, size_t)' 230 | ssize_t write(int file, const void *buffer, size_t count); subsys/shell/backends/shell_mqtt.c:787:12: error: conflicting types for 'read'; have 'int(const struct shell_transport *, void *, size_t, size_t *)' 787 | static int read(const struct shell_transport *transport, void *data, size_t length, size_t *cnt) include/zephyr/posix/unistd.h:231:9: note: previous declaration of 'read' with type 'ssize_t(int, void *, size_t)' 231 | ssize_t read(int file, void *buffer, size_t count); Signed-off-by: Jukka Rissanen <[email protected]>
This fixes this error printed by CI: Too many thread objects (21) Increase CONFIG_MAX_THREAD_BYTES to 3 Signed-off-by: Jukka Rissanen <[email protected]>
The syscall name has _impl postfix so adjusting the stub name. zephyr-sdk-0.16.5-1/x86_64-zephyr-elf/bin/../lib/gcc/ x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld.bfd: app/libapp.a(lwm2m_engine.c.obj): in function `zsock_fcntl_impl': .../syscalls/socket.h:363: undefined reference to `z_impl_zsock_fcntl_impl' Signed-off-by: Jukka Rissanen <[email protected]>
If enabling CONFIG_POSIX_API, we get three file descriptors open before any socket descriptors. The sample exit criteria checks socket 0 and 1 which is no longer a valid one, so change the check to be either 0 or 3, and 1 or 4 so that the test can be run in both when POSIX API is enabled or disabled. Also disable color printing for the test run so that it is easier to read the output log. Signed-off-by: Jukka Rissanen <[email protected]>
Use only Zephyr specific POSIX header files so that the whole system is getting values from the same files. There was an issue with native_sim run of tests/net/socket/af_packet which had O_BLOCKING set to 0x4000 from include/zephyr/posix/fcntl.h, but then the file subsys/net/lib/socket/sockets.c was having O_BLOCKING set to 0x0800 because different header files were used. Signed-off-by: Jukka Rissanen <[email protected]>
Changing remaining users of fcntl.h to use the include from our own POSIX file so that the values in there are consistent in all parts of the sources. Signed-off-by: Jukka Rissanen <[email protected]>
The native_sim USB driver gives this error currently if one enables CONFIG_POSIX_API. drivers/usb/device/usb_dc_native_posix_adapt.c:22:10: \ fatal error: sys/un.h: No such file or directory 22 | #include <sys/un.h> | ^~~~~~~~~~ compilation terminated. Disable the netusb support from networking shells for native_sim board for now so that CI can pass. Signed-off-by: Jukka Rissanen <[email protected]>
2847384
to
259935c
Compare
Changes:
|
This is rad 🤙Thanks again @jukkar |
### Summary Zephyr [recently deprecated](zephyrproject-rtos/zephyr#69950) the `CONFIG_NET_SOCKETS_POSIX_NAMES` option, which was was previously `y` by default when `CONFIG_POSIX_API=n` but is now n by default. This option matters because it adds the POSIX API to the `net/socket.h` header, which we reference in `memfault_platform_http.c`. This fix instead makes our http client code include the `posix/*` headers to get the POSIX API. ### Test Plan Builds successfully.
### Summary Zephyr [recently deprecated](zephyrproject-rtos/zephyr#69950) the `CONFIG_NET_SOCKETS_POSIX_NAMES` option, which was was previously `y` by default when `CONFIG_POSIX_API=n` but is now `n` by default. This option matters because it adds the POSIX API to the `net/socket.h` header, which we reference in `memfault_platform_http.c`. This fix instead makes our http client code include the `posix/*` headers to get the POSIX API. ### Test Plan Builds successfully.
The
CONFIG_NET_SOCKETS_POSIX_NAMES
option is marked as deprecated in favor of using normal POSIX socket API includes found under theinclude/zephyr/posix
directory. If you want to use BSD socket API calls, you need to selectPOSIX_API
and use the socket headers found in the POSIX subsystem. If you do not want to or cannot enable POSIX_API, then you must usezsock_
prefix when working with BSD socket calls.This is initial work in order to simplify the network and Posix related config options. The use of
CONFIG_NET_SOCKETS_POSIX_NAMES
is currently confusing as it conflicts withCONFIG_POSIX_API
.