initrd: use proper interface when adding s390 specific details

The current solution for s390 specific details relies on an interface to
exist before adding the s390 details. It means the ip= option must precede
the rd.znet= option. Also only a single interface can be configured. With
this change the s390 details are put to the right interface and properly
named interface is created if it hasn't existed yet.

(cherry picked from commit adcc52c3da)
This commit is contained in:
Dan Horák 2019-10-22 11:18:09 +02:00 committed by Lubomir Rintel
parent 9e6706edb7
commit deff651704

View file

@ -695,16 +695,33 @@ parse_rd_znet (GHashTable *connections, char *argument)
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;
NMConnection *connection;
NMSettingWired *s_wired;
nettype = get_word (&argument, ',');
subchannels[0] = get_word (&argument, ',');
subchannels[1] = get_word (&argument, ',');
if (!nm_streq0 (nettype, "ctc"))
subchannels[2] = get_word (&argument, ',');
connection = get_conn (connections, NULL, NM_SETTING_WIRED_SETTING_NAME);
/* 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")) {
prefix = "sl";
} else {
subchannels[2] = get_word (&argument, ',');
prefix = "en";
}
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,
NM_SETTING_WIRED_S390_NETTYPE, nettype,