-
Notifications
You must be signed in to change notification settings - Fork 8.2k
net: net_mgmt events unique bits #88495
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
Conversation
Compress the network management layer codes down to a sequential range starting at 1. Signed-off-by: Jordan Yates <jordan@embeint.com>
Shift 8 bits assigned to the layer code to the command mask instead. Leaving 7 bits (128 options) for the layer mask is plenty of space considering that there are less than 16 layers defined in-tree. On the other hand, the Wi-Fi management layer already has more than 16 unique events that can be generated. Allowing each event to be assigned a bit requires more than the 16 bits currently available. Signed-off-by: Jordan Yates <jordan@embeint.com>
|
This needs a migration note as this is a public facing API. |
Of course, I am waiting to check there is consensus and CI doesn't throw up roadblocks first |
Transition net_mgmt event codes to be bit enumerations instead of integer enumerations. This is required in order for the standard usage (and documented behaviour) of ORing together events for `net_mgmt_init_event_callback` to work properly. Since `mgmt_run_slist_callbacks` runs the event handler if *ANY* bits between the occuring command code and the registered event command bits match, ORing together integers results in event being delivered to handlers that never asked for them. Signed-off-by: Jordan Yates <jordan@embeint.com>
ba7936f to
e42db1b
Compare
More importantly, there needs to be a solution for the IPv6 events as well if we are fixing this, which might affect the migration notes. |
If we want to fix this long standing awkwardness of the net_mgmt subsys, I'd be rather leaning towards this option, let's do it once and right. Yes, this will be pretty painful API change (every net_mgmt handler would need to be aligned), however,
|
|
Hold on gents. I think we cannot change the event numbering to be bits as we will run out of bits eventually even if allocating 64 bits for these. For the layer code, we could probably use some sanitation. I am not sure why those were "random" values. As the layers need to be unique, not sure how we can guarantee that there is no conflict, so should we have a registry of those values? |
If splitting IPv6 is a bad idea and 64 bits may not be enough in the future, the only remaining solution I see is changing the semantics of The current behaviour is nonsensical. |
|
The problem with subscribing at the base level and leaving the event defines as integers is that several current API functions are not possible to implement properly (and are therefore currently broken). e.g. |
|
I have created a dedicated issue discussing the problem and possible solutions: #88534 |
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Transition net_mgmt event codes to be bit enumerations instead of integer enumerations. This is required in order for the standard usage (and documented behaviour) of ORing together events for
net_mgmt_init_event_callbackto work properly.Since
mgmt_run_slist_callbacksruns the event handler if ANY bits between the occuring command code and the registered event command bits match, ORing together integers results in event being delivered to handlers that never asked for them.This requires shifting bits from the layer code to the command mask, since both WiFi and IPv6 both have more than 16 unique events.
NOTE: IPv6 actually has more than the 20 bits currently allocated, so I have left it out of the change for now. The options I see:
As a concrete example of what this change is fixing, on current main, running this function:
Will actually result in
wifi_mgmt_event_handlerbeing called for all of the following events:Since
NET_EVENT_WIFI_CMD_AP_STA_CONNECTED(15) shares bits with all of the above.