From ed9065928afadda376666856407d03c3928a869c Mon Sep 17 00:00:00 2001 From: Miroslav Rezanina Date: Wed, 24 Jun 2026 10:28:51 +0200 Subject: [PATCH] * Wed Jun 24 2026 Miroslav Rezanina - 0-0.51.20220731git - hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch [RHEL-185419] - Resolves: RHEL-185419 (Hyper-V host fails to display guest IP address in certain network configurations [rhel-10]) --- hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch | 199 ++++++++++++++++++++ hyperv-daemons.spec | 9 +- 2 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch diff --git a/hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch b/hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch new file mode 100644 index 0000000..87c240f --- /dev/null +++ b/hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch @@ -0,0 +1,199 @@ +From 6ca5527f3de716ec307a3b4b6741878fff591a7e Mon Sep 17 00:00:00 2001 +From: Vitaly Kuznetsov +Date: Tue, 16 Jun 2026 14:35:22 +0200 +Subject: [PATCH] hv/hv_kvp_daemon: Update to v6.16 + +RH-Author: Vitaly Kuznetsov +RH-MergeRequest: 15: hv/hv_kvp_daemon: properly parse routes +RH-Jira: RHEL-185419 +RH-Acked-by: roverflow +RH-Acked-by: Ani Sinha +RH-Commit: [1/1] 363301883516a59beb498e4e77deae44bfba4cc4 (vkuznets/hyperv-daemons) + +JIRA: https://redhat.atlassian.net/browse/RHEL-185419 + +Pick two commits from upstream: + +commit 9bbb8a07fd65fca0f29a869ec3f2435761a6c676 +Author: Olaf Hering +Date: Mon Dec 2 11:19:55 2024 +0100 + + tools/hv: update route parsing in kvp daemon + +commit 175c71c2aceef173ae6d3dceb41edfc2ac0d5937 +Author: Olaf Hering +Date: Sun Dec 8 23:47:17 2024 +0000 + + tools/hv: reduce resource usage in hv_kvp_daemon + +Signed-off-by: Vitaly Kuznetsov +--- + hv_kvp_daemon.c | 117 ++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 89 insertions(+), 28 deletions(-) + +diff --git a/hv_kvp_daemon.c b/hv_kvp_daemon.c +index 0775f9b..1f64c68 100644 +--- a/hv_kvp_daemon.c ++++ b/hv_kvp_daemon.c +@@ -24,6 +24,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -723,6 +724,88 @@ static void kvp_process_ipconfig_file(char *cmd, + pclose(file); + } + ++static bool kvp_verify_ip_address(const void *address_string) ++{ ++ char verify_buf[sizeof(struct in6_addr)]; ++ ++ if (inet_pton(AF_INET, address_string, verify_buf) == 1) ++ return true; ++ if (inet_pton(AF_INET6, address_string, verify_buf) == 1) ++ return true; ++ return false; ++} ++ ++static void kvp_extract_routes(const char *line, void **output, size_t *remaining) ++{ ++ static const char needle[] = "via "; ++ const char *match, *haystack = line; ++ ++ while ((match = strstr(haystack, needle))) { ++ const char *address, *next_char; ++ ++ /* Address starts after needle. */ ++ address = match + strlen(needle); ++ ++ /* The char following address is a space or end of line. */ ++ next_char = strpbrk(address, " \t\\"); ++ if (!next_char) ++ next_char = address + strlen(address) + 1; ++ ++ /* Enough room for address and semicolon. */ ++ if (*remaining >= (next_char - address) + 1) { ++ memcpy(*output, address, next_char - address); ++ /* Terminate string for verification. */ ++ memcpy(*output + (next_char - address), "", 1); ++ if (kvp_verify_ip_address(*output)) { ++ /* Advance output buffer. */ ++ *output += next_char - address; ++ *remaining -= next_char - address; ++ ++ /* Each address needs a trailing semicolon. */ ++ memcpy(*output, ";", 1); ++ *output += 1; ++ *remaining -= 1; ++ } ++ } ++ haystack = next_char; ++ } ++} ++ ++static void kvp_get_gateway(void *buffer, size_t buffer_len) ++{ ++ static const char needle[] = "default "; ++ FILE *f; ++ void *output = buffer; ++ char *line = NULL; ++ size_t alloc_size = 0, remaining = buffer_len - 1; ++ ssize_t num_chars; ++ ++ /* Show route information in a single line, for each address family */ ++ f = popen("ip --oneline -4 route show;ip --oneline -6 route show", "r"); ++ if (!f) { ++ /* Convert buffer into C-String. */ ++ memcpy(output, "", 1); ++ return; ++ } ++ while ((num_chars = getline(&line, &alloc_size, f)) > 0) { ++ /* Skip short lines. */ ++ if (num_chars <= strlen(needle)) ++ continue; ++ /* Skip lines without default route. */ ++ if (memcmp(line, needle, strlen(needle))) ++ continue; ++ /* Remove trailing newline to simplify further parsing. */ ++ if (line[num_chars - 1] == '\n') ++ line[num_chars - 1] = '\0'; ++ /* Search routes after match. */ ++ kvp_extract_routes(line + strlen(needle), &output, &remaining); ++ } ++ /* Convert buffer into C-String. */ ++ memcpy(output, "", 1); ++ free(line); ++ pclose(f); ++} ++ + static void kvp_get_ipconfig_info(char *if_name, + struct hv_kvp_ipaddr_value *buffer) + { +@@ -731,30 +814,7 @@ static void kvp_get_ipconfig_info(char *if_name, + char *p; + FILE *file; + +- /* +- * Get the address of default gateway (ipv4). +- */ +- sprintf(cmd, "%s %s", "ip route show dev", if_name); +- strcat(cmd, " | awk '/default/ {print $3 }'"); +- +- /* +- * Execute the command to gather gateway info. +- */ +- kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, +- (MAX_GATEWAY_SIZE * 2), INET_ADDRSTRLEN, 0); +- +- /* +- * Get the address of default gateway (ipv6). +- */ +- sprintf(cmd, "%s %s", "ip -f inet6 route show dev", if_name); +- strcat(cmd, " | awk '/default/ {print $3 }'"); +- +- /* +- * Execute the command to gather gateway info (ipv6). +- */ +- kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, +- (MAX_GATEWAY_SIZE * 2), INET6_ADDRSTRLEN, 1); +- ++ kvp_get_gateway(buffer->gate_way, sizeof(buffer->gate_way)); + + /* + * Gather the DNS state. +@@ -771,7 +831,7 @@ static void kvp_get_ipconfig_info(char *if_name, + * . + */ + +- sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dns_info", if_name); ++ sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dns_info", if_name); + + /* + * Execute the command to gather DNS info. +@@ -788,7 +848,7 @@ static void kvp_get_ipconfig_info(char *if_name, + * Enabled: DHCP enabled. + */ + +- sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name); ++ sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dhcp_info", if_name); + + file = popen(cmd, "r"); + if (file == NULL) +@@ -1652,8 +1712,9 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) + * invoke the external script to do its magic. + */ + +- str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s %s", +- "hv_set_ifconfig", if_filename, nm_filename); ++ str_len = snprintf(cmd, sizeof(cmd), "exec %s %s %s", ++ KVP_SCRIPTS_PATH "hv_set_ifconfig", ++ if_filename, nm_filename); + /* + * This is a little overcautious, but it's necessary to suppress some + * false warnings from gcc 8.0.1. +-- +2.52.0 + diff --git a/hyperv-daemons.spec b/hyperv-daemons.spec index 24d1b74..4238cc2 100644 --- a/hyperv-daemons.spec +++ b/hyperv-daemons.spec @@ -13,7 +13,7 @@ Name: hyperv-daemons Version: 0 -Release: 0.50%{?snapver}%{?dist} +Release: 0.51%{?snapver}%{?dist} Summary: Hyper-V daemons suite License: GPL-2.0-only @@ -87,6 +87,8 @@ Patch13: hpvd-Use-NetworkManager-information-to-report-DHCP-settin.patch Patch14: hpvd-Use-NetworkManager-information-to-report-DNS-setting.patch # For RHEL-95811 - [RHEL-10]Backport tools: hv: Enable debug logs for hv_kvp_daemon for RHEL 10 Patch15: hpvd-tools-hv-Enable-debug-logs-for-hv_kvp_daemon.patch +# For RHEL-185419 - Hyper-V host fails to display guest IP address in certain network configurations [rhel-10] +Patch16: hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch # Hyper-V is available only on x86 and aarch64 architectures # The base empty (a.k.a. virtual) package can not be noarch @@ -318,6 +320,11 @@ fi %{_sbindir}/vmbus_testing %changelog +* Wed Jun 24 2026 Miroslav Rezanina - 0-0.51.20220731git +- hpvd-hv-hv_kvp_daemon-Update-to-v6.16.patch [RHEL-185419] +- Resolves: RHEL-185419 + (Hyper-V host fails to display guest IP address in certain network configurations [rhel-10]) + * Fri Jun 20 2025 Miroslav Rezanina - 0-0.50.20220731git - hpvd-tools-hv-Enable-debug-logs-for-hv_kvp_daemon.patch [RHEL-95811] - Resolves: RHEL-95811