-
Notifications
You must be signed in to change notification settings - Fork 2.1k
gnrc_netif: add gnrc_netif_highlander function #13226
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
In general 👍. I'm not 100% sure about the name, but maybe some sleep gets me over that. I also want to make some sample checks if the size does not change. |
hmmmm maybe |
My problem with both this name and the one proposed in the PR, is that it implies to me that the function returns |
|
@@ -333,7 +333,7 @@ static inline bool gnrc_netif_is_rtr_adv(const gnrc_netif_t *netif) | |||
* @brief Checks if the interface uses a protocol that requires 6Lo to run | |||
* | |||
* @attention Requires prior locking | |||
* @note Assumed to be true, when @ref GNRC_NETIF_NUMOF == 1 and | |||
* @note Assumed to be true, when @ref gnrc_netif_single return true and |
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.
Independent of the name
* @note Assumed to be true, when @ref gnrc_netif_single return true and | |
* @note Assumed to be true, when @ref gnrc_netif_single() return true and |
The more I think about it: Does anything speak against this joke ( |
+1 on my side :P |
Then lets go ahead with that :-) |
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.
At a closer glance, apart from the rename, there are some issues other issues:
sys/include/net/gnrc/netif.h
Outdated
if(GNRC_NETIF_NUMOF == 1) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} |
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.
Can be boiled down to
return (GNRC_NETIF_NUMOF == 1);
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 didn't have enough coffee that day
return gnrc_netif_is_rtr(netif) && gnrc_netif_is_6ln(netif); | ||
/* if flag checkers even evaluate, otherwise just assume their result */ | ||
if (GNRC_IPV6_NIB_CONF_6LR && (IS_USED(MODULE_GNRC_IPV6_ROUTER) || | ||
(GNRC_NETIF_NUMOF > 1) || |
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.
(GNRC_NETIF_NUMOF > 1) || | |
(!gnrc_netif_single()) || |
if((!gnrc_netif_single() && | ||
IS_USED(MODULE_GNRC_SIXLOWPAN)) || \ | ||
IS_USED(MODULE_GNRC_SIXLOENC)) { | ||
switch (netif->device_type) { | ||
#ifdef MODULE_GNRC_SIXLOENC | ||
case NETDEV_TYPE_ETHERNET: | ||
return (netif->flags & GNRC_NETIF_FLAGS_6LO); | ||
#endif | ||
case NETDEV_TYPE_IEEE802154: | ||
case NETDEV_TYPE_CC110X: | ||
case NETDEV_TYPE_BLE: | ||
case NETDEV_TYPE_NRFMIN: | ||
case NETDEV_TYPE_ESP_NOW: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} |
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.
Have you checked the memory impact of moving this to static inline
? examples/gnrc_border_router
should be the application to look at.
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, it increased. The last commit fixes that problem (gnrc_netif_is_6lo
is still static inline but I added a non-static function to check if the device requires 6Lo).
Now gnrc_border_router
has the same size with and without this PR :)
@miri64 may I squash? |
Yes, please! |
93338a2
to
0c54b77
Compare
done :) |
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.
Tested with make all
. The binaries for examples/gnrc_networking
/ examples/gnrc_border_router
do have the same size, but their make objdump
output differs (this might have different reasons though). For unification it could make sense to also adapt gnrc_netif_is_6ln()
to the new style, but this can also be done in a follow-up cleanup.
There were some errors due to functions defined with macros. Instead of adding "(void)" here and there, I changed those functions to their inline variant. |
Let's merge #13605 first |
Merged |
No need to let Murdock run this twice ;-). |
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.
Some style nits were introduced. Also, one style fix is possible without much notice.
Done. When I squash, I will also change the commit that introduces the function to reflect the new name of the function. |
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.
Murdock's not happy.
else { | ||
/* XXX this is just a work-around ideally this should be defined in some | ||
* run-time interface configuration */ | ||
DEBUG("auto_init_gnrc_rpl: please specify an interface" \ |
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.
You are removing a space here. The \
is also not necessary.
DEBUG("auto_init_gnrc_rpl: please specify an interface" \ | |
DEBUG("auto_init_gnrc_rpl: please specify an interface " |
@jia200x this needs rebasing now |
7ca3efb
to
c2e491d
Compare
squashed and rebased |
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.
ACK. Let's finally merge this! The line noted can also be fixed as a follow-up.
#ifdef MODULE_GNRC_SIXLOENC | ||
case NETDEV_TYPE_ETHERNET: | ||
return (netif->flags & GNRC_NETIF_FLAGS_6LO); | ||
#endif |
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.
In theory this can also use link-time optimization as well:
case NETDEV_TYPE_ETHERNET:
if (IS_USED(MODULE_GNRC_SIXLOENC)) {
return (netif->flags & GNRC_NETIF_FLAGS_6LO);
}
/* intentionally falls through */
Contribution description
This PR defines a
gnrc_netif_single
function that indicates if there's only one GNRC network interface.It has the same purpose of
GNRC_NETIF_NUMOF == 1
but having it as a function makes the migration to #12994 easier.I also rearranged some functions to use standard ifs instead of macros, so the code is more readable and can be checked by static tests.
Testing procedure
make doc
Issues/PRs references