Re: [LEDE-DEV] [PATCH netifd 1/2] system-linux: parse gre specific settings as nested json data object

2017-03-14 Thread Felix Fietkau
On 2017-03-14 21:36, Hans Dedecker wrote:
> Parse gre specific settings ikey, okey, icsum, ocsum, iseqno and oseqno
> as nested json data object
> 
> Signed-off-by: Hans Dedecker 
Are you sure this works? If I remember correctly, uci_to_blob will only
add options for which it has a policy.

- Felix


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 2/2] include: Add nomips16 CPU_SUBTYPE

2017-03-14 Thread Hauke Mehrtens
On 03/14/2017 10:46 PM, Felix Fietkau wrote:
> On 2017-03-14 18:55, hauke.mehrt...@intel.com wrote:
>> From: Hauke Mehrtens 
>>
>> This can be used to indicate that a target does not support the optional 
>> mips16
>> extension even when it is a mips32r2 or later CPU.
>>
>> This will generate a separate toolchain and a separate package folder,
>> e.g. mips_24kc_nomips16
> Which target needs this?

The Lantiq / Intel GRX350 / GRX550 MIPS interAptiv mips32r3 SoC does not
support the MIPS16e ASE. This patch is to get our SDK in sync with
upstream LEDE and I am planing in the mid term to also add support for
this SoC to LEDE. There are already products with this SoC in the retail
market.

Hauke

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] ar71xx: change image version for ubiquiti devices

2017-03-14 Thread txt.file
Good point. But if we change it to v7.0.0 now we have the same problem
sooner or later. On TP-Link devices i have often seen v0.0.0-… or similar.

Bill Moffitt:
> I don't know if it makes any difference, but insofar as there is an
> AirOS 6.0 now
> (https://community.ubnt.com/t5/airMAX-Updates-Blog/airOS-6-0-Has-Been-Released/ba-p/1769476)
> should we change the strong to something like "v7.0.0-" etc.?
> 
> 
> On 3/3/2017 7:51 AM, txt.file wrote:
>> changes the image version from hardcoded OpenWrt to
>> $VERSION_DIST. AirOS shows a notification with the image version
>> during a firmware upgrade.
>>
>> fixes #582
>>
>> Signed-off-by: Matthias Fritzsche 
>> ---
>>   target/linux/ar71xx/image/ubnt.mk | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/target/linux/ar71xx/image/ubnt.mk
>> b/target/linux/ar71xx/image/ubnt.mk
>> index 7a1fc80..c633ca1 100644
>> --- a/target/linux/ar71xx/image/ubnt.mk
>> +++ b/target/linux/ar71xx/image/ubnt.mk
>> @@ -6,7 +6,7 @@
>>   # routerboard creates partitions out of the ubnt header
>>   define Build/mkubntimage
>>  -$(STAGING_DIR_HOST)/bin/mkfwimage \
>> -   -B $(UBNT_BOARD) -v
>> $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
>> +   -B $(UBNT_BOARD) -v
>> $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-$(VERSION_DIST)-$(REVISION) \
>>  -k $(IMAGE_KERNEL) \
>>  -r $@ \
>>  -o $@
>> @@ -19,7 +19,7 @@ define Build/mkubntimage-split
>>  dd if=$@ of=$@.old1 bs=1024k count=1; \
>>  dd if=$@ of=$@.old2 bs=1024k skip=1; \
>>  $(STAGING_DIR_HOST)/bin/mkfwimage \
>> -   -B $(UBNT_BOARD) -v
>> $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
>> +   -B $(UBNT_BOARD) -v
>> $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-$(VERSION_DIST)-$(REVISION) \
>>  -k $@.old1 \
>>  -r $@.old2 \
>>  -o $@; \
>> @@ -28,7 +28,7 @@ endef
>> define Build/mkubntimage2
>>  -$(STAGING_DIR_HOST)/bin/mkfwimage2 -f 0x9f00 \
>> -   -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
>> +   -v
>> $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-$(VERSION_DIST)-$(REVISION) \
>>  -p jffs2:0x5:0xf6:0:0:$@ \
>>  -o $@.new
>>  @mv $@.new $@
> 
> 
> ___
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev



signature.asc
Description: OpenPGP digital signature
___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 2/2] include: Add nomips16 CPU_SUBTYPE

2017-03-14 Thread Felix Fietkau
On 2017-03-14 18:55, hauke.mehrt...@intel.com wrote:
> From: Hauke Mehrtens 
> 
> This can be used to indicate that a target does not support the optional 
> mips16
> extension even when it is a mips32r2 or later CPU.
> 
> This will generate a separate toolchain and a separate package folder,
> e.g. mips_24kc_nomips16
Which target needs this?

- Felix


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH netifd 1/2] system-linux: parse gre specific settings as nested json data object

2017-03-14 Thread Hans Dedecker
Parse gre specific settings ikey, okey, icsum, ocsum, iseqno and oseqno
as nested json data object

Signed-off-by: Hans Dedecker 
---
 system-linux.c | 48 +---
 system.c   | 14 ++
 system.h   | 11 +++
 3 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/system-linux.c b/system-linux.c
