[OpenWrt-Devel] [PATCHv2] mdadm: revised mdadm config & init logic
From: Joseph Tingiris This is a significant revision of /etc/init.d/mdadm. It adds new features, support for new configuration options, safer error handling, (configurable) verbose output, and contains multiple bug fixes. Most notably, mdadm was being started with the --config flag and that prevented it from using its built in Auto Assembly features. Users were required to put a correct uuid in /etc/config/mdadm. The new default startup mode is now to automatically assemble all RAID arrays attached to the machine using device scans, rather than configuation options. A new UCI section, config mdadm global, was added with new options that are supported by the accompanying /etc/init.d/mdadm. Documentation for all new (and previous) options was added as well. See the /etc/config/mdadmin or mdadm.init file itself for more details. Additionally, a new stateful 'auto' feature was added that functions similarly to the stateless Auto Assembly feature. The benefits of stateful auto assembly are to support features that mdadm 4.0 will only read from a configuration file, such as setting the MAILFROM value. The new mdadm_conf_auto() function will also aid users in troubleshooting. When verbose is turned on it provides tips and better visibility for what's actually happening. Backward compatibility was retained. Stateful UCI only configurations are supported. All previously existing configurations will work in this mode. However, these users will now have to explicitly turn it on. A new reload_service() function was added to prevent reloads from stopping mdadm. Reloads will now be ignored, though the stage is set for reloads to trigger scans for new devices. Explicit restarts still work as expected. The start_service() function was enhanced to query new UCI mdadm.global options: alert_program, config, email, email_from, monitor_frequency, and verbose. Each option is documented in /etc/mdadm/config (config.init) and some additional code comments were added. Finally, error handling and verbose output was enhanced. Users will know what's going on (if verbose is turned on). Strict reliance on a shell global ($CONF) was removed and replaced with a single global ($TMP_FILE) that's for development convenience. When/if a config file is not specified in the UCI config, it will fall back to using $TMP_FILE as the configuration file. Incremented PKG_RELEASE from 1 to 2 Signed-off-by: Joseph Tingiris (rebased and ran through shellcheck) Signed-off-by: Rosen Penev --- v2: Rebased after sysmacro patches package/utils/mdadm/Makefile | 2 +- package/utils/mdadm/files/mdadm.config | 162 ++- package/utils/mdadm/files/mdadm.init | 556 ++--- 3 files changed, 647 insertions(+), 73 deletions(-) diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile index f20a58b704..d5ea91eeed 100644 --- a/package/utils/mdadm/Makefile +++ b/package/utils/mdadm/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mdadm PKG_VERSION:=4.1 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm diff --git a/package/utils/mdadm/files/mdadm.config b/package/utils/mdadm/files/mdadm.config index 50afbc2ab6..0c78c964a8 100644 --- a/package/utils/mdadm/files/mdadm.config +++ b/package/utils/mdadm/files/mdadm.config @@ -1,18 +1,154 @@ -config mdadm +# +# The mdadm 'global' section is for options that apply to all sections. +# + +config mdadm global + + # + # option 'alert_program' values may be a path to a valid, executable binary. + # + # The default 'alert_program' is not set. + # + # When mdadm detects an event it will execute this program with 3 arguments, see https://linux.die.net/man/8/mdadm + # $1 = will be the event + # $2 = will be the meta device + # $3 = may be a related component (if one exists) + # + # * alert_program runs independently from sendmail. + # * If both options alert_program and email are set, and both work, then an email and a + # custom alert will be generated. + # * no alert program is included in mdadm 4.0-4. + # + # Lots of possibilities exist, i.e. scripts for netdata, slack, etc. + # + #option alert_program /usr/sbin/mdadm_alerts + + + # + # option 'config' values may be one of the following. + # + # The default 'config' is none (stateless auto assembly). + # + # auto - stateful, dynamically generated mdadm.conf via block info, + # stored in /var/etc/mdadm.conf + # containers- stateless, mdadm --assemble --scan --config=containers; see https://linux.die.net/man/8/mdadm + # none - stateless, mdadm --assemble --scan --config=none; aka 'Auto Assembly', + # see https://linux.die.net/man/8/mdadm + # partition - stateless, mdadm
[OpenWrt-Devel] Cannot compile cryptodev-linux using x86-64 SDK
Hi, As the subject of this email says, I get an error when trying to compile cryptodev-linux using the x86-64 SDK. (Though a different error than the one I found with the armvirt-64 SDK.) This error has been happening for a while, at least a month. (I haven't had time to follow up until now.) I suspect this is also related to the switch to the 4.19 kernel, though I have no direct evidence. The error message (included below) doesn't seem too helpful. Any help in fixing this would be appreciated. Thanks, Jeff Make output: make[2]: Entering directory '/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/feeds/base/package/kernel/cryptodev-linux' touch /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.prepared_35c87bfa80bf594a5e3809806f37d832_6664517399ebbbc92a37c5bb081b5c53_check . /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/include/shell.sh; gzip -dc /media/jeff/Jekyll/Files/openwrt/dl/cryptodev-linux-1.10.tar.gz | tar -C /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.. -xf - [ ! -d ./src/ ] || cp -fpR ./src/. /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10 touch /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.prepared_35c87bfa80bf594a5e3809806f37d832_6664517399ebbbc92a37c5bb081b5c53 rm -f /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.configured_* rm -f /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/target-x86_64_musl/stamp/.cryptodev-linux_installed touch /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.configured_68b329da9893e34099c7d8ad5cb9c940 rm -f /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.built touch /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/.built_check cat /dev/null > /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/target-x86_64_musl/pkginfo/cryptodev-linux.symvers; for subdir in .; do cat /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/target-x86_64_musl/pkginfo/*.symvers 2>/dev/null > /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/$subdir/Module.symvers; done make -C /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10 HOSTCFLAGS="-O2 -I/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/host/include -I/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/hostpkg/include -I/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/target-x86_64_musl/host/include -Wall -Wmissing-prototypes -Wstrict-prototypes" CROSS_COMPILE="x86_64-openwrt-linux-musl-" ARCH="x86" KBUILD_HAVE_NLS=no KBUILD_BUILD_USER="builder" KBUILD_BUILD_HOST="buildhost" KBUILD_BUILD_TIMESTAMP="Thu Aug 15 12:25:51 2019" KBUILD_BUILD_VERSION="0" HOST_LOADLIBES="-L/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/staging_dir/host/lib" CONFIG_SHELL="bash" V='' cmd_syscalls= KERNELRELEASE=4.19.66 KERNEL_DIR="/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/linux-4.19.66" make[3]: Entering directory '/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10' make -C /media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/linux-4.19.66 M=/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10 ARCH=x86 CROSS_COMPILE=x86_64-openwrt-linux-musl- modules make[4]: Entering directory '/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/linux-4.19.66' make[5]: *** No rule to make target '/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/ioctl.o', needed by '/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/cryptodev.o'. Stop. make[4]: *** [Makefile:1517: _module_/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10] Error 2 make[4]: Leaving directory '/media/jeff/Jekyll/Files/openwrt/testing/c/x86-64/build_dir/target-x86_64_musl/linux-x86_64/linux-4.19.66' make[3]: *** [Makefile:27: build] Error 2 make[3]: Leaving directory
Re: [OpenWrt-Devel] [PATCH procd] system: support passing "options" to the "sysupgrade" ubus method
On 16/08/2019 18:17, Bjørn Mork wrote: John Crispin writes: + for (c = name + strlen(prefix); *c; c++) { + *c = toupper(*c); + } + and, matter of tatse, but i'd drop the travolta brackets on single line clauses I thought <> were "travolta brackets", ref http://www.morethings.com/fan/quentin_tarantino/pulp_fiction/pulp_fiction1720.jpg http://www.morethings.com/fan/quentin_tarantino/pulp_fiction/pulp_fiction1710.jpg Bjørn. I know them as these https://cdn-02.independent.ie/migration_catalog/Non-Staff/article25202482.ece/3ec13/AUTOCROP/w620/359557.jpg ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH procd] system: support passing "options" to the "sysupgrade" ubus method
John Crispin writes: >> +for (c = name + strlen(prefix); *c; c++) { >> +*c = toupper(*c); >> +} >> + > > and, matter of tatse, but i'd drop the travolta brackets on single > line clauses I thought <> were "travolta brackets", ref http://www.morethings.com/fan/quentin_tarantino/pulp_fiction/pulp_fiction1720.jpg http://www.morethings.com/fan/quentin_tarantino/pulp_fiction/pulp_fiction1710.jpg Bjørn. ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd V2] system: support passing "options" to the "sysupgrade" ubus method
From: Rafał Miłecki Object passed as "options" gets translated into environment variables UPGRADE_OPT_*. E.g. "options": { "foo": 5 } will result in setting UPGRADE_OPT_FOO=5. This allows stage2 sysupgrade to get options explicitly. So far it was guessing what to do by checking for existence of some files (e.g. sysupgrade.tgz). Signed-off-by: Rafał Miłecki --- V2: Use asprintf() & drop some braces --- initd/preinit.c | 2 +- system.c| 5 - sysupgrade.c| 43 ++- sysupgrade.h| 4 +++- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/initd/preinit.c b/initd/preinit.c index fbb36df..2b4df4b 100644 --- a/initd/preinit.c +++ b/initd/preinit.c @@ -75,7 +75,7 @@ check_sysupgrade(void) fclose(sysupgrade); - sysupgrade_exec_upgraded(prefix, path, command); + sysupgrade_exec_upgraded(prefix, path, command, NULL); while (true) sleep(1); diff --git a/system.c b/system.c index 8ed3f93..738f327 100644 --- a/system.c +++ b/system.c @@ -380,6 +380,7 @@ enum { SYSUPGRADE_PATH, SYSUPGRADE_PREFIX, SYSUPGRADE_COMMAND, + SYSUPGRADE_OPTIONS, __SYSUPGRADE_MAX }; @@ -387,6 +388,7 @@ static const struct blobmsg_policy sysupgrade_policy[__SYSUPGRADE_MAX] = { [SYSUPGRADE_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, [SYSUPGRADE_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING }, [SYSUPGRADE_COMMAND] = { .name = "command", .type = BLOBMSG_TYPE_STRING }, + [SYSUPGRADE_OPTIONS] = { .name = "options", .type = BLOBMSG_TYPE_TABLE }, }; static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, @@ -404,7 +406,8 @@ static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, sysupgrade_exec_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PREFIX]), blobmsg_get_string(tb[SYSUPGRADE_PATH]), -tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL); +tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL, +tb[SYSUPGRADE_OPTIONS]); /* sysupgrade_exec_upgraded() will never return unless something has gone wrong */ return UBUS_STATUS_UNKNOWN_ERROR; diff --git a/sysupgrade.c b/sysupgrade.c index 07e33f7..29c4c9b 100644 --- a/sysupgrade.c +++ b/sysupgrade.c @@ -17,15 +17,20 @@ #include "watchdog.h" #include "sysupgrade.h" +#include #include #include #include +#include -void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) +void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command, + struct blob_attr *options) { char *wdt_fd = watchdog_fd(); char *argv[] = { "/sbin/upgraded", NULL, NULL, NULL}; + struct blob_attr *option; + int rem; int ret; ret = chroot(prefix); @@ -41,6 +46,42 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) watchdog_set_cloexec(false); setenv("WDTFD", wdt_fd, 1); } + + blobmsg_for_each_attr(option, options, rem) { + const char *prefix = "UPGRADE_OPT_"; + char value[11]; + char *name; + char *c; + int tmp; + + if (asprintf(, "%s%s", prefix, blobmsg_name(option)) < 0) + continue; + for (c = name + strlen(prefix); *c; c++) + *c = toupper(*c); + + switch (blobmsg_type(option)) { + case BLOBMSG_TYPE_INT32: + tmp = blobmsg_get_u32(option); + break; + case BLOBMSG_TYPE_INT16: + tmp = blobmsg_get_u16(option); + break; + case BLOBMSG_TYPE_INT8: + tmp = blobmsg_get_u8(option); + break; + default: + fprintf(stderr, "Option \"%s\" has unsupported type: %d\n", + blobmsg_name(option), blobmsg_type(option)); + free(name); + continue; + } + snprintf(value, sizeof(value), "%u", tmp); + + setenv(name, value, 1); + + free(name); + } + execvp(argv[0], argv); /* Cleanup on failure */ diff --git a/sysupgrade.h b/sysupgrade.h index 8c09fc9..c84e494 100644 --- a/sysupgrade.h +++ b/sysupgrade.h @@ -14,8 +14,10 @@ #ifndef __PROCD_SYSUPGRADE_H #define __PROCD_SYSUPGRADE_H +struct blob_attr; -void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command); +void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command, + struct blob_attr
[OpenWrt-Devel] [PATCH 2/2] treewide: sysupgrade: pass "save_partitions" option to the "sysupgrade" method
From: Rafał Miłecki This explicitly lets stage2 know if partitions should be preserved. No more "touch /tmp/sysupgrade.always.overwrite.bootdisk.partmap" hack. Signed-off-by: Rafał Miłecki --- package/base-files/files/lib/upgrade/stage2 | 5 - package/base-files/files/sbin/sysupgrade | 9 ++--- target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh | 2 +- target/linux/brcm2708/base-files/lib/upgrade/platform.sh | 2 +- target/linux/mvebu/base-files/lib/upgrade/sdcard.sh | 2 +- target/linux/omap/base-files/lib/upgrade/platform.sh | 2 +- target/linux/sunxi/base-files/lib/upgrade/platform.sh| 2 +- target/linux/tegra/base-files/lib/upgrade/platform.sh| 2 +- target/linux/x86/base-files/lib/upgrade/platform.sh | 2 +- 9 files changed, 9 insertions(+), 19 deletions(-) diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index 4e5837af83..ff2a9aee05 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -6,8 +6,6 @@ export IMAGE="$1" COMMAND="$2" -export SAVE_PARTITIONS=1 - export INTERACTIVE=0 export VERBOSE=1 export CONFFILES=/tmp/sysupgrade.conffiles @@ -16,9 +14,6 @@ export CONF_TAR=/tmp/sysupgrade.tgz RAMFS_COPY_BIN=# extra programs for temporary ramfs root RAMFS_COPY_DATA= # extra data files - -[ -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap ] && export SAVE_PARTITIONS=0 - include /lib/upgrade diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 15514159b3..c27c1fbc47 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -351,12 +351,6 @@ if [ $TEST -eq 1 ]; then exit 0 fi -if [ $SAVE_PARTITIONS -eq 0 ]; then - touch /tmp/sysupgrade.always.overwrite.bootdisk.partmap -else - rm -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap -fi - install_bin /sbin/upgraded v "Commencing upgrade. Closing all shell sessions." @@ -371,7 +365,8 @@ else \"path\": $(json_string "$IMAGE"), \"command\": $(json_string "$COMMAND"), \"options\": { - \"save_config\": $SAVE_CONFIG + \"save_config\": $SAVE_CONFIG, + \"save_partitions\": $SAVE_PARTITIONS } }" fi diff --git a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh index c191271149..01327d926a 100644 --- a/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh +++ b/target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh @@ -43,7 +43,7 @@ mbl_do_upgrade() { sync - if [ "$SAVE_PARTITIONS" = "1" ]; then + if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then get_partitions "/dev/$diskdev" bootdisk #extract the boot sector from the image diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh index 37e479272b..693cde7779 100644 --- a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh +++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh @@ -45,7 +45,7 @@ platform_do_upgrade() { sync - if [ "$SAVE_PARTITIONS" = "1" ]; then + if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then get_partitions "/dev/$diskdev" bootdisk #extract the boot sector from the image diff --git a/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh b/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh index 43fc2504fc..08ab17089d 100644 --- a/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh +++ b/target/linux/mvebu/base-files/lib/upgrade/sdcard.sh @@ -49,7 +49,7 @@ platform_do_upgrade_sdcard() { sync - if [ "$SAVE_PARTITIONS" = "1" ]; then + if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then get_partitions "/dev/$diskdev" bootdisk #extract the boot sector from the image diff --git a/target/linux/omap/base-files/lib/upgrade/platform.sh b/target/linux/omap/base-files/lib/upgrade/platform.sh index abe910b154..c8b0175fd5 100644 --- a/target/linux/omap/base-files/lib/upgrade/platform.sh +++ b/target/linux/omap/base-files/lib/upgrade/platform.sh @@ -45,7 +45,7 @@ platform_do_upgrade() { sync - if [ "$SAVE_PARTITIONS" = "1" ]; then + if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then get_partitions "/dev/$diskdev" bootdisk #extract the boot sector from the image diff --git a/target/linux/sunxi/base-files/lib/upgrade/platform.sh b/target/linux/sunxi/base-files/lib/upgrade/platform.sh index abe910b154..c8b0175fd5 100644 --- a/target/linux/sunxi/base-files/lib/upgrade/platform.sh +++ b/target/linux/sunxi/base-files/lib/upgrade/platform.sh @@ -45,7 +45,7 @@
[OpenWrt-Devel] [PATCH 1/2] base-files: pass "save_config" option to the "sysupgrade" method
From: Rafał Miłecki This explicitly lets stage2 know if config should be preserved. Signed-off-by: Rafał Miłecki --- package/base-files/files/lib/upgrade/common.sh | 2 +- package/base-files/files/lib/upgrade/do_stage2 | 2 +- package/base-files/files/lib/upgrade/stage2| 2 -- package/base-files/files/sbin/sysupgrade | 5 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 2afa0addb4..efa301cd95 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -218,7 +218,7 @@ indicate_upgrade() { # $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m default_do_upgrade() { sync - if [ "$SAVE_CONFIG" -eq 1 ]; then + if [ "$UPGRADE_OPT_SAVE_CONFIG" -eq 1 ]; then get_image "$1" "$2" | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}" else get_image "$1" "$2" | mtd $MTD_ARGS write - "${PART_NAME:-image}" diff --git a/package/base-files/files/lib/upgrade/do_stage2 b/package/base-files/files/lib/upgrade/do_stage2 index 8aae452560..0e6cc1bfc3 100755 --- a/package/base-files/files/lib/upgrade/do_stage2 +++ b/package/base-files/files/lib/upgrade/do_stage2 @@ -11,7 +11,7 @@ else default_do_upgrade "$IMAGE" fi -if [ "$SAVE_CONFIG" -eq 1 ] && type 'platform_copy_config' >/dev/null 2>/dev/null; then +if [ "$UPGRADE_OPT_SAVE_CONFIG" -eq 1 ] && type 'platform_copy_config' >/dev/null 2>/dev/null; then platform_copy_config fi diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index fef121f37c..4e5837af83 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -6,7 +6,6 @@ export IMAGE="$1" COMMAND="$2" -export SAVE_CONFIG=1 export SAVE_PARTITIONS=1 export INTERACTIVE=0 @@ -18,7 +17,6 @@ RAMFS_COPY_BIN= # extra programs for temporary ramfs root RAMFS_COPY_DATA= # extra data files -[ -f "$CONF_TAR" ] || export SAVE_CONFIG=0 [ -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap ] && export SAVE_PARTITIONS=0 include /lib/upgrade diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 001e644476..15514159b3 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -369,6 +369,9 @@ else ubus call system sysupgrade "{ \"prefix\": $(json_string "$RAM_ROOT"), \"path\": $(json_string "$IMAGE"), - \"command\": $(json_string "$COMMAND") + \"command\": $(json_string "$COMMAND"), + \"options\": { + \"save_config\": $SAVE_CONFIG + } }" fi -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH procd] system: support passing "options" to the "sysupgrade" ubus method
On 16/08/2019 16:28, Rafał Miłecki wrote: From: Rafał Miłecki Object passed as "options" gets translated into environment variables UPGRADE_OPT_*. E.g. "options": { "foo": 5 } will result in setting UPGRADE_OPT_FOO=5. This allows stage2 sysupgrade to get options explicitly. So far it was guessing what to do by checking for existence of some files (e.g. sysupgrade.tgz). Signed-off-by: Rafał Miłecki --- initd/preinit.c | 2 +- system.c| 5 - sysupgrade.c| 46 +- sysupgrade.h| 4 +++- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/initd/preinit.c b/initd/preinit.c index fbb36df..2b4df4b 100644 --- a/initd/preinit.c +++ b/initd/preinit.c @@ -75,7 +75,7 @@ check_sysupgrade(void) fclose(sysupgrade); - sysupgrade_exec_upgraded(prefix, path, command); + sysupgrade_exec_upgraded(prefix, path, command, NULL); while (true) sleep(1); diff --git a/system.c b/system.c index 8ed3f93..738f327 100644 --- a/system.c +++ b/system.c @@ -380,6 +380,7 @@ enum { SYSUPGRADE_PATH, SYSUPGRADE_PREFIX, SYSUPGRADE_COMMAND, + SYSUPGRADE_OPTIONS, __SYSUPGRADE_MAX }; @@ -387,6 +388,7 @@ static const struct blobmsg_policy sysupgrade_policy[__SYSUPGRADE_MAX] = { [SYSUPGRADE_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, [SYSUPGRADE_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING }, [SYSUPGRADE_COMMAND] = { .name = "command", .type = BLOBMSG_TYPE_STRING }, + [SYSUPGRADE_OPTIONS] = { .name = "options", .type = BLOBMSG_TYPE_TABLE }, }; static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, @@ -404,7 +406,8 @@ static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, sysupgrade_exec_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PREFIX]), blobmsg_get_string(tb[SYSUPGRADE_PATH]), -tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL); +tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL, +tb[SYSUPGRADE_OPTIONS]); /* sysupgrade_exec_upgraded() will never return unless something has gone wrong */ return UBUS_STATUS_UNKNOWN_ERROR; diff --git a/sysupgrade.c b/sysupgrade.c index 07e33f7..99a098e 100644 --- a/sysupgrade.c +++ b/sysupgrade.c @@ -17,15 +17,20 @@ #include "watchdog.h" #include "sysupgrade.h" +#include #include #include #include +#include -void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) +void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command, + struct blob_attr *options) { char *wdt_fd = watchdog_fd(); char *argv[] = { "/sbin/upgraded", NULL, NULL, NULL}; + struct blob_attr *option; + int rem; int ret; ret = chroot(prefix); @@ -41,6 +46,45 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) watchdog_set_cloexec(false); setenv("WDTFD", wdt_fd, 1); } + + blobmsg_for_each_attr(option, options, rem) { + const char *prefix = "UPGRADE_OPT_"; + char *name = malloc(strlen(prefix) + strlen(blobmsg_name(option))); you could possibly use asprintf() here ? + char value[11]; + char *c; + int tmp; + + if (!name) { + continue; + } + sprintf(name, "%s%s", prefix, blobmsg_name(option)); + for (c = name + strlen(prefix); *c; c++) { + *c = toupper(*c); + } + and, matter of tatse, but i'd drop the travolta brackets on single line clauses John + switch (blobmsg_type(option)) { + case BLOBMSG_TYPE_INT32: + tmp = blobmsg_get_u32(option); + break; + case BLOBMSG_TYPE_INT16: + tmp = blobmsg_get_u16(option); + break; + case BLOBMSG_TYPE_INT8: + tmp = blobmsg_get_u8(option); + break; + default: + fprintf(stderr, "Option \"%s\" has unsupported type: %d\n", + blobmsg_name(option), blobmsg_type(option)); + free(name); + continue; + } + snprintf(value, sizeof(value), "%u", tmp); + + setenv(name, value, 1); + + free(name); + } + execvp(argv[0], argv); /* Cleanup on failure */ diff --git a/sysupgrade.h b/sysupgrade.h index 8c09fc9..c84e494 100644 --- a/sysupgrade.h +++ b/sysupgrade.h @@ -14,8 +14,10 @@ #ifndef
[OpenWrt-Devel] [PATCH procd] system: support passing "options" to the "sysupgrade" ubus method
From: Rafał Miłecki Object passed as "options" gets translated into environment variables UPGRADE_OPT_*. E.g. "options": { "foo": 5 } will result in setting UPGRADE_OPT_FOO=5. This allows stage2 sysupgrade to get options explicitly. So far it was guessing what to do by checking for existence of some files (e.g. sysupgrade.tgz). Signed-off-by: Rafał Miłecki --- initd/preinit.c | 2 +- system.c| 5 - sysupgrade.c| 46 +- sysupgrade.h| 4 +++- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/initd/preinit.c b/initd/preinit.c index fbb36df..2b4df4b 100644 --- a/initd/preinit.c +++ b/initd/preinit.c @@ -75,7 +75,7 @@ check_sysupgrade(void) fclose(sysupgrade); - sysupgrade_exec_upgraded(prefix, path, command); + sysupgrade_exec_upgraded(prefix, path, command, NULL); while (true) sleep(1); diff --git a/system.c b/system.c index 8ed3f93..738f327 100644 --- a/system.c +++ b/system.c @@ -380,6 +380,7 @@ enum { SYSUPGRADE_PATH, SYSUPGRADE_PREFIX, SYSUPGRADE_COMMAND, + SYSUPGRADE_OPTIONS, __SYSUPGRADE_MAX }; @@ -387,6 +388,7 @@ static const struct blobmsg_policy sysupgrade_policy[__SYSUPGRADE_MAX] = { [SYSUPGRADE_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, [SYSUPGRADE_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING }, [SYSUPGRADE_COMMAND] = { .name = "command", .type = BLOBMSG_TYPE_STRING }, + [SYSUPGRADE_OPTIONS] = { .name = "options", .type = BLOBMSG_TYPE_TABLE }, }; static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, @@ -404,7 +406,8 @@ static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj, sysupgrade_exec_upgraded(blobmsg_get_string(tb[SYSUPGRADE_PREFIX]), blobmsg_get_string(tb[SYSUPGRADE_PATH]), -tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL); +tb[SYSUPGRADE_COMMAND] ? blobmsg_get_string(tb[SYSUPGRADE_COMMAND]) : NULL, +tb[SYSUPGRADE_OPTIONS]); /* sysupgrade_exec_upgraded() will never return unless something has gone wrong */ return UBUS_STATUS_UNKNOWN_ERROR; diff --git a/sysupgrade.c b/sysupgrade.c index 07e33f7..99a098e 100644 --- a/sysupgrade.c +++ b/sysupgrade.c @@ -17,15 +17,20 @@ #include "watchdog.h" #include "sysupgrade.h" +#include #include #include #include +#include -void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) +void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command, + struct blob_attr *options) { char *wdt_fd = watchdog_fd(); char *argv[] = { "/sbin/upgraded", NULL, NULL, NULL}; + struct blob_attr *option; + int rem; int ret; ret = chroot(prefix); @@ -41,6 +46,45 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command) watchdog_set_cloexec(false); setenv("WDTFD", wdt_fd, 1); } + + blobmsg_for_each_attr(option, options, rem) { + const char *prefix = "UPGRADE_OPT_"; + char *name = malloc(strlen(prefix) + strlen(blobmsg_name(option))); + char value[11]; + char *c; + int tmp; + + if (!name) { + continue; + } + sprintf(name, "%s%s", prefix, blobmsg_name(option)); + for (c = name + strlen(prefix); *c; c++) { + *c = toupper(*c); + } + + switch (blobmsg_type(option)) { + case BLOBMSG_TYPE_INT32: + tmp = blobmsg_get_u32(option); + break; + case BLOBMSG_TYPE_INT16: + tmp = blobmsg_get_u16(option); + break; + case BLOBMSG_TYPE_INT8: + tmp = blobmsg_get_u8(option); + break; + default: + fprintf(stderr, "Option \"%s\" has unsupported type: %d\n", + blobmsg_name(option), blobmsg_type(option)); + free(name); + continue; + } + snprintf(value, sizeof(value), "%u", tmp); + + setenv(name, value, 1); + + free(name); + } + execvp(argv[0], argv); /* Cleanup on failure */ diff --git a/sysupgrade.h b/sysupgrade.h index 8c09fc9..c84e494 100644 --- a/sysupgrade.h +++ b/sysupgrade.h @@ -14,8 +14,10 @@ #ifndef __PROCD_SYSUPGRADE_H #define __PROCD_SYSUPGRADE_H +struct blob_attr; -void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command); +void sysupgrade_exec_upgraded(const char
[OpenWrt-Devel] [PATCH] ramips: remove RAM size from device name for UniElec devices
UniElec devices are the last ones in ramips target still having the RAM size in device name although RAM size is auto-detected. Remove this from device name, compatible, etc., as it's not required and might be misleading to users and developers adding device support copying those devices. Signed-off-by: Adrian Schmutzler --- target/linux/ramips/base-files/etc/board.d/01_leds| 2 +- target/linux/ramips/base-files/etc/board.d/02_network | 6 +++--- ...6-256m-16m.dts => mt7621_unielec_u7621-06-16m.dts} | 4 ++-- ...6-512m-64m.dts => mt7621_unielec_u7621-06-64m.dts} | 4 ++-- ...128m-16m.dts => mt7628an_unielec_u7628-01-16m.dts} | 4 ++-- target/linux/ramips/image/mt7621.mk | 11 ++- target/linux/ramips/image/mt76x8.mk | 6 +++--- 7 files changed, 19 insertions(+), 18 deletions(-) rename target/linux/ramips/dts/{mt7621_unielec_u7621-06-256m-16m.dts => mt7621_unielec_u7621-06-16m.dts} (94%) rename target/linux/ramips/dts/{mt7621_unielec_u7621-06-512m-64m.dts => mt7621_unielec_u7621-06-64m.dts} (94%) rename target/linux/ramips/dts/{mt7628an_unielec_u7628-01-128m-16m.dts => mt7628an_unielec_u7628-01-16m.dts} (94%) diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds index d5ea201279..a6ebb7e2dc 100755 --- a/target/linux/ramips/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/base-files/etc/board.d/01_leds @@ -392,7 +392,7 @@ tplink,tl-wr902ac-v3) ucidef_set_led_wlan "wlan2g" "wlan2g" "$boardname:green:wlan" "phy0tpt" ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x10" ;; -unielec,u7628-01-128m-16m) +unielec,u7628-01-16m) ucidef_set_led_switch "lan1" "lan1" "u7628-01:green:lan1" "switch0" "0x2" ucidef_set_led_switch "lan2" "lan2" "u7628-01:green:lan2" "switch0" "0x4" ucidef_set_led_switch "lan3" "lan3" "u7628-01:green:lan3" "switch0" "0x8" diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network index b413b434eb..ba4ed5f1a4 100755 --- a/target/linux/ramips/base-files/etc/board.d/02_network +++ b/target/linux/ramips/base-files/etc/board.d/02_network @@ -85,8 +85,8 @@ ramips_setup_interfaces() telco-electronics,x1|\ totolink,a7000r|\ totolink,lr1200|\ - unielec,u7621-06-256m-16m|\ - unielec,u7621-06-512m-64m|\ + unielec,u7621-06-16m|\ + unielec,u7621-06-64m|\ wavlink,wl-wn570ha1|\ wavlink,wl-wn575a3|\ xiaomi,miwifi-mini|\ @@ -212,7 +212,7 @@ ramips_setup_interfaces() tplink,tl-wr841n-v13|\ tplink,tl-wr841n-v14|\ tplink,tl-wr842n-v5|\ - unielec,u7628-01-128m-16m|\ + unielec,u7628-01-16m|\ ubiquiti,edgerouterx|\ ubiquiti,edgerouterx-sfp|\ upvel,ur-326n4g|\ diff --git a/target/linux/ramips/dts/mt7621_unielec_u7621-06-256m-16m.dts b/target/linux/ramips/dts/mt7621_unielec_u7621-06-16m.dts similarity index 94% rename from target/linux/ramips/dts/mt7621_unielec_u7621-06-256m-16m.dts rename to target/linux/ramips/dts/mt7621_unielec_u7621-06-16m.dts index 78bccbf12d..603e2dd2d8 100644 --- a/target/linux/ramips/dts/mt7621_unielec_u7621-06-256m-16m.dts +++ b/target/linux/ramips/dts/mt7621_unielec_u7621-06-16m.dts @@ -40,8 +40,8 @@ #include / { - compatible = "unielec,u7621-06-256m-16m", "unielec,u7621-06", "mediatek,mt7621-soc"; - model = "UniElec U7621-06 (256M RAM/16M flash)"; + compatible = "unielec,u7621-06-16m", "unielec,u7621-06", "mediatek,mt7621-soc"; + model = "UniElec U7621-06 (16M flash)"; }; { diff --git a/target/linux/ramips/dts/mt7621_unielec_u7621-06-512m-64m.dts b/target/linux/ramips/dts/mt7621_unielec_u7621-06-64m.dts similarity index 94% rename from target/linux/ramips/dts/mt7621_unielec_u7621-06-512m-64m.dts rename to target/linux/ramips/dts/mt7621_unielec_u7621-06-64m.dts index 16baf70600..3498be044a 100644 --- a/target/linux/ramips/dts/mt7621_unielec_u7621-06-512m-64m.dts +++ b/target/linux/ramips/dts/mt7621_unielec_u7621-06-64m.dts @@ -41,8 +41,8 @@ #include / { - compatible = "unielec,u7621-06-512m-64m", "unielec,u7621-06", "mediatek,mt7621-soc"; - model = "UniElec U7621-06 (512M RAM/64M flash)"; + compatible = "unielec,u7621-06-64m", "unielec,u7621-06", "mediatek,mt7621-soc"; + model = "UniElec U7621-06 (64M flash)"; }; { diff --git a/target/linux/ramips/dts/mt7628an_unielec_u7628-01-128m-16m.dts b/target/linux/ramips/dts/mt7628an_unielec_u7628-01-16m.dts similarity index 94% rename from target/linux/ramips/dts/mt7628an_unielec_u7628-01-128m-16m.dts rename to target/linux/ramips/dts/mt7628an_unielec_u7628-01-16m.dts index c5eaf6d5d0..66fea358bd 100644 --- a/target/linux/ramips/dts/mt7628an_unielec_u7628-01-128m-16m.dts +++ b/target/linux/ramips/dts/mt7628an_unielec_u7628-01-16m.dts @@ -37,8 +37,8 @@ #include
[OpenWrt-Devel] [PATCH] ar71xx: ag71xx: add missing register writes
These are added in ath79, but were not backported here Signed-off-by: Koen Vandeputte --- .../files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c | 5 + 1 file changed, 5 insertions(+) diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c index f0d8d46a18a1..e97317bd20ff 100644 --- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c +++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c @@ -1274,6 +1274,9 @@ static int ag71xx_change_mtu(struct net_device *dev, int new_mtu) return -EBUSY; dev->mtu = new_mtu; + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, + ag71xx_max_frame_len(dev->mtu)); + return 0; } @@ -1413,6 +1416,8 @@ static int ag71xx_probe(struct platform_device *pdev) ag71xx_dump_regs(ag); + ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, 0); + ag71xx_hw_init(ag); ag71xx_dump_regs(ag); -- 2.17.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] ath9k: fix dynack in IBSS mode
Hi Joe, Lorenzo, I deployed an ath9k auto distance solution in April that is working for the AREDN community http://www.arednmesh.org . https://github.com/aredn/aredn_ar71xx/blob/develop/patches/712-auto-distance-settings.patch Summary of solution: * no dependency on wpa_supplicant * initial ack_to is set to max, to not enter late ack conditions * User level trigger to flip distance setting to static and back to auto when new 802.11 adhoc neighbor joins. (we archive and chart SNR values for neighbors and natural to hook in this trigger). Have you initialized the ackto to the max value to remove wpa_supplicant dependency or because the system is not able to trigger the 'late ack'? I did not get why you need to flip the algo off/on when new 802.11 adhoc neighbor joins Regards, Lorenzo initialized the ackto to max: A) avoidance of late-ack state B) not require wpa_supplicant -- not in use by our community today C) Suspect some conditions, e.g. low SNR Neighbors, do not trigger "late ack" (consistent, with observation of low SNR Neighbors sticking at max ack_to with my changes ) flip the algo off/on when new neighbor joins: Intended technique to reset ack_to to max. If ack_to is set to 20km and then a new adhoc neighbor joins at 30km, this would be a late ack state, and unable to detect.My early testing results showed the algo off/on would restart the ack_to to max and start the process over with the new neighbor. I trust I got it right? There are 10s to 100s of users testing this bleeding edge change from nightly builds, and so far, I've not found a failure case. Although, the findings are showing the cases where static setting has better throughput. Joe AE6XE Lorenzo, It's been a while regarding the above. I can confirm the issue that if the algorithm misses the late ack's due to low initial snr, the initial ack_to is too low to recover afterwards. Do you think it would be useful to start at high ack_to and let it estimate/drop afterwards? Ps. I've got my 24km link back if required to do some additional testing. Thanks, Koen ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] ath9k: mtd-cal-data vs firmware bin file
Hello Martin, Thank you (and Dmitry Tunin and Chuanhong Guo) for explaining this topic to me. Now it is perfectly clear. So the idea of reading mtd isn't completely abandoned, Martin's approach just seems to be more flexible and universal. On the other hand, I've never assumed sparing this 4k (even less, as I guess it's squashed) will yield any reasonable gain for tiny flash devices, it was more of internal design curiosity. Best regards Michal ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel