[OpenWrt-Devel] otrx: musl (?) compiles it as for big endian arch on bcm53xx

2015-06-20 Thread Rafał Miłecki
When compiling otrx packages on bcm53xx the following condition is true:
#if __BYTE_ORDER == __BIG_ENDIAN

It results in not working otrx app. I suspect it's a regression since
switching to musl.

Any ideas?

-- 
Rafał
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH procd] service: start apps with LD_PRELOAD & lib disabling buffering

2015-06-20 Thread Etienne Champetier
Hi,

2015-06-20 21:35 GMT+02:00 John Crispin :

>
>
> On 20/06/2015 20:53, Rafał Miłecki wrote:
> > On 20 June 2015 at 13:56, Jo-Philipp Wich  wrote:
> >>> i dont like this idea at all. calling ld-preload on every started app
> >>> just seems wrong
> >>
> >> I was the one suggesting the idea since we needed a solution which does
> >> not require modification of downstream programs. We could restrict the
> >> preloading to programs which requested stdio relaying support from procd
> >> and not preload for the rest.
> >
> > AFAIK there are 3 solutions to this:
> > 1) Modifying every app we want to support with procd + logging
> > 2) Using PTY which I tried in https://patchwork.ozlabs.org/patch/486670/
> > 3) Using LD_PRELOAD
> >
> > The PTY was pointed as not the best choice, so that's why I continued
> > with LD_PRELOAD. As Jo-Philipp pointed, it's the same solution
> > "stdbuf" uses. I'm afraid there isn't any better alternative :(
> >
>
> oh well, i still dont like it but that is not really relevant i guess ...
> :)
>
Aren't you using LD_PRELOAD for procd jailing stuff ?
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH V2 procd] service: start apps with LD_PRELOAD & lib for line buffering

2015-06-20 Thread Rafał Miłecki
Using pipe automatically switches service to block buffering which kind
of breaks our logging. We won't get anything from FD until the buffer
gets filled fully or the service exits. This makes log messages appear
with an unwanted delay.
This adds a tiny libsetlbf.so that switches stdout to line buffering and
uses this lib for every logging-enabled service started by procd.

Signed-off-by: Rafał Miłecki 
---
V2: Use strncat for safety
Use line buffering instead of no buffering
---
 CMakeLists.txt |  7 +++
 service/instance.c | 19 ++-
 service/setlbf.c   |  6 ++
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 service/setlbf.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dfa9413..6af17a3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,13 @@ IF(APPLE)
   LINK_DIRECTORIES(/opt/local/lib)
 ENDIF()
 
+
+ADD_LIBRARY(setlbf SHARED service/setlbf.c)
+INSTALL(TARGETS setlbf
+   LIBRARY DESTINATION lib
+)
+
+
 SET(SOURCES procd.c signal.c watchdog.c state.cinittab.c rcS.c ubus.c 
system.c
service/service.c service/instance.c service/validate.c 
service/trigger.c service/watch.c
plug/coldplug.c plug/hotplug.c utils/utils.c)
diff --git a/service/instance.c b/service/instance.c
index 35b2def..d0d4251 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -224,6 +224,8 @@ instance_run(struct service_instance *in, int _stdout, int 
_stderr)
struct blobmsg_list_node *var;
struct blob_attr *cur;
char **argv;
+   char ld_preload[64] = {}; /* Has to be big enough for all cases */
+   size_t ld_preload_space = sizeof(ld_preload) - 1;
int argc = 1; /* NULL terminated */
int rem, _stdin;
 
@@ -238,8 +240,23 @@ instance_run(struct service_instance *in, int _stdout, int 
_stderr)
 
if (!in->trace && !in->has_jail && in->seccomp) {
setenv("SECCOMP_FILE", in->seccomp, 1);
-   setenv("LD_PRELOAD", "/lib/libpreload-seccomp.so", 1);
+   if (ld_preload[0] && ld_preload_space > 0) {
+   strcat(ld_preload, ":");
+   ld_preload_space--;
+   }
+   strncat(ld_preload, "/lib/libpreload-seccomp.so", 
ld_preload_space);
+   ld_preload_space = sizeof(ld_preload) - strlen(ld_preload) - 1;
+   }
+   if (_stdout >= 0) {
+   if (ld_preload[0] && ld_preload_space > 0) {
+   strcat(ld_preload, ":");
+   ld_preload_space--;
+   }
+   strncat(ld_preload, "/lib/libsetlbf.so", ld_preload_space);
+   ld_preload_space = sizeof(ld_preload) - strlen(ld_preload) - 1;
}
+   if (ld_preload[0])
+   setenv("LD_PRELOAD", ld_preload, 1);
 