index 047..b7297fd 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -2316,31 +2316,41 @@ static int system_add_gre_tunnel(const char *name, 
const char *kind,
}
}
 
-   if ((cur = tb[TUNNEL_ATTR_INFO]) && (blobmsg_type(cur) == 
BLOBMSG_TYPE_STRING)) {
-   uint8_t icsum, ocsum, iseqno, oseqno;
-   if (sscanf(blobmsg_get_string(cur), "%u,%u,%hhu,%hhu,%hhu,%hhu",
-   , , , , , ) < 6) {
-   ret = -EINVAL;
-   goto failure;
-   }
+   if ((cur = tb[TUNNEL_ATTR_DATA])) {
+   struct blob_attr *tb_data[__GRE_DATA_ATTR_MAX];
+
+   blobmsg_parse(gre_data_attr_list.params, __GRE_DATA_ATTR_MAX, 
tb_data,
+   blobmsg_data(cur), blobmsg_len(cur));
 
-   if (ikey)
-   iflags |= GRE_KEY;
+   if ((cur = tb_data[GRE_DATA_IKEY])) {
+   if ((ikey = blobmsg_get_u32(cur)))
+   iflags |= GRE_KEY;
+   }
 
-   if (okey)
-   oflags |= GRE_KEY;
+   if ((cur = tb_data[GRE_DATA_OKEY])) {
+   if ((okey = blobmsg_get_u32(cur)))
+   oflags |= GRE_KEY;
+   }
 
-   if (icsum)
-   iflags |= GRE_CSUM;
+   if ((cur = tb_data[GRE_DATA_ICSUM])) {
+   if (blobmsg_get_bool(cur))
+   iflags |= GRE_CSUM;
+   }
 
-   if (ocsum)
-   oflags |= GRE_CSUM;
+   if ((cur = tb_data[GRE_DATA_OCSUM])) {
+   if (blobmsg_get_bool(cur))
+   oflags |= GRE_CSUM;
+   }
 
-   if (iseqno)
-   iflags |= GRE_SEQ;
+   if ((cur = tb_data[GRE_DATA_ISEQNO])) {
+   if (blobmsg_get_bool(cur))
+   iflags |= GRE_SEQ;
+   }
 
-   if (oseqno)
-   oflags |= GRE_SEQ;
+   if ((cur = tb[GRE_DATA_OSEQNO])) {
+   if (blobmsg_get_bool(cur))
+   oflags |= GRE_SEQ;
+   }
}
 
if (v6) {
diff --git a/system.c b/system.c
index 52172c3..f899c7b 100644
--- a/system.c
+++ b/system.c
@@ -47,6 +47,20 @@ const struct uci_blob_param_list vxlan_data_attr_list = {
.params = vxlan_data_attrs,
 };
 
+static const struct blobmsg_policy gre_data_attrs[__GRE_DATA_ATTR_MAX] = {
+   [GRE_DATA_IKEY] = { .name = "ikey", .type = BLOBMSG_TYPE_INT32 },
+   [GRE_DATA_OKEY] = { .name = "okey", .type = BLOBMSG_TYPE_INT32 },
+   [GRE_DATA_ICSUM] = { .name = "icsum", .type = BLOBMSG_TYPE_BOOL },
+   [GRE_DATA_OCSUM] = { .name = "ocsum", .type = BLOBMSG_TYPE_BOOL },
+   [GRE_DATA_ISEQNO] = { .name = "iseqno", .type = BLOBMSG_TYPE_BOOL },
+   [GRE_DATA_OSEQNO] = { .name = "oseqno", .type = BLOBMSG_TYPE_BOOL },
+};
+
+const struct uci_blob_param_list gre_data_attr_list = {
+   .n_params = __GRE_DATA_ATTR_MAX,
+   .params = gre_data_attrs,
+};
+
 void system_fd_set_cloexec(int fd)
 {
 #ifdef FD_CLOEXEC
diff --git a/system.h b/system.h
index 6501d15..14b1e53 100644
--- a/system.h
+++ b/system.h
@@ -48,7 +48,18 @@ enum vxlan_data {
__VXLAN_DATA_ATTR_MAX
 };
 
+enum gre_data {
+   GRE_DATA_IKEY,
+   GRE_DATA_OKEY,
+   GRE_DATA_ICSUM,
+   GRE_DATA_OCSUM,
+   GRE_DATA_ISEQNO,
+   GRE_DATA_OSEQNO,
+   __GRE_DATA_ATTR_MAX
+};
+
 extern const struct uci_blob_param_list vxlan_data_attr_list;
+extern const struct uci_blob_param_list gre_data_attr_list;
 
 enum bridge_opt {
/* stp and forward delay always set */
-- 
2.12.0


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH mdns] Send reverse DNS lookup entry for IPv4 address

2017-03-14 Thread Jo-Philipp Wich
Hi,

>> Whenever we send A(AAA) records, let's also include reverse lookup ones.
>> This should be extended in the future by adding IPv6.
> 
> Ping. Any opinions on this?

Go for it.

>> @@ -210,6 +210,38 @@ dns_reply_a(struct interface *iface, int ttl)
>>  freeifaddrs(ifap);
>>  }
>>
>> +static void
>> +dns_reply_rev_lookup(struct interface *iface, int ttl)
>> +{
>> +char name[32];
>> +int len;
>> +
>> +if (!iface->v6) {
>> +struct in_addr rev_v4_addr;
>> +
>> +/* PTR recored starts with IP with reversed octets order */
>> +memcpy(_v4_addr, >v4_addr, sizeof(iface->v4_addr));
>> +rev_v4_addr.s_addr = bswap_32(rev_v4_addr.s_addr);
> 
> Is there some more appropriate solution for this than bswap_32?

I prefer the more explicit variant:

 - make "rev_v4_addr" unsigned char
 - use asprintf(, "%u.%u.%u.%u.in-addr.arpa",
rev_v4_addr[3], rev_v4_addr[2],
rev_v4_addr[1], rev_v4_addr[0]);

This also makes dealing with IPv6 later easier.

~ Jo



signature.asc
Description: OpenPGP digital signature
___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH V2] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread Jo-Philipp Wich
Hi,


> musl provides a /lib/libc.so file which should be integrated into the libc
> package when the external toolchain with musl is used.
> 
> Signed-off-by: Hauke Mehrtens 

Acked-by: Jo-Philipp Wich 



signature.asc
Description: OpenPGP digital signature
___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH V2] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread Florian Fainelli
On 03/14/2017 11:18 AM, hauke.mehrt...@intel.com wrote:
> From: Hauke Mehrtens 
> 
> musl provides a /lib/libc.so file which should be integrated into the libc
> package when the external toolchain with musl is used.
> 
> Signed-off-by: Hauke Mehrtens 

Reviewed-by: Florian Fainelli 
-- 
Florian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH V2] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread hauke . mehrtens
From: Hauke Mehrtens 

musl provides a /lib/libc.so file which should be integrated into the libc
package when the external toolchain with musl is used.

Signed-off-by: Hauke Mehrtens 
---
 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 8a90b5e..0bf4824 100644
--- a/package/libs/toolchain/Makefile
+++ b/package/libs/toolchain/Makefile
@@ -164,7 +164,7 @@ define Package/libc/config
string
prompt "libc shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
-   default "./lib/ld{*.so*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+   default "./lib/ld{*.so*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*,.so}"
 
endmenu
 endef
-- 
2.10.1


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread Hauke Mehrtens

On 2017-03-14 18:34, Florian Fainelli wrote:

On 03/14/2017 10:28 AM, Hauke Mehrtens wrote:

On 2017-03-14 18:20, Florian Fainelli wrote:

On 03/14/2017 05:28 AM, hauke.mehrt...@intel.com wrote:

From: Hauke Mehrtens 

musl provides a /lib/libc.so file which should be integrated into 
the

libc
package when the external toolchain with musl is used.

Signed-off-by: Hauke Mehrtens 
---
 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 8a90b5e..09c576d 100644
--- a/package/libs/toolchain/Makefile
+++ b/package/libs/toolchain/Makefile
@@ -164,7 +164,7 @@ define Package/libc/config
 string
 prompt "libc shared library files (use wildcards)"
 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
-default "./lib/ld{*.so*,-linux*.so.*}
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"

+default "./lib/ld{*.so*,-linux*.so.*}
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}
./lib/libc.so"


