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

[PATCH 2/3 master f15-branch] Add support for ipv6 to gateway boot option (#677609)



I am consolidating added code with that of kickstart in
following patch, so that this safer part has better chance to
go into f15.

---
 loader/loader.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index 9c0ca77..208ed7d 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1089,7 +1089,33 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
             } else if (!strcasecmp(k, "netmask")) {
                 loaderData->netmask = g_strdup(v);
             } else if (!strcasecmp(k, "gateway")) {
-                loaderData->gateway = g_strdup(v);
+                char *gateway = g_strdup(v);
+                int rc;
+                struct in_addr addr;
+#ifdef ENABLE_IPV6
+                struct in6_addr addr6;
+#endif
+
+                if ((rc = inet_pton(AF_INET, gateway, &addr)) == 1) {
+                    loaderData->gateway = gateway;
+                } else if (rc == 0) {
+#ifdef ENABLE_IPV6
+                    if ((rc = inet_pton(AF_INET6, gateway, &addr6)) == 1) {
+                        loaderData->gateway6 = gateway;
+                    } else if (rc == 0) {
+#endif
+                        logMessage(WARNING,
+                                   "invalid address in boot option gateway");
+#ifdef ENABLE_IPV6
+                    } else {
+                        logMessage(ERROR, "%s (%d): %s", __func__, __LINE__,
+                                   strerror(errno));
+                    }
+#endif
+                } else {
+                    logMessage(ERROR, "%s (%d): %s", __func__, __LINE__,
+                               strerror(errno));
+                }
             } else if (!strcasecmp(k, "dns")) {
                 loaderData->dns = g_strdup(v);
             } else if (!strcasecmp(k, "ethtool")) {
-- 
1.7.2


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