Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tools/lkl/lib/hijack/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ hijack_init(void)
cpu_set_t ori_cpu;
char *offload1 = getenv("LKL_HIJACK_OFFLOAD");
int offload = 0;
/* with dhcp client by default */
char *boot_cmdline = "ip=dhcp";
char boot_cmdline[256] = "\0";

memset(&nd_args, 0, sizeof(struct lkl_netdev_args));
if (!debug) {
Expand Down Expand Up @@ -325,9 +324,9 @@ hijack_init(void)
if (single_cpu_mode == 1)
PinToFirstCpu(&ori_cpu);

/* clear cmdline if non-dhcp case */
if ((ip && strcmp(ip, "dhcp")) || (nd_id == -1))
boot_cmdline = "";
/* set cmdline if dhcp case */
if ((ip && !strcmp(ip, "dhcp")) && (nd_id != -1))
snprintf(boot_cmdline, sizeof(boot_cmdline), "ip=dhcp");

ret = lkl_start_kernel(&lkl_host_ops, 64 * 1024 * 1024UL, boot_cmdline);
if (ret) {
Expand Down
3 changes: 1 addition & 2 deletions tools/lkl/tests/net-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ static int test_net_init(int argc, char **argv)
char *debug = getenv("LKL_DEBUG");
int ret, nd_id = -1, nd_ifindex = -1;
struct lkl_netdev *nd = NULL;
/* with dhcp client by default */
char boot_cmdline[256] = "\0";

if (argc < 3) {
Expand Down Expand Up @@ -160,7 +159,7 @@ static int test_net_init(int argc, char **argv)
lkl_host_ops.print = NULL;


if (ip && !strcmp(ip, "dhcp"))
if ((ip && !strcmp(ip, "dhcp")) && (nd_id != -1))
snprintf(boot_cmdline, sizeof(boot_cmdline), "ip=dhcp");

ret = lkl_start_kernel(&lkl_host_ops, 64 * 1024 * 1024, boot_cmdline);
Expand Down