Why not change just the last part of the wildcard from: {-*.so,.so.*}
into {-*.so,.so.*,.so*} or even {*.so,.so.*}?


{-*.so,.so.*,.so*} should also work, I will change to that.

{*.so,.so.*} will add more files:
$ ls -al lib/libc{*.so,.so.*}
lib/libc.so
lib/libcc1.so -> libcc1.so.0.0.0

A little bit offtopic.
With LEDE 17.01 branch this is sufficient to use a external musl
toolchain, on the master branch the Linux kernel will not build 
because

it has some problems with the includes, it looks like it gets more
includes than the kernel wants. When I modify the wrapper file 
manually
and remove all the extra gcc options the kernel and all the other 
stuff

compiles fine.


Well, there are a ton of issues with upstream kernels that do not have
patched kernel headers, especially in the area of networking
definitions, I saw you submitted fixes for that a short while ago, but 
I

also met some issues with building netifd's system-linux.c (related).
The problems related to netifd should get fixed upstream with these 
patches:
https://lkml.org/lkml/2017/3/12/235 (I hope I sent it to the right 
people)

In LEDE these are the patches 27{1,2,3}


What extra GCC option is causing problems for you here? Is your
precompiled musl library available somewhere? The one I use is
stbgcc-4.8 (old) which can be found here:

https://github.com/Broadcom/stbgcc-4.8/releases/download/stbgcc-4.8-1.6/stbgcc-4.8-1.6.tar.bz2


I used a toolchain generated with LEDE 17.1 in LEDE master. Now I tried 
it again and can not reproduce the problem again.

The changes in this patch are needed anyway, but I will send a v2.

Hauke

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 1/2] scripts: only generate config from feature flag if fully match

2017-03-14 Thread hauke . mehrtens
From: Hauke Mehrtens 

Without this change the code checked if the string was contained in the
feature option and not if the string matches the complete word. This only
removes the nand option from the omap24xx target, the other changes are
only removing options which were added twice.