blobmsg_list_for_each(&in->limits, var)
instance_limits(blobmsg_name(var->data), 
blobmsg_data(var->data));
diff --git a/service/setlbf.c b/service/setlbf.c
new file mode 100644
index 000..df00366
--- /dev/null
+++ b/service/setlbf.c
@@ -0,0 +1,6 @@
+#include 
+
+static void __attribute__((constructor)) setlbf(void)
+{
+   setlinebuf(stdout);
+}
-- 
1.8.4.5
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH procd] service: start apps with LD_PRELOAD & lib disabling buffering

2015-06-20 Thread John Crispin


On 20/06/2015 20:53, Rafał Miłecki wrote:
> On 20 June 2015 at 13:56, Jo-Philipp Wich  wrote:
>>> i dont like this idea at all. calling ld-preload on every started app
>>> just seems wrong
>>
>> I was the one suggesting the idea since we needed a solution which does
>> not require modification of downstream programs. We could restrict the
>> preloading to programs which requested stdio relaying support from procd
>> and not preload for the rest.
> 
> AFAIK there are 3 solutions to this:
> 1) Modifying every app we want to support with procd + logging
> 2) Using PTY which I tried in https://patchwork.ozlabs.org/patch/486670/
> 3) Using LD_PRELOAD
> 
> The PTY was pointed as not the best choice, so that's why I continued
> with LD_PRELOAD. As Jo-Philipp pointed, it's the same solution
> "stdbuf" uses. I'm afraid there isn't any better alternative :(
> 

oh well, i still dont like it but that is not really relevant i guess ... :)
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH procd] service: start apps with LD_PRELOAD & lib disabling buffering

2015-06-20 Thread Rafał Miłecki
On 20 June 2015 at 13:56, Jo-Philipp Wich  wrote:
>> i dont like this idea at all. calling ld-preload on every started app
>> just seems wrong
>
> I was the one suggesting the idea since we needed a solution which does
> not require modification of downstream programs. We could restrict the
> preloading to programs which requested stdio relaying support from procd
> and not preload for the rest.

AFAIK there are 3 solutions to this:
1) Modifying every app we want to support with procd + logging
2) Using PTY which I tried in https://patchwork.ozlabs.org/patch/486670/
3) Using LD_PRELOAD

The PTY was pointed as not the best choice, so that's why I continued
with LD_PRELOAD. As Jo-Philipp pointed, it's the same solution
"stdbuf" uses. I'm afraid there isn't any better alternative :(

-- 
Rafał
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/3] ar71xx: add support for ubnt rocket-m ti

2015-06-20 Thread Alexander Couzens
rocket-m titanium is a device based on ar9344 with 802.11af poe.
It doesn't use the SoC wifi, instead it's using an ar9280 connected to
the pci bus. The gps version of the rocket-m ti is working, but
gps is untested. The gps is connected to the first serial port.

Signed-off-by: Alexander Couzens 
---
 target/linux/ar71xx/base-files/etc/diag.sh |   3 +
 .../ar71xx/base-files/etc/uci-defaults/01_leds |   9 ++
 .../ar71xx/base-files/etc/uci-defaults/02_network  |   1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh   |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh  |   1 +
 target/linux/ar71xx/image/Makefile |   9 +-
 .../904-MIPS-ath79-ubnt-rocket-m-ti-supprt.patch   | 139 +
 7 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 
target/linux/ar71xx/patches-3.18/904-MIPS-ath79-ubnt-rocket-m-ti-supprt.patch

diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index 0553251..fefe4d1 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -37,6 +37,9 @@ get_status_led() {
bullet-m | rocket-m | rocket-m-xw | nano-m | nanostation-m | 
nanostation-m-xw | loco-m-xw)
status_led="ubnt:green:link4"
;;
+   rocket-m-ti)
+   status_led="ubnt:green:link6"
+   ;;
bxu2000n-2-a1)
status_led="bhu:green:status"
;;
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds 
b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
index 41b..a6e53ed 100644
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
@@ -47,6 +47,15 @@ loco-m-xw)
ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "ubnt:green:link4" "wlan0" 
"76" "100" "-75" "13"
;;
 
