Skip to contentSkip to conversation

defaultenv-2: add bootp support

PATCH Superseded Jean-Christophe PLAGNIOL-VILLARD 3 participants 14 messages Aug 24, 2012 – Sep 1, 2012 Networking

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover defaultenv-2: add bootp support

HI,

this patch serie depends on the 2 previous fs-symlink and defaultenv-2-boot-sequence

please pull

wing changes since commit ae5c90abd8625d1f091a0a089ac29f886fb6c6f5:

defaultenv-2: add boot sequence (2012-08-24 12:02:36 +0800)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git tags/defaultenv-2-bootp

for you to fetch changes up to bc19b321f0cc42539eb573ae54edf8d93914e1ef:

defaultenv-2: add symbolic link support to boot/nfs (2012-08-24 12:56:40 +0800)

----------------------------------------------------------------
defaultenv-2: add bootp support

dhcp: add global var support

This way you can specify as previously set the dhcp parameter via global.dhcp.xxx and get the result via global.dhcp.xxx

dhcp: add retries limit support

boot: add bootp support to net (tftp)

boot: add nfs bootp support

Where the kernel and oftree as retrieved via nfs
support also the symlink file so we will mount the correct path to get the file as nfs does not follow the link as it's done on tftp

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
dhcp: add global var support
dhcp: add alternative var support
dhcp: add retries limit support
defaultenv-2: eth0 add default global.dhcp.vendor_id
defaultenv-2: boot/net add bootp support
defaultenv-2: add net boot support with kernel and oftree via nfs
defaultenv-2: add symbolic link support to boot/nfs

 defaultenv-2/base/boot/net     |   34 +++++++++++++++++++++++++++++++++-
 defaultenv-2/base/boot/nfs     |  123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 defaultenv-2/base/network/eth0 |    1 +
 net/dhcp.c                     |  152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 305 insertions(+), 5 deletions(-)
 create mode 100644 defaultenv-2/base/boot/nfs

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#2 lore raw

PATCH 2/7 dhcp: add alternative var support

In reply to Jean-Christophe PLAGNIOL-VILLARD

This is need for the defaultenv-2 to add the bootp suppport. As now the hostname is store in global.hostname not hostname.

---
 net/dhcp.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
