mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 19:20:12 +01:00
initrd: prepare interface in rd.znet only if persistent interface names are enabled
When processing the rd.znet option set the interface name only in case when the persistent interface names feature isn't disabled via net.ifnames=0 [lkundrak@v3.sk: minor tweaks to the net.ifnames=0 parsing]
This commit is contained in:
parent
c27f5030e9
commit
c7423dca89
1 changed files with 26 additions and 14 deletions
|
|
@ -683,27 +683,18 @@ parse_rd_peerdns (GHashTable *connections, char *argument)
|
|||
}
|
||||
|
||||
static void
|
||||
parse_rd_znet (GHashTable *connections, char *argument)
|
||||
parse_rd_znet (GHashTable *connections, char *argument, gboolean net_ifnames)
|
||||
{
|
||||
const char *nettype;
|
||||
const char *subchannels[4] = { 0, 0, 0, 0 };
|
||||
const char *tmp;
|
||||
const char *ifname, *prefix;
|
||||
const char *bus_id;
|
||||
size_t bus_id_len;
|
||||
size_t bus_id_start;
|
||||
gs_free char *ifname = NULL;
|
||||
const char *prefix;
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
|
||||
nettype = get_word (&argument, ',');
|
||||
subchannels[0] = get_word (&argument, ',');
|
||||
|
||||
/* The following logic is taken from names_ccw() in systemd/src/udev/udev-builtin-net_id.c */
|
||||
bus_id = subchannels[0];
|
||||
bus_id_len = strlen (bus_id);
|
||||
bus_id_start = strspn (bus_id, ".0");
|
||||
bus_id += bus_id_start < bus_id_len ? bus_id_start : bus_id_len - 1;
|
||||
|
||||
subchannels[1] = get_word (&argument, ',');
|
||||
|
||||
if (nm_streq0 (nettype, "ctc")) {
|
||||
|
|
@ -713,7 +704,20 @@ parse_rd_znet (GHashTable *connections, char *argument)
|
|||
prefix = "en";
|
||||
}
|
||||
|
||||
ifname = g_strdup_printf ("%sc%s", prefix, bus_id);
|
||||
if (net_ifnames == TRUE) {
|
||||
const char *bus_id;
|
||||
size_t bus_id_len;
|
||||
size_t bus_id_start;
|
||||
|
||||
/* The following logic is taken from names_ccw() in systemd/src/udev/udev-builtin-net_id.c */
|
||||
bus_id = subchannels[0];
|
||||
bus_id_len = strlen (bus_id);
|
||||
bus_id_start = strspn (bus_id, ".0");
|
||||
bus_id += bus_id_start < bus_id_len ? bus_id_start : bus_id_len - 1;
|
||||
|
||||
ifname = g_strdup_printf ("%sc%s", prefix, bus_id);
|
||||
}
|
||||
|
||||
connection = get_conn (connections, ifname, NM_SETTING_WIRED_SETTING_NAME);
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
g_object_set (s_wired,
|
||||
|
|
@ -752,10 +756,18 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||
gboolean ignore_bootif = FALSE;
|
||||
gboolean neednet = FALSE;
|
||||
gs_free char *bootif_val = NULL;
|
||||
gboolean net_ifnames = TRUE;
|
||||
int i;
|
||||
|
||||
connections = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
if (strcmp (argv[i], "net.ifnames=0") == 0)
|
||||
net_ifnames = FALSE;
|
||||
else if (g_str_has_prefix (argv[i], "net.ifnames="))
|
||||
net_ifnames = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
gs_free char *argument_clone = NULL;
|
||||
char *argument;
|
||||
|
|
@ -787,7 +799,7 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||
else if (strcmp (tag, "rd.neednet") == 0)
|
||||
neednet = _nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||
else if (strcmp (tag, "rd.znet") == 0)
|
||||
parse_rd_znet (connections, argument);
|
||||
parse_rd_znet (connections, argument, net_ifnames);
|
||||
else if (strcasecmp (tag, "BOOTIF") == 0) {
|
||||
nm_clear_g_free (&bootif_val);
|
||||
bootif_val = g_strdup (argument);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue