fix: dhcp client host name resend

Signed-off-by: Ejub Sabic <ejub1946@outlook.com>
This commit is contained in:
Ejub Sabic
2026-04-28 18:00:32 +02:00
parent 17965bf4cc
commit 08ca47fdab
2 changed files with 19 additions and 13 deletions
+14
View File
@@ -180,6 +180,20 @@ int dhcp_client_change(sr_session_ctx_t *session, struct lyd_node *config, struc
ifaces = lydx_get_descendant(config, "interfaces", "interface", NULL);
difaces = lydx_get_descendant(diff, "interfaces", "interface", NULL);
if (diff && lydx_get_xpathf(diff, "/ietf-system:system/hostname")) {
LYX_LIST_FOR_EACH(ifaces, iface, "interface") {
const char *ifname = lydx_get_cattr(iface, "name");
ipv4 = lydx_get_descendant(lyd_child(iface), "ipv4", NULL);
if (!ipv4)
continue;
dhcp = lydx_get_descendant(lyd_child(ipv4), "dhcp", NULL);
if (dhcp)
add(ifname, dhcp);
}
}
/* find the modified interfaces */
LYX_LIST_FOR_EACH(difaces, diface, "interface") {
const char *ifname = lydx_get_cattr(diface, "name");
+5 -13
View File
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
"""DHCP Hostname Resend
Verify that updating the system hostname regenerates the DHCP client
Finit service file so subsequent DHCP requests advertise the current
hostname (option 12, RFC 2132).
Verify that updating the system hostname restarts the DHCP client so
subsequent DHCP requests advertise the current hostname (option 12,
RFC 2132).
Regression test for a bug where the DHCP client callback only reacts
on diffs in infix-dhcp-client, so a standalone change of
ietf-system:system/hostname leaves the previously written
/etc/finit.d/available/dhcp-client-<iface>.conf untouched and the
running udhcpc keeps announcing the old name.
ietf-system:system/hostname leaves the running udhcpc untouched with
the old '-x hostname:' argument from when it was first started.
"""
@@ -17,13 +16,6 @@ import infamy
from infamy.util import until
def finit_conf(ssh, ifname):
"""Return the contents of the generated DHCP client Finit service file."""
path = f"/etc/finit.d/available/dhcp-client-{ifname}.conf"
cmd = ssh.runsh(f"cat {path} 2>/dev/null")
return cmd.stdout
def udhcpc_cmdline(ssh, ifname):
"""Return the NUL-separated argv of the running udhcpc for ifname."""
pidfile = f"/run/dhcp-client-{ifname}.pid"