tools/hv: Make the sample hv_get_dhcp_info script more useful
authorBen Hutchings <benh@debian.org>
Sun, 15 Jun 2025 21:35:52 +0000 (23:35 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Sat, 20 Dec 2025 09:15:48 +0000 (10:15 +0100)
commita7509fd41ffd768a57d1ba0d6a7f905b2579ec3d
treef26afb3afd0014a7044b12e3f58694b8e4c90d6f
parentde512a61f0ee86e98cc2a7f909cf0c706d9aad6d
tools/hv: Make the sample hv_get_dhcp_info script more useful

Origin: https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit?id=29c75ddc2d1952528a1195b6ac52054c47c0ee89
Bug-Debian: https://bugs.debian.org/919350

Currently the sample hv_get_dhcp_info script only supports the old Red
Hat network-scripts configuration format and leaves everything else to
downstream distributions.

However, Network Manager and systemd-networkd are available across
many distributions, so it makes more sense to implement support for
them here.

Debian's ifupdown is also used in several distributions that are not
Debian derivatives, so I think it makes sense to implement support for
that here too.

Extend the script to support all of these:

- Add a report function that reports the status based on the result of
  the previous command
- Add a function for each configuration system that checks whether
  that system in use for the given interface, and:
  - If so, checks and reports the DHCP status
  - If not, returns failure
- Call each of those functions, exiting once one of them succeeds,
  with a final fallback to reporting 'Disabled'

The network-scripts check is placed last, because it only checks a
file and not the actual interface state and so is the least reliable
check.

Signed-off-by: Ben Hutchings <benh@debian.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tools-hv-Make-the-sample-hv_get_dhcp_info-script-mor.patch
tools/hv/hv_get_dhcp_info.sh