X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fplatform-powerpc.c;h=22d213d0a6dac503267d277711f67b86f5b6c575;hp=ed5733eb6166f79d7a7dac2d802df8811381cdd1;hb=ecc2146363f272c5e34a4878d2144a01041d453f;hpb=093178c4a93ab6f25aa40101de1910368260228f diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index ed5733e..22d213d 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -4,9 +4,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -16,6 +16,7 @@ #include #include #include +#include #include "hostboot.h" #include "platform.h" @@ -287,7 +288,7 @@ static int parse_one_interface_config(struct config *config, char *confstr) { struct interface_config *ifconf; - char *tok, *saveptr; + char *tok, *tok_gw, *tok_url, *saveptr; ifconf = talloc_zero(config, struct interface_config); @@ -320,18 +321,26 @@ static int parse_one_interface_config(struct config *config, ifconf->static_config.address = talloc_strdup(ifconf, tok); - tok = strtok_r(NULL, ",", &saveptr); - if (tok) { - ifconf->static_config.gateway = - talloc_strdup(ifconf, tok); + /* + * If a url is set but not a gateway, we can accidentally + * interpret the url as the gateway. To avoid changing the + * parameter format check if the "gateway" is actually a + * pb-url if it's the last token. + */ + tok_gw = strtok_r(NULL, ",", &saveptr); + tok_url = strtok_r(NULL, ",", &saveptr); + + if (tok_gw) { + if (tok_url || !is_url(tok_gw)) + ifconf->static_config.gateway = + talloc_strdup(ifconf, tok_gw); + else + tok_url = tok_gw; } - tok = strtok_r(NULL, ",", &saveptr); - if (tok) { + if (tok_url) ifconf->static_config.url = - talloc_strdup(ifconf, tok); - } - + talloc_strdup(ifconf, tok_url); } else { pb_log("Unknown network configuration method %s\n", tok); goto out_err; @@ -1184,7 +1193,7 @@ static void get_ipmi_network_override(struct platform_powerpc *platform, memcpy(&cookie, &resp[i], sizeof(cookie)); cookie = __be32_to_cpu(cookie); if (cookie != magic_value) { - pb_log("%s: Incorrect cookie %x\n", __func__, cookie); + pb_log_fn("Incorrect cookie %x\n", cookie); return; } i += sizeof(cookie); @@ -1250,7 +1259,7 @@ static int load_config(struct platform *p, struct config *config) rc = parse_nvram(platform); if (rc) - pb_log("%s: Failed to parse nvram\n", __func__); + pb_log_fn("Failed to parse nvram\n"); populate_config(platform, config);