Signed-off-by: Hauke Mehrtens 
---
 scripts/target-metadata.pl | 62 +++---
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/scripts/target-metadata.pl b/scripts/target-metadata.pl
index 31de3c7..cbc3403 100755
--- a/scripts/target-metadata.pl
+++ b/scripts/target-metadata.pl
@@ -9,37 +9,37 @@ sub target_config_features(@) {
my $ret;
 
while ($_ = shift @_) {
-   /arm_v(\w+)/ and $ret .= "\tselect arm_v$1\n";
-   /broken/ and $ret .= "\tdepends on BROKEN\n";
-   /audio/ and $ret .= "\tselect AUDIO_SUPPORT\n";
-   /display/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
-   /dt/ and $ret .= "\tselect USES_DEVICETREE\n";
-   /gpio/ and $ret .= "\tselect GPIO_SUPPORT\n";
-   /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
-   /pcie/ and $ret .= "\tselect PCIE_SUPPORT\n";
-   /usb/ and $ret .= "\tselect USB_SUPPORT\n";
-   /usbgadget/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
-   /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
-   /rtc/ and $ret .= "\tselect RTC_SUPPORT\n";
-   /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
-   /jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
-   /jffs2_nand/ and $ret .= "\tselect USES_JFFS2_NAND\n";
-   /ext4/ and $ret .= "\tselect USES_EXT4\n";
-   /targz/ and $ret .= "\tselect USES_TARGZ\n";
-   /cpiogz/ and $ret .= "\tselect USES_CPIOGZ\n";
-   /minor/ and $ret .= "\tselect USES_MINOR\n";
-   /ubifs/ and $ret .= "\tselect USES_UBIFS\n";
-   /fpu/ and $ret .= "\tselect HAS_FPU\n";
-   /spe_fpu/ and $ret .= "\tselect HAS_SPE_FPU\n";
-   /ramdisk/ and $ret .= "\tselect USES_INITRAMFS\n";
-   /powerpc64/ and $ret .= "\tselect powerpc64\n";
-   /nommu/ and $ret .= "\tselect NOMMU\n";
-   /mips16/ and $ret .= "\tselect HAS_MIPS16\n";
-   /rfkill/ and $ret .= "\tselect RFKILL_SUPPORT\n";
-   /low_mem/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
-   /small_flash/ and $ret .= "\tselect SMALL_FLASH\n";
-   /nand/ and $ret .= "\tselect NAND_SUPPORT\n";
-   /virtio/ and $ret .= "\tselect VIRTIO_SUPPORT\n";
+   /^arm_v(\w+)$/ and $ret .= "\tselect arm_v$1\n";
+   /^broken$/ and $ret .= "\tdepends on BROKEN\n";
+   /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n";
+   /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
+   /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n";
+   /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n";
+   /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n";
+   /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n";
+   /^usb$/ and $ret .= "\tselect USB_SUPPORT\n";
+   /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
+   /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
+   /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n";
+   /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n";
+   /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
+   /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n";
+   /^ext4$/ and $ret .= "\tselect USES_EXT4\n";
+   /^targz$/ and $ret .= "\tselect USES_TARGZ\n";
+   /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n";
+   /^minor$/ and $ret .= "\tselect USES_MINOR\n";
+   /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n";
+   /^fpu$/ and $ret .= "\tselect HAS_FPU\n";
+   /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n";
+   /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n";
+   /^powerpc64$/ and $ret .= "\tselect powerpc64\n";
+   /^nommu$/ and $ret .= "\tselect NOMMU\n";
+   /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n";
+   /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n";
+   /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
+   /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n";
+   /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n";
+   /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n";
}
return $ret;
 }
-- 
2.10.1


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 2/2] include: Add nomips16 CPU_SUBTYPE

2017-03-14 Thread hauke . mehrtens
From: Hauke Mehrtens 

This can be used to indicate that a target does not support the optional mips16
extension even when it is a mips32r2 or later CPU.

This will generate a separate toolchain and a separate package folder,
e.g. mips_24kc_nomips16

Signed-off-by: Hauke Mehrtens 
---
 include/target.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/target.mk b/include/target.mk
index 5490d48..61489ca 100644
--- a/include/target.mk
+++ b/include/target.mk
@@ -258,7 +258,9 @@ ifeq ($(DUMP),1)
   FEATURES += virtio
 endif
 ifneq ($(CONFIG_CPU_MIPS32_R2),)
-  FEATURES += mips16
+  ifneq ($(CPU_SUBTYPE),nomips16)
+FEATURES += mips16
+  endif
 endif
 FEATURES += $(foreach v,6 7,$(if $(CONFIG_CPU_V$(v)),arm_v$(v)))
 
