X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=lib%2Fpb-config%2Fstorage-powerpc-nvram.c;fp=lib%2Fpb-config%2Fstorage-powerpc-nvram.c;h=734741e2cb08340ab9660745b10423a2725d6359;hb=f53d1e4dc6735b90806ceed54f9d73572b5960f5;hp=e6bf7df5544408900d5b1c24fc0f9d608a076798;hpb=2b41985dde73e71daad90c36fa5d06c199da3ae1;p=petitboot diff --git a/lib/pb-config/storage-powerpc-nvram.c b/lib/pb-config/storage-powerpc-nvram.c index e6bf7df..734741e 100644 --- a/lib/pb-config/storage-powerpc-nvram.c +++ b/lib/pb-config/storage-powerpc-nvram.c @@ -243,7 +243,7 @@ static int parse_one_interface_config(struct config *config, } else if (!strcmp(tok, "static")) { ifconf->method = CONFIG_METHOD_STATIC; - /* ip/mask, [optional] gateway, [optional] dns */ + /* ip/mask, [optional] gateway */ tok = strtok_r(NULL, ",", &saveptr); if (!tok) goto out_err; @@ -254,13 +254,8 @@ static int parse_one_interface_config(struct config *config, if (tok) { ifconf->static_config.gateway = talloc_strdup(ifconf, tok); - tok = strtok_r(NULL, ",", &saveptr); } - if (tok) { - ifconf->static_config.dns = - talloc_strdup(config, tok); - } } else { pb_log("Unknown network configuration method %s\n", tok); goto out_err; @@ -279,6 +274,27 @@ out_err: return -1; } +static int parse_one_dns_config(struct config *config, + char *confstr) +{ + char *tok, *saveptr; + + for (tok = strtok_r(confstr, ",", &saveptr); tok; + tok = strtok_r(NULL, ",", &saveptr)) { + + char *server = talloc_strdup(config, tok); + + config->network.dns_servers = talloc_realloc(config, + config->network.dns_servers, const char *, + ++config->network.n_dns_servers); + + config->network.dns_servers[config->network.n_dns_servers - 1] + = server; + } + + return 0; +} + static void populate_network_config(struct powerpc_nvram_storage *nv, struct config *config) { @@ -299,7 +315,10 @@ static void populate_network_config(struct powerpc_nvram_storage *nv, if (!tok) break; - parse_one_interface_config(config, tok); + if (strncmp(tok, "dns,", strlen("dns,"))) + parse_one_dns_config(config, tok + strlen("dns,")); + else + parse_one_interface_config(config, tok); }