net/dhcp.c +16 -1
index 51c4283..b32af6a 100644
@@ -110,6 +110,7 @@ struct dhcp_opt {
 	unsigned char option;
 	/* request automatically the option when creating the DHCP request */
 	bool optional;
+	bool copy_only_if_valid;
 	const char *barebox_var_name;
 	const char *barebox_var_alt_name;
 	const char *barebox_dhcp_global;
@@ -153,7 +154,13 @@ static void env_str_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen
 
 	memcpy(tmp, popt, optlen);
 	tmp[optlen] = 0;
+
+	if (opt->copy_only_if_valid && !strlen(tmp))
+		return;
+
 	setenv(opt->barebox_var_name, tmp);
+	if (opt->barebox_var_alt_name)
+		setenv(opt->barebox_var_alt_name, tmp);
 	if (opt->barebox_dhcp_global)
 		dhcp_set_barebox_global(opt->barebox_dhcp_global, tmp);
 
@@ -207,8 +214,10 @@ struct dhcp_opt dhcp_options[] = {
 		.barebox_var_name = "net.nameserver",
 	}, {
 		.option = 12,
+		.copy_only_if_valid = 1,
 		.handle = env_str_handle,
 		.barebox_var_name = "hostname",
+		.barebox_var_alt_name = "global.hostname",
 	}, {
 		.option = 15,
 		.handle = env_str_handle,
@@ -263,6 +272,9 @@ static int dhcp_set_string_options(struct dhcp_param *param, u8 *e)
 	if (!str && param->barebox_var_name)
 		str = (char*)getenv(param->barebox_var_name);
 
+	if (!str && param->barebox_var_alt_name)
+		str = (char*)getenv(param->barebox_var_alt_name);
+
 	if (!str && param->barebox_dhcp_global)
 		str = (char*)dhcp_get_barebox_global(param->barebox_dhcp_global);
 
@@ -291,6 +303,7 @@ struct dhcp_param dhcp_params[] = {
 		.option = DHCP_HOSTNAME,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "hostname",
+		.barebox_var_alt_name = "global.hostname",
 	}, {
 		.option = DHCP_VENDOR_ID,
 		.handle = dhcp_set_string_options,
@@ -655,10 +668,12 @@ static void dhcp_reset_env(void)
 
 	for (i = 0; i < ARRAY_SIZE(dhcp_options); i++) {
 		opt = &dhcp_options[i];
-		if (!opt->barebox_var_name)
+		if (!opt->barebox_var_name || opt->copy_only_if_valid)
 			continue;
 
 		setenv(opt->barebox_var_name,"");
+		if (opt->barebox_var_alt_name)
+			setenv(opt->barebox_var_alt_name,"");
 		if (opt->barebox_dhcp_global)
 			dhcp_set_barebox_global(opt->barebox_dhcp_global,"");
 	}
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/7 dhcp: add global var support

In reply to Jean-Christophe PLAGNIOL-VILLARD

This way you can specify as previously set the dhcp parameter via global.dhcp.xxx and get the result via global.dhcp.xxx

This is need for the defaultenv-2 to add the bootp suppport.

---
 net/dhcp.c |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
net/dhcp.c +99 -1
index 79efa3e..51c4283 100644
@@ -19,6 +19,8 @@
 #include <magicvar.h>
 #include <linux/err.h>
 #include <getopt.h>
+#include <globalvar.h>
+#include <init.h>
 
 #define OPT_SIZE 312	/* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
 
@@ -78,11 +80,39 @@ static IPaddr_t net_dhcp_server_ip;
 static uint64_t dhcp_start;
 static char dhcp_tftpname[256];
 
+static const char* dhcp_get_barebox_global(const char * var)
+{
+	char * var_global = asprintf("global.dhcp.%s", var);
+	const char *val;
+
+	if (!var_global)
+		return NULL;
+
+	val = getenv(var_global);
+	free(var_global);
+	return val;
+}
+
+static int dhcp_set_barebox_global(const char * var, char *val)
+{
+	char * var_global = asprintf("global.dhcp.%s", var);
+	int ret;
+
+	if (!var_global)
+		return -ENOMEM;
+
+	ret = setenv(var_global, val);
+	free(var_global);
+	return ret;
+}
+
 struct dhcp_opt {
 	unsigned char option;
 	/* request automatically the option when creating the DHCP request */
 	bool optional;
 	const char *barebox_var_name;
+	const char *barebox_var_alt_name;
+	const char *barebox_dhcp_global;
 	void (*handle)(struct dhcp_opt *opt, unsigned char *data, int tlen);
 	void *data;
 
@@ -124,6 +154,9 @@ static void env_str_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen
 	memcpy(tmp, popt, optlen);
 	tmp[optlen] = 0;
 	setenv(opt->barebox_var_name, tmp);
+	if (opt->barebox_dhcp_global)
+		dhcp_set_barebox_global(opt->barebox_dhcp_global, tmp);
+
 }
 
 static void copy_uint32_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
@@ -184,6 +217,7 @@ struct dhcp_opt dhcp_options[] = {
 		.option = 17,
 		.handle = env_str_handle,
 		.barebox_var_name = "rootpath",
+		.barebox_dhcp_global = "rootpath",
 	}, {
 		.option = 51,
 		.handle = copy_uint32_handle,
@@ -197,21 +231,26 @@ struct dhcp_opt dhcp_options[] = {
 		.option = 66,
 		.handle = env_str_handle,
 		.barebox_var_name = "dhcp_tftp_server_name",
+		.barebox_dhcp_global = "tftp_server_name",
 		.data = dhcp_tftpname,
 	}, {
 		.option = 67,
 		.handle = bootfile_vendorex_handle,
 		.barebox_var_name = "bootfile",
+		.barebox_dhcp_global = "bootfile",
 	}, {
 		.option = 224,
 		.handle = env_str_handle,
 		.barebox_var_name = "dhcp_oftree_file",
+		.barebox_dhcp_global = "oftree_file",
 	},
 };
 
 struct dhcp_param {
 	unsigned char option;
 	const char *barebox_var_name;
+	const char *barebox_var_alt_name;
+	const char *barebox_dhcp_global;
 	int (*handle)(struct dhcp_param *param, u8 *e);
 	void *data;
 };
@@ -224,6 +263,9 @@ static int dhcp_set_string_options(struct dhcp_param *param, u8 *e)
 	if (!str && param->barebox_var_name)
 		str = (char*)getenv(param->barebox_var_name);
 
+	if (!str && param->barebox_dhcp_global)
+		str = (char*)dhcp_get_barebox_global(param->barebox_dhcp_global);
+
 	if (!str)
 		return 0;
 
@@ -253,18 +295,22 @@ struct dhcp_param dhcp_params[] = {
 		.option = DHCP_VENDOR_ID,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_vendor_id",
+		.barebox_dhcp_global = "vendor_id",
 	}, {
 		.option = DHCP_CLIENT_ID,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_client_id",
+		.barebox_dhcp_global = "client_id",
 	}, {
 		.option = DHCP_USER_CLASS,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_user_class",
+		.barebox_dhcp_global = "user_class",
 	}, {
 		.option = DHCP_CLIENT_UUID,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_client_uuid",
+		.barebox_dhcp_global = "client_uuid",
 	}
 };
 
@@ -345,8 +391,10 @@ static void bootp_copy_net_params(struct bootp *bp)
 	if (tmp_ip != 0)
 		net_set_serverip(tmp_ip);
 
-	if (strlen(bp->bp_file) > 0)
+	if (strlen(bp->bp_file) > 0) {
 		setenv("bootfile", bp->bp_file);
+		dhcp_set_barebox_global("bootfile", bp->bp_file);
+	}
 
 	debug("bootfile: %s\n", bp->bp_file);
 }
@@ -611,9 +659,50 @@ static void dhcp_reset_env(void)
 			continue;
 
 		setenv(opt->barebox_var_name,"");
+		if (opt->barebox_dhcp_global)
+			dhcp_set_barebox_global(opt->barebox_dhcp_global,"");
 	}
 }
 
+static void dhcp_global_add(const char *var)
+{
+	char * var_global = asprintf("dhcp.%s", var);
+
+	if (!var_global)
+		return;
+
+	globalvar_add_simple(var_global);
+	free(var_global);
+}
+
+static int dhcp_global_init(void)
+{
+	struct dhcp_opt *opt;
+	struct dhcp_param *param;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(dhcp_options); i++) {
+		opt = &dhcp_options[i];
+
+		if (!opt->barebox_dhcp_global)
+			continue;
+
+		dhcp_global_add(opt->barebox_dhcp_global);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dhcp_params); i++) {
+		param = &dhcp_params[i];
+
+		if (!param->barebox_dhcp_global)
+			continue;
+
+		dhcp_global_add(param->barebox_dhcp_global);
+	}
+
+	return 0;
+}
+late_initcall(dhcp_global_init);
+
 static int do_dhcp(int argc, char *argv[])
 {
 	int ret, opt;
@@ -718,3 +807,12 @@ BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_user_class, "user class to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_tftp_server_name, "TFTP server Name returned from DHCP request");
 BAREBOX_MAGICVAR(dhcp_oftree_file, "OF tree returned from DHCP request (option 224)");
+
+BAREBOX_MAGICVAR_NAMED(global_dhcp_bootfile, global.dhcp.bootfile, "bootfile returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_rootpath, global.dhcp.rootpath, "rootpath returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_vendor_id, global.dhcp.vendor_id, "vendor id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_client_uuid, global.dhcp.client_uuid, "cliend uuid to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "cliend id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user class to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/7 dhcp: add retries limit support

via -r opt, global.dhcp.retries or dhcp_retries

set the priority order;

This will allow to do not stay infinite loop if no dhcp availlable for boot sequence as example

---
 net/dhcp.c |   35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
net/dhcp.c +33 -2
index b32af6a..40709e5 100644
@@ -718,13 +718,27 @@ static int dhcp_global_init(void)
 }
 late_initcall(dhcp_global_init);
 
+static void dhcp_getenv_int(const char *name, int *i)
+{
+	const char* str = getenv(name);
+
+	if (!str)
+		return;
+
+	*i = simple_strtoul(str, NULL, 10);
+}
+
 static int do_dhcp(int argc, char *argv[])
 {
 	int ret, opt;
+	int retries = -1;
 
 	dhcp_reset_env();
 
-	while((opt = getopt(argc, argv, "H:v:c:u:U:")) > 0) {
+	dhcp_getenv_int("dhcp_retries", &retries);
+	dhcp_getenv_int("global.dhcp.retries", &retries);
+
+	while((opt = getopt(argc, argv, "H:v:c:u:U:r:")) > 0) {
 		switch(opt) {
 		case 'H':
 			dhcp_set_param_data(DHCP_HOSTNAME, optarg);
@@ -741,9 +755,17 @@ static int do_dhcp(int argc, char *argv[])
 		case 'U':
 			dhcp_set_param_data(DHCP_USER_CLASS, optarg);
 			break;
+		case 'r':
+			retries = simple_strtoul(optarg, NULL, 10);
+			break;
 		}
 	}
 
+	if (!retries) {
+		printf("retries is set to zero, set it to -1\n");
+		retries = -1;
+	}
+
 	dhcp_con = net_udp_new(0xffffffff, PORT_BOOTPS, dhcp_handler, NULL);
 	if (IS_ERR(dhcp_con)) {
 		ret = PTR_ERR(dhcp_con);
@@ -764,11 +786,17 @@ static int do_dhcp(int argc, char *argv[])
 	while (dhcp_state != BOUND) {
 		if (ctrlc())
 			break;
+		if (!retries) {
+			ret = ETIMEDOUT;
+			goto out1;
+		}
 		net_poll();
 		if (is_timeout(dhcp_start, 3 * SECOND)) {
 			dhcp_start = get_time_ns();
 			printf("T ");
 			ret = bootp_request();
+			/* no need to check if retries > 0 as we check if != 0 */
+			retries--;
 			if (ret)
 				goto out1;
 		}
@@ -803,7 +831,8 @@ BAREBOX_CMD_HELP_OPT  ("-u <client_uuid>",
 BAREBOX_CMD_HELP_OPT  ("-U <user_class>",
 "DHCP User class (code 77) submitted in DHCP requests. It can\n"
 "be used in the DHCP server's configuration to select options\n"
-"(e.g. bootfile or server) which are valid for barebox clients only.\n");
+"(e.g. bootfile or server) which are valid for barebox clients only.\n")
+BAREBOX_CMD_HELP_OPT  ("-r <retry>", "retry limi\n");
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(dhcp)
@@ -822,6 +851,7 @@ BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_user_class, "user class to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_tftp_server_name, "TFTP server Name returned from DHCP request");
 BAREBOX_MAGICVAR(dhcp_oftree_file, "OF tree returned from DHCP request (option 224)");
+BAREBOX_MAGICVAR(dhcp_retries, "retry limit");
 
 BAREBOX_MAGICVAR_NAMED(global_dhcp_bootfile, global.dhcp.bootfile, "bootfile returned from DHCP request");
 BAREBOX_MAGICVAR_NAMED(global_dhcp_rootpath, global.dhcp.rootpath, "rootpath returned from DHCP request");
@@ -831,3 +861,4 @@ BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "cliend id
 BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user class to send to the DHCP server");
 BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");
 BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_retries, global.dhcp.retries, "retry limit");
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 4/7 defaultenv-2: eth0 add default global.dhcp.vendor_id

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 defaultenv-2/base/network/eth0 |    1 +
 1 file changed, 1 insertion(+)
defaultenv-2/base/network/eth0 +1 -0
index 048a288..7e731ca 100644
@@ -2,6 +2,7 @@
 
 # ip setting (static/dhcp)
 ip=dhcp
+global.dhcp.vendor_id=barebox-${global.hostname}
 
 # static setup used if ip=static
 ipaddr=
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 5/7 defaultenv-2: boot/net add bootp support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 defaultenv-2/base/boot/net |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
defaultenv-2/base/boot/net +33 -1
index 922bef1..a232e8c 100644
@@ -7,8 +7,40 @@ fi
 
 path="/mnt/tftp"
 
+# to get the dhcp info (global.dhcp.rootpath, global.dhcp.bootfile, global.dhcp.oftree_file)
+ifup eth0
+
 global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
 #global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}"
-nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
+
+if [ -n "${global.dhcp.rootpath}" ]; then
+	bootp=1
+	nfsroot="${global.dhcp.rootpath}"
+else
+	nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
+fi
+
+if [ -n "${global.dhcp.bootfile}" -o -n "${global.dhcp.oftree_file}" ]; then
+	bootp=1
+	path="/mnt/dhcp"
+
+	if [ -d "${path}" ]; then
+		umount "${path}"
+	else
+		mkdir "${path}"
+	fi
+	mount -t tftp $eth0.serverip "${path}"
+
+	[ -n "${global.dhcp.bootfile}" ] && global.bootm.image="${path}/${global.dhcp.bootfile}"
+	[ -n "${global.dhcp.oftree_file}" ] && global.bootm.oftree="${path}/${global.dhcp.oftree_file}"
+fi
+
+if [ x${bootp} = x1 ]; then
+	echo "Boot via bootp/dhcp on server ${eth0.serverip}"
+	[ -n "${global.dhcp.bootfile}" ] && echo "bootm.image => ${global.dhcp.bootfile}"
+	[ -n "${global.dhcp.oftree_file}" ] && echo "bootm.oftree => ${global.dhcp.oftree_file}"
+	[ -n "${global.dhcp.rootpath}" ] && echo "nfsroot => ${global.dhcp.rootpath}"
+fi
+
 bootargs-ip
 bootargs-root-nfs -n "$nfsroot"
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 6/7 defaultenv-2: add net boot support with kernel and oftree via nfs

In reply to Jean-Christophe PLAGNIOL-VILLARD

This also support the bootp.

---
 defaultenv-2/base/boot/nfs |   74 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 defaultenv-2/base/boot/nfs
defaultenv-2/base/boot/nfs new file +74 -0
new file mode 100644
index 0000000..248f975
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "network (nfs, nfs)"
+	exit
+fi
+
+path="/mnt/tftp"
+
+# to get the dhcp info (global.dhcp.rootpath, global.dhcp.bootfile, global.dhcp.oftree_file)
+ifup eth0
+
+global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
+#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}"
+
+if [ -n "${global.dhcp.rootpath}" ]; then
+	bootp=1
+	nfsroot="${global.dhcp.rootpath}"
+else
+	nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
+fi
+
+dhcp_patch_base="/mnt/dhcp"
+if [ -d "${dhcp_patch_base}" ]; then
+	umount "${dhcp_patch_base}"
+else
+	mkdir "${dhcp_patch_base}"
+fi
+
+if [ -n "${global.dhcp.bootfile}" ]; then
+	bootp=1
+	path="${dhcp_patch_base}/bootfile"
+
+	if [ -d "${path}" ]; then
+		umount "${path}"
+	else
+		mkdir "${path}"
+	fi
+
+	dirname "${global.dhcp.bootfile}" mnt
+	basename "${global.dhcp.bootfile}" bootfile
+
+	mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
+
+	global.bootm.image="${path}/${bootfile}"
+fi
+
+if [ -n "${global.dhcp.oftree_file}" ]; then
+	bootp=1
+	path="${dhcp_patch_base}/oftree_file"
+
+	if [ -d "${path}" ]; then
+		umount "${path}"
+	else
+		mkdir "${path}"
+	fi
+
+	dirname "${global.dhcp.oftree_file}" mnt
+	basename "${global.dhcp.oftree_file}" bootfile
+
+	mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
+
+	global.bootm.oftree="${path}/${bootfile}"
+fi
+
+if [ x${bootp} = x1 ]; then
+	echo "Boot via bootp/dhcp on server ${eth0.serverip}"
+	[ -n "${global.dhcp.bootfile}" ] && echo "bootm.image => ${global.dhcp.bootfile}"
+	[ -n "${global.dhcp.oftree_file}" ] && echo "bootm.oftree => ${global.dhcp.oftree_file}"
+	[ -n "${global.dhcp.rootpath}" ] && echo "nfsroot => ${global.dhcp.rootpath}"
+fi
+
+bootargs-ip
+bootargs-root-nfs -n "$nfsroot"
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH 7/7 defaultenv-2: add symbolic link support to boot/nfs

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 defaultenv-2/base/boot/nfs |   55 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)
defaultenv-2/base/boot/nfs +52 -3
index 248f975..a33a21c 100644
@@ -43,6 +43,18 @@ if [ -n "${global.dhcp.bootfile}" ]; then
 	mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
 
 	global.bootm.image="${path}/${bootfile}"
+
+	if [ -L "${global.bootm.image}" ]; then
+		readlink -f "${global.bootm.image}" bootfile_symlink
+
+		dirname -V "${bootfile_symlink}" mnt
+		basename "${bootfile_symlink}" bootfile
+
+		umount "${path}"
+		mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
+
+		global.bootm.image="${path}/${bootfile}"
+	fi
 fi
 
 if [ -n "${global.dhcp.oftree_file}" ]; then
@@ -61,13 +73,50 @@ if [ -n "${global.dhcp.oftree_file}" ]; then
 	mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
 
 	global.bootm.oftree="${path}/${bootfile}"
+
+	if [ -L "${global.bootm.oftree}" ]; then
+		readlink -f "${global.bootm.oftree}" oftree_symlink
+
+		dirname -V "${oftree_symlink}" mnt
+		basename "${oftree_symlink}" bootfile
+
+		umount "${path}"
+		mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
+
+		global.bootm.oftree="${path}/${bootfile}"
+	fi
+fi
+
+if [ ${global.allow_color} = "true" ]; then
+	blue="\e[1;36m"
+	normal="\e[0m"
 fi
 
 if [ x${bootp} = x1 ]; then
 	echo "Boot via bootp/dhcp on server ${eth0.serverip}"
-	[ -n "${global.dhcp.bootfile}" ] && echo "bootm.image => ${global.dhcp.bootfile}"
-	[ -n "${global.dhcp.oftree_file}" ] && echo "bootm.oftree => ${global.dhcp.oftree_file}"
-	[ -n "${global.dhcp.rootpath}" ] && echo "nfsroot => ${global.dhcp.rootpath}"
+	if [ -n "${global.dhcp.bootfile}" ]; then
+		echo -n "bootm.image => "
+		if [ "x${bootfile_symlink}" != x ]; then
+			echo -e -n "${blue}${global.dhcp.bootfile}${normal}"
+			echo -n " -> ${bootfile_symlink}"
+		else
+			echo -n "${global.dhcp.bootfile}"
+		fi
+		echo ""
+	fi
+
+	if [ -n "${global.dhcp.oftree_file}" ]; then
+		echo "bootm.oftree => "
+		if [ "x${oftree_symlink}" != x ]; then
+			echo -e -n "${blue}${global.dhcp.oftree_file}${normal}"
+			echo -n " -> ${oftree_symlink}"
+		else
+			echo -n "${global.dhcp.oftree_file}"
+		fi
+		echo ""
+	fi
+
+	[ -n "${global.dhcp.rootpath}" ] && echo "nfsroot -> ${global.dhcp.rootpath}"
 fi
 
 bootargs-ip
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

Re: [PATCH 3/7] dhcp: add retries limit support

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hi

Quoted 47 lines · Jean-Christophe PLAGNIOL-VILLARD

via -r opt, global.dhcp.retries or dhcp_retries

set the priority order;

This will allow to do not stay infinite loop if no dhcp availlable for boot sequence as example

---
 net/dhcp.c |   35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
net/dhcp.c +15 -1
index b32af6a..40709e5 100644
@@ -718,13 +718,27 @@ static int dhcp_global_init(void)
 }
 late_initcall(dhcp_global_init);
 
+static void dhcp_getenv_int(const char *name, int *i)
+{
+       const char* str = getenv(name);
+
+       if (!str)
+               return;
+
+       *i = simple_strtoul(str, NULL, 10);
+}
+
 static int do_dhcp(int argc, char *argv[])
 {
        int ret, opt;
+       int retries = -1;
 
        dhcp_reset_env();
 
-       while((opt = getopt(argc, argv, "H:v:c:u:U:")) > 0) {
+       dhcp_getenv_int("dhcp_retries", &retries);
+       dhcp_getenv_int("global.dhcp.retries", &retries);
+
+       while((opt = getopt(argc, argv, "H:v:c:u:U:r:")) > 0) {
                switch(opt) {
                case 'H':
                        dhcp_set_param_data(DHCP_HOSTNAME, optarg);
@@ -741,9 +755,17 @@ static int do_dhcp(int argc, char *argv[])
                case 'U':

net/dhcp.c static int do_dhcp(int argc, char *argv[]) · line 765

Quoted 10 lines
net/dhcp.c +5 -0
                        dhcp_set_param_data(DHCP_USER_CLASS, optarg);
                        break;
+               case 'r':
+                       retries = simple_strtoul(optarg, NULL, 10);
+                       break;
                }
        }
 
+       if (!retries) {
+               printf("retries is set to zero, set it to -1\n");

I don't think the user needs to know that in the background you're using -1 to express zero retries. I suppose a comment would suffice.

Quoted 25 lines
net/dhcp.c +9 -0
+               retries = -1;
+       }
+
        dhcp_con = net_udp_new(0xffffffff, PORT_BOOTPS, dhcp_handler, NULL);
        if (IS_ERR(dhcp_con)) {
                ret = PTR_ERR(dhcp_con);
@@ -764,11 +786,17 @@ static int do_dhcp(int argc, char *argv[])
        while (dhcp_state != BOUND) {
                if (ctrlc())
                        break;
+               if (!retries) {
+                       ret = ETIMEDOUT;
+                       goto out1;
+               }
                net_poll();
                if (is_timeout(dhcp_start, 3 * SECOND)) {
                        dhcp_start = get_time_ns();
                        printf("T ");
                        ret = bootp_request();
+                       /* no need to check if retries > 0 as we check if != 0 */
+                       retries--;
                        if (ret)
                                goto out1;
                }

net/dhcp.c BAREBOX_CMD_HELP_OPT ("-u <client_uuid>", · line 835

Quoted 6 lines
net/dhcp.c +2 -1
@@ -803,7 +831,8 @@ BAREBOX_CMD_HELP_OPT  ("-u <client_uuid>",
 BAREBOX_CMD_HELP_OPT  ("-U <user_class>",
 "DHCP User class (code 77) submitted in DHCP requests. It can\n"
 "be used in the DHCP server's configuration to select options\n"
-"(e.g. bootfile or server) which are valid for barebox clients only.\n");
+"(e.g. bootfile or server) which are valid for barebox clients only.\n")
+BAREBOX_CMD_HELP_OPT  ("-r <retry>", "retry limi\n");

s/limi/limit/

Regards
Roberto Nibali

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#11 lore raw

Re: [PATCH 1/7] dhcp: add global var support

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hi

Minor nitpick below:

Quoted 14 lines · Jean-Christophe PLAGNIOL-VILLARD

This way you can specify as previously set the dhcp parameter via global.dhcp.xxx and get the result via global.dhcp.xxx

This is need for the defaultenv-2 to add the bootp suppport.

---
 net/dhcp.c |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
net/dhcp. renamed from net/dhcp.c +0 -0
index 79efa3e..51c4283 100644

[...]

net/dhcp. BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server"); · line 814

Quoted 9 lines
net/dhcp. renamed from net/dhcp.c +5 -0
@@ -718,3 +807,12 @@ BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_user_class, "user class to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_tftp_server_name, "TFTP server Name returned from DHCP request");
 BAREBOX_MAGICVAR(dhcp_oftree_file, "OF tree returned from DHCP request (option 224)");
+
+BAREBOX_MAGICVAR_NAMED(global_dhcp_bootfile, global.dhcp.bootfile, "bootfile returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_rootpath, global.dhcp.rootpath, "rootpath returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_vendor_id, global.dhcp.vendor_id, "vendor id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_client_uuid, global.dhcp.client_uuid, "cliend uuid to send to the DHCP server");

s/cliend/client/

net/dhcp. BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server"); · line 815

Quoted 1 line
net/dhcp. renamed from net/dhcp.c +1 -0
+BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "cliend id to send to the DHCP server");

s/cliend/client/

net/dhcp. BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server"); · line 817

Quoted 2 lines
net/dhcp. renamed from net/dhcp.c +2 -0
+BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user class to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");

s/Name/name/

net/dhcp. BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server"); · line 818

Quoted 1 line
net/dhcp. renamed from net/dhcp.c +1 -0
+BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");

Cheers
Roberto

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#12 lore raw

Re: [PATCH 1/7] dhcp: add global var support

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 24 lines · Jean-Christophe PLAGNIOL-VILLARD

This way you can specify as previously set the dhcp parameter via global.dhcp.xxx and get the result via global.dhcp.xxx

This is need for the defaultenv-2 to add the bootp suppport.

---
 net/dhcp.c |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
net/dhcp.c +2 -0
index 79efa3e..51c4283 100644
@@ -19,6 +19,8 @@
 #include <magicvar.h>
 #include <linux/err.h>
 #include <getopt.h>
+#include <globalvar.h>
+#include <init.h>
 
 #define OPT_SIZE 312	/* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
 

net/dhcp.c static IPaddr_t net_dhcp_server_ip; · line 83

Quoted 4 lines
net/dhcp.c +1 -0
@@ -78,11 +80,39 @@ static IPaddr_t net_dhcp_server_ip;
 static uint64_t dhcp_start;
 static char dhcp_tftpname[256];
 
+static const char* dhcp_get_barebox_global(const char * var)

static const char *dhcp_get_barebox_global

net/dhcp.c static IPaddr_t net_dhcp_server_ip; · line 85

Quoted 2 lines
net/dhcp.c +2 -0
+{
+	char * var_global = asprintf("global.dhcp.%s", var);

char *var_global =

Generally I don't think we should introduce a second set of variables. Drop The other ones instead.

Sascha

Quoted 196 lines
net/dhcp.c +94 -1
+	const char *val;
+
+	if (!var_global)
+		return NULL;
+
+	val = getenv(var_global);
+	free(var_global);
+	return val;
+}
+
+static int dhcp_set_barebox_global(const char * var, char *val)
+{
+	char * var_global = asprintf("global.dhcp.%s", var);
+	int ret;
+
+	if (!var_global)
+		return -ENOMEM;
+
+	ret = setenv(var_global, val);
+	free(var_global);
+	return ret;
+}
+
 struct dhcp_opt {
 	unsigned char option;
 	/* request automatically the option when creating the DHCP request */
 	bool optional;
 	const char *barebox_var_name;
+	const char *barebox_var_alt_name;
+	const char *barebox_dhcp_global;
 	void (*handle)(struct dhcp_opt *opt, unsigned char *data, int tlen);
 	void *data;
 
@@ -124,6 +154,9 @@ static void env_str_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen
 	memcpy(tmp, popt, optlen);
 	tmp[optlen] = 0;
 	setenv(opt->barebox_var_name, tmp);
+	if (opt->barebox_dhcp_global)
+		dhcp_set_barebox_global(opt->barebox_dhcp_global, tmp);
+
 }
 
 static void copy_uint32_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
@@ -184,6 +217,7 @@ struct dhcp_opt dhcp_options[] = {
 		.option = 17,
 		.handle = env_str_handle,
 		.barebox_var_name = "rootpath",
+		.barebox_dhcp_global = "rootpath",
 	}, {
 		.option = 51,
 		.handle = copy_uint32_handle,
@@ -197,21 +231,26 @@ struct dhcp_opt dhcp_options[] = {
 		.option = 66,
 		.handle = env_str_handle,
 		.barebox_var_name = "dhcp_tftp_server_name",
+		.barebox_dhcp_global = "tftp_server_name",
 		.data = dhcp_tftpname,
 	}, {
 		.option = 67,
 		.handle = bootfile_vendorex_handle,
 		.barebox_var_name = "bootfile",
+		.barebox_dhcp_global = "bootfile",
 	}, {
 		.option = 224,
 		.handle = env_str_handle,
 		.barebox_var_name = "dhcp_oftree_file",
+		.barebox_dhcp_global = "oftree_file",
 	},
 };
 
 struct dhcp_param {
 	unsigned char option;
 	const char *barebox_var_name;
+	const char *barebox_var_alt_name;
+	const char *barebox_dhcp_global;
 	int (*handle)(struct dhcp_param *param, u8 *e);
 	void *data;
 };
@@ -224,6 +263,9 @@ static int dhcp_set_string_options(struct dhcp_param *param, u8 *e)
 	if (!str && param->barebox_var_name)
 		str = (char*)getenv(param->barebox_var_name);
 
+	if (!str && param->barebox_dhcp_global)
+		str = (char*)dhcp_get_barebox_global(param->barebox_dhcp_global);
+
 	if (!str)
 		return 0;
 
@@ -253,18 +295,22 @@ struct dhcp_param dhcp_params[] = {
 		.option = DHCP_VENDOR_ID,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_vendor_id",
+		.barebox_dhcp_global = "vendor_id",
 	}, {
 		.option = DHCP_CLIENT_ID,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_client_id",
+		.barebox_dhcp_global = "client_id",
 	}, {
 		.option = DHCP_USER_CLASS,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_user_class",
+		.barebox_dhcp_global = "user_class",
 	}, {
 		.option = DHCP_CLIENT_UUID,
 		.handle = dhcp_set_string_options,
 		.barebox_var_name = "dhcp_client_uuid",
+		.barebox_dhcp_global = "client_uuid",
 	}
 };
 
@@ -345,8 +391,10 @@ static void bootp_copy_net_params(struct bootp *bp)
 	if (tmp_ip != 0)
 		net_set_serverip(tmp_ip);
 
-	if (strlen(bp->bp_file) > 0)
+	if (strlen(bp->bp_file) > 0) {
 		setenv("bootfile", bp->bp_file);
+		dhcp_set_barebox_global("bootfile", bp->bp_file);
+	}
 
 	debug("bootfile: %s\n", bp->bp_file);
 }
@@ -611,9 +659,50 @@ static void dhcp_reset_env(void)
 			continue;
 
 		setenv(opt->barebox_var_name,"");
+		if (opt->barebox_dhcp_global)
+			dhcp_set_barebox_global(opt->barebox_dhcp_global,"");
 	}
 }
 
+static void dhcp_global_add(const char *var)
+{
+	char * var_global = asprintf("dhcp.%s", var);
+
+	if (!var_global)
+		return;
+
+	globalvar_add_simple(var_global);
+	free(var_global);
+}
+
+static int dhcp_global_init(void)
+{
+	struct dhcp_opt *opt;
+	struct dhcp_param *param;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(dhcp_options); i++) {
+		opt = &dhcp_options[i];
+
+		if (!opt->barebox_dhcp_global)
+			continue;
+
+		dhcp_global_add(opt->barebox_dhcp_global);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dhcp_params); i++) {
+		param = &dhcp_params[i];
+
+		if (!param->barebox_dhcp_global)
+			continue;
+
+		dhcp_global_add(param->barebox_dhcp_global);
+	}
+
+	return 0;
+}
+late_initcall(dhcp_global_init);
+
 static int do_dhcp(int argc, char *argv[])
 {
 	int ret, opt;
@@ -718,3 +807,12 @@ BAREBOX_MAGICVAR(dhcp_client_id, "cliend id to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_user_class, "user class to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_tftp_server_name, "TFTP server Name returned from DHCP request");
 BAREBOX_MAGICVAR(dhcp_oftree_file, "OF tree returned from DHCP request (option 224)");
+
+BAREBOX_MAGICVAR_NAMED(global_dhcp_bootfile, global.dhcp.bootfile, "bootfile returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_rootpath, global.dhcp.rootpath, "rootpath returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_vendor_id, global.dhcp.vendor_id, "vendor id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_client_uuid, global.dhcp.client_uuid, "cliend uuid to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "cliend id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user class to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

Re: [PATCH 7/7] defaultenv-2: add symbolic link support to boot/nfs

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Jean-Christophe PLAGNIOL-VILLARD
---
 defaultenv-2/base/boot/nfs |   55 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)
defaultenv-2/base/boot/nfs +2 -0
index 248f975..a33a21c 100644
@@ -43,6 +43,18 @@ if [ -n "${global.dhcp.bootfile}" ]; then
 	mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
 
 	global.bootm.image="${path}/${bootfile}"
+
+	if [ -L "${global.bootm.image}" ]; then

defaultenv-2/base/boot/nfs if [ -n "${global.dhcp.bootfile}" ]; then · line 57

Quoted 10 lines
defaultenv-2/base/boot/nfs +10 -0
+		readlink -f "${global.bootm.image}" bootfile_symlink
+
+		dirname -V "${bootfile_symlink}" mnt
+		basename "${bootfile_symlink}" bootfile
+
+		umount "${path}"
+		mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
+
+		global.bootm.image="${path}/${bootfile}"
+	fi

There is something wrong here. I do not understand what you do here, but symlinks are not supposed to bash on them with dirname/basename until you get something which fits your needs.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

Re: [PATCH 7/7] defaultenv-2: add symbolic link support to boot/nfs

Quoted 22 lines · Sascha Hauer
Quoted 21 lines · Jean-Christophe PLAGNIOL-VILLARD
---
 defaultenv-2/base/boot/nfs |   55 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)
defaultenv-2/base/boot/nfs +8 -0
index 248f975..a33a21c 100644
@@ -43,6 +43,18 @@ if [ -n "${global.dhcp.bootfile}" ]; then
 	mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
 
 	global.bootm.image="${path}/${bootfile}"
+
+	if [ -L "${global.bootm.image}" ]; then
+		readlink -f "${global.bootm.image}" bootfile_symlink
+
+		dirname -V "${bootfile_symlink}" mnt
+		basename "${bootfile_symlink}" bootfile
+
+		umount "${path}"
Quoted 8 lines

defaultenv-2/base/boot/nfs if [ -n "${global.dhcp.bootfile}" ]; then · line 57

Quoted 4 lines
defaultenv-2/base/boot/nfs +4 -0
+		mount -t nfs "${eth0.serverip}:${mnt}" "${path}"
+
+		global.bootm.image="${path}/${bootfile}"
+	fi

There is something wrong here. I do not understand what you do here, but symlinks are not supposed to bash on them with dirname/basename until you get something which fits your needs.

here the issue is that on nfs you need to mount the correct path otherwise you can not get the real file

so we need to detect it and mount the correct path

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#13 lore raw

Re: [PATCH 1/7] dhcp: add global var support

In reply to Sascha Hauer
Quoted 32 lines · Sascha Hauer
Quoted 24 lines · Jean-Christophe PLAGNIOL-VILLARD

This way you can specify as previously set the dhcp parameter via global.dhcp.xxx and get the result via global.dhcp.xxx

This is need for the defaultenv-2 to add the bootp suppport.

---
 net/dhcp.c |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
net/dhcp.c +2 -0
index 79efa3e..51c4283 100644
@@ -19,6 +19,8 @@
 #include <magicvar.h>
 #include <linux/err.h>
 #include <getopt.h>
+#include <globalvar.h>
+#include <init.h>
 
 #define OPT_SIZE 312	/* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
 

net/dhcp.c static IPaddr_t net_dhcp_server_ip; · line 83

Quoted 4 lines
net/dhcp.c +1 -0
@@ -78,11 +80,39 @@ static IPaddr_t net_dhcp_server_ip;
 static uint64_t dhcp_start;
 static char dhcp_tftpname[256];
 
+static const char* dhcp_get_barebox_global(const char * var)

static const char *dhcp_get_barebox_global

Quoted 7 lines

net/dhcp.c static IPaddr_t net_dhcp_server_ip; · line 85

Quoted 2 lines
net/dhcp.c +2 -0
+{
+	char * var_global = asprintf("global.dhcp.%s", var);

char *var_global =

Generally I don't think we should introduce a second set of variables. Drop The other ones instead.

I'm ok with it as I 'm going to switch all my board to the defaultenv-2

but other people may not so the only to keep this feature on both env are

1) 2 set of var
2) use glovalbar on defaultenv

I've no preference

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox