-
Notifications
You must be signed in to change notification settings - Fork 8.3k
net: Namespace network symbols to avoid conflicts with POSIX or libc #99169
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
net: Namespace network symbols to avoid conflicts with POSIX or libc #99169
Conversation
|
Initial work on namespacing the network APIs, this is WIP. Creating a draft in order to get some faster CI runs than what I can do locally. |
|
Instructions for the reviewers. The main changes are in
The majority of the other changes are just to there to support the API naming changes. |
cfriedt
left a comment
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.
Good work so far. I just left a couple of comments for non-sockaddr things. Although I'm sure you are already aware and planning for those too.
| static int send_temperature(struct coap_resource *resource, | ||
| const struct sockaddr *addr, socklen_t addr_len, | ||
| const struct net_sockaddr *addr, socklen_t addr_len, |
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.
socklen_t should probably also be changed to uint32_t within the network subsystem.
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 did not go that route, but just changed socklen_t to net_socklen_t. Not sure if we should do that uint32_t change as now it is easy to map the socklen variable between the network and Posix apis (because the naming is similar).
What other reviewers think about this, I am open to replace net_socklen_t if there are good arguments for it.
| addr.hci_channel = HCI_CHANNEL_USER; | ||
|
|
||
| if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { | ||
| if (bind(fd, (struct net_sockaddr *)&addr, sizeof(addr)) < 0) { |
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.
Calls to bind() should also be replaced with zsock_bind() (unless being used via POSIX through a sample).
Similarly, connect(), close(), should be switched to zsock_connect(), zsock_close(), etc.
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.
That file is for native_sim driver so I think I need to remove all the changes I did there.
| } | ||
|
|
||
| if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { | ||
| if (connect(fd, (struct net_sockaddr *)&addr, sizeof(addr)) < 0) { |
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.
This should use zsock_connect()
| { | ||
| struct net_eth_hdr *eth_hdr = (struct net_eth_hdr *)rx_buf; | ||
|
|
||
| switch (ntohs(eth_hdr->type)) { |
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.
we should have a non-POSIX version of ntohs() and others too.
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.
Yes, I will change these. I started to change the source all over the code base but there was just so much of it, so I decided to concentrate my efforts first to subsys/net, tests/net and include/zephyr/net directories. Some of the drivers contain already changes and I will continue this work.
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.
Thanks @jukkar , overall it is looking good to me :)
4a5aa36 to
1f46999
Compare
Rename network symbols in modem drivers to use the renamed network APIs. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Rename network symbols in usb drivers to use the renamed network APIs. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Rename network symbols in wifi drivers to use the renamed network APIs. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Removing Posix header inclusion as networking APIs and code should be self contained now. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Do not include Posix header files inside network stack as we should not depend on Posix symbols in net stack. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Use namespaced network symbols in order to avoid circular dependency between Posix and network subsystems. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We need certain network related Posix header files so that the network sample compiles ok. Previously the Posix symbols were introduced by network stack automatically even if user had not enabled Posix, but that is no longer the case. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We need certain network related Posix header files so that the network tests using Posix symbols compiles ok. Previously the Posix symbols were introduced by network stack automatically, but that is no longer the case. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Mark the err variable as possibly unsed depending on the enabled config options. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Compliance checker complains
TYPO_SPELLING: 'in in' may be misspelled - perhaps 'is in'?
for code like this
static struct net_sockaddr_in in_addr_my = {
so change the variable to ipv4_addr_my. Similar change is
done for IPv6 variables for consistency.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The network backend needs nothing from Posix so remove the dependency. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make sure we test coap client/server, MQTT SN, telnet and logging network backend when testing all network options. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
cb7bee8 to
eea9c41
Compare
|
|
|
If CI fails or something requires me to send a new version, I will also add a commit adding a note to migration guide. Otherwise I will send the migration guide changes in a separate PR immediately after this is merged. |
This commit aims to refactor the application code after network namespace symbols have been changed zephyrproject-rtos#99169 Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
In this commit, `net_socket_service_register` is called when a platform module that has sockets is deinitialized, and it's socket/sockets are closed. This commit also handles a case when a module tries to join a multicast group and a subscription, from another module, is already present. Also, covered network namespace changes done in zephyrproject-rtos#99169 Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
In this commit, `net_socket_service_register` is called when a platform module that has sockets is deinitialized, and it's socket/sockets are closed. This commit also handles a case when a module tries to join a multicast group and a subscription, from another module, is already present. Also, covered network namespace changes done in zephyrproject-rtos#99169 Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
In this commit, `net_socket_service_register` is called when a platform module that has sockets is deinitialized, and it's socket/sockets are closed. This commit also handles a case when a module tries to join a multicast group and a subscription, from another module, is already present. Also, covered network namespace changes done in #99169 Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>



Rename network symbols i.e., add
net_,NET_orZSOCK_prefixes to those network symbols that can be found in POSIX or libc. This way we can avoid circular dependency issues.Fixes #97050