+rocket-m-ti)
+   ucidef_set_led_rssi "rssiverylow"   "RSSIVERYLOW"   
"ubnt:green:link1" "wlan0" "1" "100" "0" "13"
+   ucidef_set_led_rssi "rssilow"   "RSSILOW"   
"ubnt:green:link2" "wlan0" "26" "100" "-25" "13"
+   ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" 
"ubnt:green:link3" "wlan0" "51" "100" "-50" "13"
+   ucidef_set_led_rssi "rssimediumhigh""RSSIMEDIUMHIGH"
"ubnt:green:link4" "wlan0" "76" "100" "-75" "13"
+   ucidef_set_led_rssi "rssihigh"  "RSSIHIGH"  
"ubnt:green:link5" "wlan0" "76" "100" "-75" "13"
+   ucidef_set_led_rssi "rssiveryhigh"  "RSSIVERYHIGH"  
"ubnt:green:link4" "wlan0" "76" "100" "-75" "13"
+   ;;
+
 bxu2000n-2-a1)
ucidef_set_led_wlan "wlan" "WLAN" "bhu:green:wlan" "phy0tpt"
;;
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network 
b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
index f5c6865..f7ae983 100644
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
@@ -18,6 +18,7 @@ case "$board" in
 all0315n |\
 all0258n |\
 ja76pf2|\
+rocket-m-ti |\
 ubnt-unifi-outdoor)
ucidef_set_interface_lan "eth0 eth1"
;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index b13be1e..fe08a50 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -631,6 +631,9 @@ ar71xx_board_detect() {
*"Rocket M")
name="rocket-m"
;;
+   *"Rocket M TI")
+   name="rocket-m-ti"
+   ;;
*"Rocket M XW")
name="rocket-m-xw"
;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 3dbd91c..5c91801 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -227,6 +227,7 @@ platform_check_image() {
nanostation-m | \
rocket-m | \
rocket-m-xw | \
+   rocket-m-ti | \
nanostation-m-xw | \
rw2458n | \
wndap360 | \
diff --git a/target/linux/ar71xx/image/Makefile 
b/target/linux/ar71xx/image/Makefile
index 21d0d66..9f23348 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -763,7 +763,14 @@ define Device/ubnt-rocket-m-xw
   $(Device/ubnt-xw)
   BOARDNAME := UBNT-RM-XW
 endef
-TARGET_DEVICES += ubnt-nano-m-xw ubnt-loco-m-xw ubnt-rocket-m-xw
+
+define Device/ubnt-rocket-m-ti
+  $(Device/ubnt-xw)
+  BOARDNAME := UBNT-RM-TI
+  UBNT_TYPE := TI
+  UBNT_BOARD := XM
+endef
+TARGET_DEVICES += ubnt-nano-m-xw ubnt-loco-m-xw ubnt-rocket-m-xw 
ubnt-rocket-m-ti
 
 define Device/ubnt-air-gateway
   $(Device/ubnt-xm)
diff --git 
a/target/linux/ar71xx/patches-3.18/904-MIPS-ath79-ubnt-rocket-m-ti-supprt.patch 
b/target/linux/ar71xx/patches-3.

[OpenWrt-Devel] [PATCH 2/3] ar71xx: allow pci calibration fixup to work with ar9344

2015-06-20 Thread Alexander Couzens
Signed-off-by: Alexander Couzens 
---
 target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c 
b/target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c
index fcca1d2..2202351 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c
@@ -73,6 +73,9 @@ static void ath9k_pci_fixup(struct pci_dev *dev)
case ATH79_SOC_AR7242:
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0x1000);
break;
+   case ATH79_SOC_AR9344:
+   pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0x1000);
+   break;
 
default:
BUG();
-- 
2.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] phy/at803x: fix null-pointer access when platform data isn't set

2015-06-20 Thread Alexander Couzens
Signed-off-by: Alexander Couzens 
---
 .../patches-3.18/425-net-phy-at803x-allow-to-configure-via-pdata.patch  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/target/linux/ar71xx/patches-3.18/425-net-phy-at803x-allow-to-configure-via-pdata.patch
 
