From fe803a577ce01acc1eb46239e54eb67b8b38f6df Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 2 Jul 2019 09:45:22 +0200 Subject: [PATCH] initrd: allow specifying the net mask in form of a prefix This is not documented in dracut.cmdline(7), however it seems to have worked and has users and Red Hat even seems to recommend this (thanks to Dan Horak for the pointers): https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-installer-booting-ipl-s390 https://bugzilla.redhat.com/show_bug.cgi?id=1725872 (cherry picked from commit 390d79079eeabe6879f19ee9afee7ca8e1c6b778) --- src/initrd/nmi-cmdline-reader.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index ae33576956..a8f015493a 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -270,11 +270,13 @@ parse_ip (GHashTable *connections, const char *sysfs_dir, char *argument) if (netmask && *netmask) { NMIPAddr addr; - if (nm_utils_parse_inaddr_bin (AF_INET, netmask, NULL, &addr)) { + if (nm_utils_parse_inaddr_bin (AF_INET, netmask, NULL, &addr)) client_ip_prefix = nm_utils_ip4_netmask_to_prefix (addr.addr4); - } else { + else + client_ip_prefix = _nm_utils_ascii_str_to_int64 (netmask, 10, 0, 32, -1); + + if (client_ip_prefix == -1) _LOGW (LOGD_CORE, "Invalid IP mask: %s", netmask); - } } /* Static IP configuration might be present. */