[OpenWrt-Devel] [PATCH v3] mac80211: remove error from detect script
Signed-off-by: Michel Stam --- package/kernel/mac80211/files/lib/wifi/mac80211.sh | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh index a3b2199..0b662eb 100644 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -19,9 +19,11 @@ lookup_phy() { local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')" [ -n "$macaddr" ] && { - for _phy in $(ls /sys/class/ieee80211 2>/dev/null); do - [ "$macaddr" = "$(cat /sys/class/ieee80211/${_phy}/macaddress)" ] || continue - phy="$_phy" + for _phy in /sys/class/ieee80211/*; do + [ -e "$_phy" ] || continue + + [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue + phy="${_phy##*/}" return done } @@ -65,7 +67,12 @@ detect_mac80211() { [ -n "$type" ] || break devidx=$(($devidx + 1)) done - for dev in $(ls /sys/class/ieee80211); do + + for _dev in /sys/class/ieee80211/*; do + [ -e "$_dev" ] || continue + + dev="${_dev##*/}" + found=0 config_foreach check_mac80211_device wifi-device [ "$found" -gt 0 ] && continue -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2] mac80211: remove error from detect script
Signed-off-by: Michel Stam --- package/kernel/mac80211/files/lib/wifi/mac80211.sh | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh index a3b2199..a1ed6f6 100644 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -19,9 +19,11 @@ lookup_phy() { local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')" [ -n "$macaddr" ] && { - for _phy in $(ls /sys/class/ieee80211 2>/dev/null); do - [ "$macaddr" = "$(cat /sys/class/ieee80211/${_phy}/macaddress)" ] || continue - phy="$_phy" + for _phy in /sys/class/ieee80211/*; do + [ -e "$_phy" ] || continue + + phy="${_phy##*/}" + [ "$macaddr" = "$(cat /sys/class/ieee80211/${phy}/macaddress)" ] || continue return done } @@ -65,7 +67,12 @@ detect_mac80211() { [ -n "$type" ] || break devidx=$(($devidx + 1)) done - for dev in $(ls /sys/class/ieee80211); do + + for _dev in /sys/class/ieee80211/*; do + [ -e "$_dev" ] || continue + + dev="${_dev##*/}" + found=0 config_foreach check_mac80211_device wifi-device [ "$found" -gt 0 ] && continue -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 3/3 v2] busybox/netifd: make zcip log to syslog (always)
zcip is not the most talkative beast at the best of times. It would be nice to see -something- in syslog when an IP address is acquired. Signed-off-by: Michel Stam --- .../netifd/files/lib/netifd/proto/zeroconf.sh | 2 +- .../busybox/patches/460-zcip-always-syslog.patch | 44 ++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 package/utils/busybox/patches/460-zcip-always-syslog.patch diff --git a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh index f7a6f76..998d2c6 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh @@ -21,7 +21,7 @@ proto_zeroconf_setup() { proto_run_command "$config" zcip \ ${ipaddr:+-r $ipaddr} \ ${range:+-l $range} \ - -f "$iface" \ + -f -s -v "$iface" \ /lib/netifd/zeroconf.script } diff --git a/package/utils/busybox/patches/460-zcip-always-syslog.patch b/package/utils/busybox/patches/460-zcip-always-syslog.patch new file mode 100644 index 000..7519aa0 --- /dev/null +++ b/package/utils/busybox/patches/460-zcip-always-syslog.patch @@ -0,0 +1,44 @@ +From 297563d4d859643de249d180f3bf308f9536de18 Mon Sep 17 00:00:00 2001 +From: Michel Stam +Date: Thu, 25 Sep 2014 14:06:39 +0200 +Subject: [PATCH] zcip: add an option to force logging to syslog even if + running -f + +Signed-off-by: Michel Stam +--- + networking/zcip.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/networking/zcip.c b/networking/zcip.c +index 2a57543..2997503 100644 +--- a/networking/zcip.c b/networking/zcip.c +@@ -32,6 +32,7 @@ + //usage: "\n -r 169.254.x.x Request this address first" + //usage: "\n -l w.x.0.0 Use this class B range instead of 169.254" + //usage: "\n -v Verbose" ++//usage: "\n -s Log to syslog (even in foreground)" + //usage: "\n" + //usage: "\nWith no -q, runs continuously monitoring for ARP conflicts," + //usage: "\nexits only on I/O errors (link down etc)" +@@ -238,7 +239,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + // parse commandline: prog [options] ifname script + // exactly 2 args; -v accumulates and implies -f + opt_complementary = "=2:vv:vf"; +- opts = getopt32(argv, "fqr:l:v", &r_opt, &l_opt, &verbose); ++ opts = getopt32(argv, "fqr:l:vs", &r_opt, &l_opt, &verbose); + #if !BB_MMU + // on NOMMU reexec early (or else we will rerun things twice) + if (!FOREGROUND) +@@ -248,7 +249,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + // (need to do it before openlog to prevent openlog from taking + // fd 3 (sock_fd==3)) + xmove_fd(xsocket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)), sock_fd); +- if (!FOREGROUND) { ++ if (!FOREGROUND || (opts & 16)) { + // do it before all bb_xx_msg calls + openlog(applet_name, 0, LOG_DAEMON); + logmode |= LOGMODE_SYSLOG; +-- +1.7.12.1 + -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3 v2] netifd: implement zeroconf
The scripts were based on the netifd dhcp scripts, and should add zeroconf support to /etc/config/network Example: config interface 'lan' option ifname 'eth0' option auto '0' option proto 'zeroconf' Optionally, the desired IP address can be added by: option ipaddr '169.254.200.100' and the range from which addresses are desired can be added by: option range '192.168.0.0' Note that zcip in Busybox must be enabled for this to work. Signed-off-by: Michel Stam --- .../netifd/files/lib/netifd/proto/zeroconf.sh | 34 ++ .../config/netifd/files/lib/netifd/zeroconf.script | 29 ++ 2 files changed, 63 insertions(+) create mode 100755 package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh create mode 100755 package/network/config/netifd/files/lib/netifd/zeroconf.script diff --git a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh new file mode 100755 index 000..f7a6f76 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +proto_zeroconf_init_config() { + proto_config_add_string 'ipaddr:ipaddr' + proto_config_add_string 'range:ipaddr' +} + +proto_zeroconf_setup() { + local config="$1" + local iface="$2" + + local ipaddr + local range + json_get_vars ipaddr range + + proto_export "INTERFACE=$config" + proto_run_command "$config" zcip \ + ${ipaddr:+-r $ipaddr} \ + ${range:+-l $range} \ + -f "$iface" \ + /lib/netifd/zeroconf.script +} + +proto_zeroconf_teardown() { + local interface="$1" + proto_kill_command "$INTERFACE" +} + +add_protocol zeroconf + diff --git a/package/network/config/netifd/files/lib/netifd/zeroconf.script b/package/network/config/netifd/files/lib/netifd/zeroconf.script new file mode 100755 index 000..8d34a67 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/zeroconf.script @@ -0,0 +1,29 @@ +#!/bin/sh +[ -z "$1" ] && echo "Error: should be run by zcip" && exit 1 + +. /lib/functions.sh +. /lib/netifd/netifd-proto.sh + +setup_interface () { + proto_init_update "*" 1 + proto_add_ipv4_address "$ip" '255.255.0.0' + proto_send_update "$INTERFACE" +} + +deconfig_interface() { + proto_init_update "*" 0 + proto_send_update "$INTERFACE" +} + +case "$1" in + deconfig) + deconfig_interface + ;; + config) + setup_interface + ;; + *|init) + ;; +esac + +exit 0 -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2 procd 3/8] Fix curses applications to work with procd
The problem was caused by procd not opening /dev/tty* (which ever was specified in /etc/inittab), causing /proc/PID/fd to point to /console instead. /dev/console is a non-controlling tty (CTTY), and cannot be used as one, which is exactly what curses applications want. Since this is very likely to cause problems with other programs, procd now opens /dev/tty? when the ID field of the inittab assigns one. Signed-off-by: Michel Stam --- inittab.c| 62 utils/askfirst.c | 28 ++--- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/inittab.c b/inittab.c index c8540b1..5ddf4f0 100644 --- a/inittab.c +++ b/inittab.c @@ -63,10 +63,48 @@ static char *ask = "/sbin/askfirst"; static LIST_HEAD(actions); +static int dev_open(const char *dev) +{ + int fd = -1; + + if (dev) { + chdir("/dev"); + fd = open( dev, O_RDWR); + chdir("/"); + } + + return fd; +} + +static int dev_exist(const char *dev) +{ + int res; + + res = dev_open(dev); + if (res != -1) { + close(res); + } + + return (res != -1); +} + static void fork_worker(struct init_action *a) { + int fd; + pid_t p; + a->proc.pid = fork(); if (!a->proc.pid) { + p = setsid( ); + fd = dev_open(a->id); + if (fd != -1) + { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + tcsetpgrp(fd, p); + close(fd); + } execvp(a->argv[0], a->argv); ERROR("Failed to execute %s\n", a->argv[0]); exit(-1); @@ -110,22 +148,17 @@ static void runrc(struct init_action *a) static void askfirst(struct init_action *a) { - struct stat s; int i; - chdir("/dev"); - i = stat(a->id, &s); - chdir("/"); - if (i || (console && !strcmp(console, a->id))) { + if (!dev_exist(a->id) || (console && !strcmp(console, a->id))) { DEBUG(4, "Skipping %s\n", a->id); return; } a->tout.cb = respawn; - for (i = MAX_ARGS - 2; i >= 2; i--) - a->argv[i] = a->argv[i - 2]; + for (i = MAX_ARGS - 1; i >= 1; i--) + a->argv[i] = a->argv[i - 1]; a->argv[0] = ask; - a->argv[1] = a->id; a->respawn = 500; a->proc.cb = child_exit; @@ -134,7 +167,6 @@ static void askfirst(struct init_action *a) static void askconsole(struct init_action *a) { - struct stat s; char line[256], *tty; int i, r, fd = open("/proc/cmdline", O_RDONLY); regex_t pat_cmdline; @@ -153,20 +185,16 @@ static void askconsole(struct init_action *a) line[matches[1].rm_eo] = '\0'; tty = &line[matches[1].rm_so]; - chdir("/dev"); - i = stat(tty, &s); - chdir("/"); - if (i) { + if (!dev_exist(tty)) { DEBUG(4, "skipping %s\n", tty); goto err_out; } - console = strdup(tty); a->tout.cb = respawn; - for (i = MAX_ARGS - 2; i >= 2; i--) - a->argv[i] = a->argv[i - 2]; + for (i = MAX_ARGS - 1; i >= 1; i--) + a->argv[i] = a->argv[i - 1]; + a->id = strdup(tty); a->argv[0] = ask; - a->argv[1] = strdup(tty); a->respawn = 500; a->proc.cb = child_exit; diff --git a/utils/askfirst.c b/utils/askfirst.c index 6ad77aa..e1f757a 100644 --- a/utils/askfirst.c +++ b/utils/askfirst.c @@ -19,34 +19,10 @@ #include #include -static int redirect_output(const char *dev) -{ - pid_t p = setsid(); - int fd; - - chdir("/dev"); - fd = open(dev, O_RDWR); - chdir("/"); - - if (fd < 0) - return -1; - - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - tcsetpgrp(fd, p); - close(fd); - - return 0; -} - int main(int argc, char **argv) { int c; - if (redirect_output(argv[1])) - fprintf(stderr, "%s: Failed to open %s\n", argv[0], argv[1]); - printf("Please press Enter to activate this console.\n"); do { c = getchar(); @@ -55,8 +31,8 @@ int main(int argc, char **argv) } while (c != 0xA); - execvp(argv[2], &argv[2]); - printf("%s: Failed to execute %s\n", argv[0], argv[2]); + execvp(argv[1], &argv[1]); + printf("%s: Failed to execute %s\n", argv[0], argv[1]); return -1; } -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2] base-files: remove a 'not found' error message during system boot
During boot, a not found message is displayed for systems which do not have uci 'network.globals.ula_prefix' defined in /etc/config/network. The error message itself is not used and can be ignored. Signed-off-by: Michel Stam --- package/base-files/files/etc/uci-defaults/12_network-generate-ula | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula index 56b7eb3..8871427 100644 --- a/package/base-files/files/etc/uci-defaults/12_network-generate-ula +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -1,6 +1,6 @@ #!/bin/sh -[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0 +[ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0 r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"') r2=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"') -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/3] busybox: allow own class B range to be used for zeroconf
169.254 may be used by local networks. This patch allows specifying your own IP range. Signed-off-by: Michel Stam --- .../busybox/patches/450-zcip-own-ip-range.patch| 110 + 1 file changed, 110 insertions(+) create mode 100644 package/utils/busybox/patches/450-zcip-own-ip-range.patch diff --git a/package/utils/busybox/patches/450-zcip-own-ip-range.patch b/package/utils/busybox/patches/450-zcip-own-ip-range.patch new file mode 100644 index 000..7193402 --- /dev/null +++ b/package/utils/busybox/patches/450-zcip-own-ip-range.patch @@ -0,0 +1,110 @@ +From bddeb00a36df927c8372fc40b96e6e8dd13e6609 Mon Sep 17 00:00:00 2001 +From: Michel Stam +Date: Thu, 25 Sep 2014 13:43:33 +0200 +Subject: [PATCH] zcip: allow our own class B range to be used for ZeroConf + +169.254 may already be used by a local network. This patch allows +specifying your own IP range. + +Signed-off-by: Michel Stam +--- + networking/zcip.c | 21 ++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +diff --git a/networking/zcip.c b/networking/zcip.c +index 45d1f7c..2a57543 100644 +--- a/networking/zcip.c b/networking/zcip.c +@@ -30,6 +30,7 @@ + //usage: "\n -f Run in foreground" + //usage: "\n -q Quit after obtaining address" + //usage: "\n -r 169.254.x.x Request this address first" ++//usage: "\n -l w.x.0.0 Use this class B range instead of 169.254" + //usage: "\n -v Verbose" + //usage: "\n" + //usage: "\nWith no -q, runs continuously monitoring for ARP conflicts," +@@ -87,10 +88,12 @@ enum { + struct globals { + struct sockaddr saddr; + struct ether_addr eth_addr; ++ uint32_t localnet_addr; + } FIX_ALIASING; + #define G (*(struct globals*)&bb_common_bufsiz1) + #define saddr(G.saddr ) + #define eth_addr (G.eth_addr) ++#define localnet_addr (G.localnet_addr) + #define INIT_G() do { } while (0) + + +@@ -105,7 +108,7 @@ static uint32_t pick(void) + do { + tmp = rand() & IN_CLASSB_HOST; + } while (tmp > (IN_CLASSB_HOST - 0x0200)); +- return htonl((LINKLOCAL_ADDR + 0x0100) + tmp); ++ return htonl((localnet_addr + 0x0100) + tmp); + } + + /** +@@ -197,6 +200,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + { + int state; + char *r_opt; ++ char *l_opt; + unsigned opts; + + // ugly trick, but I want these zeroed in one go +@@ -204,6 +208,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + const struct in_addr null_ip; + const struct ether_addr null_addr; + struct in_addr ip; ++ struct in_addr net; + struct ifreq ifr; + int timeout_ms; /* must be signed */ + unsigned conflicts; +@@ -215,6 +220,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + #define null_ip(L.null_ip ) + #define null_addr (L.null_addr ) + #define ip (L.ip) ++#define net(L.net ) + #define ifr(L.ifr ) + #define timeout_ms (L.timeout_ms) + #define conflicts (L.conflicts ) +@@ -224,6 +230,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + #define verbose(L.verbose ) + + memset(&L, 0, sizeof(L)); ++ localnet_addr = LINKLOCAL_ADDR; // Assume default 169.254.x.x + INIT_G(); + + #define FOREGROUND (opts & 1) +@@ -231,7 +238,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + // parse commandline: prog [options] ifname script + // exactly 2 args; -v accumulates and implies -f + opt_complementary = "=2:vv:vf"; +- opts = getopt32(argv, "fqr:v", &r_opt, &verbose); ++ opts = getopt32(argv, "fqr:l:v", &r_opt, &l_opt, &verbose); + #if !BB_MMU + // on NOMMU reexec early (or else we will rerun things twice) + if (!FOREGROUND) +@@ -246,9 +253,17 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + openlog(applet_name, 0, LOG_DAEMON); + logmode |= LOGMODE_SYSLOG; + } ++ if (opts & 8) { // -l n.n.n.n ++ if (inet_aton(l_opt, &net) == 0 ++ || (net.s_addr & htonl(IN_CLASSB_NET)) != net.s_addr ++ ) { ++ bb_error_msg_and_die("invalid network address"); ++ } ++ localnet_addr = ntohl(net.s_addr); ++ } + if (opts & 4) { // -r n.n.n.n + if (inet_aton(r_opt, &ip) == 0 +- || (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR ++ || (ntohl(ip.s_addr) & IN_CLASSB_NET) != localnet_addr + ) { + bb_error_msg_and_die("invalid link address"); + } +-- +1.7.12.1 + -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 3/3] busybox/netifd: make zcip log to syslog (always)
zcip is not the most talkative beast at the best of times. It would be nice to see -something- in syslog when an IP address is acquired. Signed-off-by: Michel Stam --- .../netifd/files/lib/netifd/proto/zeroconf.sh | 2 +- .../busybox/patches/460-zcip-always-syslog.patch | 44 ++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 package/utils/busybox/patches/460-zcip-always-syslog.patch diff --git a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh index cec7605..a1214e3 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh @@ -20,7 +20,7 @@ proto_zeroconf_setup() { proto_run_command "$config" zcip \ ${ipaddr:+-r $ipaddr} \ ${cmdline} \ - -f "$iface" \ + -f -s -v "$iface" \ /lib/netifd/zeroconf.script } diff --git a/package/utils/busybox/patches/460-zcip-always-syslog.patch b/package/utils/busybox/patches/460-zcip-always-syslog.patch new file mode 100644 index 000..7519aa0 --- /dev/null +++ b/package/utils/busybox/patches/460-zcip-always-syslog.patch @@ -0,0 +1,44 @@ +From 297563d4d859643de249d180f3bf308f9536de18 Mon Sep 17 00:00:00 2001 +From: Michel Stam +Date: Thu, 25 Sep 2014 14:06:39 +0200 +Subject: [PATCH] zcip: add an option to force logging to syslog even if + running -f + +Signed-off-by: Michel Stam +--- + networking/zcip.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/networking/zcip.c b/networking/zcip.c +index 2a57543..2997503 100644 +--- a/networking/zcip.c b/networking/zcip.c +@@ -32,6 +32,7 @@ + //usage: "\n -r 169.254.x.x Request this address first" + //usage: "\n -l w.x.0.0 Use this class B range instead of 169.254" + //usage: "\n -v Verbose" ++//usage: "\n -s Log to syslog (even in foreground)" + //usage: "\n" + //usage: "\nWith no -q, runs continuously monitoring for ARP conflicts," + //usage: "\nexits only on I/O errors (link down etc)" +@@ -238,7 +239,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + // parse commandline: prog [options] ifname script + // exactly 2 args; -v accumulates and implies -f + opt_complementary = "=2:vv:vf"; +- opts = getopt32(argv, "fqr:l:v", &r_opt, &l_opt, &verbose); ++ opts = getopt32(argv, "fqr:l:vs", &r_opt, &l_opt, &verbose); + #if !BB_MMU + // on NOMMU reexec early (or else we will rerun things twice) + if (!FOREGROUND) +@@ -248,7 +249,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) + // (need to do it before openlog to prevent openlog from taking + // fd 3 (sock_fd==3)) + xmove_fd(xsocket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)), sock_fd); +- if (!FOREGROUND) { ++ if (!FOREGROUND || (opts & 16)) { + // do it before all bb_xx_msg calls + openlog(applet_name, 0, LOG_DAEMON); + logmode |= LOGMODE_SYSLOG; +-- +1.7.12.1 + -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3] netifd: implement zeroconf
The scripts were based on the netifd dhcp scripts, and should add zeroconf support to /etc/config/network Example: config interface 'lan' option ifname 'eth0' option auto '0' option proto 'zeroconf' Optionally, the desired IP address can be added by: option ipaddr '169.254.200.100' any extra commandline arguments can be added by: option cmdline '-v' Note that zcip in Busybox must be enabled for this to work. Signed-off-by: Michel Stam --- .../netifd/files/lib/netifd/proto/zeroconf.sh | 33 ++ .../config/netifd/files/lib/netifd/zeroconf.script | 29 +++ 2 files changed, 62 insertions(+) create mode 100755 package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh create mode 100755 package/network/config/netifd/files/lib/netifd/zeroconf.script diff --git a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh new file mode 100755 index 000..cec7605 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +proto_zeroconf_init_config() { + proto_config_add_string 'ipaddr:ipaddr' + proto_config_add_string cmdline +} + +proto_zeroconf_setup() { + local config="$1" + local iface="$2" + + local ipaddr + json_get_vars ipaddr cmdline + + proto_export "INTERFACE=$config" + proto_run_command "$config" zcip \ + ${ipaddr:+-r $ipaddr} \ + ${cmdline} \ + -f "$iface" \ + /lib/netifd/zeroconf.script +} + +proto_zeroconf_teardown() { + local interface="$1" + proto_kill_command "$INTERFACE" +} + +add_protocol zeroconf + diff --git a/package/network/config/netifd/files/lib/netifd/zeroconf.script b/package/network/config/netifd/files/lib/netifd/zeroconf.script new file mode 100755 index 000..8d34a67 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/zeroconf.script @@ -0,0 +1,29 @@ +#!/bin/sh +[ -z "$1" ] && echo "Error: should be run by zcip" && exit 1 + +. /lib/functions.sh +. /lib/netifd/netifd-proto.sh + +setup_interface () { + proto_init_update "*" 1 + proto_add_ipv4_address "$ip" '255.255.0.0' + proto_send_update "$INTERFACE" +} + +deconfig_interface() { + proto_init_update "*" 0 + proto_send_update "$INTERFACE" +} + +case "$1" in + deconfig) + deconfig_interface + ;; + config) + setup_interface + ;; + *|init) + ;; +esac + +exit 0 -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] busybox: add option for tweaking arpping to udhcpd
Some clients have a very short timeout for sending the DHCP DISCOVER, shorter than the arpping timeout of 2000 milliseconds that udhcpd uses by default. This patch allows tweaking the timeout, or disabling of arpping altogether, at the risk of handing out addresses which are already in use. Signed-off-by: Michel Stam --- package/utils/busybox/Config-defaults.in | 6 ++ .../busybox/config/networking/udhcp/Config.in | 20 ++ .../utils/busybox/patches/245-udhcp_arpping.patch | 73 ++ 3 files changed, 99 insertions(+) create mode 100644 package/utils/busybox/patches/245-udhcp_arpping.patch diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in index 5f5bdd0..dfed895 100644 --- a/package/utils/busybox/Config-defaults.in +++ b/package/utils/busybox/Config-defaults.in @@ -2221,6 +2221,9 @@ config BUSYBOX_DEFAULT_FEATURE_UDHCPD_WRITE_LEASES_EARLY config BUSYBOX_DEFAULT_FEATURE_UDHCPD_BASE_IP_ON_MAC bool default n +config BUSYBOX_DEFAULT_FEATURE_UDHCPD_ARPPING + bool + default y config BUSYBOX_DEFAULT_DHCPD_LEASES_FILE string default "" @@ -2236,6 +2239,9 @@ config BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT config BUSYBOX_DEFAULT_UDHCP_DEBUG int default 0 +config BUSYBOX_DEFAULT_UDHCP_ARPPING_TIMEOUT + int + default 2000 config BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397 bool default y diff --git a/package/utils/busybox/config/networking/udhcp/Config.in b/package/utils/busybox/config/networking/udhcp/Config.in index 576a01a..b6f84d1 100644 --- a/package/utils/busybox/config/networking/udhcp/Config.in +++ b/package/utils/busybox/config/networking/udhcp/Config.in @@ -61,6 +61,16 @@ config BUSYBOX_CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC for the same client to (almost always) contain the same IP address. +config BUSYBOX_CONFIG_FEATURE_UDHCPD_ARPPING + bool "arpping addresses before offering" + default BUSYBOX_DEFAULT_FEATURE_UDHCPD_ARPPING + depends on BUSYBOX_CONFIG_UDHCPD + help + If selected, udhcpd will perform an arpping before offering an + address for a lease. + + This increases server response time. + config BUSYBOX_CONFIG_DHCPD_LEASES_FILE string "Absolute path to lease file" default BUSYBOX_DEFAULT_DHCPD_LEASES_FILE @@ -110,6 +120,16 @@ config BUSYBOX_CONFIG_UDHCP_DEBUG Bigger values result in bigger code. Levels above 1 are very verbose and useful for debugging only. +config BUSYBOX_CONFIG_UDHCP_ARPPING_TIMEOUT + int "Timeout in msec for arppings sent" + default BUSYBOX_DEFAULT_UDHCP_ARPPING_TIMEOUT + depends on BUSYBOX_CONFIG_FEATURE_UDHCPC_ARPING || BUSYBOX_CONFIG_FEATURE_UDHCPD_ARPPING + help + Set the number of milliseconds to wait for arppings + to timeout. + + Bigger values result in an increase in response time. + config BUSYBOX_CONFIG_FEATURE_UDHCP_RFC3397 bool "Support for RFC3397 domain search (experimental)" default BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397 diff --git a/package/utils/busybox/patches/245-udhcp_arpping.patch b/package/utils/busybox/patches/245-udhcp_arpping.patch new file mode 100644 index 000..91f86ee --- /dev/null +++ b/package/utils/busybox/patches/245-udhcp_arpping.patch @@ -0,0 +1,73 @@ +diff -r -U 3 -p busybox-1.19.4/networking/udhcp/Config.src busybox-1.19.4/networking/udhcp/Config.src +--- busybox-1.19.4/networking/udhcp/Config.src 2012-02-04 20:24:55.0 +0100 busybox-1.19.4/networking/udhcp/Config.src 2014-05-02 14:22:49.389127249 +0200 +@@ -55,6 +55,16 @@ config FEATURE_UDHCPD_BASE_IP_ON_MAC + for the same client to (almost always) contain the same + IP address. + ++config FEATURE_UDHCPD_ARPPING ++ bool "arpping addresses before offering" ++ default y ++ depends on UDHCPD ++ help ++If selected, udhcpd will perform an arpping before offering an ++address for a lease. ++ ++This increases server response time. ++ + config DHCPD_LEASES_FILE + string "Absolute path to lease file" + default "/var/lib/misc/udhcpd.leases" +@@ -104,6 +114,16 @@ config UDHCP_DEBUG + Bigger values result in bigger code. Levels above 1 + are very verbose and useful for debugging only. + ++config UDHCP_ARPPING_TIMEOUT ++ int "Timeout in msec for arppings sent" ++ default 2000 ++ depends on FEATURE_UDHCPC_ARPPING || FEATURE_UDHCPD_ARPPING ++ help ++Set the number of milliseconds to wait for arppings ++to timeout. ++ ++Bigger values result in an increase in response time. ++ + config FEATURE_UDHCP_RFC3397 + bool "Support for RFC3397 domain search (experimental)" + default y +diff -r -U 3 -p busybox-1.19.4/networ
[OpenWrt-Devel] [PATCH] authsae: update to latest version
Send a netlink call to leave the mesh when meshd exits Make hunting-and-pecking loop (more) resistant to side channel attack Signed-off-by: Michel Stam --- package/network/services/authsae/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/services/authsae/Makefile b/package/network/services/authsae/Makefile index 2d3ff1d..e7f786f 100644 --- a/package/network/services/authsae/Makefile +++ b/package/network/services/authsae/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=authsae -PKG_VERSION:=2014-04-19 +PKG_VERSION:=2014-06-09 PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=git://github.com/cozybit/authsae.git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=295164a83717ce59ca280468fc2f7edcea6b3cbf +PKG_SOURCE_VERSION:=8531ab158910a525d4bcbb3ad02c08342f6987f2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_BUILD_PARALLEL:=1 -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] lldpd: update to version 0.7.10
Allow discovery protocols to be disabled from menuconfig Signed-off-by: Michel Stam --- package/network/services/lldpd/Config.in | 28 + package/network/services/lldpd/Makefile| 47 -- .../lldpd/patches/002-no-stack-protector.patch | 5 ++- 3 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 package/network/services/lldpd/Config.in diff --git a/package/network/services/lldpd/Config.in b/package/network/services/lldpd/Config.in new file mode 100644 index 000..c7d4795 --- /dev/null +++ b/package/network/services/lldpd/Config.in @@ -0,0 +1,28 @@ +menu "Configuration" + depends on PACKAGE_lldpd + +config LLDPD_WITH_CDP + bool + default y + prompt "Enable support for the Cisco Discovery Protocol (CDP) version 1 and 2" + +config LLDPD_WITH_FDP + bool + default y + prompt "Enable support for the Foundry Discovery Protocol (FDP)" + +config LLDPD_WITH_EDP + bool + default y + prompt "Enable support for the Extreme Discovery Protocol (EDP)" + +config LLDPD_WITH_SONMP + bool + default y + prompt "Enable support for the SynOptics Network Management Protocol" + +config LLDPD_WITH_JSON + bool + prompt "Enable JSON output for the LLDP Command-Line Interface" + default n +endmenu diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 0b85848..bd95d4e 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lldpd -PKG_VERSION:=0.7.7 +PKG_VERSION:=0.7.10 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://media.luffy.cx/files/lldpd -PKG_MD5SUM:=9031734c69940dd79a0a175123275f83 +PKG_MD5SUM:=508f2e76703abf8420d9223aae3db548 PKG_MAINTAINER:=Jo-Philipp Wich @@ -30,8 +30,13 @@ define Package/lldpd SUBMENU:=Routing and Redirection TITLE:=Link Layer Discovery Protocol daemon URL:=https://github.com/vincentbernat/lldpd/wiki - DEPENDS:=+libevent2 +USE_EGLIBC:libbsd + DEPENDS:=+libevent2 +USE_EGLIBC:libbsd +LLDPD_WITH_JSON:libjson-c USERID:=lldp:lldp + MENU:=1 +endef + +define Package/lldpd/config +source "$(SOURCE)/Config.in" endef define Package/lldpd/description @@ -45,12 +50,25 @@ endef define Package/lldpd/install $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/etc/lldpd.d $(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/sbin $(CP) $(PKG_INSTALL_DIR)/usr/sbin/lldp{cli,ctl,d} $(1)/usr/sbin/ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/ $(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd $(INSTALL_DATA) ./files/lldpd.config $(1)/etc/config/lldpd +ifneq ($(CONFIG_LLDPD_WITH_CDP),y) + sed -i -e '/cdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +ifneq ($(CONFIG_LLDPD_WITH_FDP),y) + sed -i -e '/fdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +ifneq ($(CONFIG_LLDPD_WITH_EDP),y) + sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +ifneq ($(CONFIG_LLDPD_WITH_SONMP),y) + sed -i -e '/sonmp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif endef define Package/lldpd/conffiles @@ -61,6 +79,27 @@ CONFIGURE_ARGS += \ --with-privsep-user=lldp \ --with-privsep-group=lldp \ --with-privsep-chroot=/var/run/lldp \ - --with-readline=no + --with-readline=no \ + --with-embedded-libevent=no + +ifneq ($(CONFIG_LLDPD_WITH_CDP),y) +CONFIGURE_ARGS += --disable-cdp +endif + +ifneq ($(CONFIG_LLDPD_WITH_FDP),y) +CONFIGURE_ARGS += --disable-fdp +endif + +ifneq ($(CONFIG_LLDPD_WITH_EDP),y) +CONFIGURE_ARGS += --disable-edp +endif + +ifneq ($(CONFIG_LLDPD_WITH_SONMP),y) +CONFIGURE_ARGS += --disable-sonmp +endif + +ifeq ($(CONFIG_LLDPD_WITH_JSON),y) +CONFIGURE_ARGS += --with-json=json-c +endif $(eval $(call BuildPackage,lldpd)) diff --git a/package/network/services/lldpd/patches/002-no-stack-protector.patch b/package/network/services/lldpd/patches/002-no-stack-protector.patch index dc861ba..8a49d2d 100644 --- a/package/network/services/lldpd/patches/002-no-stack-protector.patch +++ b/package/network/services/lldpd/patches/002-no-stack-protector.patch @@ -1,10 +1,11 @@ --- a/configure.ac +++ b/configure.ac -@@ -62,7 +62,6 @@ AX_CFLAGS_GCC_OPTION([-Wformat]) +@@ -62,7 +62,5 @@ AX_CFLAGS_GCC_OPTION([-Wformat]) AX_CFLAGS_GCC_OPTION([-Wformat-security]) AX_CFLAGS_GCC_OPTION([-Wcast-align]) AX_CFLAGS_GCC_OPTION([-Winline]) -AX_CFLAGS_GCC_OPTION([-fstack-protector]) +-AX_CFLAGS_GCC_OPTION([-fstack-protector-strong]) + AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer]) AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2]) - AX_C
[OpenWrt-Devel] [PATCH] include: make sure modules are modposted after initramfs image is built
From: Tjalling Hattink Otherwise the modpost steps for individual modules that are compiled manually (using make package//install) will give warning of missing symbols when that module depends other modules. This is caused by the Module.symvers file not containing any symbols anymore of external modules when the initramfs image is built without specifically giving the modules target. Signed-off-by: Tjalling Hattink --- include/kernel-defaults.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index da06abd..2f2e564 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -151,6 +151,7 @@ endef define Kernel/CompileImage/Default rm -f $(TARGET_DIR)/init +$(MAKE) $(KERNEL_MAKEOPTS) $(subst ",,$(KERNELNAME)) + +$(MAKE) $(KERNEL_MAKEOPTS) modules #") $(call Kernel/CopyImage) endef @@ -161,6 +162,7 @@ define Kernel/CompileImage/Initramfs $(CP) $(GENERIC_PLATFORM_DIR)/base-files/init $(TARGET_DIR)/init rm -rf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/usr/initramfs_data.cpio* +$(MAKE) $(KERNEL_MAKEOPTS) $(subst ",,$(KERNELNAME)) + +$(MAKE) $(KERNEL_MAKEOPTS) modules #") #") $(call Kernel/CopyImage,-initramfs) -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] libiconv: do not replace untranslatable characters with * or ?
From: Tjalling Hattink Instead throw an -EILSEQ error. Signed-off-by: Tjalling Hattink --- package/libs/libiconv/src/iconv.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package/libs/libiconv/src/iconv.c b/package/libs/libiconv/src/iconv.c index cb4e947..d2e19e3 100644 --- a/package/libs/libiconv/src/iconv.c +++ b/package/libs/libiconv/src/iconv.c @@ -244,7 +244,7 @@ static inline int utf8dec_wchar(wchar_t *c, unsigned char *in, size_t inb) return -1; } -static inline char latin9_translit(wchar_t c) +static inline wchar_t latin9_translit(wchar_t c) { /* a number of trivial iso-8859-15 <> utf-8 transliterations */ switch (c) { @@ -256,7 +256,7 @@ static inline char latin9_translit(wchar_t c) case 0x0152: return 0xBC; /* OE */ case 0x0153: return 0xBD; /* oe */ case 0x0178: return 0xBE; /* Y diaeresis */ - default: return '?'; + default: return 0xFFFD; /* cannot translate */ } } @@ -394,9 +394,9 @@ charok: c = latin9_translit(c); /* fall through */ case LATIN_1: + if (c > 0xff) goto ilseq; if (!*outb) goto toobig; - if (c < 0x100) **out = c; - else x++, **out = '*'; //FIXME: translit? + **out = c; ++*out; --*outb; break; -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] mac80211: remove error from detect script
Signed-off-by: Michel Stam --- package/kernel/mac80211/files/lib/wifi/mac80211.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh index a3b2199..2af4dc5 100644 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -65,7 +65,7 @@ detect_mac80211() { [ -n "$type" ] || break devidx=$(($devidx + 1)) done - for dev in $(ls /sys/class/ieee80211); do + for dev in $(ls /sys/class/ieee80211 2>/dev/null); do found=0 config_foreach check_mac80211_device wifi-device [ "$found" -gt 0 ] && continue -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] netifd: fix an error message during network shutdown
When 'wifi down' is called by /etc/init.d/network, it is run from stop_service( ). This function is in turn invoked from stop( ). stop( ) messes up the order by first procd_kill-ing the network settings, then calling wifi to down the wifi networking interfaces. By redefining stop( ) instead, the proper order is restored. Signed-off-by: Michel Stam --- package/network/config/netifd/files/etc/init.d/network | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network index 1d8a5b3..fbba9ec 100755 --- a/package/network/config/netifd/files/etc/init.d/network +++ b/package/network/config/netifd/files/etc/init.d/network @@ -32,8 +32,9 @@ reload_service() { /sbin/wifi reload_legacy } -stop_service() { +stop() { /sbin/wifi down + procd_kill network '' } service_running() { -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] base-files: remove a 'not found' error message during system boot
During boot, a not found message is displayed for systems which do not have uci 'network.globals.ula_prefix' defined in /etc/config/network. The error message itself is not used and can be ignored. Signed-off-by: Michel Stam --- package/base-files/files/etc/uci-defaults/12_network-generate-ula | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula index 56b7eb3..fb4e3eb 100644 --- a/package/base-files/files/etc/uci-defaults/12_network-generate-ula +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -1,6 +1,6 @@ #!/bin/sh -[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0 +[ "$(uci get network.globals.ula_prefix 2>/dev/null)" != "auto" ] && exit 0 r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"') r2=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"') -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] base-files: remove the deluge of driver messages during bootup
Early during bootup, kmodloader is started which loads the drivers in /etc/modules.d. Unfortunately at this time the system script has not run yet, which is supposed to set the console log level. Having the S10system script moved to an earlier time is not an option, as this in turn will not work because the system script will try to register itself with ubusd, which is not running either. This only happens after S12log is run. As a quick fix, temporarily show only errors and more severe messages. S10system will quickly fix that shortly after, at least the bootup is more sane (and readable). Signed-off-by: Michel Stam --- package/base-files/files/etc/init.d/boot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index f10db13..9223807 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -35,6 +35,9 @@ boot() { grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + # Prevent module load messages from flooding the boot process; 'system' service will fix this + /bin/dmesg -n 3 + /sbin/kmodloader # allow wifi modules time to settle -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] busybox: remove validation message from bootup
A message: uinteger - 9 = true is displayed during boot. This is the result of the validate_data command checking the cron log level. As the output is not interesting, only the result, filter... Signed-off-by: Michel Stam --- package/utils/busybox/files/cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/utils/busybox/files/cron b/package/utils/busybox/files/cron index 8f54527..19ecc43 100755 --- a/package/utils/busybox/files/cron +++ b/package/utils/busybox/files/cron @@ -17,7 +17,7 @@ start_service () { loglevel=$(uci_get "system.@system[0].cronloglevel") [ -z "${loglevel}" ] || { - /sbin/validate_data uinteger "${loglevel}" + /sbin/validate_data uinteger "${loglevel}" 2>/dev/null [ "$?" -eq 0 ] || { echo "validation failed" return 1 -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] toolchain: Fix libthreaddb not being installed
Signed-off-by: Michel Stam --- package/libs/toolchain/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile index 36cf8c4..72ce6b9 100644 --- a/package/libs/toolchain/Makefile +++ b/package/libs/toolchain/Makefile @@ -508,7 +508,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) $(INSTALL_DIR) $(1)/lib $(CP) \ $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib - ifeq ($(USE_UCLIBC),y) + ifeq ($(CONFIG_USE_UCLIBC),y) $(CP) \ $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \ $(1)/lib/ -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 7/8] Show the shutdown sequence on the active virtual terminal
procd by default writes to /dev/console. When rebooting, this means that the terminal on which the reboot sequence was started will not see what is going on. This patch fixes that by reopening stdin, stdout and stderr to /dev/tty0 upon reboot. Also, due to (probably) pivot-root, /proc/1/fd shows 1-3 pointing to /console. This patch also fixes that. Signed-off-by: Michel Stam --- state.c | 13 + 1 file changed, 13 insertions(+) diff --git a/state.c b/state.c index e6c8712..2268de3 100644 --- a/state.c +++ b/state.c @@ -12,7 +12,9 @@ * GNU General Public License for more details. */ +#include #include +#include #include #include #include @@ -37,6 +39,14 @@ enum { static int state = STATE_NONE; static int reboot_event; +static void set_stdio( const char* tty ) +{ + freopen( tty, "r", stdin ); + freopen( tty, "w", stdout ); + freopen( tty, "w", stderr ); + fcntl(STDERR_FILENO, F_SETFL, fcntl(STDERR_FILENO, F_GETFL) | O_NONBLOCK); +} + static void state_enter(void) { char ubus_cmd[] = "/sbin/ubusd"; @@ -55,6 +65,7 @@ static void state_enter(void) LOG("- ubus -\n"); procd_connect_ubus(); + set_stdio( "/dev/console" ); LOG("- init -\n"); service_init(); service_start_early("ubus", ubus_cmd); @@ -71,6 +82,8 @@ static void state_enter(void) break; case STATE_SHUTDOWN: + /* Redirect output to the current virtual terminal for the users' benefit */ + set_stdio( "/dev/tty0" ); LOG("- shutdown -\n"); procd_inittab_run("shutdown"); sync(); -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 8/8] Fix 'reboot' message when the system is powering down
While executing a system halt (via the powerbutton or otherwise), the system displays rebooting, whereas it should display that it is going to turn off. Signed-off-by: Michel Stam --- state.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/state.c b/state.c index 2268de3..c31f6a8 100644 --- a/state.c +++ b/state.c @@ -98,7 +98,10 @@ static void state_enter(void) kill(-1, SIGKILL); sync(); sleep(1); - LOG("- reboot -\n"); + if (reboot_event == RB_POWER_OFF) + LOG("- power down -\n"); + else + LOG("- reboot -\n"); /* Allow time for last message to reach serial console, etc */ sleep(1); -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 5/8] Kill processes on shutdown
Procd as it currently is does not kill the running processes during shutdown. As this might cause undesired behaviour, this should be implemented. Implementation was taken from busybox 1.19.4 Signed-off-by: Michel Stam --- state.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/state.c b/state.c index 2de32e1..05f7dc5 100644 --- a/state.c +++ b/state.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "procd.h" #include "syslog.h" @@ -75,6 +77,14 @@ static void state_enter(void) break; case STATE_HALT: + LOG("- SIGTERM processes -\n"); + kill(-1, SIGTERM); + sync(); + sleep(1); + LOG("- SIGKILL processes -\n"); + kill(-1, SIGKILL); + sync(); + sleep(1); LOG("- reboot -\n"); reboot(reboot_event); break; -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 3/8] Fix curses applications to work with procd
The problem was caused by procd not opening /dev/tty* (which ever was specified in /etc/inittab), causing /proc/PID/fd to point to /console instead. /dev/console is a non-controlling tty (CTTY), and cannot be used as one, which is exactly what curses applications want. Since this is very likely to cause problems with other programs, procd now opens /dev/tty? when the ID field of the inittab assigns one, and forces this to be a CTTY. Signed-off-by: Michel Stam --- inittab.c| 64 +--- utils/askfirst.c | 28 ++--- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/inittab.c b/inittab.c index c8540b1..344c55d 100644 --- a/inittab.c +++ b/inittab.c @@ -25,6 +25,7 @@ #include #include +#include #include "procd.h" #include "rcS.h" @@ -63,10 +64,49 @@ static char *ask = "/sbin/askfirst"; static LIST_HEAD(actions); +static int dev_open(const char *dev) +{ + int fd = -1; + + if (dev) { + chdir("/dev"); + fd = open( dev, O_RDWR); + chdir("/"); + } + + return fd; +} + +static int dev_exist(const char *dev) +{ + int res; + + res = dev_open(dev); + if (res != -1) { + close(res); + } + + return (res != -1); +} + static void fork_worker(struct init_action *a) { + int fd; + pid_t p; + a->proc.pid = fork(); if (!a->proc.pid) { + p = setsid( ); + fd = dev_open(a->id); + if (fd != -1) + { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + tcsetpgrp(fd, p); + close(fd); + ioctl(STDIN_FILENO, TIOCSCTTY, 1); + } execvp(a->argv[0], a->argv); ERROR("Failed to execute %s\n", a->argv[0]); exit(-1); @@ -110,22 +150,17 @@ static void runrc(struct init_action *a) static void askfirst(struct init_action *a) { - struct stat s; int i; - chdir("/dev"); - i = stat(a->id, &s); - chdir("/"); - if (i || (console && !strcmp(console, a->id))) { + if (!dev_exist(a->id) || (console && !strcmp(console, a->id))) { DEBUG(4, "Skipping %s\n", a->id); return; } a->tout.cb = respawn; - for (i = MAX_ARGS - 2; i >= 2; i--) - a->argv[i] = a->argv[i - 2]; + for (i = MAX_ARGS - 1; i >= 1; i--) + a->argv[i] = a->argv[i - 1]; a->argv[0] = ask; - a->argv[1] = a->id; a->respawn = 500; a->proc.cb = child_exit; @@ -134,7 +169,6 @@ static void askfirst(struct init_action *a) static void askconsole(struct init_action *a) { - struct stat s; char line[256], *tty; int i, r, fd = open("/proc/cmdline", O_RDONLY); regex_t pat_cmdline; @@ -153,20 +187,16 @@ static void askconsole(struct init_action *a) line[matches[1].rm_eo] = '\0'; tty = &line[matches[1].rm_so]; - chdir("/dev"); - i = stat(tty, &s); - chdir("/"); - if (i) { + if (!dev_exist(tty)) { DEBUG(4, "skipping %s\n", tty); goto err_out; } - console = strdup(tty); a->tout.cb = respawn; - for (i = MAX_ARGS - 2; i >= 2; i--) - a->argv[i] = a->argv[i - 2]; + for (i = MAX_ARGS - 1; i >= 1; i--) + a->argv[i] = a->argv[i - 1]; + a->id = strdup(tty); a->argv[0] = ask; - a->argv[1] = strdup(tty); a->respawn = 500; a->proc.cb = child_exit; diff --git a/utils/askfirst.c b/utils/askfirst.c index 6ad77aa..e1f757a 100644 --- a/utils/askfirst.c +++ b/utils/askfirst.c @@ -19,34 +19,10 @@ #include #include -static int redirect_output(const char *dev) -{ - pid_t p = setsid(); - int fd; - - chdir("/dev"); - fd = open(dev, O_RDWR); - chdir("/"); - - if (fd < 0) - return -1; - - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - tcsetpgrp(fd, p); - close(fd); - - return 0; -} - int main(int argc, char **argv) { int c; - if (redirect_output(argv[1])) - fprintf(stderr, "%s: Failed to open %s\n", argv[0], argv[1]); - printf("Please press Enter to activate this console.\n"); do { c = getchar(); @@ -55
[OpenWrt-Devel] [PATCH procd 4/8] Fix scroll lock blocking procd
On x86, pressing the scrolllock button may effectively prevent procd from rebooting the system. This happens because procd tries to write to /dev/console, which in that situation is blocked, effectively blocking procd from rebooting the system. This patch puts procd's stderr access into non-blocking, which will prevent the boot from being stuck. Signed-off-by: Michel Stam --- procd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/procd.c b/procd.c index 6ec7cd0..32febd6 100644 --- a/procd.c +++ b/procd.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,7 @@ int main(int argc, char **argv) return usage(argv[0]); } } + fcntl(STDERR_FILENO, F_SETFL, fcntl(STDERR_FILENO, F_GETFL) | O_NONBLOCK); uloop_init(); uloop_release_sigint(); procd_signal(); -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 6/8] Reboot busybox style via procd
It has been observed that, very rarely, the system does not reboot when procd enters the shutdown state. Busybox seems to have an obscure fix in its shutdown, where the parent (procd) process is put in an infinite loop, and a special child is executed to execute reboot(). This may very well be the cause. Signed-off-by: Michel Stam --- state.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/state.c b/state.c index 05f7dc5..e6c8712 100644 --- a/state.c +++ b/state.c @@ -86,7 +86,20 @@ static void state_enter(void) sync(); sleep(1); LOG("- reboot -\n"); - reboot(reboot_event); + + /* Allow time for last message to reach serial console, etc */ + sleep(1); + + /* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS) +* in linux/kernel/sys.c, which can cause the machine to panic when +* the init process exits... */ + if (!vfork( )) { /* child */ + reboot(reboot_event); + _exit(EXIT_SUCCESS); + } + + while (1) + sleep(1); break; default: -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 2/8] Log startup/shutdown to console
procd has the habit of logging startup/shutdown via rcS to syslog, which is pointless in case of a shutdown, and unlikely to be complete on a startup (as syslog is not running). Write to /dev/console instead. Signed-off-by: Michel Stam --- rcS.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rcS.c b/rcS.c index 4545621..e01fc49 100644 --- a/rcS.c +++ b/rcS.c @@ -18,10 +18,11 @@ #include #include +#include #include #include #include - +#include #include #include #include @@ -43,8 +44,9 @@ struct initd { static void pipe_cb(struct ustream *s, int bytes) { char *newline, *str; - int len; + int len, console_fd; + console_fd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK); do { str = ustream_get_read_buf(s, NULL); if (!str) @@ -52,11 +54,11 @@ static void pipe_cb(struct ustream *s, int bytes) newline = strchr(str, '\n'); if (!newline) break; - *newline = 0; len = newline + 1 - str; - syslog(0, "%s", str); + write(console_fd, str, len); ustream_consume(s, len); } while (1); + close(console_fd); } static void q_initd_run(struct runqueue *q, struct runqueue_task *t) -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd 1/8] Fix procd not handling rapid reboot signals very well
When keeping ctrl-alt-del pressed, or when running; while true; do /sbin/reboot done effectively the procd shutdown cycle gets into an undefined state, Signed-off-by: Michel Stam --- state.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/state.c b/state.c index e5f0015..2de32e1 100644 --- a/state.c +++ b/state.c @@ -94,8 +94,10 @@ void procd_state_next(void) void procd_shutdown(int event) { - DEBUG(2, "Shutting down system with event %x\n", event); - reboot_event = event; - state = STATE_SHUTDOWN; - state_enter(); + if (state < STATE_SHUTDOWN) { + DEBUG(2, "Shutting down system with event %x\n", event); + reboot_event = event; + state = STATE_SHUTDOWN; + state_enter(); + } } -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH procd] Add ctrlaltdel handler to procd
Procd, up until now, did not support the ctrlaltdel handler. Thus, the system would immediately reboot upon the three-finger salute, and no shutdown scripts would be run. This patch adds the handler for the /etc/inittab entry, so that /sbin/reboot can be run and in turn the shutdown scripts can be invoked. Signed-off-by: Michel Stam --- procd.c | 1 + signal.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/procd.c b/procd.c index ad80284..6ec7cd0 100644 --- a/procd.c +++ b/procd.c @@ -62,6 +62,7 @@ int main(int argc, char **argv) } } uloop_init(); + uloop_release_sigint(); procd_signal(); trigger_init(); if (getpid() != 1) diff --git a/signal.c b/signal.c index 74cabcb..6c00fd9 100644 --- a/signal.c +++ b/signal.c @@ -36,6 +36,7 @@ static void signal_shutdown(int signal, siginfo_t *siginfo, void *data) char *msg = NULL; switch(signal) { + case SIGINT: case SIGTERM: event = RB_AUTOBOOT; msg = "reboot"; @@ -91,4 +92,6 @@ void procd_signal(void) sigaction(SIGHUP, &sa_dummy, NULL); sigaction(SIGKILL, &sa_dummy, NULL); sigaction(SIGSTOP, &sa_dummy, NULL); + sigaction(SIGINT, &sa_shutdown, NULL); + reboot(RB_DISABLE_CAD); } -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH libubox] Allow SIGINT to be released on request
SIGINT is captured by uloop by default. This does not work for procd, where SIGINT is used by the kernel to indicate that the system must be rebooted. Signed-off-by: Michel Stam --- uloop.c | 24 +--- uloop.h | 1 + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/uloop.c b/uloop.c index c3d206a..5180a80 100644 --- a/uloop.c +++ b/uloop.c @@ -57,6 +57,7 @@ static struct list_head timeouts = LIST_HEAD_INIT(timeouts); static struct list_head processes = LIST_HEAD_INIT(processes); static int poll_fd = -1; +static bool uloop_catch_sigint = true; bool uloop_cancelled = false; bool uloop_handle_sigchld = true; static bool do_sigchld = false; @@ -549,6 +550,11 @@ static void uloop_handle_processes(void) } +void uloop_release_sigint(void) +{ + uloop_catch_sigint = false; +} + static void uloop_handle_sigint(int signo) { uloop_cancelled = true; @@ -562,18 +568,22 @@ static void uloop_sigchld(int signo) static void uloop_setup_signals(bool add) { static struct sigaction old_sigint, old_sigchld; + static bool sigint_caught = false; struct sigaction s; memset(&s, 0, sizeof(struct sigaction)); - if (add) { - s.sa_handler = uloop_handle_sigint; - s.sa_flags = 0; - } else { - s = old_sigint; - } + if (uloop_catch_sigint || sigint_caught) { + sigint_caught = true; + if (add) { + s.sa_handler = uloop_handle_sigint; + s.sa_flags = 0; + } else { + s = old_sigint; + } - sigaction(SIGINT, &s, &old_sigint); + sigaction(SIGINT, &s, &old_sigint); + } if (!uloop_handle_sigchld) return; diff --git a/uloop.h b/uloop.h index 7564514..b38d213 100644 --- a/uloop.h +++ b/uloop.h @@ -105,5 +105,6 @@ static inline void uloop_end(void) int uloop_init(void); void uloop_run(void); void uloop_done(void); +void uloop_release_sigint(void); #endif -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH ubox] Use different loglevels
Ubox logs various messages during OpenWRT boot which are not very interesting, such as the number of iterations made. This fix implements several loglevels for debug/info/error so that more useful messages are shown. Signed-off-by: Michel Stam --- kmodloader.c | 75 +--- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/kmodloader.c b/kmodloader.c index 633570f..04d7c1d 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -38,10 +38,17 @@ #define DEF_MOD_PATH "/lib/modules/%s/" -#define LOG(fmt, ...) do { \ +#define INFO(fmt, ...) do { \ syslog(LOG_INFO, fmt, ## __VA_ARGS__); \ printf("kmod: "fmt, ## __VA_ARGS__); \ } while (0) +#define ERROR(fmt, ...) do { \ + syslog(LOG_ERR, fmt, ## __VA_ARGS__); \ + fprintf(stderr,"kmod: "fmt, ## __VA_ARGS__); \ + } while (0) +#define DEBUG(fmt, ...) do { \ + syslog(LOG_DEBUG, fmt, ## __VA_ARGS__); \ + } while (0) enum { @@ -165,7 +172,7 @@ static int elf_find_section(char *map, const char *section, unsigned int *offset else if (clazz == ELFCLASS64) return elf64_find_section(map, section, offset, size); - LOG("unknown elf format %d\n", clazz); + ERROR("unknown elf format %d\n", clazz); return -1; } @@ -208,7 +215,7 @@ static int scan_loaded_modules(void) fp = fopen("/proc/modules", "r"); if (!fp) { - LOG("failed to open /proc/modules\n"); + ERROR("failed to open /proc/modules\n"); return -1; } @@ -243,23 +250,23 @@ static struct module* get_module_info(const char *module, const char *name) struct stat s; if (!fd) { - LOG("failed to open %s\n", module); + ERROR("failed to open %s\n", module); return NULL; } if (fstat(fd, &s) == -1) { - LOG("failed to stat %s\n", module); + ERROR("failed to stat %s\n", module); return NULL; } map = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (map == MAP_FAILED) { - LOG("failed to mmap %s\n", module); + ERROR("failed to mmap %s\n", module); return NULL; } if (elf_find_section(map, ".modinfo", &offset, &size)) { - LOG("failed to load the .modinfo section from %s\n", module); + ERROR("failed to load the .modinfo section from %s\n", module); return NULL; } @@ -329,23 +336,23 @@ static int print_modinfo(char *module) char *map, *strings; if (!fd) { - LOG("failed to open %s\n", module); + ERROR("failed to open %s\n", module); return -1; } if (fstat(fd, &s) == -1) { - LOG("failed to stat %s\n", module); + ERROR("failed to stat %s\n", module); return -1; } map = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (map == MAP_FAILED) { - LOG("failed to mmap %s\n", module); + ERROR("failed to mmap %s\n", module); return -1; } if (elf_find_section(map, ".modinfo", &offset, &size)) { - LOG("failed to load the .modinfo section from %s\n", module); + ERROR("failed to load the .modinfo section from %s\n", module); return -1; } @@ -390,9 +397,9 @@ static int deps_available(struct module *m, int verbose) m = find_module(dep); if (verbose && !m) - LOG("missing dependency %s\n", dep); + ERROR("missing dependency %s\n", dep); if (verbose && m && (m->state != LOADED)) - LOG("dependency not loaded %s\n", dep); + ERROR("dependency not loaded %s\n", dep); if (!m || (m->state != LOADED)) err++; dep += strlen(dep) + 1; @@ -408,13 +415,13 @@ static int insert_module(char *path, const char *options) int fd, ret = -1; if (stat(path, &s)) { - LOG("missing module %s\n", path); + ERROR("missing module %s\n", path); return ret; } fd = open(path, O_RDONLY); if (!fd) { - LOG("cannot open %s\n", path); + ERROR("cannot open %s\n", path); return ret; } @@
[OpenWrt-Devel] [PATCH netifd] proto-shell: fix for not handling switch from DHCP to static race
When a shell script call is finished, proto_shell_task_finish( ) is called to monitor processes, and determine the next interface state. When the interface is brought up after a reconfiguration from dhcp to static, it will first try to (erroneously?) reconfigure the interface for DHCP. Upon doing this, it realises the mistake and kills off the script by setting the state to S_SETUP_ABORT. This is done by the proto_shell_handler. When this happens. the scripts have 1 second to finish. When this happens, S_SETUP_ABORT in proto_shell_task_finish( ) should issue a 'teardown' event to the shell script to deconfigure the interface. It is here that things go wrong. Shell scripts do not execute commands themselves, they should finish as quick as possible. This is very race condition sensitive, though; Instead of executing commands, they post messages to execute commands. It is therefore possible that when the script finishes, there's still commands to execute. The dhcp protocol handler script, one of the scripts involved, notifies netifd of changes by (indirectly) calling proto_shell_update_link( ). Once every so often, the dhcp script will not be finished in time, and proto_shell_task_finish( ) cannot immediately continue, because (in this case) the proto_task is still pending. If this happens, the proto_shell_task_finish( ) will wait, but if the proto_shell_update_link( ) notification is then received, it will set the statemachine to idle, thus breaking the S_SETUP_ABORT. Furthermore, an event is generated to indicate that the network interface should be set to UP, rather than DOWN. This confuses netifd, and the result is a stuck process that does not respond to UCI calls anymore. Note that a similar situation happens in the S_TEARDOWN state in proto_shell_task_finish( ). The fix, although a bit ugly, is to prevent the UP event from being sent, and not to reset the state machine to idle in proto_shell_update_link( ). Signed-off-by: Michel Stam --- proto-shell.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proto-shell.c b/proto-shell.c index 7c23caa..0131e19 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -506,9 +506,11 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, interface_update_complete(state->proto.iface); - if (!keep) - state->proto.proto_event(&state->proto, IFPEV_UP); - state->sm = S_IDLE; + if ((state->sm != S_SETUP_ABORT) && (state->sm != S_TEARDOWN)) { + if (!keep) + state->proto.proto_event(&state->proto, IFPEV_UP); + state->sm = S_IDLE; + } return 0; } -- 1.7.12.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel