-
Notifications
You must be signed in to change notification settings - Fork 7.3k
mgmt: hawkbit: change hawkbit interface to support directly supplying server ip address #89374
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. |
Hello @nealjack, and thank you very much for your first pull request to the Zephyr project! |
962a99d
to
437b27e
Compare
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.
Please remove the subsys:
prefix from commit subject of the both commits, it is not needed
437b27e
to
c776b00
Compare
From what I know, when using a NAT64 and you want you want to resolve DNS addresses you should also have a DNS64 server, that will do the transition for you. You could even use a public DNS64 server like the one from Google (https://developers.google.com/speed/public-dns/docs/dns64) for that. The application and the end device should not care and therefore also not know, that there is even a NAT64 with a DNS64 in place. If that's not possible, I think it's better to implement some DNS64 resolver in |
Please note, that changes that are not directly related to each other, should at least go into their own commit. This is even more unrelated and I recommend splitting it into it's own PR. |
Should it be though? https://man7.org/linux/man-pages/man3/getaddrinfo.3.html makes no mention of DNS64, there is |
I agree we should avoid API changes, although I also see a need to be able to specify hostname when using numeric address representation for TLS purposes. How about we simplify the change set, I. e. keep the current configuration as is (use |
Unfortunately, the openthread border router implementation does not use a static, well-known NAT64 prefix (https://openthread.io/codelabs/openthread-border-router-nat64#1). It is dynamically generated and potentially different for every network. End devices must query for the prefix and synthesize an IPv6 address using I could see a world where zephyr's implementation of getaddrinfo does the translation if using Openthread as the L2 layer, but as @rlubos mentions, it would result in a non-standard getaddrinfo implementation.
I agree with this proposal. |
I will work on splitting the PR to address this. |
For that it's fine, but it should be put behind a Kconfig, which is disabled by default. |
Put it behind a Kconfig, then it can be implemented and activated for only that use case. |
c776b00
to
b551d00
Compare
b551d00
to
27a1b82
Compare
I split up this PR into three (#89500, #89497, and this one). I have updated this PR to address specifically adding a Yes, this is a workaround due to the Zephyr OS not providing support for NAT64 translation, especially with the dynamic NAT64 prefix generation that Openthread does. I don't think there was consensus about whether to alter However, I am wondering if it would be more appropriate to alter Zephyr's DNS Resolve Library to be Openthread/NAT64 aware, as it is a zephyr-specific library above lower level posix calls. It allows users to provide a list of DNS servers at runtime and could be altered to accept a NAT64 prefix for translation at runtime too. This would require changing the hawkbit subsystem to use the async DNS resolve library. I'm open to any ideas or thoughts. |
Note that getaddrinfo is using the zephyr dns resolver lib and not the other way around. |
@nealjack please check the compliance checks. you f.e. forgot the <> around your email in the signed off |
27a1b82
to
15a849a
Compare
15a849a
to
da6c9dd
Compare
@nealjack please remove the unrelated samples: sensor: lps22hh: fix title commit |
374d1e1
to
a6d7986
Compare
Previously, hawkbit interface only supported a url/hostname and a port, and internally it resolves to an IP address. This does not work for network layers that rely on NAT64, like OpenThread. Zephyr's implementation of `getaddrinfo` is not aware of NAT64. DNS will resolve an IPV4 address that needs to be converted to IPV6 with the NAT64 prefix. This commit alters the Hawkbit interface to allow providing an explicit domain name as a string via `server_domain`, and an already resolved IP address as `server_addr`. This commit changes the usage of `hawkbit_runtime_config.server_addr` to point to either an IP address or domain name. It adds a new Kconfig (`HAWKBIT_USE_DOMAIN_NAME`) to specify an explicit domain name and adds a new variable `hawkbit_runtime_config.server_domain`. If `HAWKBIT_USE_DOMAIN_NAME` is enabled and a user provides an IP address to `server_addr`, the user must provide a domain name to `server_domain`. Signed-off-by: Neal Jackson <[email protected]>
a6d7986
to
5512401
Compare
The hawkbit subsystem assumes that
getaddrinfo
will supply a valid, usable IP address. This isn't the case when using a network layer that depends on NAT64 for IPv4 traffic, like OpenThread. A DNS address obtained while behind a NAT64 requires conversion to IPv6 and adding the NAT64 prefix. As of now,getaddrinfo
is not aware of NAT64 and does not handle this. In this case it can be better for the application itself to handle DNS resolution and provide properly prefixed IP addresses to the hawkbit subsystem.This pull request adds an additional interface field (
server_hostname
) for the server hostname and changesserver_addr
to optionally point to an IP address. This is a potentially less confusing naming scheme, as hawkbit does not currently work if an address is provided toserver_addr
instead of a hostname.This commit also increases the default DNS name length slightly to accommodate larger hostnames longer than 20 bytes, i.e. (hawkbit.yourcompany.com). I also added some error handling in case a hostname is too long, so the hawkbit interface returns an error instead of quietly using a truncated and incorrect hostname.
This commit also changes how the
controllerId
is generated based on device id, and disentangles the two. ThecontrollerId
is what hawkbit uses to uniquely identify a device, and is not necessarily the same as the device id, and should be fully customizable by the user if needed. Previously, all custom device ids were being prepended withCONFIG_BOARD
. When a user selectsCONFIG_HAWKBIT_CUSTOM_DEVICE_ID
, they should be able to specify the fullcontrollerId
used with hawkbit.