[OpenWrt-Devel] [PATCH v5] ramips: add support for JS76x8 series DEV boards

2019-11-04 Thread Robinson Wu
This commit adds support for the ZhuoTK JS76x8 series development boards.
These devices have the following specifications:

- SOC: MT7628AN/NN, MT7688AN, MT7628DAN
- RAM of MT7628AN/NN and MT7688AN: 64/128/256 MB (DDR2)
- RAM of MT7628DAN: 64 MB (DDR2)
- FLASH:8/16/32 MB (SPI NOR)
- Ethernet:3x 10/100 Mbps ethernet ports (MT76x8 built-in switch)
- WIFI:1x 2T2R 2.4 GHz Wi-Fi
- LEDs:1x system status green LED, 1x wifi green LED,
   3x ethernet green LED
- Buttons:1x reset button, 2x user defined button
- 1x microSD slot
- 4x USB 2.0 port
- 1x mini-usb debug UART
- 1x DC jack for main power (DC 5V)
- 1x TTL/RS232 UART
- 1x TTL/RS485 UART
- 13x GPIO header
- 1x audio codec(wm8960)

Installation via OpenWrt:

The original firmware is OpenWrt, so both LuCI or sysupgrade can be used.

Installation via U-boot web:

1. Power on board with reset button pressed, release it
   after wifi led start blinking.
2. Setup static IP 192.168.1.123/4 on your PC.
3. Go to 192.168.1.8 in browser and upload "sysupgrade" image.

Installation via U-boot tftp:
1. Connect to serial console at the mini usb, which has been connected to UART0
   on board (115200 8N1)
2. Setup static IP 192.168.1.123/4 on your PC.
3. Place openwrt-firmware.bin on your PC tftp server (192.168.1.123).
3. Connect one of LAN ports on board to your PC.
4. Start terminal software (e.g. screen /dev/ttyUSB0 115200) on PC.
5. Apply power to board.
6. Interrupt U-boot with keypress of "2".
7. At u-boot prompts:
   Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N) Y
   Input device IP (192.168.1.8) ==:192.168.1.8
   Input server IP (192.168.1.123) ==:192.168.1.123
   Input Linux Kernel filename (root_uImage) ==:openwrt-firmware.bin
8. board will download file from tftp server, write it to flash and reboot.

Other notes:

Vist www.zhuotk.com for further information.

Signed-off-by: Robinson Wu 
---
 .../ramips/dts/mt7628an_zhuotk_js76x8-16m.dts  |  12 ++
 .../ramips/dts/mt7628an_zhuotk_js76x8-32m.dts  |  12 ++
 .../linux/ramips/dts/mt7628an_zhuotk_js76x8-8m.dts |  12 ++
 .../linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi   | 156 +
 target/linux/ramips/image/mt76x8.mk|  30 
 .../ramips/mt76x8/base-files/etc/board.d/01_leds   |   6 +
 .../mt76x8/base-files/etc/board.d/02_network   |  10 +-
 7 files changed, 236 insertions(+), 2 deletions(-)
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js76x8-32m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js76x8-8m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi

diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts 
b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts
new file mode 100644
index 000..a9524fc
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+#include "mt7628an_zhuotk_js76x8.dtsi"
+
+/ {
+   compatible = "zhuotk,js76x8-16m", "zhuotk,js76x8", 
"mediatek,mt7628an-soc";
+   model = "ZhuoTK JS76x8 (16M)";
+};
+
+ {
+   reg = <0x5 0xfb>;
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-32m.dts 
b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-32m.dts
new file mode 100644
index 000..aece3dd
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-32m.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+#include "mt7628an_zhuotk_js76x8.dtsi"
+
+/ {
+   compatible = "zhuotk,js76x8-32m", "zhuotk,js76x8", 
"mediatek,mt7628an-soc";
+   model = "ZhuoTK JS76x8 (32M)";
+};
+
+ {
+   reg = <0x5 0x1fb>;
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-8m.dts 
b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-8m.dts
new file mode 100644
index 000..3902218
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-8m.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+#include "mt7628an_zhuotk_js76x8.dtsi"
+
+/ {
+   compatible = "zhuotk,js76x8-8m", "mediatek,mt7628an-soc";
+   model = "ZhuoTK JS76x8 (8M)";
+};
+
+ {
+   reg = <0x5 0x7b>;
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi 
b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi
new file mode 100644
index 000..cab24d9
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi
@@ -0,0 +1,156 @@
+#include "mt7628an.dtsi"
+
+#include 
+#include 
+
+/ {
+   compatible = "zhuotk,js76x8", "mediatek,mt7628an-soc";
+
+   aliases {
+   led-boot = _system;
+   led-failsafe = _system;
+   led-running = _system;
+   led-upgrade = _system;
+   };
+
+   chosen {
+   bootargs = "console=ttyS0,115200";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_system: system {
+   label = "js76x8:green:system";
+   gpios = < 5 GPIO_ACTIVE_LOW>;
+ 

Re: [OpenWrt-Devel] [PATCH uci 18/18] lua: fix error handling

2019-11-04 Thread Rosen Penev
On Mon, Nov 4, 2019 at 4:40 PM Petr Štetiar  wrote:
>
> scan-build from clang version 9 has reported following issues:
Note that CMake has integrated clang-tidy support. It supports all the
clang-analyzer stuff and more.
>
>  uci.c:389:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:393:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_NOTFOUND;
> ^ 
>  uci.c:417:4: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:524:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:533:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:565:4: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:575:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:584:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:642:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>  uci.c:651:3: warning: Value stored to 'err' is never read
> err = UCI_ERR_INVAL;
> ^ ~
>
> Signed-off-by: Petr Štetiar 
> ---
>  lua/uci.c | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/lua/uci.c b/lua/uci.c
> index a7aaad375c20..1ed73e4f67dc 100644
> --- a/lua/uci.c
> +++ b/lua/uci.c
> @@ -386,11 +386,11 @@ uci_lua_get_any(lua_State *L, bool all)
>
> lookup_ptr(ctx, , NULL, true);
> if (!all && !ptr.s) {
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
> if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) {
> -   err = UCI_ERR_NOTFOUND;
> +   ctx->err = UCI_ERR_NOTFOUND;
> goto error;
> }
>
> @@ -414,7 +414,7 @@ uci_lua_get_any(lua_State *L, bool all)
> uci_push_option(L, ptr.o);
> break;
> default:
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
> if (s)
> @@ -521,7 +521,7 @@ uci_lua_rename(lua_State *L)
> ptr.option = NULL;
> break;
> default:
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
>
> @@ -530,7 +530,7 @@ uci_lua_rename(lua_State *L)
> goto error;
>
> if (((ptr.s == NULL) && (ptr.option != NULL)) || (ptr.value == NULL)) 
> {
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
>
> @@ -562,7 +562,7 @@ uci_lua_reorder(lua_State *L)
> case 1:
> /* Format: uci.set("p.s=v") or uci.set("p.s=v") */
> if (ptr.option) {
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
> break;
> @@ -572,7 +572,7 @@ uci_lua_reorder(lua_State *L)
> ptr.option = NULL;
> break;
> default:
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
>
> @@ -581,7 +581,7 @@ uci_lua_reorder(lua_State *L)
> goto error;
>
> if ((ptr.s == NULL) || (ptr.value == NULL)) {
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
>
> @@ -639,7 +639,7 @@ uci_lua_set(lua_State *L)
> ptr.option = NULL;
> break;
> default:
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
>
> @@ -648,7 +648,7 @@ uci_lua_set(lua_State *L)
> goto error;
>
> if (((ptr.s == NULL) && (ptr.option != NULL)) || (ptr.value == NULL)) 
> {
> -   err = UCI_ERR_INVAL;
> +   ctx->err = UCI_ERR_INVAL;
> goto error;
> }
>
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org

[OpenWrt-Devel] [PATCH uci 12/18] tests: add cram based unit tests

2019-11-04 Thread Petr Štetiar
I find them more flexible then shunit2 ones.

Signed-off-by: Petr Štetiar 
---
 .gitignore|  3 ++
 tests/CMakeLists.txt  |  1 +
 tests/cram/CMakeLists.txt | 21 ++
 tests/cram/config/network | 25 +
 tests/cram/lua/basic.lua  | 44 +
 tests/cram/test_ucilua.t  | 58 +++
 6 files changed, 152 insertions(+)
 create mode 100644 tests/cram/CMakeLists.txt
 create mode 100644 tests/cram/config/network
 create mode 100644 tests/cram/lua/basic.lua
 create mode 100644 tests/cram/test_ucilua.t

diff --git a/.gitignore b/.gitignore
index 652da1960acc..8d2927f94d7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,8 +6,11 @@ CMakeFiles
 *.a
 *.so
 *.dylib
+*.pyc
 install_manifest.txt
 
 uci
 uci_config.h
 tests/shunit2/save
+tests/cram/*.t.err
+.venv
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b7a7ccb0e60b..872ed6de12d4 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1 +1,2 @@
+ADD_SUBDIRECTORY(cram)
 ADD_SUBDIRECTORY(shunit2)
diff --git a/tests/cram/CMakeLists.txt b/tests/cram/CMakeLists.txt
new file mode 100644
index ..06c7c9419c7e
--- /dev/null
+++ b/tests/cram/CMakeLists.txt
@@ -0,0 +1,21 @@
+FIND_PACKAGE(PythonInterp 3 REQUIRED)
+FILE(GLOB test_cases "test_*.t")
+
+SET(PYTHON_VENV_DIR "${CMAKE_CURRENT_BINARY_DIR}/.venv")
+SET(PYTHON_VENV_PIP "${PYTHON_VENV_DIR}/bin/pip")
+SET(PYTHON_VENV_CRAM "${PYTHON_VENV_DIR}/bin/cram")
+
+ADD_CUSTOM_COMMAND(
+   OUTPUT ${PYTHON_VENV_CRAM}
+   COMMAND ${PYTHON_EXECUTABLE} -m venv ${PYTHON_VENV_DIR}
+   COMMAND ${PYTHON_VENV_PIP} install cram
+)
+ADD_CUSTOM_TARGET(prepare-cram-venv ALL DEPENDS ${PYTHON_VENV_CRAM})
+
+ADD_TEST(
+   NAME cram
+   COMMAND ${PYTHON_VENV_CRAM} ${test_cases}
+   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+SET_PROPERTY(TEST cram APPEND PROPERTY ENVIRONMENT 
"UCI_LUA=$")
diff --git a/tests/cram/config/network b/tests/cram/config/network
new file mode 100644
index ..f42ea7c6a37d
--- /dev/null
+++ b/tests/cram/config/network
@@ -0,0 +1,25 @@
+config 'alias' 'a'
+   option 'interface' 'lan'
+
+config 'alias' 'b'
+   option 'interface' 'lan'
+
+config 'interface' 'lan'
+   option 'proto' 'static'
+   option 'ifname' 'eth0'
+   option 'test' '123'
+   option 'enabled' 'off'
+   option 'ipaddr' '2.3.4.5'
+
+config 'interface' 'wan'
+   option 'proto'  'dhcp'
+   option 'ifname' 'eth1'
+   option 'enabled' 'on'
+   option 'aliases' 'c d'
+
+config 'alias' 'c'
+   option 'interface' 'wan'
+
+config 'alias' 'd'
+   option 'interface' 'wan'
+
diff --git a/tests/cram/lua/basic.lua b/tests/cram/lua/basic.lua
new file mode 100644
index ..ceb706f6973e
--- /dev/null
+++ b/tests/cram/lua/basic.lua
@@ -0,0 +1,44 @@
+local A = assert
+local c = uci.cursor(os.getenv("CONFIG_DIR"))
+
+c:foreach("network", "interface", function(s)
+   print("---")
+   for k, v in pairs(s) do
+   print(k .. ': ' .. tostring(v))
+   end
+end)
+
+local t = c:get_all("network")
+
+A(t.wan.ifname == 'eth1')
+A(t.wan.proto == 'dhcp')
+A(c:get("network", "wan", "ifname") == "eth1")
+A(c:get("network", "wan", "proto") == "dhcp")
+
+A(t.lan.ifname == 'eth0')
+A(t.lan.enabled == 'off')
+A(c:get("network", "lan", "ifname") == "eth0")
+A(c:get("network", "lan", "enabled") == "off")
+
+A(c:set("network", "lan", "ifname", "eth5"))
+A(c:get("network", "lan", "ifname") == "eth5")
+A(c:revert("network"))
+A(c:get("network", "lan", "ifname") == "eth0")
+
+A(c:set("network", "lan", "ifname", "eth5"))
+A(c:get("network", "lan", "ifname") == "eth5")
+A(c:commit("network"))
+A(c:set("network", "lan", "ifname", "eth0"))
+A(c:revert("network"))
+A(c:commit("network"))
+A(c:get("network", "lan", "ifname") == "eth5")
+
+A(c:set("network", "lan", "dns", {
+   "ns1.king.banik.cz",
+   "ns2.openwrt.org",
+}))
+
+local t = c:get("network", "lan", "dns")
+A(#t == 2)
+A(t[1] == "ns1.king.banik.cz")
+A(t[2] == "ns2.openwrt.org")
diff --git a/tests/cram/test_ucilua.t b/tests/cram/test_ucilua.t
new file mode 100644
index ..1544e23c1bf4
--- /dev/null
+++ b/tests/cram/test_ucilua.t
@@ -0,0 +1,58 @@
+set LUA_CPATH and ucilua for convenience:
+
+  $ export LC_ALL=C
+  $ [ -n "$UCI_LUA" ] && export LUA_CPATH="$(dirname "$UCI_LUA")/?.so"
+  $ alias ucilua="valgrind --quiet --leak-check=full lua -luci"
+
+check available methods:
+
+  $ ucilua -e 'table.foreach(uci,function(m) print(m) end)'
+  add_history
+  add_delta
+  close
+  set_confdir
+  save
+  cursor
+  get_all
+  foreach
+  __gc
+  delete
+  set_savedir
+  set
+  revert
+  get_savedir
+  changes
+  reorder
+  get_confdir
+  list_configs
+  commit
+  unload
+  rename
+  add
+  load
+  get
+
+run basic Lua tests:
+
+  $ cp -R "$TESTDIR/config" .
+  $ export CONFIG_DIR=$(pwd)/config
+  $ ucilua $TESTDIR/lua/basic.lua
+  ---
+  enabled: off
+  

[OpenWrt-Devel] [PATCH uci 15/18] cli: remove unused variable assigment

2019-11-04 Thread Petr Štetiar
scan-build from clang version 9 has reported following issue:

 cli.c:574:8: warning: Although the value stored to 'ret' is used in the 
enclosing expression, the value is never actually read from 'ret'
if ((ret = uci_parse_argument(ctx, input, , [i])) != 
UCI_OK) {
 ^ ~~

Signed-off-by: Petr Štetiar 
---
 cli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cli.c b/cli.c
index 1ce4d5ed1d33..8970f4f0b8ce 100644
--- a/cli.c
+++ b/cli.c
@@ -571,7 +571,7 @@ static int uci_batch_cmd(void)
return 1;
}
argv[i] = NULL;
-   if ((ret = uci_parse_argument(ctx, input, , [i])) != 
UCI_OK) {
+   if (uci_parse_argument(ctx, input, , [i]) != UCI_OK) {
cli_perror();
i = 0;
break;

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 16/18] delta: prevent possible null pointer use

2019-11-04 Thread Petr Štetiar
scan-build from clang version 9 has reported following issue:

 delta.c:39:13: warning: Null pointer passed to 1st parameter expecting 
'nonnull'
int size = strlen(section) + 1;
   ^~~

Signed-off-by: Petr Štetiar 
---
 delta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/delta.c b/delta.c
index 97bdd29d3005..228a328c21a1 100644
--- a/delta.c
+++ b/delta.c
@@ -392,7 +392,7 @@ static void uci_filter_delta(struct uci_context *ctx, const 
char *name, const ch
match = false;
}
 
-   if (!match) {
+   if (!match && ptr.section) {
uci_add_delta(ctx, , c,
ptr.section, ptr.option, ptr.value);
}

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 18/18] lua: fix error handling

2019-11-04 Thread Petr Štetiar
scan-build from clang version 9 has reported following issues:

 uci.c:389:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:393:3: warning: Value stored to 'err' is never read
err = UCI_ERR_NOTFOUND;
^ 
 uci.c:417:4: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:524:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:533:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:565:4: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:575:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:584:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:642:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~
 uci.c:651:3: warning: Value stored to 'err' is never read
err = UCI_ERR_INVAL;
^ ~

Signed-off-by: Petr Štetiar 
---
 lua/uci.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lua/uci.c b/lua/uci.c
index a7aaad375c20..1ed73e4f67dc 100644
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -386,11 +386,11 @@ uci_lua_get_any(lua_State *L, bool all)
 
lookup_ptr(ctx, , NULL, true);
if (!all && !ptr.s) {
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) {
-   err = UCI_ERR_NOTFOUND;
+   ctx->err = UCI_ERR_NOTFOUND;
goto error;
}
 
@@ -414,7 +414,7 @@ uci_lua_get_any(lua_State *L, bool all)
uci_push_option(L, ptr.o);
break;
default:
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
if (s)
@@ -521,7 +521,7 @@ uci_lua_rename(lua_State *L)
ptr.option = NULL;
break;
default:
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
 
@@ -530,7 +530,7 @@ uci_lua_rename(lua_State *L)
goto error;
 
if (((ptr.s == NULL) && (ptr.option != NULL)) || (ptr.value == NULL)) {
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
 
@@ -562,7 +562,7 @@ uci_lua_reorder(lua_State *L)
case 1:
/* Format: uci.set("p.s=v") or uci.set("p.s=v") */
if (ptr.option) {
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
break;
@@ -572,7 +572,7 @@ uci_lua_reorder(lua_State *L)
ptr.option = NULL;
break;
default:
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
 
@@ -581,7 +581,7 @@ uci_lua_reorder(lua_State *L)
goto error;
 
if ((ptr.s == NULL) || (ptr.value == NULL)) {
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
 
@@ -639,7 +639,7 @@ uci_lua_set(lua_State *L)
ptr.option = NULL;
break;
default:
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
 
@@ -648,7 +648,7 @@ uci_lua_set(lua_State *L)
goto error;
 
if (((ptr.s == NULL) && (ptr.option != NULL)) || (ptr.value == NULL)) {
-   err = UCI_ERR_INVAL;
+   ctx->err = UCI_ERR_INVAL;
goto error;
}
 

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 09/18] iron out all extra compiler warnings

2019-11-04 Thread Petr Štetiar
gcc 9.1 on x86/64 has reported following issues:

 list.c:140:11: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:572:51: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:850:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:865:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 delta.c:199:6: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:80:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:81:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 file.c:572:51: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:850:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:865:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 delta.c:199:6: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:80:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:81:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 ucimap.c:146:16: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:151:17: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:243:34: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:247:9: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:254:39: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:258:9: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:285:34: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:363:17: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:563:12: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:753:18: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:879:17: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]

Signed-off-by: Petr Štetiar 
---
 delta.c   |  1 +
 file.c|  5 +++--
 list.c|  4 ++--
 lua/uci.c |  3 ++-
 parse.c   |  2 ++
 ucimap.c  | 15 ---
 6 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/delta.c b/delta.c
index 386167db4cd1..97bdd29d3005 100644
--- a/delta.c
+++ b/delta.c
@@ -198,6 +198,7 @@ static inline int uci_parse_delta_tuple(struct uci_context 
*ctx, struct uci_ptr
case UCI_CMD_LIST_ADD:
if (!ptr->option)
goto error;
+   /* fall through */
case UCI_CMD_LIST_DEL:
if (!ptr->option)
goto error;
diff --git a/file.c b/file.c
index 7333e48d51f7..bb102f52680a 100644
--- a/file.c
+++ b/file.c
@@ -569,7 +569,7 @@ static const char *uci_escape(struct uci_context *ctx, 
const char *str)
len = end - str;
 
/* make sure that we have enough room in the buffer */
-   while (ofs + len + sizeof(UCI_QUOTE_ESCAPE) + 1 > ctx->bufsz) {
+   while (ofs + len + (int) sizeof(UCI_QUOTE_ESCAPE) + 1 > 
ctx->bufsz) {
ctx->bufsz *= 2;
ctx->buf = uci_realloc(ctx, ctx->buf, ctx->bufsz);
}
@@ -834,7 +834,8 @@ static char **uci_list_config_files(struct uci_context *ctx)
 {
char **configs;
glob_t globbuf;
-   int size, i, j, skipped;
+   int size, j, skipped;
+   size_t i;
char *buf;
char *dir;
 
diff --git a/list.c b/list.c
index 78efbafe1c06..35d78f8d9ef2 100644
--- a/list.c
+++ b/list.c
@@ -137,7 +137,7 @@ static unsigned int djbhash(unsigned int hash, char *str)
int i;
 
/* initial value */
-   if (hash == ~0)
+   if (hash == ~0U)
hash = 5381;
 
for(i = 0; i < len; i++) {
@@ -149,7 +149,7 @@ static unsigned int djbhash(unsigned int hash, char *str)
 /* fix up an unnamed section, e.g. after adding options to it */
 static void uci_fixup_section(struct uci_context *ctx, struct uci_section *s)
 {
-   unsigned int hash = ~0;
+   unsigned int hash = ~0U;
struct uci_element *e;
char buf[16];
 
diff --git a/lua/uci.c b/lua/uci.c
index b29c347b1d91..f4dce89b7c9f 100644
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -605,7 +605,8 @@ uci_lua_set(lua_State *L)
int err = UCI_ERR_MEM;
char *s = NULL;
const char *v;
-   int i, nargs, offset = 0;
+   unsigned int i;
+   int nargs, 

[OpenWrt-Devel] [PATCH uci 13/18] lua: fix memory leak in changes method

2019-11-04 Thread Petr Štetiar
Configs returned by uci_list_configs call are not freed when not needed,
leading to the memory leak. While at it make the code cleaner.

Signed-off-by: Petr Štetiar 
---
 lua/uci.c | 15 ---
 tests/cram/lua/test_cases/changes_doesnt_leak.lua | 11 +++
 tests/cram/test_ucilua_testcases.t| 10 ++
 3 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 tests/cram/lua/test_cases/changes_doesnt_leak.lua
 create mode 100644 tests/cram/test_ucilua_testcases.t

diff --git a/lua/uci.c b/lua/uci.c
index 323f81a68c17..42fe4b785901 100644
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -880,16 +880,17 @@ uci_lua_changes(lua_State *L)
lua_newtable(L);
if (package) {
uci_lua_changes_pkg(L, ctx, package);
-   } else {
-   if (uci_list_configs(ctx, ) != 0)
-   goto done;
+   return 1;
+   }
 
-   for(i = 0; config[i] != NULL; i++) {
-   uci_lua_changes_pkg(L, ctx, config[i]);
-   }
+   if ((uci_list_configs(ctx, ) != UCI_OK) || !config)
+   return 1;
+
+   for (i = 0; config[i] != NULL; i++) {
+   uci_lua_changes_pkg(L, ctx, config[i]);
}
 
-done:
+   free(config);
return 1;
 }
 
diff --git a/tests/cram/lua/test_cases/changes_doesnt_leak.lua 
b/tests/cram/lua/test_cases/changes_doesnt_leak.lua
new file mode 100644
index ..68f0ed05bc2a
--- /dev/null
+++ b/tests/cram/lua/test_cases/changes_doesnt_leak.lua
@@ -0,0 +1,11 @@
+local A = assert
+local c = uci.cursor(os.getenv("CONFIG_DIR"))
+
+A(c:set("network", "lan", "dns", {
+   "ns1.king.banik.cz",
+   "ns2.openwrt.org",
+}))
+
+local changes = c:changes()
+A(changes.network.lan.dns[1] == "ns1.king.banik.cz")
+A(changes.network.lan.dns[2] == "ns2.openwrt.org")
diff --git a/tests/cram/test_ucilua_testcases.t 
b/tests/cram/test_ucilua_testcases.t
new file mode 100644
index ..279dfce9422a
--- /dev/null
+++ b/tests/cram/test_ucilua_testcases.t
@@ -0,0 +1,10 @@
+set LUA_CPATH and ucilua for convenience:
+
+  $ [ -n "$UCI_LUA" ] && export LUA_CPATH="$(dirname "$UCI_LUA")/?.so"
+  $ alias ucilua="valgrind --quiet --leak-check=full lua -luci"
+
+check that changes method doesnt leak memory:
+
+  $ cp -R "$TESTDIR/config" .
+  $ export CONFIG_DIR=$(pwd)/config
+  $ ucilua $TESTDIR/lua/test_cases/changes_doesnt_leak.lua

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 14/18] lua: fix memory leak in set method

2019-11-04 Thread Petr Štetiar
scan-build from clang version 9 has reported following issue:

 uci.c:624:12: warning: Potential leak of memory pointed to by 's'
   return luaL_error(L, "Cannot set an uci option to an empty table value");
  ^~

valgrind confirmed it on the supplied test case:

 ==31013== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
 ==31013==by 0x56C49B9: strdup (strdup.c:42)

Signed-off-by: Petr Štetiar 
---
 lua/uci.c  | 5 -
 .../lua/test_cases/set_with_empty_table_doesnt_leak.lua| 2 ++
 tests/cram/test_ucilua_testcases.t | 7 +++
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 
tests/cram/lua/test_cases/set_with_empty_table_doesnt_leak.lua

diff --git a/lua/uci.c b/lua/uci.c
index 42fe4b785901..a7aaad375c20 100644
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -620,8 +620,11 @@ uci_lua_set(lua_State *L)
case 4:
/* Format: uci.set("p", "s", "o", "v") */
if (lua_istable(L, nargs)) {
-   if (lua_rawlen(L, nargs) < 1)
+   if (lua_rawlen(L, nargs) < 1) {
+   if (s)
+   free(s);
return luaL_error(L, "Cannot set an uci option 
to an empty table value");
+   }
lua_rawgeti(L, nargs, 1);
ptr.value = luaL_checkstring(L, -1);
lua_pop(L, 1);
diff --git a/tests/cram/lua/test_cases/set_with_empty_table_doesnt_leak.lua 
b/tests/cram/lua/test_cases/set_with_empty_table_doesnt_leak.lua
new file mode 100644
index ..83e91d3ab264
--- /dev/null
+++ b/tests/cram/lua/test_cases/set_with_empty_table_doesnt_leak.lua
@@ -0,0 +1,2 @@
+local c = uci.cursor(os.getenv("CONFIG_DIR"))
+print(pcall(c.set, c, "network", "lan", "dns", {}))
diff --git a/tests/cram/test_ucilua_testcases.t 
b/tests/cram/test_ucilua_testcases.t
index 279dfce9422a..6a0216b3ded8 100644
--- a/tests/cram/test_ucilua_testcases.t
+++ b/tests/cram/test_ucilua_testcases.t
@@ -8,3 +8,10 @@ check that changes method doesnt leak memory:
   $ cp -R "$TESTDIR/config" .
   $ export CONFIG_DIR=$(pwd)/config
   $ ucilua $TESTDIR/lua/test_cases/changes_doesnt_leak.lua
+
+check that set method with empty table value doesn't leak memory:
+
+  $ cp -R "$TESTDIR/config" .
+  $ export CONFIG_DIR=$(pwd)/config
+  $ ucilua $TESTDIR/lua/test_cases/set_with_empty_table_doesnt_leak.lua
+  false\tCannot set an uci option to an empty table value (esc)

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 08/18] tests: shunit2: run all tests under Valgrind by default

2019-11-04 Thread Petr Štetiar
The more tests, the better.

Signed-off-by: Petr Štetiar 
---
 tests/shunit2/tests.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/shunit2/tests.sh b/tests/shunit2/tests.sh
index 72c48749feb6..00f56c5e3195 100755
--- a/tests/shunit2/tests.sh
+++ b/tests/shunit2/tests.sh
@@ -11,6 +11,8 @@ UCI_BIN=${UCI_BIN:-"../uci"}
echo "uci is not present." >&2
return 1
 }
+VALGRIND="valgrind --quiet --show-leak-kinds=all --leak-check=full 
--track-origins=yes"
+UCI_BIN="${VALGRIND} ${UCI_BIN}"
 UCI="${UCI_BIN} -c ${CONFIG_DIR} -p ${CHANGES_DIR}"
 UCI_Q="${UCI_BIN} -c ${CONFIG_DIR} -p ${CHANGES_DIR} -q"
 

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 17/18] ucimap: fix possible use of memory after it is freed

2019-11-04 Thread Petr Štetiar
scan-build from clang version 9 has reported following issue:

 ucimap.c:710:8: warning: Use of memory after it is freed
err = ucimap_parse_options(map, sm, sd, s);
  ^~~~

Signed-off-by: Petr Štetiar 
---
 ucimap.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/ucimap.c b/ucimap.c
index d5fd5c4f7143..7c2b0435d308 100644
--- a/ucimap.c
+++ b/ucimap.c
@@ -490,16 +490,21 @@ ucimap_add_section_list(struct uci_map *map, struct 
ucimap_section_data *sd)
map->sdata_tail = >next;
 }
 
-static void
+static int
 ucimap_add_section(struct ucimap_section_data *sd)
 {
+   int r;
struct uci_map *map = sd->map;
 
sd->next = NULL;
-   if (sd->sm->add(map, ucimap_section_ptr(sd)) < 0)
+   r = sd->sm->add(map, ucimap_section_ptr(sd));
+   if (r < 0) {
ucimap_free_section(map, sd);
-   else
+   return r;
+   } else
ucimap_add_section_list(map, sd);
+
+   return 0;
 }
 
 #ifdef UCI_DEBUG
@@ -702,7 +707,9 @@ ucimap_parse_section(struct uci_map *map, struct 
uci_sectionmap *sm, struct ucim
goto error;
 
if (map->parsed) {
-   ucimap_add_section(sd);
+   err = ucimap_add_section(sd);
+   if (err)
+   return err;
} else {
ucimap_add_section_list(map, sd);
}

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 06/18] cmake: build Lua module only if enabled

2019-11-04 Thread Petr Štetiar
Makes the resulting lua/CMakeLists.txt file simpler.

Signed-off-by: Petr Štetiar 
---
 CMakeLists.txt |  4 +++-
 lua/CMakeLists.txt | 32 
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2559b1ec1507..0bbd3b2046ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,9 @@ ENDIF(BUILD_STATIC)
 
 ADD_LIBRARY(ucimap STATIC ucimap.c)
 
-ADD_SUBDIRECTORY(lua)
+IF(BUILD_LUA)
+  ADD_SUBDIRECTORY(lua)
+ENDIF()
 
 IF(UNIT_TESTING)
   ENABLE_TESTING()
diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt
index b9f513a9c044..96b122aa5029 100644
--- a/lua/CMakeLists.txt
+++ b/lua/CMakeLists.txt
@@ -15,12 +15,9 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
 IF(APPLE)
   INCLUDE_DIRECTORIES(/opt/local/include)
   LINK_DIRECTORIES(/opt/local/lib)
+  SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS 
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
 ENDIF()
 
-IF(APPLE)
-   SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS 
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
-ENDIF(APPLE)
-
 IF(NOT LUAPATH)
EXECUTE_PROCESS(
COMMAND  lua -e "for k in string.gmatch(package.cpath .. \";\", 
\"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
@@ -29,23 +26,18 @@ IF(NOT LUAPATH)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
 
-   IF(BUILD_LUA)
-   IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR "${LUAPATH}" EQUAL "")
-   MESSAGE(SEND_ERROR "Lua was not found on your system")
-   ENDIF()
+   IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR "${LUAPATH}" EQUAL "")
+   MESSAGE(SEND_ERROR "Lua was not found on your system")
ENDIF()
 ENDIF()
 
-IF(BUILD_LUA)
-   ADD_LIBRARY(uci_lua MODULE uci.c)
-   SET_TARGET_PROPERTIES(uci_lua PROPERTIES
-   OUTPUT_NAME uci
-   PREFIX ""
-   )
-   TARGET_LINK_LIBRARIES(uci_lua uci dl)
-
-   INSTALL(TARGETS uci_lua
-   LIBRARY DESTINATION ${LUAPATH}
-   )
-ENDIF()
+ADD_LIBRARY(uci_lua MODULE uci.c)
+SET_TARGET_PROPERTIES(uci_lua PROPERTIES
+   OUTPUT_NAME uci
+   PREFIX ""
+)
+TARGET_LINK_LIBRARIES(uci_lua uci dl)
 
+INSTALL(TARGETS uci_lua
+   LIBRARY DESTINATION ${LUAPATH}
+)

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 10/18] cli: fix realloc issue spotted by cppcheck

2019-11-04 Thread Petr Štetiar
Cppcheck 1.90 dev reports following:

 cli.c:117:4: error: Common realloc mistake: 'typestr' nulled but not freed 
upon failure [memleakOnRealloc]
typestr = realloc(typestr, maxlen);
^

Signed-off-by: Petr Štetiar 
---
 cli.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cli.c b/cli.c
index f8b45dba091f..1ce4d5ed1d33 100644
--- a/cli.c
+++ b/cli.c
@@ -113,8 +113,16 @@ uci_lookup_section_ref(struct uci_section *s)
maxlen = strlen(s->type) + 1 + 2 + 10;
if (!typestr) {
typestr = malloc(maxlen);
+   if (!typestr)
+   return NULL;
} else {
-   typestr = realloc(typestr, maxlen);
+   void *p = realloc(typestr, maxlen);
+   if (!p) {
+   free(typestr);
+   return NULL;
+   }
+
+   typestr = p;
}
 
if (typestr)

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 11/18] lua: fix copy in error string

2019-11-04 Thread Petr Štetiar
When uci_set_confdir fails we should say so.

Signed-off-by: Petr Štetiar 
---
 lua/uci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lua/uci.c b/lua/uci.c
index f4dce89b7c9f..323f81a68c17 100644
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -1006,7 +1006,7 @@ uci_lua_cursor(lua_State *L)
case 1:
if (lua_isstring(L, 1) &&
(uci_set_confdir(*u, luaL_checkstring(L, 1)) != 
UCI_OK))
-   return luaL_error(L, "Unable to set savedir");
+   return luaL_error(L, "Unable to set confdir");
break;
default:
break;

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 05/18] tests: shunit2: fix issues reported by shellcheck

2019-11-04 Thread Petr Štetiar
 In tests.sh line 10:
 [ -x $UCI_BIN ] || {
  ^--^ SC2086: Double quote to prevent globbing and word splitting.

 In tests.sh line 63:
 for suite in $(ls ${SCRIPTS_DIR}/*)
  ^^ SC2045: Iterating over ls output is 
fragile. Use globs.

 In tests.sh line 65:
cat ${suite} >> ${FULL_SUITE}
 ^--^ SC2086: Double quote to prevent globbing and word 
splitting.

Signed-off-by: Petr Štetiar 
---
 tests/shunit2/tests.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/shunit2/tests.sh b/tests/shunit2/tests.sh
index a7c6d9004987..72c48749feb6 100755
--- a/tests/shunit2/tests.sh
+++ b/tests/shunit2/tests.sh
@@ -7,7 +7,7 @@ TMP_DIR=${TESTS_DIR}"/tmp"
 FULL_SUITE=${TESTS_DIR}"/full_suite.sh"
 
 UCI_BIN=${UCI_BIN:-"../uci"}
-[ -x $UCI_BIN ] || {
+[ -x "$UCI_BIN" ] || {
echo "uci is not present." >&2
return 1
 }
@@ -60,9 +60,9 @@ assertFailWithNoReturn() {
 }
 EOF
 
-for suite in $(ls ${SCRIPTS_DIR}/*)
+for suite in "${SCRIPTS_DIR}"/*
 do
-   cat ${suite} >> ${FULL_SUITE}
+   cat "${suite}" >> ${FULL_SUITE}
 done
 
 echo ". ${DO_TEST}" >> ${FULL_SUITE}

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 07/18] cmake: enable extra compiler checks

2019-11-04 Thread Petr Štetiar
Let's enforce additional automatic checks enforced by the compiler in
order to catch possible errors during compilation.

Signed-off-by: Petr Štetiar 
---
 CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0bbd3b2046ec..92adf4a47121 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 2.6)
 PROJECT(uci C)
 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
-ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -I. 
-DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")
+ADD_DEFINITIONS(-Os -Wall -Werror -Wextra --std=gnu99 -g3 -I. 
-DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")
+ADD_DEFINITIONS(-Wno-unused-parameter)
 
 OPTION(UCI_DEBUG "debugging support" OFF)
 OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 03/18] tests: shunit2: make it working under CMake

2019-11-04 Thread Petr Štetiar
uci is being passed from CMake as environment variable.

Signed-off-by: Petr Štetiar 
---
 tests/shunit2/tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 mode change 100644 => 100755 tests/shunit2/tests.sh

diff --git a/tests/shunit2/tests.sh b/tests/shunit2/tests.sh
old mode 100644
new mode 100755
index ee72c316775d..a7c6d9004987
--- a/tests/shunit2/tests.sh
+++ b/tests/shunit2/tests.sh
@@ -6,7 +6,7 @@ CHANGES_DIR="/tmp/.uci"
 TMP_DIR=${TESTS_DIR}"/tmp"
 FULL_SUITE=${TESTS_DIR}"/full_suite.sh"
 
-UCI_BIN="../uci"
+UCI_BIN=${UCI_BIN:-"../uci"}
 [ -x $UCI_BIN ] || {
echo "uci is not present." >&2
return 1

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 01/18] test: move shunit2 tests under standalone subdirectory

2019-11-04 Thread Petr Štetiar
So we could start adding other tests as well. While at it rename the
parent directory from test to the more common tests name.

Signed-off-by: Petr Štetiar 
---
 .gitignore  | 2 +-
 {test => tests/shunit2}/Makefile| 0
 {test => tests/shunit2}/README  | 0
 {test => tests/shunit2}/config/network  | 0
 {test => tests/shunit2}/references/add_list_changes.result  | 0
 {test => tests/shunit2}/references/add_list_config.result   | 0
 {test => tests/shunit2}/references/add_list_show.result | 0
 {test => tests/shunit2}/references/add_section.result   | 0
 {test => tests/shunit2}/references/batch_comments.result| 0
 {test => tests/shunit2}/references/batch_set.result | 0
 .../shunit2}/references/cli.options.delta.commit.result | 0
 .../shunit2}/references/cli.options.delta.export.result | 0
 {test => tests/shunit2}/references/del_list_config.result   | 0
 .../shunit2}/references/del_list_multiline_config.result| 0
 {test => tests/shunit2}/references/export.data  | 0
 {test => tests/shunit2}/references/export.result| 0
 {test => tests/shunit2}/references/get.data | 0
 {test => tests/shunit2}/references/get_multiline.data   | 0
 {test => tests/shunit2}/references/get_parsing.data | 0
 {test => tests/shunit2}/references/import.data  | 0
 {test => tests/shunit2}/references/import.result| 0
 {test => tests/shunit2}/references/revert_option.result | 0
 .../shunit2}/references/revert_option_multiline.result  | 0
 {test => tests/shunit2}/references/revert_section.result| 0
 {test => tests/shunit2}/references/set_existing_option.data | 0
 {test => tests/shunit2}/references/set_existing_option.result   | 0
 .../shunit2}/references/set_existing_option_multiline.result| 0
 {test => tests/shunit2}/references/set_named_section.result | 0
 {test => tests/shunit2}/references/set_nonexisting_option.data  | 0
 .../shunit2}/references/set_nonexisting_option.result   | 0
 .../shunit2}/references/set_nonexisting_option_multiline.result | 0
 {test => tests/shunit2}/references/set_parsing.data | 0
 {test => tests/shunit2}/references/set_parsing_multiline.data   | 0
 {test => tests/shunit2}/references/show_parsing.data| 0
 {test => tests/shunit2}/references/show_parsing_multiline.data  | 0
 .../shunit2}/references/show_parsing_multiline_option.result| 0
 .../shunit2}/references/show_parsing_multiline_package.result   | 0
 .../shunit2}/references/show_parsing_multiline_section.result   | 0
 {test => tests/shunit2}/references/ucimap_example_1.result  | 0
 {test => tests/shunit2}/references/ucimap_example_2.result  | 0
 {test => tests/shunit2}/shunit2/shunit2 | 0
 {test => tests/shunit2}/tests.d/000_import  | 0
 {test => tests/shunit2}/tests.d/010_export  | 0
 {test => tests/shunit2}/tests.d/020_get | 0
 {test => tests/shunit2}/tests.d/030_set | 0
 {test => tests/shunit2}/tests.d/040_add | 0
 {test => tests/shunit2}/tests.d/050_show| 0
 {test => tests/shunit2}/tests.d/060_batch   | 0
 {test => tests/shunit2}/tests.d/070_revert  | 0
 {test => tests/shunit2}/tests.d/080_list| 0
 {test => tests/shunit2}/tests.d/090_cli_options | 0
 {test => tests/shunit2}/tests.d/100_changes | 0
 {test => tests/shunit2}/tests.sh| 0
 53 files changed, 1 insertion(+), 1 deletion(-)
 rename {test => tests/shunit2}/Makefile (100%)
 rename {test => tests/shunit2}/README (100%)
 rename {test => tests/shunit2}/config/network (100%)
 rename {test => tests/shunit2}/references/add_list_changes.result (100%)
 rename {test => tests/shunit2}/references/add_list_config.result (100%)
 rename {test => tests/shunit2}/references/add_list_show.result (100%)
 rename {test => tests/shunit2}/references/add_section.result (100%)
 rename {test => tests/shunit2}/references/batch_comments.result (100%)
 rename {test => tests/shunit2}/references/batch_set.result (100%)
 rename {test => tests/shunit2}/references/cli.options.delta.commit.result 
(100%)
 rename {test => tests/shunit2}/references/cli.options.delta.export.result 
(100%)
 rename {test => tests/shunit2}/references/del_list_config.result (100%)
 rename {test => tests/shunit2}/references/del_list_multiline_config.result 
(100%)
 rename {test => tests/shunit2}/references/export.data (100%)
 rename {test => tests/shunit2}/references/export.result (100%)
 rename {test => tests/shunit2}/references/get.data (100%)
 rename {test => 

[OpenWrt-Devel] [PATCH uci 00/18] fixes and improvements

2019-11-04 Thread Petr Štetiar
Hi,

while working on possible test case for CVE-2019-15513, I've made uci compile
with -Wextra flags (needs Hauke's PW#1188122[1] patch), tried to make
clang/cppcheck static code analyzers happy, fixed some memleaks in Lua module,
integrated shunit2 tests in CMake and run them under valgrind by default,
added few Lua tests under cram as well.

1. https://patchwork.ozlabs.org/patch/1188122/

Petr Štetiar (18):
  test: move shunit2 tests under standalone subdirectory
  cmake: add unit testing option and shunit2 tests
  tests: shunit2: make it working under CMake
  add initial GitLab CI support
  tests: shunit2: fix issues reported by shellcheck
  cmake: build Lua module only if enabled
  cmake: enable extra compiler checks
  tests: shunit2: run all tests under Valgrind by default
  iron out all extra compiler warnings
  cli: fix realloc issue spotted by cppcheck
  lua: fix copy in error string
  tests: add cram based unit tests
  lua: fix memory leak in changes method
  lua: fix memory leak in set method
  cli: remove unused variable assigment
  delta: prevent possible null pointer use
  ucimap: fix possible use of memory after it is freed
  lua: fix error handling

 .gitignore|  5 +-
 .gitlab-ci.yml|  8 +++
 CMakeLists.txt| 12 +++-
 cli.c | 12 +++-
 delta.c   |  3 +-
 file.c|  5 +-
 list.c|  4 +-
 lua/CMakeLists.txt| 34 +--
 lua/uci.c | 45 +++---
 parse.c   |  2 +
 tests/CMakeLists.txt  |  2 +
 tests/cram/CMakeLists.txt | 21 +++
 tests/cram/config/network | 25 
 tests/cram/lua/basic.lua  | 44 ++
 .../lua/test_cases/changes_doesnt_leak.lua| 11 
 .../set_with_empty_table_doesnt_leak.lua  |  2 +
 tests/cram/test_ucilua.t  | 58 +++
 tests/cram/test_ucilua_testcases.t| 17 ++
 tests/shunit2/CMakeLists.txt  |  7 +++
 {test => tests/shunit2}/Makefile  |  0
 {test => tests/shunit2}/README|  0
 {test => tests/shunit2}/config/network|  0
 .../references/add_list_changes.result|  0
 .../references/add_list_config.result |  0
 .../shunit2}/references/add_list_show.result  |  0
 .../shunit2}/references/add_section.result|  0
 .../shunit2}/references/batch_comments.result |  0
 .../shunit2}/references/batch_set.result  |  0
 .../cli.options.delta.commit.result   |  0
 .../cli.options.delta.export.result   |  0
 .../references/del_list_config.result |  0
 .../del_list_multiline_config.result  |  0
 .../shunit2}/references/export.data   |  0
 .../shunit2}/references/export.result |  0
 {test => tests/shunit2}/references/get.data   |  0
 .../shunit2}/references/get_multiline.data|  0
 .../shunit2}/references/get_parsing.data  |  0
 .../shunit2}/references/import.data   |  0
 .../shunit2}/references/import.result |  0
 .../shunit2}/references/revert_option.result  |  0
 .../references/revert_option_multiline.result |  0
 .../shunit2}/references/revert_section.result |  0
 .../references/set_existing_option.data   |  0
 .../references/set_existing_option.result |  0
 .../set_existing_option_multiline.result  |  0
 .../references/set_named_section.result   |  0
 .../references/set_nonexisting_option.data|  0
 .../references/set_nonexisting_option.result  |  0
 .../set_nonexisting_option_multiline.result   |  0
 .../shunit2}/references/set_parsing.data  |  0
 .../references/set_parsing_multiline.data |  0
 .../shunit2}/references/show_parsing.data |  0
 .../references/show_parsing_multiline.data|  0
 .../show_parsing_multiline_option.result  |  0
 .../show_parsing_multiline_package.result |  0
 .../show_parsing_multiline_section.result |  0
 .../references/ucimap_example_1.result|  0
 .../references/ucimap_example_2.result|  0
 {test => tests/shunit2}/shunit2/shunit2   |  0
 {test => tests/shunit2}/tests.d/000_import|  0
 {test => tests/shunit2}/tests.d/010_export|  0
 {test => tests/shunit2}/tests.d/020_get   |  0
 {test => tests/shunit2}/tests.d/030_set   |  0
 {test => tests/shunit2}/tests.d/040_add   |  0
 {test => tests/shunit2}/tests.d/050_show  |  0
 {test => tests/shunit2}/tests.d/060_batch |  0
 {test => tests/shunit2}/tests.d/070_revert|  0
 {test => tests/shunit2}/tests.d/080_list  |  0
 .../shunit2}/tests.d/090_cli_options  |  0
 {test => tests/shunit2}/tests.d/100_changes   |  0
 {test => tests/shunit2}/tests.sh  

[OpenWrt-Devel] [PATCH uci 02/18] cmake: add unit testing option and shunit2 tests

2019-11-04 Thread Petr Štetiar
For convenient tests invocation.

Signed-off-by: Petr Štetiar 
---
 CMakeLists.txt   | 5 +
 tests/CMakeLists.txt | 1 +
 tests/shunit2/CMakeLists.txt | 7 +++
 3 files changed, 13 insertions(+)
 create mode 100644 tests/CMakeLists.txt
 create mode 100644 tests/shunit2/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 170eb0b7b887..2559b1ec1507 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,11 @@ ADD_LIBRARY(ucimap STATIC ucimap.c)
 
 ADD_SUBDIRECTORY(lua)
 
+IF(UNIT_TESTING)
+  ENABLE_TESTING()
+  ADD_SUBDIRECTORY(tests)
+ENDIF()
+
 INSTALL(FILES uci.h uci_config.h uci_blob.h ucimap.h
DESTINATION include
 )
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index ..b7a7ccb0e60b
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(shunit2)
diff --git a/tests/shunit2/CMakeLists.txt b/tests/shunit2/CMakeLists.txt
new file mode 100644
index ..42cb43fd37a9
--- /dev/null
+++ b/tests/shunit2/CMakeLists.txt
@@ -0,0 +1,7 @@
+ADD_TEST(
+   NAME shunit2
+   COMMAND tests.sh
+   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+SET_PROPERTY(TEST shunit2 APPEND PROPERTY ENVIRONMENT 
"UCI_BIN=$")

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uci 04/18] add initial GitLab CI support

2019-11-04 Thread Petr Štetiar
Uses currently proof-of-concept openwrt-ci[1] in order to:

 * improve the quality of the codebase in various areas
 * decrease code review time and help merging contributions faster
 * get automagic feedback loop on various platforms and tools
   - out of tree build with OpenWrt SDK on following targets:
 * ath79-generic
 * imx6-generic
 * malta-be
 * mvebu-cortexa53
   - out of tree native build on x86/64 with GCC (versions 7, 8, 9) and Clang 9
   - out of tree native x86/64 static code analysis with cppcheck and
 scan-build from Clang 9

1. https://gitlab.com/ynezz/openwrt-ci/

Signed-off-by: Petr Štetiar 
---
 .gitlab-ci.yml | 8 
 1 file changed, 8 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index ..02136247518f
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,8 @@
+variables:
+  CI_ENABLE_UNIT_TESTING: 1
+  CI_TARGET_BUILD_DEPENDS: uci
+  CI_CMAKE_EXTRA_BUILD_ARGS: -DLUAPATH=/usr/lib/lua
+
+include:
+  - remote: 
https://gitlab.com/ynezz/openwrt-ci/raw/master/openwrt-ci/gitlab/main.yml
+  - remote: 
https://gitlab.com/ynezz/openwrt-ci/raw/master/openwrt-ci/gitlab/pipeline.yml

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH uci 2/2] build: Add -Wclobbered to detect problems with longjmp

2019-11-04 Thread Petr Štetiar
Hi,

Hauke Mehrtens  [2019-11-01 17:06:34]:

> +ADD_DEFINITIONS(-Os -Wall -Werror -Wclobbered --std=gnu99 -g3 -I. 
> -DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")

is there any reason to not use -Wextra directly?

 list.c:140:11: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:572:51: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:850:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:865:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 delta.c:199:6: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:80:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:81:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 file.c:572:51: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:850:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 file.c:865:15: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 delta.c:199:6: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:80:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 parse.c:81:12: error: this statement may fall through 
[-Werror=implicit-fallthrough=]
 ucimap.c:146:16: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:151:17: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:243:34: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:247:9: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:254:39: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:258:9: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:285:34: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:363:17: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:563:12: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:753:18: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]
 ucimap.c:879:17: error: comparison between signed and unsigned integer 
expressions [-Werror=sign-compare]

Yousong Zhou  [2019-11-04 11:29:05]:

> The -Wclobber check can produce false-positives right?

I didn't looked deeper, but GCC 6,7,8,9 on x86/64 reports following:

 list.c:626:21: error: variable ‘prev’ might be clobbered by ‘longjmp’ or 
‘vfork’ [-Werror=clobbered]
  626 |  struct uci_option *prev = NULL;
  | ^~~~

 list.c:627:14: error: variable ‘value2’ might be clobbered by ‘longjmp’ or 
‘vfork’ [-Werror=clobbered]
  627 |  const char *value2 = NULL;
  |  ^~

but clang 9,10 on x86/64 doesn't.

-- ynezz

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/3] Further preparations for USB gadget usage

2019-11-04 Thread Michael Heimpold
This patch series bundles some more steps towards the usage
of I2SE Duckbills as USB gadget devices.

Michael Heimpold (3):
  procd: start additional consoles during hotplugging
  mxs: switch to askconsole
  mxs: start a console on USB gadget serial ports

 package/system/procd/Makefile   | 2 +-
 package/system/procd/files/hotplug.json | 4 
 target/linux/mxs/base-files/etc/inittab | 3 ++-
 3 files changed, 7 insertions(+), 2 deletions(-)

-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/3] mxs: start a console on USB gadget serial ports

2019-11-04 Thread Michael Heimpold
The I2SE Duckbill devices are pen-drive like and thus the usage
of the USB gadget subsystem is highly indicated.

Spawning a console if a serial gadget is configured saves
us from connecting a physical debug uart.

On Olimex OLinuXino Maxi/Mini boards, this does not hurt.

Signed-off-by: Michael Heimpold 
---
 target/linux/mxs/base-files/etc/inittab | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/mxs/base-files/etc/inittab 
b/target/linux/mxs/base-files/etc/inittab
index 9820e7144b..253036402d 100644
--- a/target/linux/mxs/base-files/etc/inittab
+++ b/target/linux/mxs/base-files/etc/inittab
@@ -1,3 +1,4 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K shutdown
 ::askconsole:/usr/libexec/login.sh
+ttyGS0::askfirst:/usr/libexec/login.sh
-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] procd: start additional consoles during hotplugging

2019-11-04 Thread Michael Heimpold
Now that 'start-console' procd command has reached the main repo,
we can add a rule to start consoles on serial devices which are
created when USB gadget driver reports creation with hotplugging.

Signed-off-by: Michael Heimpold 
---
 package/system/procd/Makefile   | 2 +-
 package/system/procd/files/hotplug.json | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile
index 8090b87dd5..c4b86ba746 100644
--- a/package/system/procd/Makefile
+++ b/package/system/procd/Makefile
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=procd
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
diff --git a/package/system/procd/files/hotplug.json 
b/package/system/procd/files/hotplug.json
index f676bac79e..7e0f129d35 100644
--- a/package/system/procd/files/hotplug.json
+++ b/package/system/procd/files/hotplug.json
@@ -37,6 +37,10 @@
[ "load-firmware", "/lib/firmware" ],
[ "return" ]
]
+   ],
+   [ "if",
+   [ "regex", "DEVNAME", "^ttyGS" ],
+   [ "start-console", "%DEVNAME%" ]
]
],
"remove" : [
-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] mxs: switch to askconsole

2019-11-04 Thread Michael Heimpold
Remove the dedicated tty name and use askconsole to spawn the console
on serial debug uart.

Signed-off-by: Michael Heimpold 
---
 target/linux/mxs/base-files/etc/inittab | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/mxs/base-files/etc/inittab 
b/target/linux/mxs/base-files/etc/inittab
index 9991ac4909..9820e7144b 100644
--- a/target/linux/mxs/base-files/etc/inittab
+++ b/target/linux/mxs/base-files/etc/inittab
@@ -1,3 +1,3 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K shutdown
-ttyAMA0::askfirst:/usr/libexec/login.sh
+::askconsole:/usr/libexec/login.sh
-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] uboot-mxs: bump to v2019.10

2019-11-04 Thread Michael Heimpold
Also update the U-Boot BSP patch for I2SE Duckbill devices.

Run tested on I2SE Duckbill and Olimex OLinuXino Maxi boards.

Signed-off-by: Michael Heimpold 
---

Superseeds my patch to upgrade to v2019.07.

 package/boot/uboot-mxs/Makefile  |  4 ++--
 .../patches/001-add-i2se-duckbill.patch  | 16 +---
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/package/boot/uboot-mxs/Makefile b/package/boot/uboot-mxs/Makefile
index c4485f5b3d..04d3f15f95 100644
--- a/package/boot/uboot-mxs/Makefile
+++ b/package/boot/uboot-mxs/Makefile
@@ -8,10 +8,10 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
-PKG_VERSION:=2019.01
+PKG_VERSION:=2019.10
 PKG_RELEASE:=1
 
-PKG_HASH:=50bd7e5a466ab828914d080d5f6a432345b500e8fba1ad3b7b61e95e60d51c22
+PKG_HASH:=8d6d6070739522dd236cba7055b8736bfe92b4fac0ea18ad809829ca79667014
 
 include $(INCLUDE_DIR)/u-boot.mk
 include $(INCLUDE_DIR)/package.mk
diff --git a/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch 
b/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch
index 9acb6a508d..c7b8fd63ea 100644
--- a/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch
+++ b/package/boot/uboot-mxs/patches/001-add-i2se-duckbill.patch
@@ -1,6 +1,6 @@
-From 6af0148a38b23ba761905f98a7211fab986033ce Mon Sep 17 00:00:00 2001
+From 821d083ae4cfb795eab385eda43a20cdc8c3cacd Mon Sep 17 00:00:00 2001
 From: Michael Heimpold 
-Date: Thu, 13 Sep 2018 21:40:19 +0200
+Date: Sun, 3 Nov 2019 00:50:21 +0100
 Subject: [PATCH] arm: mxs: add support for I2SE's Duckbill boards
 
 The Duckbill devices are small, pen-drive sized boards based on
@@ -32,9 +32,9 @@ Signed-off-by: Stefan Wahren 
  board/i2se/duckbill/Makefile|  10 ++
  board/i2se/duckbill/duckbill.c  | 186 
  board/i2se/duckbill/iomux.c | 156 +++
- configs/duckbill_defconfig  |  38 +++
+ configs/duckbill_defconfig  |  40 +++
  include/configs/duckbill.h  | 179 ++
- 8 files changed, 595 insertions(+)
+ 8 files changed, 597 insertions(+)
  create mode 100644 board/i2se/duckbill/Kconfig
  create mode 100644 board/i2se/duckbill/MAINTAINERS
  create mode 100644 board/i2se/duckbill/Makefile
@@ -471,10 +471,10 @@ index 00..1db3c52c34
 +}
 diff --git a/configs/duckbill_defconfig b/configs/duckbill_defconfig
 new file mode 100644
-index 00..f92a67d53d
+index 00..5a8c561b4e
 --- /dev/null
 +++ b/configs/duckbill_defconfig
-@@ -0,0 +1,38 @@
+@@ -0,0 +1,40 @@
 +CONFIG_ARM=y
 +CONFIG_ARCH_MX28=y
 +CONFIG_SYS_TEXT_BASE=0x40002000
@@ -483,8 +483,9 @@ index 00..f92a67d53d
 +CONFIG_SPL_LIBGENERIC_SUPPORT=y
 +CONFIG_TARGET_DUCKBILL=y
 +CONFIG_SPL_SERIAL_SUPPORT=y
-+CONFIG_SPL=y
 +CONFIG_NR_DRAM_BANKS=1
++CONFIG_SPL=y
++CONFIG_SPL_TEXT_BASE=0x1000
 +CONFIG_BOOTDELAY=1
 +CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 +CONFIG_VERSION_VARIABLE=y
@@ -508,6 +509,7 @@ index 00..f92a67d53d
 +CONFIG_CMD_FS_GENERIC=y
 +CONFIG_DOS_PARTITION=y
 +CONFIG_ENV_IS_IN_MMC=y
++CONFIG_MXS_GPIO=y
 +CONFIG_MMC_MXS=y
 +CONFIG_MII=y
 +CONFIG_CONS_INDEX=0
-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH RESEND] mxs: add support and switch to kernel 4.19

2019-11-04 Thread Michael Heimpold
Also remove kernel 4.14 support and the meanwhile obsolete patch.

This was run-tested on I2SE Duckbill device and
Olimex OLinuXino Maxi board.

Signed-off-by: Michael Heimpold 
---
 target/linux/mxs/Makefile |  2 +-
 target/linux/mxs/{config-4.14 => config-4.19} | 42 +++
 ...0-crypto-mxsdcp-provide-importexport.patch | 51 ---
 3 files changed, 19 insertions(+), 76 deletions(-)
 rename target/linux/mxs/{config-4.14 => config-4.19} (89%)
 delete mode 100644 
target/linux/mxs/patches-4.14/110-crypto-mxsdcp-provide-importexport.patch

diff --git a/target/linux/mxs/Makefile b/target/linux/mxs/Makefile
index 39064ae1ae..96aba031d7 100644
--- a/target/linux/mxs/Makefile
+++ b/target/linux/mxs/Makefile
@@ -13,7 +13,7 @@ FEATURES:=ext4 rtc usb gpio
 CPU_TYPE:=arm926ej-s
 
 MAINTAINER:=Zoltan HERPAI 
-KERNEL_PATCHVER:=4.14
+KERNEL_PATCHVER:=4.19
 KERNELNAME:=zImage dtbs
 
 define Target/Description
diff --git a/target/linux/mxs/config-4.14 b/target/linux/mxs/config-4.19
similarity index 89%
rename from target/linux/mxs/config-4.14
rename to target/linux/mxs/config-4.19
index abad1807cd..4daf49f809 100644
--- a/target/linux/mxs/config-4.14
+++ b/target/linux/mxs/config-4.19
@@ -2,7 +2,11 @@ CONFIG_ALIGNMENT_TRAP=y
 CONFIG_ARCH_CLOCKSOURCE_DATA=y
 CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y
 CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
 CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+CONFIG_ARCH_HAS_KCOV=y
+CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y
+CONFIG_ARCH_HAS_PHYS_TO_DMA=y
 CONFIG_ARCH_HAS_SET_MEMORY=y
 CONFIG_ARCH_HAS_SG_CHAIN=y
 CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
@@ -19,9 +23,6 @@ CONFIG_ARCH_MULTI_V5=y
 CONFIG_ARCH_MXS=y
 CONFIG_ARCH_NR_GPIO=0
 CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y
-# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set
-# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
-# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
 CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
 CONFIG_ARCH_SUPPORTS_UPROBES=y
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
@@ -43,7 +44,7 @@ CONFIG_ARM_PATCH_PHYS_VIRT=y
 CONFIG_ARM_THUMB=y
 CONFIG_ATAGS=y
 CONFIG_AUTO_ZRELADDR=y
-# CONFIG_CACHE_L2X0 is not set
+CONFIG_CC_HAS_ASM_GOTO=y
 CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLKSRC_MMIO=y
 CONFIG_CLONE_BACKWARDS=y
@@ -84,7 +85,6 @@ CONFIG_CRYPTO_RNG2=y
 CONFIG_CRYPTO_WORKQUEUE=y
 CONFIG_DEBUG_ALIGN_RODATA=y
 CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
-# CONFIG_DEBUG_UART_8250 is not set
 # CONFIG_DEBUG_USER is not set
 CONFIG_DMADEVICES=y
 CONFIG_DMA_ENGINE=y
@@ -98,7 +98,9 @@ CONFIG_FEC=y
 CONFIG_FIXED_PHY=y
 CONFIG_FIX_EARLYCON_MEM=y
 CONFIG_FRAME_POINTER=y
+CONFIG_FS_IOMAP=y
 CONFIG_FS_MBCACHE=y
+CONFIG_GCC_VERSION=80300
 CONFIG_GENERIC_ALLOCATOR=y
 CONFIG_GENERIC_ATOMIC64=y
 CONFIG_GENERIC_BUG=y
@@ -106,8 +108,8 @@ CONFIG_GENERIC_CLOCKEVENTS=y
 CONFIG_GENERIC_CPU_AUTOPROBE=y
 CONFIG_GENERIC_EARLY_IOREMAP=y
 CONFIG_GENERIC_IDLE_POLL_SETUP=y
-CONFIG_GENERIC_IO=y
 CONFIG_GENERIC_IRQ_CHIP=y
+CONFIG_GENERIC_IRQ_MULTI_HANDLER=y
 CONFIG_GENERIC_IRQ_SHOW=y
 CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
 CONFIG_GENERIC_PCI_IOMAP=y
@@ -122,28 +124,23 @@ CONFIG_GPIO_GENERIC=y
 CONFIG_GPIO_GENERIC_PLATFORM=y
 CONFIG_GPIO_MXS=y
 CONFIG_GPIO_SYSFS=y
-# CONFIG_GRO_CELLS is not set
 CONFIG_HANDLE_DOMAIN_IRQ=y
 CONFIG_HARDIRQS_SW_RESEND=y
 CONFIG_HAS_DMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT_MAP=y
-# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
 CONFIG_HAVE_ARCH_AUDITSYSCALL=y
-# CONFIG_HAVE_ARCH_BITREVERSE is not set
 CONFIG_HAVE_ARCH_JUMP_LABEL=y
 CONFIG_HAVE_ARCH_KGDB=y
 CONFIG_HAVE_ARCH_PFN_VALID=y
 CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y
 CONFIG_HAVE_ARCH_TRACEHOOK=y
-# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
-CONFIG_HAVE_CC_STACKPROTECTOR=y
 CONFIG_HAVE_CLK=y
 CONFIG_HAVE_CLK_PREPARE=y
 CONFIG_HAVE_CONTEXT_TRACKING=y
 CONFIG_HAVE_C_RECORDMCOUNT=y
 CONFIG_HAVE_DEBUG_KMEMLEAK=y
-CONFIG_HAVE_DMA_API_DEBUG=y
 CONFIG_HAVE_DMA_CONTIGUOUS=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y
@@ -153,6 +150,7 @@ CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
 CONFIG_HAVE_FUNCTION_TRACER=y
 CONFIG_HAVE_GENERIC_DMA_COHERENT=y
 CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y
 CONFIG_HAVE_MEMBLOCK=y
 CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
 CONFIG_HAVE_NET_DSA=y
@@ -163,6 +161,7 @@ CONFIG_HAVE_PERF_REGS=y
 CONFIG_HAVE_PERF_USER_STACK_DUMP=y
 CONFIG_HAVE_PROC_CPU=y
 CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_RSEQ=y
 CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_HAVE_UID16=y
 CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
@@ -185,7 +184,6 @@ CONFIG_IIO_SYSFS_TRIGGER=y
 CONFIG_IIO_TRIGGER=y
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_INPUT=y
-CONFIG_IOMMU_HELPER=y
 CONFIG_IRQCHIP=y
 CONFIG_IRQ_DOMAIN=y
 CONFIG_IRQ_FORCED_THREADING=y
@@ -194,18 +192,21 @@ CONFIG_IRQ_WORK=y
 # CONFIG_ISDN is not set
 CONFIG_JBD2=y
 CONFIG_LIBFDT=y
+CONFIG_LOCK_DEBUGGING_SUPPORT=y
 CONFIG_MDIO_BUS=y
 CONFIG_MDIO_DEVICE=y
+CONFIG_MEMFD_CREATE=y
 CONFIG_MFD_CORE=y
 CONFIG_MFD_MXS_LRADC=y
 CONFIG_MIGHT_HAVE_PCI=y

[OpenWrt-Devel] [PATCH v2] build: unify SIGNATURE and make it reproducible

2019-11-04 Thread Paul Spooren
The SIGNATURE variable is a unique ID used as partition identifier for
x86, tegra and mvebu. This patch unifies the generation of SIGNATURE by
creating it once in include/image.mk instead differently for each
target.

Also make it reproducible by using SOURCE_DATE_EPOCH, resulting in equal
SIGNATURE valuess over multiple build with the same commit.

This is another step in the direction of reproducible OpenWrt images.

Signed-off-by: Paul Spooren 
---
I'm currently trying to step up my commit message game, please comment
if the message is unclear or confusing!

 include/image.mk  | 2 ++
 target/linux/mvebu/image/Makefile | 2 --
 target/linux/tegra/image/Makefile | 2 --
 target/linux/x86/image/Makefile   | 1 -
 4 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/image.mk b/include/image.mk
index 940ae812ea..4884ad9fe2 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -45,6 +45,8 @@ 
IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(IMG_PREFIX_VERNUM)$(IMG_PREFIX_VERCODE)$
 IMG_ROOTFS:=$(IMG_PREFIX)-rootfs
 IMG_COMBINED:=$(IMG_PREFIX)-combined
 
+SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))
+
 MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
 
 ifneq ($(CONFIG_BIG_ENDIAN),)
diff --git a/target/linux/mvebu/image/Makefile 
b/target/linux/mvebu/image/Makefile
index 967a1e4ee1..1c96a5e175 100644
--- a/target/linux/mvebu/image/Makefile
+++ b/target/linux/mvebu/image/Makefile
@@ -13,8 +13,6 @@ include $(INCLUDE_DIR)/image.mk
 
 KERNEL_LOADADDR := 0x8000
 
-SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))
-
 define Build/boot-scr
rm -f $@-boot.scr
sed \
diff --git a/target/linux/tegra/image/Makefile 
b/target/linux/tegra/image/Makefile
index 2ce8659995..39073a47d2 100644
--- a/target/linux/tegra/image/Makefile
+++ b/target/linux/tegra/image/Makefile
@@ -7,8 +7,6 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
 
-SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))
-
 define Build/tegra-sdcard
rm -fR $@.boot
mkdir -p $@.boot
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index ac70e771c8..73e468d38f 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -40,7 +40,6 @@ ifneq ($(GRUB_TERMINALS),)
   GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output 
$(GRUB_TERMINALS)
 endif
 
-SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0x))')
 ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
 ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(SIGNATURE)-02)
 
-- 
2.24.0.rc1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v3 2/2] base-files: rename hostname with EUI of mac address

2019-11-04 Thread Adrian Schmutzler
From: Rosy Song 

If a label MAC address is provided for device, system
will rename the hostname with OpenWrt_{eui mac address}.
This helps to distinguish between different devices.

Since it's no good idea to nest json_* functions, this code does
not use get_mac_label directly, but only get_mac_label_dt as
external resource.

Signed-off-by: Rosy Song 
[merged with commit introducing macaddr_geteui, rebased on updated
label MAC address storage, extended commit message]
Signed-off-by: Adrian Schmutzler 
---
 package/base-files/files/bin/config_generate | 16 +++-
 package/base-files/files/lib/functions/system.sh |  7 +++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/bin/config_generate 
b/package/base-files/files/bin/config_generate
index 3ca035ca8b..b473eba9e9 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -3,6 +3,7 @@
 CFG=/etc/board.json
 
 . /usr/share/libubox/jshn.sh
+. /lib/functions/system.sh
 
 [ -s $CFG ] || /bin/board_detect || exit 1
 [ -s /etc/config/network -a -s /etc/config/system ] && exit 0
@@ -253,9 +254,22 @@ generate_static_system() {
add_list system.ntp.server='3.openwrt.pool.ntp.org'
EOF
 
+   local label_macaddr=$(get_mac_label_dt)
+   local hostname
+
+   if json_is_a system object; then
+   json_select system
+   [ -n "$label_macaddr" ] || json_get_var label_macaddr 
label_macaddr
+   json_select ..
+   fi
+
+   if [ -n "$label_macaddr" ]; then
+   hostname="OpenWrt-$(macaddr_geteui $label_macaddr)"
+   uci -q set "system.@system[-1].hostname=$hostname"
+   fi
+
if json_is_a system object; then
json_select system
-   local hostname
if json_get_var hostname hostname; then
uci -q set 
"system.@system[-1].hostname=$hostname"
fi
diff --git a/package/base-files/files/lib/functions/system.sh 
b/package/base-files/files/lib/functions/system.sh
index be7efe4e2e..c4dc3cc3a9 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -144,6 +144,13 @@ macaddr_add() {
echo $oui:$nic
 }
 
+macaddr_geteui() {
+   local mac=$1
+   local sep=$2
+
+   echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2}
+}
+
 macaddr_setbit_la() {
local mac=$1
 
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v3 1/2] base-files: don't store label MAC address in uci system config

2019-11-04 Thread Adrian Schmutzler
If set, label MAC address is available from one of two sources,
device tree or board.json. So far, the function get_mac_label
was meant for retrieving the address, while an option in uci
system config was specified only for case 2 (board.json).

The uci config option has several drawbacks:
- it is only used for a fraction of devices (those not in DT)
- label MAC address is a device property, while config implies
  user interaction
- label_macaddr option will only be set if /etc/config/system
  does not exist (i.e. only for new installations)

Thus, this patch changes the behavior of get_mac_label:
Instead of writing the value in board.json to uci system config
and reading from this location afterwards, get_mac_label now
extracts data from board.json directly. The uci config option
won't be used anymore.
In addition, two utility functions for extraction only from DT
or from board.json are introduced.

Since this is only changing the access to the label MAC address, it
won't interfere with the addresses stored in the code base so far.

Signed-off-by: Adrian Schmutzler 

---

This is an ALTERNATE version for discussion in competition to the
v2 patchset. It has been tested on device already.
---
 package/base-files/files/bin/config_generate  |  5 ---
 .../base-files/files/lib/functions/system.sh  | 35 +--
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/package/base-files/files/bin/config_generate 
b/package/base-files/files/bin/config_generate
index 0b26afe57f..3ca035ca8b 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -260,11 +260,6 @@ generate_static_system() {
uci -q set 
"system.@system[-1].hostname=$hostname"
fi
 
-   local label_macaddr
-   if json_get_var label_macaddr label_macaddr; then
-   uci -q set 
"system.@system[-1].label_macaddr=$label_macaddr"
-   fi
-
if json_is_a ntpserver array; then
local keys key
json_get_keys keys ntpserver
diff --git a/package/base-files/files/lib/functions/system.sh 
b/package/base-files/files/lib/functions/system.sh
index cb0508fe9c..be7efe4e2e 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -1,5 +1,7 @@
 # Copyright (C) 2006-2013 OpenWrt.org
 
+. /usr/share/libubox/jshn.sh
+
 get_mac_binary() {
local path="$1"
local offset="$2"
@@ -12,14 +14,41 @@ get_mac_binary() {
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
 }
 
-get_mac_label() {
+get_mac_label_dt() {
local basepath="/proc/device-tree"
local macdevice="$(cat "$basepath/aliases/label-mac-device" 
2>/dev/null)"
local macaddr
 
-   [ -n "$macdevice" ] && macaddr=$(get_mac_binary 
"$basepath/$macdevice/mac-address" 0 2>/dev/null)
+   [ -n "$macdevice" ] || return
+
+   macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 
2>/dev/null)
[ -n "$macaddr" ] || macaddr=$(get_mac_binary 
"$basepath/$macdevice/local-mac-address" 0 2>/dev/null)
-   [ -n "$macaddr" ] || macaddr=$(uci -q get 
system.@system[0].label_macaddr)
+
+   echo $macaddr
+}
+
+get_mac_label_json() {
+   local cfg="/etc/board.json"
+   local macaddr
+
+   [ -s "$cfg" ] || return
+
+   json_init
+   json_load "$(cat $cfg)"
+   if json_is_a system object; then
+   json_select system
+   json_get_var macaddr label_macaddr
+   json_select ..
+   fi
+
+   echo $macaddr
+}
+
+get_mac_label() {
+   local macaddr=$(get_mac_label_dt)
+
+   [ -n "$macaddr" ] || macaddr=$(get_mac_label_json)
+
echo $macaddr
 }
 
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ath79: add D-Link DIR-615 rev. E4

2019-11-04 Thread Paul Fertser
On Mon, Nov 04, 2019 at 05:16:15PM +0100, Adrian Schmutzler wrote:
> > +   power_green: power_green {
> > +   label = "d-link:green:power";
> 
> It's policy to use boardname instead of "d-link" here, except for tplink as 
> far as I know.

But in this case there're three other boards that can be supported by
almost the same code (they lack "wlan" led but they also get a bigger
firmware partition becase they have no "lp" partition). I am not sure
how to properly add support for all of them, especially given I have
no way to test on real hardware (except for the E4). 

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercer...@gmail.com

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH uci 2/2] build: Add -Wclobbered to detect problems with longjmp

2019-11-04 Thread Hauke Mehrtens
On 11/4/19 4:29 AM, Yousong Zhou wrote:
> Hi Hauke
> 
> On Sat, 2 Nov 2019 at 00:07, Hauke Mehrtens  wrote:
>>
>> When we jump back to a save point in UCI_THROW() with longjmp all the
>> registers will be reset to the old values when we called UCI_TRAP_SAVE()
>> last time, but the memory is not restored. This will revert all the
>> variables which are stored in registers, but not the variables stored on
>> the stack.
>>
>> Mark all the variables which the compiler could put into a register as
>> volatile to store them safely on the stack and make sure they have the
>> defined current values also after longjmp was called.
>>
>> This also activates a compiler warning which should warn us in such
>> cases.
>> This could fix some potential problem in error paths like the one
>> reported in CVE-2019-15513.
>>
>> Signed-off-by: Hauke Mehrtens 
> 
> Not sure I understand the internals right.  It seems to me a few
> changes below may not be necessary.  The -Wclobber check can produce
> false-positives right?  Are these changes made mainly for "better safe
> than regret"?

Hi Yousong,

Yes, some of the volatiles are not necessary, but I activated the
warning -Wclobbered and GCC is not so intelligent and warns for all
variables which are written after setjmp() is called.
When we activate the warning everyone gets this warning and no one will
introduce such a problem again, but we probably have volatile also in
some places where it is not needed.

I want to handle this part of the setjmp() manpage:

The  compiler  may  optimize  variables into registers, and longjmp()
may restore the values of other registers in addition to the stack
pointer and program counter.  Consequently, the values of automatic
variables are unspecified after a call to longjmp() if they meet all the
following criteria:
* they are local to the function that made the corresponding setjmp()
  call;
* their values are changed between the calls to setjmp() and longjmp();
  and
* they are not declared as volatile.


The GCC documentation says this:

-Wclobbered
Warn for variables that might be changed by longjmp or vfork. This
warning is also enabled by -Wextra.


Hauke



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] New ath10k-ct firmware available

2019-11-04 Thread Ben Greear

Please see new file names and checksums below:

988x
3b2c584f7070c3e286ce27a370cc181d70b45f9cdaa462fb4f44c6c20d2ee8c1  
firmware-2-ct-full-community-22.bin.lede.012
a7042b2c90de82b21e87f243411b6fb12142bb4fb28266ea92cdf3101557b6de  
firmware-2-ct-full-htt-mgt-community-22.bin.lede.012
/home/greearb/candela_html/downloads
9887
c3f891b2cd4e225e1c635a328af3dce94481b096432020e445f71144dda749d5  
firmware-2-ct-full-community-22.bin.lede.012
f5e9825279d590a2362f44aef4ced345376cccd65d9b826c131d4dbcef4e689c  
firmware-2-ct-full-htt-mgt-community-22.bin.lede.012
/home/greearb/candela_html/downloads
9980
4b90fa91dcab68350fe695b3c918cb9a4fb09c2b419519b8b84b71da4cfde5e8  
firmware-5-ct-full-community-12.bin-lede.012
6dd40233fe99d99c69781d6514cf9ba7862b3f66c647f7921ca8be6100799986  
firmware-5-ct-full-htt-mgt-community-12.bin-lede.012
/home/greearb/candela_html/downloads
9984
2551f5c0bfa6c1b1222bd9452e14f60b8e29c8c0fe85de8af95393f31d544ea3  
firmware-5-ct-full-community-12.bin-lede.012
90f947257e1f42496b22cbdd29be99fbc8ea8700045b4ed2380acc980b4c247b  
firmware-5-ct-full-htt-mgt-community-12.bin-lede.012
/home/greearb/candela_html/downloads
4019
cd85fc9df8b3652f7b12c2ab745b2a9691dca5ca38f8d65a02003e938ad8b570  
firmware-5-ct-full-community-12.bin-lede.012
67a923cda6ec3936ef23ec6c30c80dfc9bfd2cee73a142d2e308e8f035b8ed3a  
firmware-5-ct-full-htt-mgt-community-12.bin-lede.012
/home/greearb/candela_html/downloads
9888
4bdb71b50c68f1a07c88d21f84a6c054fe1b8cb5bacd089a6b9f0a56448535d3  
firmware-5-ct-full-community-12.bin-lede.012
e1f0242a91af58ec5628bb4f7c015f6c8dba55f92e2813f8f0b97c86ec496d2d  
firmware-5-ct-full-htt-mgt-community-12.bin-lede.012
/home/greearb/candela_html/downloads


The release notes since last time for wave-1:

  *  October 5, 2019: Fix too-short msg caused by invalid use of PayloadLen in 
receive path.
  This appears to resolve the issue of getting (and 
ignoring) too-short commands
  when we detect loss of CE interrupts and go into polling 
mode.

  *  October 12, 2019:  Fix regression in IBSS mode that caused SWBA overrun 
issues.  Related to
regression added during the ct-station logic, 
specifically TSF allocation.
Thanks for Ahmed Zaki @ Mage-Networks for helping to 
diagnose and test.

  *  October 15, 2019:  Only send beacon tx completion events if we can detect 
CT driver is being
used (based on CT_STATS_OK flag being set).  This 
should help CT firmware work
better on stock driver.



The release notes since last time for wave-2:

  *  October 15, 2019:  Only send beacon tx completion events if we can detect 
CT driver is being
used (based on ATH10k_USE_TXCOMPL_TXRATE2 | 
ATH10k_USE_TXCOMPL_TXRATE1 flags being set).
This should help CT firmware work better on stock 
driver.

  *  October 31, 2019:  Compile out peer-ratecode-list-event.  ath10k driver 
ignores the event.

  *  November 1, 2019:  Fix rate-ctrl related crash when nss and other things 
were changed while
station stays associated.  See bug: 
https://github.com/greearb/ath10k-ct/issues/96

Thanks,
Ben

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v4] ramips: add support for JS76x8 series DEV boards

2019-11-04 Thread Adrian Schmutzler
Hi,

there has been a split of the board.d files in ramips target towards the 
subtargets, so you would have to rebase onto that. (Put your definitions into 
mt76x8/base-files/etc/board.d/0x... instead of base-files/etc/board.d/0x...).

Despite, two additional comments below.

> diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts
> b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts
> new file mode 100644
> index 000..7123e63
> --- /dev/null
> +++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8-16m.dts
> @@ -0,0 +1,60 @@
> +/dts-v1/;
> +
> +#include "mt7628an_zhuotk_js76x8.dtsi"
> +
> +/ {
> + compatible = "zhuotk,js76x8-16m", "zhuotk,js76x8",
> "mediatek,mt7628an-soc";
> + model = "ZhuoTK JS76x8 (16M)";
> +};
> +
> + {
> + status = "okay";

The only difference between your DTS files here is the size of the firmware 
partition. Thus, you should move the entire spi0 node to the DTSI. There you 
would add a label to the partition@5 node:

firmware: partition@5 {

Then, remove the reg entry for the firmware partition in the DTSI and just put 
that one in the DTS files. With that change, DTS file would only contain 
compatible/model and firmware partition size:

 {
reg = <0x5 0x7b>;
};

Obviously, just use the correct size for the according DTS files. 

[...]
> +
> + gpio-leds {

This should be named "leds".

Best

Adrian 


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ath79: add D-Link DIR-615 rev. E4

2019-11-04 Thread Paul Fertser
Hello,

Thank you for the review indeed!

On Mon, Nov 04, 2019 at 05:16:15PM +0100, Adrian Schmutzler wrote:
> > +   power_green: power_green {
> > +   label = "d-link:green:power";
> 
> It's policy to use boardname instead of "d-link" here, except for tplink as 
> far as I know.

My bad, I was using tp-link 741 code for inspiration.

> > +   firmware: partition@4 {
> > +   compatible = "denx,uimage";
> > +   reg = <0x4 0x37>;
> 
> 3520k? Does this even build with standard buildbot settings?

I did not know I need to check with standard buildbot settings, I
haven't noticed anything like that in the patch guide.

That said, I find these settings meaningful for a home AP+router:

CONFIG_TARGET_ath79=y
CONFIG_TARGET_ath79_tiny=y
CONFIG_TARGET_ath79_tiny_DEVICE_dlink_dir-615-e4=y
CONFIG_PACKAGE_6in4=y
# CONFIG_PACKAGE_iwinfo is not set
CONFIG_PACKAGE_kmod-iptunnel=y
CONFIG_PACKAGE_kmod-iptunnel4=y
# CONFIG_PACKAGE_kmod-ppp is not set
CONFIG_PACKAGE_kmod-sit=y
# CONFIG_PACKAGE_libiwinfo is not set
# CONFIG_PACKAGE_openwrt-keyring is not set
# CONFIG_PACKAGE_ppp is not set
# CONFIG_PACKAGE_uboot-envtools is not set
# CONFIG_PACKAGE_usign is not set
# CONFIG_SIGNATURE_CHECK is not set
# CONFIG_SIGNED_PACKAGES is not set

With that I have 6 eraseblocks left for the rootfs_data partition (5
is the absolute minimum jffs2 allows).
 
> Be aware that you might not find someone willing to merge this.

I do not think this device is any worse than the other 4M devices
supported by ath79. Moreover, it can easily (two usb pulldown
resistors and two series) be modded to add a USB port (much easier
than TL-WR741ND).

Regarding the firmware partition size, it can be made 4 eraseblocks
more if the next two useless partitions are merged into it.

> > +   mac: partition@3b {
> > +   reg = <0x3b 0x1>;
> > +   label = "mac";
> 
> Why is there a partition labelled mac that is not used for MAC
> addresses? Have you checked the partition for MAC addresses?

I have, and it certainly doesn't have the address printed on device
label. I would guess the partition is a rudiment of Cameo99 reference
design or something like that, and D-Link in their wisdom decided to
store MACs elsewhere.

> > +   lp: partition@3c {
> > +   reg = <0x3c 0x3>;
> > +   label = "lp";
> > +   read-only;
> > +   };

This I have no idea what can be used for. hexdumping it reveals some
filenames and "whiteout" strings which might hint at using it as some
kind of a writeable overlay. I can't be sure I still have the factory
data in it though, but I do not remember specifically overwriting or
anyhow abusing it either, probably it was done before me.

Anyway, I do not see any good reason to care much about running
factory (old, buggy and flawed) vendor firmware on this ancient device
(it came with an old-school 50Hz transformer PSU, you can imagine how
old it is!)

> > case "$board" in
> > +   dlink,dir-615-e4)
> > +   lan_mac=$(mtd_get_mac_ascii "nvram" "lan_mac")
> > +   wan_mac=$(mtd_get_mac_ascii "nvram" "wan_mac")
> > +   ;;
> 
> I didn't find a reference to "wan_mac" in nvram in ar71xx. Did you deduce 
> that by yourself?

Yes, that's where I deviate from code in ar71xx. I grepped strings in
nvram partition and noticed lan_mac and wan_mac, both made perfect
sense. Regarding wlan mac in vendor firmware, I do not think I've ever
seen vendor firmware running on this board so I can't tell. Guess
whoever added support for it (and the other 3 almost identical boards)
in ar71xx have checked all the options.

All your other points noted, thanks a lot!

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercer...@gmail.com

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ath79: add D-Link DIR-615 rev. E4

2019-11-04 Thread Adrian Schmutzler
Hi,

> > +   dlink,dir-615-e4)
> > +   caldata_extract "art" 0x1000 0x1000
> > +   ath9k_patch_mac_crc $(mtd_get_mac_ascii "nvram" "lan_mac")
> 0x10c
> 
> lan mac seems to be used for wlan as is (without +1/-1) by ar71xx
> code.

That's not uncommon, however you'll only know for sure if you check with vendor 
firmware.

Best

Adrian 


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ath79: add D-Link DIR-615 rev. E4

2019-11-04 Thread Adrian Schmutzler
Hi,

> diff --git a/target/linux/ath79/dts/ar7240_dlink_dir-600-a1.dtsi
> b/target/linux/ath79/dts/ar7240_dlink_dir-600-a1.dtsi
> new file mode 100644
> index 00..e6206f6f42
> --- /dev/null
> +++ b/target/linux/ath79/dts/ar7240_dlink_dir-600-a1.dtsi
> @@ -0,0 +1,173 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
> +
> +#include 
> +#include 
> +
> +#include "ar7240.dtsi"
> +
> +/ {
> + aliases {
> + led-boot = _amber;
> + led-failsafe = _amber;
> + led-running = _green;
> + led-upgrade = _amber;
> + label-mac-device = 

This only works when the address is set in DT, but you use 02_network.

> + };
> +
> + keys {
> + compatible = "gpio-keys";
> +
> + reset {
> + label = "reset";
> + linux,code = ;
> + gpios = < 8 GPIO_ACTIVE_LOW>;
> + debounce-interval = <60>;
> + };
> +
> + wps {
> + label = "wps";
> + linux,code = ;
> + gpios = < 12 GPIO_ACTIVE_LOW>;
> + debounce-interval = <60>;
> + };
> + };
> +
> + gpio-leds {

Use "leds".

> + compatible = "gpio-leds";
> + pinctrl-names = "default";
> + pinctrl-0 = <_led_pins>;
> +
> + power_green: power_green {
> + label = "d-link:green:power";

It's policy to use boardname instead of "d-link" here, except for tplink as far 
as I know.

> + gpios = < 6 GPIO_ACTIVE_HIGH>;
> + };
> +
> + power_amber: power_amber {
> + label = "d-link:amber:power";
> + gpios = < 1 GPIO_ACTIVE_HIGH>;
> + };
> +
> + wps {
> + label = "d-link:blue:wps";
> + gpios = < 0 GPIO_ACTIVE_LOW>;
> + };
> +
> + lan1 {
> + label = "d-link:green:lan1";
> + gpios = < 13 GPIO_ACTIVE_LOW>;
> + };
> +
> + lan2 {
> + label = "d-link:green:lan2";
> + gpios = < 14 GPIO_ACTIVE_LOW>;
> + };
> +
> + lan3 {
> + label = "d-link:green:lan3";
> + gpios = < 15 GPIO_ACTIVE_LOW>;
> + };
> +
> + lan4 {
> + label = "d-link:green:lan4";
> + gpios = < 16 GPIO_ACTIVE_LOW>;
> + };
> +
> + wan_amber {
> + label = "d-link:amber:wan";
> + gpios = < 7 GPIO_ACTIVE_HIGH>;
> + };
> +
> + wan_green {
> + label = "d-link:green:wan";
> + gpios = < 17 GPIO_ACTIVE_LOW>;
> + };
> + };
> +};
> +
> + {
> + status = "okay";
> + num-cs = <1>;
> +
> + flash@0 {
> + compatible = "jedec,spi-nor";
> + reg = <0>;
> + spi-max-frequency = <2500>;
> +
> + partitions {
> + compatible = "fixed-partitions";
> + #address-cells = <1>;
> + #size-cells = <1>;
> +
> + uboot: partition@0 {
> + reg = <0x0 0x3>;
> + label = "u-boot";
> + read-only;
> + };
> +
> + nvram: partition@3 {
> + reg = <0x3 0x1>;
> + label = "nvram";
> + read-only;
> + };
> +
> + firmware: partition@4 {
> + compatible = "denx,uimage";
> + reg = <0x4 0x37>;

3520k? Does this even build with standard buildbot settings?
Be aware that you might not find someone willing to merge this.

> + label = "firmware";
> + };
> +
> + mac: partition@3b {
> + reg = <0x3b 0x1>;
> + label = "mac";

Why is there a partition labelled mac that is not used for MAC addresses? Have 
you checked the partition for MAC addresses?

> + read-only;
> + };
> +
> + lp: partition@3c {
> + reg = <0x3c 0x3>;
> + label = "lp";
> + read-only;
> + };
> +
> + art: partition@3f {
> + reg = <0x3f 0x1>;
> + label = "art";
> + read-only;
> + };
> + };
> + };
> +};
> +
> + {
> +

Re: [OpenWrt-Devel] [PATCH v2 1/2] base-files: always store label MAC address in uci system config

2019-11-04 Thread Kristian Evensen
Hi,

On Mon, Nov 4, 2019 at 4:36 PM Adrian Schmutzler
 wrote:
> However, I'm not aware of a case where board.json is used for anything else 
> than setting up config files, like in a script with user-interaction etc.

While I agree that those are the most common use-cases for board.json,
board.json is used by for example luci to determine which parts of
network configuration to display.

> So, if I want to bring the label MAC address to users updating to 
> 20.xx/master, I'd either have to use board.json in get_mac_label, or add 
> label_macaddr for those not having it even though /etc/config/system already 
> exists. One could still think about providing a label_macaddr option in uci 
> only for _overwriting_ the provided value.

I am not overly familiar with them, but I think this problem can be
resolved by a uci-defaults script. As far as I have understood, those
scripts are run once and then remove. You could create a script that
checks board.json/device tree (basically a combination of the changes
in your patch) and update system-config accordingly.

BR,
Kristian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v2 1/2] base-files: always store label MAC address in uci system config

2019-11-04 Thread Adrian Schmutzler
Hi,

> -Original Message-
> From: Kristian Evensen [mailto:kristian.even...@gmail.com]
> Sent: Montag, 4. November 2019 14:57
> To: Adrian Schmutzler 
> Cc: OpenWrt Development List 
> Subject: Re: [OpenWrt-Devel] [PATCH v2 1/2] base-files: always store label MAC
> address in uci system config
> 
> Hi Adrian,
> 
> On Mon, Nov 4, 2019 at 11:44 AM Adrian Schmutzler
>  wrote:
> >
> > If set, label MAC address is available from one of two sources,
> > device tree or board.json. So far, the function get_mac_label
> > was meant for retrieving the address, while an option in uci
> > system config was specified only for case 2 (board.json).
> >
> > Since this has been perceived as counter-intuitive, this patch
> > changes front-end access to the label MAC address:
> > During first-boot, the label MAC address will be written to uci
> > system config file for both cases, no matter whether is was
> > specified in DT or in board.json (via 02_network). A user of
> > the label MAC address will then read the value from
> > system.@system[0].label_macaddr, which is easier and more intuitive
> > than using a function and still have an uci value set.
> >
> > Since this is only changing the access to the label MAC address, it
> > won't interfere with the addresses stored in the code base so far.
> >
> > Signed-off-by: Adrian Schmutzler 
> 
> I am not an authority on anything, but I don't think a "runtime" value
> like the label mac should be stored in a persistent configuration
> file. For example, if someone makes a mistake with the label MAC, you
> would need a uci-default script for fixing up the config. You also
> have the issue of devices that have already been installed, without a
> uci-defaults script they will not have a label mac in UCI.
> 
> Instead, I would keep board.json as the source for label MAC and have
> get_mac_label parse the JSON-file. I guess you might also have to
> patch the generation of board.json to include the device tree. At
> least I think that board.json is as easy to work with as uci from
> scripts, Luci, etc.

I also thought about that.

However, I'm not aware of a case where board.json is used for anything else 
than setting up config files, like in a script with user-interaction etc.
So, I hesitate to start with that (as it might also be counter-intuitive for 
some people).

Concerning address fixes: There might also be users that don't want the address 
to change if it has been wrong for some time and they have implemented that 
particular address into their system. This might be more relevant for 
downstream projects than for use cases directly in OpenWrt, but this is 
actually a somewhat separate aspect. Despite, having the uci option will allow 
users to change the address (if it's wrong or for other reasons) or provide it 
when upstream support is not there (yet). Just having a function reading from 
DT/board.json would be much less user-friendly there.
However, I do admit that my arguments here are practical, while you are right 
that strictly the label MAC address is a device parameter that should not be 
altered by the user.

> You also
> have the issue of devices that have already been installed, without a
> uci-defaults script they will not have a label mac in UCI.

That's a valid argument I haven't thought about before, and it 
eliminates/weakens most of my arguments from the previous paragraph.

So, if I want to bring the label MAC address to users updating to 20.xx/master, 
I'd either have to use board.json in get_mac_label, or add label_macaddr for 
those not having it even though /etc/config/system already exists. One could 
still think about providing a label_macaddr option in uci only for 
_overwriting_ the provided value.

I see, I will have to think about that (again) for some time ...

Thanks for the input

Adrian


> 
> BR,
> Kristian


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v3 2/2] ramips: Add support for ZBT WE1026-H

2019-11-04 Thread Kristian Evensen
Hi,

On Sun, Nov 3, 2019 at 3:14 PM  wrote:
> Okay, if it's not visible I do not think it's worth to deviate from normal 
> procedure here.
>
> I've remove the power_led label and aliases.
>
> Feel free to test and provide an updated solution for the use as USB LED.
>
> Despite, note that the first word after "ramips:" should be lower-case in 
> commit title for future submissions.

Thanks a lot for you help and feedback. When I have some time, I will
take look and see if I can come up with a solution for USB LED.

Kristian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v2 1/2] base-files: always store label MAC address in uci system config

2019-11-04 Thread Kristian Evensen
Hi Adrian,

On Mon, Nov 4, 2019 at 11:44 AM Adrian Schmutzler
 wrote:
>
> If set, label MAC address is available from one of two sources,
> device tree or board.json. So far, the function get_mac_label
> was meant for retrieving the address, while an option in uci
> system config was specified only for case 2 (board.json).
>
> Since this has been perceived as counter-intuitive, this patch
> changes front-end access to the label MAC address:
> During first-boot, the label MAC address will be written to uci
> system config file for both cases, no matter whether is was
> specified in DT or in board.json (via 02_network). A user of
> the label MAC address will then read the value from
> system.@system[0].label_macaddr, which is easier and more intuitive
> than using a function and still have an uci value set.
>
> Since this is only changing the access to the label MAC address, it
> won't interfere with the addresses stored in the code base so far.
>
> Signed-off-by: Adrian Schmutzler 

I am not an authority on anything, but I don't think a "runtime" value
like the label mac should be stored in a persistent configuration
file. For example, if someone makes a mistake with the label MAC, you
would need a uci-default script for fixing up the config. You also
have the issue of devices that have already been installed, without a
uci-defaults script they will not have a label mac in UCI.

Instead, I would keep board.json as the source for label MAC and have
get_mac_label parse the JSON-file. I guess you might also have to
patch the generation of board.json to include the device tree. At
least I think that board.json is as easy to work with as uci from
scripts, Luci, etc.

BR,
Kristian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ipset: update to 7.4

2019-11-04 Thread DENG Qingfang
Signed-off-by: DENG Qingfang 
---
 package/network/utils/ipset/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/network/utils/ipset/Makefile 
b/package/network/utils/ipset/Makefile
index 2cb6ec981e..0bab21a12f 100644
--- a/package/network/utils/ipset/Makefile
+++ b/package/network/utils/ipset/Makefile
@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=ipset
-PKG_VERSION:=7.3
+PKG_VERSION:=7.4
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://ipset.netfilter.org
-PKG_HASH:=4644c7c5005e90a9b6385d625283eb0b69b34de7192301428665dd909fdaa35a
+PKG_HASH:=4a974176e57fe4b7e2984abb231c4a18af2291bdc41536ef64e4b8ec4d4a1884
 
 PKG_MAINTAINER:=Jo-Philipp Wich 
 PKG_LICENSE:=GPL-2.0
-- 
2.23.0




___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] x86: generate reproducible UUID

2019-11-04 Thread Petr Štetiar
On November 4, 2019 4:02:07 AM UTC, Yousong Zhou  wrote:
>On Mon, 4 Nov 2019 at 07:47, Paul Spooren  wrote:
>>
>> -SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0x))')
>> +SIGNATURE:=$(shell echo "$(SOURCE_DATE_EPOCH)" | sha256sum | cut -c
>1-8 -z)
>
>Maybe just unify with other targets should be enough.

Or even better, provide reusable variable in some included makefile and use 
that instead?

>target/linux/tegra/image/Makefile
>10:SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))
>
>target/linux/x86/image/Makefile
>43:SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0x))')
>
>target/linux/mvebu/image/Makefile
>16:SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))




___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 2/2] base-files: rename hostname with EUI of mac address

2019-11-04 Thread Adrian Schmutzler
From: Rosy Song 

If a label MAC address is provided for device, system
will rename the hostname with OpenWrt_{eui mac address}.
This helps to distinguish between different devices.

Signed-off-by: Rosy Song 
[merged with commit introducing macaddr_geteui, rebased on updated
label MAC address storage]
Signed-off-by: Adrian Schmutzler 
---
 package/base-files/files/bin/config_generate | 4 +++-
 package/base-files/files/lib/functions/system.sh | 7 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/bin/config_generate 
b/package/base-files/files/bin/config_generate
index bb6117e6dc..2c33bca09a 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -255,6 +255,7 @@ generate_static_system() {
EOF
 
local label_macaddr=$(get_mac_label_dt)
+   local hostname
 
if json_is_a system object; then
json_select system
@@ -264,11 +265,12 @@ generate_static_system() {
 
if [ -n "$label_macaddr" ]; then
uci -q set "system.@system[-1].label_macaddr=$label_macaddr"
+   hostname="OpenWrt-$(macaddr_geteui $label_macaddr)"
+   uci -q set "system.@system[-1].hostname=$hostname"
fi
 
if json_is_a system object; then
json_select system
-   local hostname
if json_get_var hostname hostname; then
uci -q set 
"system.@system[-1].hostname=$hostname"
fi
diff --git a/package/base-files/files/lib/functions/system.sh 
b/package/base-files/files/lib/functions/system.sh
index 5b4ced836c..f2b8f2395c 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -115,6 +115,13 @@ macaddr_add() {
echo $oui:$nic
 }
 
+macaddr_geteui() {
+   local mac=$1
+   local sep=$2
+
+   echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2}
+}
+
 macaddr_setbit_la() {
local mac=$1
 
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 1/2] base-files: always store label MAC address in uci system config

2019-11-04 Thread Adrian Schmutzler
If set, label MAC address is available from one of two sources,
device tree or board.json. So far, the function get_mac_label
was meant for retrieving the address, while an option in uci
system config was specified only for case 2 (board.json).

Since this has been perceived as counter-intuitive, this patch
changes front-end access to the label MAC address:
During first-boot, the label MAC address will be written to uci
system config file for both cases, no matter whether is was
specified in DT or in board.json (via 02_network). A user of
the label MAC address will then read the value from
system.@system[0].label_macaddr, which is easier and more intuitive
than using a function and still have an uci value set.

Since this is only changing the access to the label MAC address, it
won't interfere with the addresses stored in the code base so far.

Signed-off-by: Adrian Schmutzler 

---

This has been tested with DT address, 02_network address, and
without address.

---
 package/base-files/files/bin/config_generate   | 18 +-
 .../base-files/files/lib/functions/system.sh   |  6 +++---
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/package/base-files/files/bin/config_generate 
b/package/base-files/files/bin/config_generate
index 0b26afe57f..bb6117e6dc 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -3,6 +3,7 @@
 CFG=/etc/board.json
 
 . /usr/share/libubox/jshn.sh
+. /lib/functions/system.sh
 
 [ -s $CFG ] || /bin/board_detect || exit 1
 [ -s /etc/config/network -a -s /etc/config/system ] && exit 0
@@ -253,6 +254,18 @@ generate_static_system() {
add_list system.ntp.server='3.openwrt.pool.ntp.org'
EOF
 
+   local label_macaddr=$(get_mac_label_dt)
+
+   if json_is_a system object; then
+   json_select system
+   [ -n "$label_macaddr" ] || json_get_var label_macaddr 
label_macaddr
+   json_select ..
+   fi
+
+   if [ -n "$label_macaddr" ]; then
+   uci -q set "system.@system[-1].label_macaddr=$label_macaddr"
+   fi
+
if json_is_a system object; then
json_select system
local hostname
@@ -260,11 +273,6 @@ generate_static_system() {
uci -q set 
"system.@system[-1].hostname=$hostname"
fi
 
-   local label_macaddr
-   if json_get_var label_macaddr label_macaddr; then
-   uci -q set 
"system.@system[-1].label_macaddr=$label_macaddr"
-   fi
-
if json_is_a ntpserver array; then
local keys key
json_get_keys keys ntpserver
diff --git a/package/base-files/files/lib/functions/system.sh 
b/package/base-files/files/lib/functions/system.sh
index cb0508fe9c..5b4ced836c 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -12,14 +12,14 @@ get_mac_binary() {
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
 }
 
-get_mac_label() {
+get_mac_label_dt() {
local basepath="/proc/device-tree"
local macdevice="$(cat "$basepath/aliases/label-mac-device" 
2>/dev/null)"
local macaddr
 
-   [ -n "$macdevice" ] && macaddr=$(get_mac_binary 
"$basepath/$macdevice/mac-address" 0 2>/dev/null)
+   [ -n "$macdevice" ] || return
+   macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 
2>/dev/null)
[ -n "$macaddr" ] || macaddr=$(get_mac_binary 
"$basepath/$macdevice/local-mac-address" 0 2>/dev/null)
-   [ -n "$macaddr" ] || macaddr=$(uci -q get 
system.@system[0].label_macaddr)
echo $macaddr
 }
 
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] busybox: support output new-linux model for arp

2019-11-04 Thread daxiong
Compatible with the output of net-tools.
Using new-linux model by default.

arp -n:
  Address  HWtype  HWaddress   Flags Mask
Iface
  192.168.1.1  ether   00:11:22:33:44:55   C 
eth1

arp -an:
  ? (192.168.1.1) at 00:11:22:33:44:55 [ether]  on eth1

Signed-off-by: daxiong 
---
 .../patches/540-arpshow-support-new-linux.patch| 94 ++
 1 file changed, 94 insertions(+)
 create mode 100644 
package/utils/busybox/patches/540-arpshow-support-new-linux.patch

diff --git a/package/utils/busybox/patches/540-arpshow-support-new-linux.patch 
b/package/utils/busybox/patches/540-arpshow-support-new-linux.patch
new file mode 100644
index 000..1bb6629
--- /dev/null
+++ b/package/utils/busybox/patches/540-arpshow-support-new-linux.patch
@@ -0,0 +1,94 @@
+--- a/networking/arp.c 2019-11-04 15:42:52.171010629 +0800
 b/networking/arp.c 2019-11-04 16:39:46.455539779 +0800
+@@ -353,6 +353,56 @@ static int arp_set(char **args)
+ 
+ 
+ /* Print the contents of an ARP request block. */
++static void arp_disp_2(char *name, int type, int arp_flags, char *hwa, char 
*mask, char *dev)
++{
++static int title = 0;
++const struct hwtype *xhw;
++char flags[10];
++
++xhw = get_hwntype(type);
++if (xhw == NULL)
++  xhw = get_hwtype(DFLT_HW);
++
++if (title++ == 0) {
++  printf("Address  HWtype  HWaddress   Flags Mask 
   Iface\n");
++}
++/* Setup the flags. */
++flags[0] = '\0';
++if (arp_flags & ATF_COM)
++  strcat(flags, "C");
++if (arp_flags & ATF_PERM)
++  strcat(flags, "M");
++if (arp_flags & ATF_PUBL)
++  strcat(flags, "P");
++#ifdef HAVE_ATF_MAGIC
++if (arp_flags & ATF_MAGIC)
++  strcat(flags, "A");
++#endif
++#ifdef HAVE_ATF_DONTPUB
++if (arp_flags & ATF_DONTPUB)
++  strcat(flags, "!");
++#endif
++if (arp_flags & ATF_USETRAILERS)
++  strcat(flags, "T");
++
++if (!(arp_flags & ATF_NETMASK))
++  mask = (char *)"";
++
++printf("%-23.23s  ", name);
++
++if (!(arp_flags & ATF_COM)) {
++  if (arp_flags & ATF_PUBL)
++  printf("%-8.8s%-20.20s", "*", "*");
++  else
++  printf("%-8.8s%-20.20s", "", "(incomplete)");
++} else {
++  printf("%-8.8s%-20.20s", xhw->name, hwa);
++}
++
++printf("%-6.6s%-15.15s %s\n", flags, mask, dev);
++}
++
++/* Print the contents of an ARP request block. */
+ static void
+ arp_disp(const char *name, char *ip, int type, int arp_flags,
+   char *hwa, char *mask, char *dev)
+@@ -457,18 +507,25 @@ static int arp_show(char *name)
+ 
+   shown++;
+   /* This IS ugly but it works -be */
+-  hostname = "?";
+-  if (!(option_mask32 & ARP_OPT_n)) {
+-  if (ap->input(ip, ) < 0)
+-  hostname = ip;
+-  else
+-  hostname = ap->sprint(, (option_mask32 & 
ARP_OPT_n) | 0x8000);
+-  if (strcmp(hostname, ip) == 0)
+-  hostname = "?";
++  if (option_mask32 & ARP_OPT_n) {
++  hostname = "?";
++  } else {
++  if (!(option_mask32 & ARP_OPT_n)) {
++  if (ap->input(ip, ) < 0)
++  hostname = ip;
++  else
++  hostname = ap->sprint(, 
(option_mask32 & ARP_OPT_n) | 0x8000);
++  if (strcmp(hostname, ip) == 0)
++  hostname = "?";
++  }
+   }
+ 
+-  arp_disp(hostname, ip, type, flags, hwa, mask, dev);
++  if (option_mask32 & ARP_OPT_a)
++  arp_disp(hostname, ip, type, flags, hwa, mask, dev);
++  else
++  arp_disp_2((char *)(hostname[0] == '?' ? ip : 
hostname), type, flags, hwa, mask, dev);
+   }
++
+   if (option_mask32 & ARP_OPT_v)
+   printf("Entries: %u\tSkipped: %u\tFound: %u\n",
+   entries, entries - shown, shown);
-- 
1.9.1





___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel