Skip to content

Commit

Permalink
lkl: Properly apply network configuration specified in env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
midchildan committed Feb 28, 2019
1 parent 50107f4 commit 554684f
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions tools/lkl/lib/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,43 @@ int lkl_load_config_env(struct lkl_config *cfg)

if (!cfg)
return -1;
if (envtap || enviftype)
cfg->ifnum = 1;

/* general config */
ret = cfgcpy(&cfg->gateway, envgateway);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->gateway6, envgateway6);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->debug, envdebug);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->mount, envmount);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->single_cpu, envsingle_cpu);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->sysctls, envsysctls);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->boot_cmdline, envboot_cmdline);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->dump, envdump);
if (ret < 0)
return ret;

/* network config */
if (!(envtap || enviftype))
return 0;

iface = malloc(sizeof(struct lkl_config_iface));
if (!iface)
return -1;
memset(iface, 0, sizeof(struct lkl_config_iface));
cfg->ifnum = 1;
cfg->ifaces = iface;

ret = cfgcpy(&iface->iftap, envtap);
if (ret < 0)
Expand Down Expand Up @@ -315,30 +347,7 @@ int lkl_load_config_env(struct lkl_config *cfg)
ret = cfgcpy(&iface->ifqdisc_entries, envqdisc_entries);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->gateway, envgateway);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->gateway6, envgateway6);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->debug, envdebug);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->mount, envmount);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->single_cpu, envsingle_cpu);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->sysctls, envsysctls);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->boot_cmdline, envboot_cmdline);
if (ret < 0)
return ret;
ret = cfgcpy(&cfg->dump, envdump);
if (ret < 0)
return ret;

return 0;
}

Expand Down

0 comments on commit 554684f

Please sign in to comment.