-- 
2.10.1


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread Florian Fainelli
On 03/14/2017 10:28 AM, Hauke Mehrtens wrote:
> On 2017-03-14 18:20, Florian Fainelli wrote:
>> On 03/14/2017 05:28 AM, hauke.mehrt...@intel.com wrote:
>>> From: Hauke Mehrtens 
>>>
>>> musl provides a /lib/libc.so file which should be integrated into the
>>> libc
>>> package when the external toolchain with musl is used.
>>>
>>> Signed-off-by: Hauke Mehrtens 
>>> ---
>>>  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 8a90b5e..09c576d 100644
>>> --- a/package/libs/toolchain/Makefile
>>> +++ b/package/libs/toolchain/Makefile
>>> @@ -164,7 +164,7 @@ define Package/libc/config
>>>  string
>>>  prompt "libc shared library files (use wildcards)"
>>>  depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
>>> -default "./lib/ld{*.so*,-linux*.so.*}
>>> ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
>>>
>>> +default "./lib/ld{*.so*,-linux*.so.*}
>>> ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}
>>> ./lib/libc.so"
>>
>> Why not change just the last part of the wildcard from: {-*.so,.so.*}
>> into {-*.so,.so.*,.so*} or even {*.so,.so.*}?
> 
> {-*.so,.so.*,.so*} should also work, I will change to that.
> 
> {*.so,.so.*} will add more files:
> $ ls -al lib/libc{*.so,.so.*}
> lib/libc.so
> lib/libcc1.so -> libcc1.so.0.0.0
> 
> A little bit offtopic.
> With LEDE 17.01 branch this is sufficient to use a external musl
> toolchain, on the master branch the Linux kernel will not build because
> it has some problems with the includes, it looks like it gets more
> includes than the kernel wants. When I modify the wrapper file manually
> and remove all the extra gcc options the kernel and all the other stuff
> compiles fine.

Well, there are a ton of issues with upstream kernels that do not have
patched kernel headers, especially in the area of networking
definitions, I saw you submitted fixes for that a short while ago, but I
also met some issues with building netifd's system-linux.c (related).

What extra GCC option is causing problems for you here? Is your
precompiled musl library available somewhere? The one I use is
stbgcc-4.8 (old) which can be found here:

https://github.com/Broadcom/stbgcc-4.8/releases/download/stbgcc-4.8-1.6/stbgcc-4.8-1.6.tar.bz2
-- 
Florian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread Hauke Mehrtens

On 2017-03-14 18:20, Florian Fainelli wrote:

On 03/14/2017 05:28 AM, hauke.mehrt...@intel.com wrote:

From: Hauke Mehrtens 

musl provides a /lib/libc.so file which should be integrated into the 
libc

package when the external toolchain with musl is used.

Signed-off-by: Hauke Mehrtens 
---
 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 8a90b5e..09c576d 100644
--- a/package/libs/toolchain/Makefile
+++ b/package/libs/toolchain/Makefile
@@ -164,7 +164,7 @@ define Package/libc/config
string
prompt "libc shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
-		default "./lib/ld{*.so*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+		default "./lib/ld{*.so*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*} 
./lib/libc.so"


Why not change just the last part of the wildcard from: {-*.so,.so.*}
into {-*.so,.so.*,.so*} or even {*.so,.so.*}?


{-*.so,.so.*,.so*} should also work, I will change to that.

{*.so,.so.*} will add more files:
$ ls -al lib/libc{*.so,.so.*}
lib/libc.so
lib/libcc1.so -> libcc1.so.0.0.0

A little bit offtopic.
With LEDE 17.01 branch this is sufficient to use a external musl 
toolchain, on the master branch the Linux kernel will not build because 
it has some problems with the includes, it looks like it gets more 
includes than the kernel wants. When I modify the wrapper file manually 
and remove all the extra gcc options the kernel and all the other stuff 
compiles fine.


Hauke

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread Florian Fainelli
On 03/14/2017 05:28 AM, hauke.mehrt...@intel.com wrote:
> From: Hauke Mehrtens 
> 
> musl provides a /lib/libc.so file which should be integrated into the libc
> package when the external toolchain with musl is used.
> 
> Signed-off-by: Hauke Mehrtens 
> ---
>  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 8a90b5e..09c576d 100644
> --- a/package/libs/toolchain/Makefile
> +++ b/package/libs/toolchain/Makefile
> @@ -164,7 +164,7 @@ define Package/libc/config
>   string
>   prompt "libc shared library files (use wildcards)"
>   depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
> - default "./lib/ld{*.so*,-linux*.so.*} 
> ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
> + default "./lib/ld{*.so*,-linux*.so.*} 
> ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}
>  ./lib/libc.so"

Why not change just the last part of the wildcard from: {-*.so,.so.*}
into {-*.so,.so.*,.so*} or even {*.so,.so.*}?
-- 
Florian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] x86: image: avoid duplicating some ops by using Image/Prepare/grub2

