mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 06:00:08 +01:00
core: persist the bootfile from DHCP
The bootfile location is needed by the anaconda dracut module; write it to the device state file.
This commit is contained in:
parent
3c79944e15
commit
9a09c02012
3 changed files with 28 additions and 11 deletions
|
|
@ -2343,8 +2343,9 @@ _nm_config_state_set(NMConfig *self, gboolean allow_persist, gboolean force_pers
|
|||
"route-metric-default-aspired"
|
||||
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_ROUTE_METRIC_DEFAULT_EFFECTIVE \
|
||||
"route-metric-default-effective"
|
||||
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_ROOT_PATH "root-path"
|
||||
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_NEXT_SERVER "next-server"
|
||||
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_ROOT_PATH "root-path"
|
||||
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_NEXT_SERVER "next-server"
|
||||
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_DHCP_BOOTFILE "dhcp-bootfile"
|
||||
|
||||
static NM_UTILS_LOOKUP_STR_DEFINE(
|
||||
_device_state_managed_type_to_str,
|
||||
|
|
@ -2565,7 +2566,8 @@ nm_config_device_state_write(int ifindex,
|
|||
guint32 route_metric_default_aspired,
|
||||
guint32 route_metric_default_effective,
|
||||
const char * next_server,
|
||||
const char * root_path)
|
||||
const char * root_path,
|
||||
const char * dhcp_bootfile)
|
||||
{
|
||||
char path[NM_STRLEN(NM_CONFIG_DEVICE_STATE_DIR "/") + DEVICE_STATE_FILENAME_LEN_MAX + 1];
|
||||
GError *local = NULL;
|
||||
|
|
@ -2632,6 +2634,12 @@ nm_config_device_state_write(int ifindex,
|
|||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_ROOT_PATH,
|
||||
root_path);
|
||||
}
|
||||
if (dhcp_bootfile) {
|
||||
g_key_file_set_string(kf,
|
||||
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
||||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_DHCP_BOOTFILE,
|
||||
dhcp_bootfile);
|
||||
}
|
||||
|
||||
if (!g_key_file_save_to_file(kf, path, &local)) {
|
||||
_LOGW("device-state: write #%d (%s) failed: %s", ifindex, path, local->message);
|
||||
|
|
@ -2639,7 +2647,9 @@ nm_config_device_state_write(int ifindex,
|
|||
return FALSE;
|
||||
}
|
||||
_LOGT("device-state: write #%d (%s); managed=%s%s%s%s%s%s%s, "
|
||||
"route-metric-default=%" G_GUINT32_FORMAT "-%" G_GUINT32_FORMAT "%s%s%s%s%s%s",
|
||||
"route-metric-default=%" G_GUINT32_FORMAT "-%" G_GUINT32_FORMAT "%s%s%s"
|
||||
"%s%s%s"
|
||||
"%s%s%s",
|
||||
ifindex,
|
||||
path,
|
||||
_device_state_managed_type_to_str(managed),
|
||||
|
|
@ -2648,7 +2658,8 @@ nm_config_device_state_write(int ifindex,
|
|||
route_metric_default_aspired,
|
||||
route_metric_default_effective,
|
||||
NM_PRINT_FMT_QUOTED(next_server, ", next-server=", next_server, "", ""),
|
||||
NM_PRINT_FMT_QUOTED(root_path, ", root-path=", root_path, "", ""));
|
||||
NM_PRINT_FMT_QUOTED(root_path, ", root-path=", root_path, "", ""),
|
||||
NM_PRINT_FMT_QUOTED(dhcp_bootfile, ", dhcp-bootfile=", dhcp_bootfile, "", ""));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,8 @@ gboolean nm_config_device_state_write(int
|
|||
guint32 route_metric_default_aspired,
|
||||
guint32 route_metric_default_effective,
|
||||
const char * next_server,
|
||||
const char * root_path);
|
||||
const char * root_path,
|
||||
const char * dhcp_bootfile);
|
||||
|
||||
void nm_config_device_state_prune_stale(GHashTable *preserve_ifindexes,
|
||||
NMPlatform *preserve_in_platform);
|
||||
|
|
|
|||
|
|
@ -6803,8 +6803,9 @@ nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifinde
|
|||
guint32 route_metric_default_effective;
|
||||
NMTernary nm_owned;
|
||||
NMDhcpConfig * dhcp_config;
|
||||
const char * next_server = NULL;
|
||||
const char * root_path = NULL;
|
||||
const char * next_server = NULL;
|
||||
const char * root_path = NULL;
|
||||
const char * dhcp_bootfile = NULL;
|
||||
|
||||
NM_SET_OUT(out_ifindex, 0);
|
||||
|
||||
|
|
@ -6848,8 +6849,11 @@ nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifinde
|
|||
|
||||
dhcp_config = nm_device_get_dhcp_config(device, AF_INET);
|
||||
if (dhcp_config) {
|
||||
root_path = nm_dhcp_config_get_option(dhcp_config, "root_path");
|
||||
next_server = nm_dhcp_config_get_option(dhcp_config, "next_server");
|
||||
root_path = nm_dhcp_config_get_option(dhcp_config, "root_path");
|
||||
next_server = nm_dhcp_config_get_option(dhcp_config, "next_server");
|
||||
dhcp_bootfile = nm_dhcp_config_get_option(dhcp_config, "filename");
|
||||
if (!dhcp_bootfile)
|
||||
dhcp_bootfile = nm_dhcp_config_get_option(dhcp_config, "bootfile_name");
|
||||
}
|
||||
|
||||
if (!nm_config_device_state_write(ifindex,
|
||||
|
|
@ -6860,7 +6864,8 @@ nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifinde
|
|||
route_metric_default_aspired,
|
||||
route_metric_default_effective,
|
||||
next_server,
|
||||
root_path))
|
||||
root_path,
|
||||
dhcp_bootfile))
|
||||
return FALSE;
|
||||
|
||||
NM_SET_OUT(out_ifindex, ifindex);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue