summaryrefslogtreecommitdiff
path: root/boot/pxe_utils.c
diff options
context:
space:
mode:
authorMartyn Welch <martyn.welch@collabora.com>2024-10-09 14:15:38 +0100
committerTom Rini <trini@konsulko.com>2024-10-15 10:24:27 -0600
commitd2faad3ff31f0fab0cf280c05ee333992f7a7d27 (patch)
treedb4686097e1a44fb9717dc4ab0c79916a896c684 /boot/pxe_utils.c
parentd2061828a4c1b60b44cd2307b6a782ac2efbffbe (diff)
boot: pxe_utils: Add fallback support
When configured correctly, we can detect when boot fails after the boot process has been handed over to the kernel through the use of U-Boot's bootcount support. In some instances, such as when we are performing atomic updates via a system such as OSTree, it is desirable to provide a fallback option so that we can return to a previous (hopefully working) state. Add a "fallback" option to the supported extlinux configuration options that points to a label like "default" so that we can utilise this in later commits. Signed-off-by: Martyn Welch <martyn.welch@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/pxe_utils.c')
-rw-r--r--boot/pxe_utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 4e27842b088..a80119c9a3b 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -781,6 +781,7 @@ enum token_type {
T_IPAPPEND,
T_BACKGROUND,
T_KASLRSEED,
+ T_FALLBACK,
T_INVALID
};
@@ -814,6 +815,7 @@ static const struct token keywords[] = {
{"ipappend", T_IPAPPEND,},
{"background", T_BACKGROUND,},
{"kaslrseed", T_KASLRSEED,},
+ {"fallback", T_FALLBACK,},
{NULL, T_INVALID}
};
@@ -1356,6 +1358,18 @@ static int parse_pxefile_top(struct pxe_context *ctx, char *p, unsigned long bas
break;
+ case T_FALLBACK:
+ err = parse_sliteral(&p, &label_name);
+
+ if (label_name) {
+ if (cfg->fallback_label)
+ free(cfg->fallback_label);
+
+ cfg->fallback_label = label_name;
+ }
+
+ break;
+
case T_INCLUDE:
err = handle_include(ctx, &p,
base + ALIGN(strlen(b), 4), cfg,
@@ -1395,6 +1409,7 @@ void destroy_pxe_menu(struct pxe_menu *cfg)
free(cfg->title);
free(cfg->default_label);
+ free(cfg->fallback_label);
list_for_each_safe(pos, n, &cfg->labels) {
label = list_entry(pos, struct pxe_label, list);