2017-03-14 Thread Felix Fietkau
On 2017-03-13 00:00, Rafał Miłecki wrote:
> From: Rafał Miłecki 
> 
> These commands aren't root filesystem image specific so it's OK to
> execute them just once. It saves some time when building images.
> 
> Signed-off-by: Rafał Miłecki 
> ---
>  target/linux/x86/image/Makefile | 50 
> +
>  1 file changed, 26 insertions(+), 24 deletions(-)
> 
> diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
> index f34788d67b..8a153e6392 100644
> --- a/target/linux/x86/image/Makefile
> +++ b/target/linux/x86/image/Makefile
> @@ -51,6 +51,32 @@ ifneq ($(CONFIG_TARGET_x86_xen_domu),)
>GRUB_ROOT = xen/xvda,msdos1
>  endif
>  
> +define Image/Prepare/grub2
> + $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
> + $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
> +
> + grub-mkimage \
> + -p /boot/grub \
> + -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
> + -o $(KDIR)/grub2/core.img \
> + -O i386-pc \
> + -c ./grub-early.cfg \
> + $(GRUB2_MODULES)
> + $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/
> +
> + grub-mkimage \
> + -p /boot/grub \
> + -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
> + -o $(KDIR)/grub2/eltorito.img \
> + -O i386-pc \
> + -c ./grub-early.cfg \
> + $(GRUB2_MODULES_ISO)
> + cat \
> + $(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \
> + $(KDIR)/grub2/eltorito.img \
> + > $(KDIR)/root.grub/boot/grub/eltorito.img
> +endef
But now you're executing the iso commands even if ISO images aren't
being used. Also, since you're making the code duplication painfully
obvious by moving the duplicated lines next to each other, maybe it's
time to address that as well ;)

- Felix


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2] mac80211: Fix race condition leading to wifi interfaces not coming up at boot sometimes.

2017-03-14 Thread Vittorio Gambaletta (VittGam)
In the drv_mac80211_setup function, mac80211_interface_cleanup
is called to ask the kernel to delete all existing interfaces
for the phy that is being configured via netlink.

Later in the first function, mac80211_prepare_vif is called to
set up the new interfaces as required.

But sometimes, when mac80211_prepare_vif (and so the relevant
`iw phy x interface add y` command) runs, the kernel might still
be cleaning up the old interface with the same ifname. It usually
takes very few time to do that; possibly a few milliseconds of
sleep in the script after detecting this error condition could be
enough, but the busybox sh does not support sub-second sleep
intervals.

When this happens, iw obviously fails to create the new interface;
and the following message is printed in the system log, followed by
subsequent failure messages from hostapd in case this would have been
an AP interface.

Tue Mar 14 04:21:57 2017 daemon.notice netifd: radio1 (2767): command failed: 
Too many open files in system (-23)

This was a long-standing issue existing since at least OpenWrt Backfire,
and today I finally managed to debug and (hopefully) solve it.
It was happening very few times on most devices; but it was happening
a lot more frequently on fast platforms with multiple radios, such as
the powerpc-based dual-ath9k-radio tl-wdr4900-v1.

Signed-off-by: Vittorio Gambaletta 

---
 .../mac80211/files/lib/netifd/wireless/mac80211.sh |   32 +---
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh 
b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
index baa023e..9ebd76b 100644
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -411,6 +411,28 @@ mac80211_check_ap() {
has_ap=1
 }
 
+mac80211_iw_interface_add() {
+   local phy="$1"
+   local ifname="$2"
+   local type="$3"
+   local wdsflag="$4"
+   local rc
+
+   iw phy "$phy" interface add "$ifname" type "$type" $wdsflag
+   rc="$?"
+
+   [ "$rc" = 233 ] && {
+   # Device might have just been deleted, give the kernel some 
time to finish cleaning it up
+   sleep 1
+
+   iw phy "$phy" interface add "$ifname" type "$type" $wdsflag
+   rc="$?"
+   }
+
+   [ "$rc" != 0 ] && wireless_setup_failed INTERFACE_CREATION_FAILED
+   return $rc
+}
+
 mac80211_prepare_vif() {
json_select config
 
@@ -437,7 +459,7 @@ mac80211_prepare_vif() {
# It is far easier to delete and create the desired interface
case "$mode" in
adhoc)
-   iw phy "$phy" interface add "$ifname" type adhoc
+   mac80211_iw_interface_add "$phy" "$ifname" adhoc || 
return
;;
ap)
# Hostapd will handle recreating the interface and
@@ -451,21 +473,21 @@ mac80211_prepare_vif() {
mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" 
"$type" || return
 
[ -n "$hostapd_ctrl" ] || {
-   iw phy "$phy" interface add "$ifname" type __ap
+   mac80211_iw_interface_add "$phy" "$ifname" __ap 
|| return

hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
}
;;
mesh)
-   iw phy "$phy" interface add "$ifname" type mp
+   mac80211_iw_interface_add "$phy" "$ifname" mp || return
;;
monitor)
-   iw phy "$phy" interface add "$ifname" type monitor
+   mac80211_iw_interface_add "$phy" "$ifname" monitor || 
return
;;
sta)
local wdsflag=
staidx="$(($staidx + 1))"
[ "$wds" -gt 0 ] && wdsflag="4addr on"
-   iw phy "$phy" interface add "$ifname" type managed 
$wdsflag
+   mac80211_iw_interface_add "$phy" "$ifname" managed 
"$wdsflag" || return
[ "$powersave" -gt 0 ] && powersave="on" || 
powersave="off"
iw "$ifname" set power_save "$powersave"
;;


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] toolchain: add musl libc.so to external toolchain

2017-03-14 Thread hauke . mehrtens
From: Hauke Mehrtens 

musl provides a /lib/libc.so file which should be integrated into the libc
package when the external toolchain with musl is used.