b/target/linux/ar71xx/patches-3.18/425-net-phy-at803x-allow-to-configure-via-pdata.patch
index d046ede..462a63e 100644
--- 
a/target/linux/ar71xx/patches-3.18/425-net-phy-at803x-allow-to-configure-via-pdata.patch
+++ 
b/target/linux/ar71xx/patches-3.18/425-net-phy-at803x-allow-to-configure-via-pdata.patch
@@ -142,7 +142,7 @@
priv->phy_reset = false;
}
 +  }
-+  if (pdata->fixup_rgmii_tx_delay &&
++  if (pdata && pdata->fixup_rgmii_tx_delay &&
 +  phydev->speed != priv->prev_speed) {
 +  switch (phydev->speed) {
 +  case SPEED_10:
-- 
2.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH procd] service: start apps with LD_PRELOAD & lib disabling buffering

2015-06-20 Thread Jo-Philipp Wich
Hi John,

> i dont like this idea at all. calling ld-preload on every started app
> just seems wrong

I was the one suggesting the idea since we needed a solution which does
not require modification of downstream programs. We could restrict the
preloading to programs which requested stdio relaying support from procd
and not preload for the rest.

~ Jow
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH procd] service: start apps with LD_PRELOAD & lib disabling buffering

2015-06-20 Thread John Crispin
i dont like this idea at all. calling ld-preload on every started app
just seems wrong


On 20/06/2015 01:03, Rafał Miłecki wrote:
> Using pipe automatically switches service to block buffering which kind
> of breaks our logging. We won't get anything from FD until the buffer
> gets filled fully or the service exits. This makes log messages appear
> with an unwanted delay.
> This adds a tiny libsetnbf.so that disables stdout buffering and uses it
> for every service started by procd.
> 
> Signed-off-by: Rafał Miłecki 
> ---
>  CMakeLists.txt |  7 +++
>  service/instance.c | 12 +++-
>  service/setnbf.c   |  6 ++
>  3 files changed, 24 insertions(+), 1 deletion(-)
>  create mode 100644 service/setnbf.c
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index dfa9413..c3b7c1e 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -10,6 +10,13 @@ IF(APPLE)
>LINK_DIRECTORIES(/opt/local/lib)
>  ENDIF()
>  
> +
> +ADD_LIBRARY(setnbf SHARED service/setnbf.c)
> +INSTALL(TARGETS setnbf
> + LIBRARY DESTINATION lib
> +)
> +
> +
>  SET(SOURCES procd.c signal.c watchdog.c state.c  inittab.c rcS.c ubus.c 
> system.c
>   service/service.c service/instance.c service/validate.c 
> service/trigger.c service/watch.c
>   plug/coldplug.c plug/hotplug.c utils/utils.c)
> diff --git a/service/instance.c b/service/instance.c
> index 35b2def..726f859 100644
> --- a/service/instance.c
> +++ b/service/instance.c
> @@ -224,6 +224,7 @@ instance_run(struct service_instance *in, int _stdout, 
> int _stderr)
>   struct blobmsg_list_node *var;
>   struct blob_attr *cur;
>   char **argv;
> + char ld_preload[64] = {}; /* Has to be big enough for all cases */
>   int argc = 1; /* NULL terminated */
>   int rem, _stdin;
>  
> @@ -238,8 +239,17 @@ instance_run(struct service_instance *in, int _stdout, 
> int _stderr)
>  
>   if (!in->trace && !in->has_jail && in->seccomp) {
>   setenv("SECCOMP_FILE", in->seccomp, 1);
> - setenv("LD_PRELOAD", "/lib/libpreload-seccomp.so", 1);
> + if (ld_preload[0])
> + strcat(ld_preload, ":");
> + strcat(ld_preload, "/lib/libpreload-seccomp.so");
>   }
> + if (_stdout >= 0) {
> + if (ld_preload[0])
> + strcat(ld_preload, ":");
> + strcat(ld_preload, "/lib/libsetnbf.so");
> + }
> + if (ld_preload[0])
> + setenv("LD_PRELOAD", ld_preload, 1);
>  
>   blobmsg_list_for_each(&in->limits, var)
>   instance_limits(blobmsg_name(var->data), 
> blobmsg_data(var->data));
> diff --git a/service/setnbf.c b/service/setnbf.c
> new file mode 100644
> index 000..7b5f3bd
> --- /dev/null
> +++ b/service/setnbf.c
> @@ -0,0 +1,6 @@
> +#include 
> +
> +static void __attribute__((constructor)) setnbf(void)
> +{
> + setbuf(stdout, NULL);
> +}
> 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel