-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
mgmt: hawkbit: change hawkbit interface to support directly supplying server ip address #89374
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
15a849a
to
da6c9dd
Compare
@nealjack please remove the unrelated samples: sensor: lps22hh: fix title commit |
a6d7986
to
5512401
Compare
7009027
to
ba503e5
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 fix the documentation
include/zephyr/mgmt/hawkbit/config.h
Outdated
/** | ||
* @brief Set the hawkBit server hostname. | ||
* | ||
* @param hostname_str Server hostname to set. |
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.
It should be domain_str
- that's why documentation build fails.
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.
Thanks - should be fixed in the rebase
@nealjack rebase needed |
ba503e5
to
1037d39
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 <neal@blueirislabs.com>
1037d39
to
8111575
Compare
|
@nealjack pls rebase, due to some bug that failed ci and is now fixed in the current main |
Apparently rerun was enough, no need to rebase. |
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.