Signed-off-by: Hauke Mehrtens 
---
 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 8a90b5e..09c576d 100644
--- a/package/libs/toolchain/Makefile
+++ b/package/libs/toolchain/Makefile
@@ -164,7 +164,7 @@ define Package/libc/config
string
prompt "libc shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
-   default "./lib/ld{*.so*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+   default "./lib/ld{*.so*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*} 
./lib/libc.so"
 
endmenu
 endef
-- 
2.10.1


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] Implement NetJSON output in ubus (OpenWRT/LEDE)

2017-03-14 Thread Nemesis
We are looking for students that want to work on this GSoC idea:

Implement NetJSON output in ubus (OpenWRT/LEDE):
https://wiki.freifunk.net/Ideas#Implement_NetJSON_output_in_ubus_.28OpenWRT.2FLEDE.29

If you are interested, get in touch with Eric Shultz and myself.
Thank you

Federico

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH mdns] Send reverse DNS lookup entry for IPv4 address

2017-03-14 Thread Rafał Miłecki

On 02/10/2017 11:40 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki 
>
> Whenever we send A(AAA) records, let's also include reverse lookup ones.
> This should be extended in the future by adding IPv6.

Ping. Any opinions on this?


> @@ -210,6 +210,38 @@ dns_reply_a(struct interface *iface, int ttl)
>freeifaddrs(ifap);
>  }
>
> +static void
> +dns_reply_rev_lookup(struct interface *iface, int ttl)
> +{
> +  char name[32];
> +  int len;
> +
> +  if (!iface->v6) {
> +  struct in_addr rev_v4_addr;
> +
> +  /* PTR recored starts with IP with reversed octets order */
> +  memcpy(_v4_addr, >v4_addr, sizeof(iface->v4_addr));
> +  rev_v4_addr.s_addr = bswap_32(rev_v4_addr.s_addr);

Is there some more appropriate solution for this than bswap_32?


> +
> +  /* Prepare name with reversed IP & second level domain suffix */
> +  inet_ntop(AF_INET, _v4_addr, name, sizeof(name));
> +  strcat(name, ".in-addr.arpa");
> +
> +  dns_init_answer();
> +  len = dn_comp(mdns_hostname_local, mdns_buf, sizeof(mdns_buf), 
NULL, NULL);
> +  if (len > 0)
> +  dns_add_answer(TYPE_PTR, mdns_buf, len, ttl);
> +  dns_send_answer(iface, name);
> +  }
> +}

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] mac80211: Fix race condition leading to wifi interfaces not coming up at boot sometimes.

2017-03-14 Thread Bastian Bittorf
* Vittorio Gambaletta (VittGam)  [14.03.2017 07:55]:
> +mac80211_iw_interface_add() {
> + local phy="$1"
> + local ifname="$2"
> + local type="$3"
> + local wdsflag="$4"

please add a 'local ret' here, or better use the common 'local rc=0'
and later always "return $rc"

> +
> + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag
> + ret="$?"
> +
> + [ "$ret" = 233 ] && {
> + # Device might have just been deleted, give the kernel some 
> time to finish cleaning it up
> + sleep 1
> +
> + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag
> + ret="$?"
> + }
> +
> + [ "$ret" != 0 ] && {
> + wireless_setup_failed INTERFACE_CREATION_FAILED
> + return 1
> + }
> +
> + return 0
> +}

thank you for debugging this! bye, bastian

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] Problem with console without console=ttyS0 bootarg

2017-03-14 Thread Rafał Miłecki

My current DTS file contains following entry:
bootargs = "console=ttyS0,115200"
and it works in a following way:

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[9.320212] procd: - early -
[9.323174] procd: - watchdog -
[9.924724] procd: - ubus -
[9.986055] procd: - init -
Please press Enter to activate this console.
=== WARNING! =
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--
root@LEDE:/#



If I enable "ttylogin" in /etc/config/system it works quite similarly (just 
asks for a login):

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[9.362481] procd: - early -
[9.365550] procd: - watchdog -
[9.983522] procd: - ubus -
[   10.044877] procd: - init -
Please press Enter to activate this console.
LEDE login:
LEDE login: root
=== WARNING! =
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--
root@LEDE:~#


My problem appears when I drop bootargs and use:
stdout-path = "/chipcommonA/serial@0300:115200";
instead (which is a non-deprecated DTS solution).
In such case I can't login anymore:

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[9.340180] procd: - early -
[9.343141] procd: - watchdog -
[9.944758] procd: - ubus -
[   10.006092] procd: - init -


Do you know what's the reason for this? Can we have a proper console support
while using upstream preferred syntax for the stdout-path?
Please note entering failsafe mode it not affected by this.
I'm also attaching a diff switching to alias + stdout-path.

diff --git a/arch/arm/boot/dts/bcm4708-smartrg-sr400ac.dts 
b/arch/arm/boot/dts/bcm4708-smartrg-sr400ac.dts
index 36b628b..a5442a9 100644
--- a/arch/arm/boot/dts/bcm4708-smartrg-sr400ac.dts
+++ b/arch/arm/boot/dts/bcm4708-smartrg-sr400ac.dts
@@ -17,7 +17,7 @@
model = "SmartRG SR400ac";

chosen {
-   bootargs = "console=ttyS0,115200 earlycon";
+   bootargs = "earlycon";
};

memory {
diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
index 4fbb089..5a9fa3e 100644
--- a/arch/arm/boot/dts/bcm5301x.dtsi
+++ b/arch/arm/boot/dts/bcm5301x.dtsi
@@ -18,8 +18,12 @@
 / {
interrupt-parent = <>;

+   aliases {
+   serial0 = 
+   };
+
chosen {
-   stdout-path = 
+   stdout-path = "serial0:115200n8";
};

chipcommonA {

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] mac80211: Fix race condition leading to wifi interfaces not coming up at boot sometimes.

2017-03-14 Thread Vittorio G (VittGam)
If you're wondering where the -ENFILE error comes from...

At first I thought it was obviously related to fs.file-max that
defaults to "just" 8192.

But it was not. It took me a while to figure out that the error
came from here instead...

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c?id=13baa00ad01bb3a9f893e3a08cbc2d072fc0c15d#n1070

In fact, -ENFILE is returned every time one tries to add a wireless
virtual interface with the same name as another existing one.
(Maybe the error code should be changed to -EEXIST when an explicit
interface name is requested and it turns out to be already taken,
like in this case... Time for a kernel patch, maybe!)

This issue was also very time-sensitive; when I added some debug
prints to iw, it disappeared...

On 14/03/2017 06:19:44 CET, Vittorio Gambaletta (VittGam) wrote:
> In the drv_mac80211_setup function, mac80211_interface_cleanup
> is called to ask the kernel to delete all existing interfaces
> for the phy that is being configured via netlink.
> 
> Later in the first function, mac80211_prepare_vif is called to
> set up the new interfaces as required.
> 
> But sometimes, when mac80211_prepare_vif (and so the relevant
> `iw phy x interface add y` command) runs, the kernel might still
> be cleaning up the old interface with the same ifname. It usually
> takes very few time to do that; possibly a few milliseconds of
> sleep in the script after detecting this error condition could be
> enough, but the busybox sh does not support sub-second sleep
> intervals.
> 
> When this happens, iw obviously fails to create the new interface;
> and the following message is printed in the system log, followed by
> subsequent failure messages from hostapd in case this would have been
> an AP interface.
> 
> Tue Mar 14 04:21:57 2017 daemon.notice netifd: radio1 (2767): command failed: 
> Too many open files in system (-23)
> 
> This was a long-standing issue existing since at least OpenWrt Backfire,
> and today I finally managed to debug and (hopefully) solve it.
> It was happening very few times on most devices; but it was happening
> a lot more frequently on fast platforms with multiple radios, such as
> the powerpc-based dual-ath9k-radio tl-wdr4900-v1.
> 
> Signed-off-by: Vittorio Gambaletta 
> 
> ---
>  .../mac80211/files/lib/netifd/wireless/mac80211.sh |   35 
> +---
>  1 file changed, 30 insertions(+), 5 deletions(-)
> 
> diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh 
> b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
> index baa023e..5058b01 100644
> --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
> +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
> @@ -411,6 +411,31 @@ mac80211_check_ap() {
>   has_ap=1
>  }
>  
> +mac80211_iw_interface_add() {
> + local phy="$1"
> + local ifname="$2"
> + local type="$3"
> + local wdsflag="$4"
> +
> + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag
> + ret="$?"
> +
> + [ "$ret" = 233 ] && {
> + # Device might have just been deleted, give the kernel some 
> time to finish cleaning it up
> + sleep 1
> +
> + iw phy "$phy" interface add "$ifname" type "$type" $wdsflag
> + ret="$?"
> + }
> +
> + [ "$ret" != 0 ] && {
> + wireless_setup_failed INTERFACE_CREATION_FAILED
> + return 1
> + }
> +
> + return 0
> +}
> +
>  mac80211_prepare_vif() {
>   json_select config
>  
> @@ -437,7 +462,7 @@ mac80211_prepare_vif() {
>   # It is far easier to delete and create the desired interface
>   case "$mode" in
>   adhoc)
> - iw phy "$phy" interface add "$ifname" type adhoc
> + mac80211_iw_interface_add "$phy" "$ifname" adhoc || 
> return
>   ;;
>   ap)
>   # Hostapd will handle recreating the interface and
> @@ -451,21 +476,21 @@ mac80211_prepare_vif() {
>   mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" 
> "$type" || return
>  
>   [ -n "$hostapd_ctrl" ] || {
> - iw phy "$phy" interface add "$ifname" type __ap
> + mac80211_iw_interface_add "$phy" "$ifname" __ap 
> || return
>   
> hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
>   }
>   ;;
>   mesh)
> - iw phy "$phy" interface add "$ifname" type mp
> + mac80211_iw_interface_add "$phy" "$ifname" mp || return
>   ;;
>   monitor)
> - iw phy "$phy" interface add "$ifname" type monitor
> + mac80211_iw_interface_add "$phy" "$ifname" monitor || 
> return
>   ;;
>   sta)
>   local wdsflag=
>