busybox: udhcpc6: return error when interface is down
Busybox dhcp will quit without error if the interface is down during a
dhcp loop. Systemd needs to restart it if such error occurs so we need
to return failures.
Tested:
systemctl start gbmc-br-dhcp
ip link set eth0 down
Dec 15 11:05:24 yscef4-nfd01.prod.google.com systemd[1]: gbmc-br-dhcp.service: Scheduled restart job, restart counter is at 2.
Dec 15 11:05:24 yscef4-nfd01.prod.google.com systemd[1]: Stopped gBMC DHCP Client.
Dec 15 11:05:24 yscef4-nfd01.prod.google.com systemd[1]: Starting gBMC DHCP Client...
Dec 15 11:05:24 yscef4-nfd01.prod.google.com systemd[1]: Started gBMC DHCP Client.
Dec 15 11:05:24 yscef4-nfd01.prod.google.com udhcpc6[4823]: udhcpc6: can't get link-local IPv6 address
Dec 15 11:05:24 yscef4-nfd01.prod.google.com systemd[1]: gbmc-br-dhcp.service: Main process exited, code=exited, status=1/FAILURE
Dec 15 11:05:24 yscef4-nfd01.prod.google.com systemd[1]: gbmc-br-dhcp.service: Failed with result 'exit-code'.
Dec 15 11:05:29 yscef4-nfd01.prod.google.com systemd[1]: gbmc-br-dhcp.service: Scheduled restart job, restart counter is at 3.
Dec 15 11:05:29 yscef4-nfd01.prod.google.com systemd[1]: Stopped gBMC DHCP Client.
Dec 15 11:05:29 yscef4-nfd01.prod.google.com systemd[1]: Starting gBMC DHCP Client...
Dec 15 11:05:29 yscef4-nfd01.prod.google.com systemd[1]: Started gBMC DHCP Client.
Dec 15 11:05:29 yscef4-nfd01.prod.google.com udhcpc6[4829]: udhcpc6: can't get link-local IPv6 address
Dec 15 11:05:29 yscef4-nfd01.prod.google.com systemd[1]: gbmc-br-dhcp.service: Main process exited, code=exited, status=1/FAILURE
Change-Id: I242b7507b8d75bd55c173a6405353ee5ac331e41
Signed-off-by: Yuxiao Zhang <yuxiaozhang@google.com>
(cherry picked from commit d2359615af1a5fc16f41e5380ebd5c8b4130e62a)
diff --git a/recipes-core/busybox/busybox/0001-udhcpc6-return-error-in-interface-read-failure-in-dh.patch b/recipes-core/busybox/busybox/0001-udhcpc6-return-error-in-interface-read-failure-in-dh.patch
new file mode 100644
index 0000000..8910ed2
--- /dev/null
+++ b/recipes-core/busybox/busybox/0001-udhcpc6-return-error-in-interface-read-failure-in-dh.patch
@@ -0,0 +1,38 @@
+From ffa00c98515c5cda16c7fc454bdb1d18ae6e2525 Mon Sep 17 00:00:00 2001
+From: Yuxiao Zhang <yuxiaozhang@google.com>
+Date: Fri, 15 Dec 2023 09:44:04 -0800
+Subject: [PATCH] udhcpc6: return error in interface read failure in dhcp loop
+
+The interface can be reconfigured during the dhcp process and such
+should be a failure instead of success. We rely on systemd to restart
+the dhcp service in that case.
+
+Patch Tracking Bug: N/A
+Upstream-Status: Pending
+Justification: Need to check with busybox maintainer and see if they
+want to return failure with this specific case, we need this because we
+rely on systemd to restart the service if dhcp fails because of
+interface reconfiguration.
+Signed-off-by: Yuxiao Zhang <yuxiaozhang@google.com>
+---
+ networking/udhcp/d6_dhcpc.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
+index 8e7e6d07b..86df60857 100644
+--- a/networking/udhcp/d6_dhcpc.c
++++ b/networking/udhcp/d6_dhcpc.c
+@@ -1385,7 +1385,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
+ &client6_data.ll_ip6,
+ client_data.client_mac)
+ ) {
+- goto ret0; /* iface is gone? */
++ /* iface is gone? */
++ retval=1;
++ goto ret;
+ }
+
+ if (clientid_mac_ptr)
+--
+2.43.0.472.g3155946c3a-goog
+
diff --git a/recipes-core/busybox/busybox_%.bbappend b/recipes-core/busybox/busybox_%.bbappend
index 344d7ff..f3b65e6 100644
--- a/recipes-core/busybox/busybox_%.bbappend
+++ b/recipes-core/busybox/busybox_%.bbappend
@@ -1,2 +1,5 @@
FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/busybox:"
-SRC_URI:append:gbmc = " file://0001-Work-around-broken-dhcp6-server-on-fqdn-option.patch"
+SRC_URI:append:gbmc = " \
+ file://0001-Work-around-broken-dhcp6-server-on-fqdn-option.patch \
+ file://0001-udhcpc6-return-error-in-interface-read-failure-in-dh.patch \
+ "