-
Notifications
You must be signed in to change notification settings - Fork 2.1k
gnrc_netif: fix highlander function #13736
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
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 fixes the issue I was observing and the logic is sound.
Meh, I now get an assertion error on the border router:
|
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.
NACK. IMHO gnrc_netif_highlander()
should stay an optimizing function. The tagline even says "there can onyl be one", not "there may only be one" ;-). Also using gnrc_netif_numof()
has the potential to bring very long runtimes (as it iterates over the list of all interfaces) if the number of interfaces is greater than 1. IMHO we should fix this rather in ping6
. udp send
in gnrc_networking
is still working.
Not just --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c
+++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c
@@ -28,7 +28,7 @@
void auto_init_gnrc_rpl(void)
{
- if (gnrc_netif_highlander()) {
+ if (gnrc_netif_numof() == 1) {
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
if (netif == NULL) {
/* XXX this is just a work-around ideally this would happen with
diff --git a/sys/net/gnrc/sock/include/gnrc_sock_internal.h b/sys/net/gnrc/sock/include/gnrc_sock_internal.h
index a91a94ce25..45eb29e9f5 100644
--- a/sys/net/gnrc/sock/include/gnrc_sock_internal.h
+++ b/sys/net/gnrc/sock/include/gnrc_sock_internal.h
@@ -95,7 +95,7 @@ static inline void gnrc_ep_set(sock_ip_ep_t *out, const sock_ip_ep_t *in,
size_t in_size)
{
memcpy(out, in, in_size);
- if (gnrc_netif_highlander()) {
+ if (gnrc_netif_numof() == 1) {
/* set interface implicitly */
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
diff --git a/sys/shell/commands/sc_gnrc_icmpv6_echo.c b/sys/shell/commands/sc_gnrc_icmpv6_echo.c
index 9dddcc8abe..623144333c 100644
--- a/sys/shell/commands/sc_gnrc_icmpv6_echo.c
+++ b/sys/shell/commands/sc_gnrc_icmpv6_echo.c
@@ -187,7 +187,7 @@ static int _configure(int argc, char **argv, _ping_data_t *data)
if (iface) {
data->netif = gnrc_netif_get_by_pid(atoi(iface));
}
- else if (gnrc_netif_highlander()) {
+ else if (gnrc_netif_numof() == 1) {
data->netif = gnrc_netif_iter(NULL);
}
@@ -371,7 +371,7 @@ static void _print_reply(_ping_data_t *data, gnrc_pktsnip_t *icmpv6,
data->num_recv++;
dupmsg += 7;
}
- if (gnrc_netif_highlander() || (if_pid == KERNEL_PID_UNDEF) ||
+ if ((gnrc_netif_numof() == 1) || (if_pid == KERNEL_PID_UNDEF) ||
!ipv6_addr_is_link_local(from)) {
printf("%u bytes from %s: icmp_seq=%u ttl=%u",
(unsigned)icmpv6->size,
|
Again |
But |
Yes, because there can be more (because interfaces are lists now, so dynamically enlargable).
Again, this function was introduced as a static optimization function and should only be used as such. |
|
This is legitimate. There are even warnings printed that configuration is missing in case
Dito. An API should not assume the interface that there is more than one interface possible. This was the same behavior before when
Will provide fix |
I'm all for whimsical names, but in this case maybe a |
as discussed offline with @miri64, it's probably a good idea to introduce a |
Ok, but I think this is a distinct effort from this PR and now that #13737 we can close this PR. |
Contribution description
This PR fixes the
gnrc_netif_highlander
function to provide the correct values when GNRC_NETIF_SINGLE is not defined. There are cases where GNRC_NETIF_SINGLE=0 but there's only one interface, which was not covered by the upstream implementation.This fixes the issue described in #12994 (comment)
Testing procedure
It should pass for both cases of GNRC_NETIF_SINGLE when there's only one interface. It should also pass when GNRC_NETIF_SINGLE=0 and there's more than one interface.
Issues/PRs references
Fixes #12994 (comment)