[PATCH 1/2 rhel6-branch] Support prefix length in ipv6= cmdline option (#679108)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



e.g. ipv6=2001:aaaa::1/48

Related: rhbz#679108
---
 loader/loader.c |   24 ++++++++++++------------
 loader/net.c    |   16 ++++++++++++++++
 loader/net.h    |    1 +
 3 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index 0c1aeb4..177d8a3 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -748,19 +748,14 @@ static void readNetInfo(struct loaderData_s ** ld) {
                     loaderData->gateway = strdup(val);
 #ifdef ENABLE_IPV6
                 } else if (!g_strcmp0(pair[0], "IPV6ADDR")) {
-                    gchar **elements = g_strsplit(val, "/", 2);
-
-                    if (elements[0]) {
-                        loaderData->ipv6 = strdup(elements[0]);
+                    if (split_ipv6addr_prefix_length(val,
+                                                     &(loaderData->ipv6),
+                                                     &(loaderData->ipv6prefix))) {
                         loaderData->ipv6info_set = 1;
                         flags |= LOADER_FLAGS_IPV6_PARAM;
-                        if (elements[1]) {
-                            loaderData->ipv6prefix = strdup(elements[1]);
-                        }
                     } else {
                       logMessage(WARNING, "readNetInfo could not parse IPV6ADDR: %s", val);
                     }
-                    g_strfreev(elements);
                 } else if (!g_strcmp0(pair[0], "IPV6_DEFAULTGW")) {
                     loaderData->gateway6 = strdup(val);
 #endif
@@ -866,13 +861,18 @@ static void parseCmdLineIp(struct loaderData_s * loaderData, char *argv)
 
 #ifdef ENABLE_IPV6
 /*
- * parse anaconda ipv6= arguments
+ * parse anaconda ipv6= arguments - split prefix length if found
  */
 static void parseCmdLineIpv6(struct loaderData_s * loaderData, char *argv)
 {
-    loaderData->ipv6 = strdup(argv+5);
-    loaderData->ipv6info_set = 1;
-    flags |= LOADER_FLAGS_IPV6_PARAM;
+    if (split_ipv6addr_prefix_length(argv+5,
+                                     &(loaderData->ipv6),
+                                     &(loaderData->ipv6prefix))) {
+        loaderData->ipv6info_set = 1;
+        flags |= LOADER_FLAGS_IPV6_PARAM;
+    } else {
+      logMessage(WARNING, "parseCmdLineIpv6 could not parse %s", argv);
+    }
 }
 #endif
 
diff --git a/loader/net.c b/loader/net.c
index 92bfe27..fc4e271 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -243,6 +243,22 @@ static void parseEthtoolSettings(struct loaderData_s * loaderData) {
     free(buf);
 }
 
+int split_ipv6addr_prefix_length(char *str, char **address, char **prefix) {
+    gchar **elements = g_strsplit(str, "/", 2);
+    int rc = 0;
+
+    if (elements[0]) {
+        *address = strdup(elements[0]);
+        if (elements[1]) {
+            *prefix = strdup(elements[1]);
+        }
+        rc = 1;
+    }
+    g_strfreev(elements);
+    return rc;
+}
+
+
 /* given loader data from kickstart, populate network configuration struct */
 void setupIfaceStruct(iface_t * iface, struct loaderData_s * loaderData) {
     struct in_addr addr;
diff --git a/loader/net.h b/loader/net.h
index a737e0c..e23582a 100644
--- a/loader/net.h
+++ b/loader/net.h
@@ -83,5 +83,6 @@ void splitHostname (char *str, char **host, char **port);
 int wait_for_iface_activation(char * ifname);
 int wait_for_iface_disconnection(char *ifname);
 int isURLRemote(char *url);
+int split_ipv6addr_prefix_length(char *str, char **address, char **prefix);
 
 #endif
-- 
1.7.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux