Skip to content

netutils: add netutils_get_ipv6()#16634

Merged
miri64 merged 6 commits intoRIOT-OS:masterfrom
benpicco:gnrc_netif_parse_hostname
Jul 21, 2021
Merged

netutils: add netutils_get_ipv6()#16634
miri64 merged 6 commits intoRIOT-OS:masterfrom
benpicco:gnrc_netif_parse_hostname

Conversation

@benpicco
Copy link
Copy Markdown
Contributor

Contribution description

Parsing the IP address / hostname currently involves a lot of boilerplate and copy & paste.
Only the version in gnrc_icmpv6_echo has support for DNS hostnames.

To reduce code duplication and ensure feature parity, add a new gnrc_netif_parse_hostname() helper function.

Testing procedure

Run examples/gnrc_networking. The ping command should still work as before, but now also the udp command can resolve hostnames via DNS if the sock_dns module is used.

Issues/PRs references

@benpicco benpicco added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Jul 10, 2021
@github-actions github-actions bot added Area: examples Area: Example Applications Area: network Area: Networking Area: sys Area: System labels Jul 10, 2021
@benpicco benpicco force-pushed the gnrc_netif_parse_hostname branch from ebdb2fa to 8e28ff4 Compare July 10, 2021 13:38
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 10, 2021
@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 12, 2021

Centralizing code is a good idea in general, but why put a hostname parser (more of an application layer thing) into gnrc_netif (network interfaces i.e. link layer)?

@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Jul 12, 2021

tbh I didn't know where else to put it - maybe create a gnrc/util folder, I also have a gnrc_netif_wait_for_prefix() that could go in there.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 12, 2021

tbh I didn't know where else to put it - maybe create a gnrc/util folder, I also have a gnrc_netif_wait_for_prefix() that could go in there.

Does it have to be part of GNRC even? From what I can tell, the only GNRC-specific thing is gnrc_netif_t which inherits from netif_t nowadays.

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jul 12, 2021

Does it have to be part of GNRC even? From what I can tell, the only GNRC-specific thing is gnrc_netif_t which inherits from netif_t nowadays.

I have the same concern. The whole snippet in gnrc_netif_parse_hostname is stack independent and there can be replaced by netif_xxx functions.

I'm also think this is more a kind of "netutils" rather than netif specific. But I could live with the later.

@benpicco
Copy link
Copy Markdown
Contributor Author

The "auto-detect interface if there is only one interface and address is link-local" part is GNRC specific though

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jul 12, 2021

The "auto-detect interface if there is only one interface and address is link-local" part is GNRC specific though

But what prevents to make it stack independent? And why it wouldn't be possible to still implement it in a generic way?

There's on-going work for using the netif interface as the OS entry point of an interface, instead of using gnrc_netif. We are already able to use e.g LWM2M with LWIP through #16563 and it will become more important to have these "generic" API (not GNRC, but rather OS entry points) when other stacks fully support netif_xxx (there's ongoing work for OpenThread).

It's true that it's not possible to write apps fully stack independent yet unfortunately, but removing gcoap and sock dependencies to GNRC will definitely help to move forward on this direction.

@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Jul 12, 2021

~~Is there a stack intependent alternative for gnrc_netif_iter()? ~~

nvm netif_iter() does exist.

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Jul 12, 2021

Is there a stack intependent alternative for gnrc_netif_iter()

Yes. Fetching interfaces, registering and setting/getting options is already implemented for GNRC and there's on-going work for LWIP. Same for OpenThread

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 12, 2021

nvm netif_iter() does exist.

Just remember, that the part after the % is the name, not the ID of the interface ;-).

@benpicco benpicco changed the title sys/net/gnrc/netif: add gnrc_netif_parse_hostname() sys/net/netif: add netif_parse_hostname() Jul 12, 2021
@benpicco benpicco changed the title sys/net/netif: add netif_parse_hostname() netutils: add netutil_parse_hostname() Jul 12, 2021
@benpicco benpicco force-pushed the gnrc_netif_parse_hostname branch 2 times, most recently from 36104d0 to 22253a0 Compare July 13, 2021 08:58
@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 13, 2021

All the tests using ping now don't have ping anymore ;-) that's why I proposed to make precursor PR instead ;-)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 13, 2021

And the fuzzing applications might also need that, but not sure. I guess all apps that include shell_commands and gnrc_icpmv6_echo require this module now.

@benpicco
Copy link
Copy Markdown
Contributor Author

I removed the changes to the ping command from this PR.

@benpicco benpicco force-pushed the gnrc_netif_parse_hostname branch from 22253a0 to 6633442 Compare July 13, 2021 09:41
@benpicco
Copy link
Copy Markdown
Contributor Author

It's only a dependency if also shell_commands is used.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 20, 2021

It's only a dependency if also shell_commands is used.

Exactly, so this should be reflected in the dependency resolution ;-) (same goes for xtimer/ztimer but that can be done as a follow-up).

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 20, 2021

(And it can then be removed from the example Makefiles btw. not sure why you try both in this PR then...)

@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Jul 20, 2021

so this should be reflected in the dependency resolution

What's wrong with

ifneq (,$(filter shell_commands,$(USEMODULE)))

  …

  ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
    USEMODULE += netutils
  endif

  …

endif

And it can then be removed from the example Makefiles btw.

Well the examples also use netutils_get_ipv6() in udp.c/gcoap_cli.c so I thought the proper thing to do would be not to rely on transient dependencies.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 20, 2021

Well the examples also use netutils_get_ipv6() in udp.c/gcoap_cli.c so I thought the proper thing to do would be not to rely on transient dependencies.

👍

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 20, 2021

so this should be reflected in the dependency resolution

What's wrong with

ifneq (,$(filter shell_commands,$(USEMODULE)))

  …

  ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
    USEMODULE += netutils
  endif

  …

endif

Ah, sorry, did not see this was in the dependency resolution of shell_commands. Then this is fine.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 20, 2021

However, please address the other concerns in my review as well.

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final nits. Please squash immediately.

@miri64 miri64 added the CI: run tests If set, CI server will run tests on hardware for the labeled PR label Jul 20, 2021
@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 20, 2021

(also, a Makefile.ci is required for the new test).

@benpicco benpicco force-pushed the gnrc_netif_parse_hostname branch from b18183a to dead4fe Compare July 20, 2021 20:45
@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 21, 2021

@benpicco
[tests/riotboot_flashwrite: add nucleo-g07xrb to Makefile.ci](/RIOT-OS/RIOT/pull/16634/commits/e2a8c2506f509b392e20bbeb8236d52fc6b3e51a)

How is that one growing?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 21, 2021

@benpicco
[tests/riotboot_flashwrite: add nucleo-g07xrb to Makefile.ci](/RIOT-OS/RIOT/pull/16634/commits/e2a8c2506f509b392e20bbeb8236d52fc6b3e51a)

How is that one growing?

Ah, because it is using said new module and abstraction always has cost ;-).

@miri64 miri64 merged commit 7793098 into RIOT-OS:master Jul 21, 2021
@benpicco benpicco deleted the gnrc_netif_parse_hostname branch July 21, 2021 09:00
@benpicco benpicco changed the title netutils: add netutils_parse_hostname() netutils: add netutils_get_ipv6() Aug 11, 2021
@benpicco benpicco added this to the Release 2021.10 milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: examples Area: Example Applications Area: network Area: Networking Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants