Re: [OpenWrt-Devel] [PATCH 0/4] add μrngd: true RNG based on timing jitter

2019-05-27 Thread Rosen Penev
On Mon, May 27, 2019 at 2:30 PM Petr Štetiar  wrote:
>
> Hi,
>
> this patch series fixes some of the current urandom-seed flaws and improves
> situation with low entropy in the kernel during the boot.
>
> First, simply writing to /dev/urandom does not increase the kernel's entropy
> count, this casuses processes obtaining randomness to block.  Particularly
> processes using OpenSSL's RAND_bytes() will block until the kernel emits
> 'random: crng init done'. This can take upwards of twenty minutes.
>
> According to random(4) the entropy count is only increased when using the
> RNDADDENTROPY ioctl, which urandom-seed currently doesn't use when feeding the
> kernel RNG.
>
> Second, urandom-seed is using /etc/urandom.seed file to seed the kernel's RNG
> machinery upon every boot. The problem is, that this file is created only once
> during first-boot and then reused on every consecutive boot, so pretty much
> static.
>
> So this patch series adds μrngd, which is a new micro non-physical true random
> number generator (system service) based on timing jitter. On devices which
> provide a reliable and precise enough timer, μrngd can provide sufficient
> entropy.
>
> μrngd is using the Jitter RNG core under the hood, which provides an entropy
> source that μrngd feeds into the Linux /dev/random device if its entropy runs
> low.  It updates the /dev/random entropy estimator such that the newly
> provided entropy unblocks /dev/random.
>
> The seeding of /dev/random also ensures that /dev/urandom benefits from
> entropy. Especially during boot time, when the entropy of Linux is low, the
> Jitter RNG based μrngd provides a source of sufficient entropy.
>
> Some RNG init time numbers from qca9563 (TP-Link Archer C7 v5):
>
>  [   12.045693] random: crng init done(μrngd)
>  [  120.043132] random: crng init done(urandom-seed)
>
> μrngd binary has 4579 bytes on ath79.
>
> I'm creating separate packages for getrandom and urandom-seed, so they can be
> removed easily on platforms where either μrngd or any other hardware based RNG
> provides good entropy. I'm not removing urandom-seed package from the
> defaults, because during the testing of μrngd I've found out, that for example
> MediaTek MT7620A ver:2 eco:6 (MIPS 24KEc V5.0) doesn't provide high precision
> timer which is needed for Jitter RNG so the initialization of Jitter RNG
> inside μrngd ends with following error:
>
>  jent-rng init failed, err: 2 (ECOARSETIME)
>
> so on such platforms it might still be probably better to stick to
> urandom-seed as a fallback. The Jitter RNG implements a startup test that is
> intended to detect non-appropriate timers. If it identifies such
> non-appropriate timers, the Jitter RNG will deactivate. Thus, the Jitter RNG
> always tries to reach a secure state.
>
> I believe, that μrngd is going to improve entropy situation on most of current
> platforms OpenWrt supports, so I would like to enable it as default.  Having
> another source of reliable noise in the system doesn't hurt, it only helps.
>
> I would like to note, that most of this stuff is based on the amazing work
> done[1] by Stephan Müller, I've just bend it over and packaged it for OpenWrt.
>
> 1. http://www.chronox.de/jent/doc/CPU-Jitter-NPTRNG.html
Tested this on both mt7621 and Turris Omnia. Works pretty well. Init
gets done fast.

The Turris people might want something like this or they need to fix
haveged to run earlier.
>
> Petr Štetiar (4):
>   urng: add micro non-physical true RNG based on timing jitter
>   ubox: move getrandom into separate getrandom package
>   base-files: move urandom seed bits into separate package
>   build: add urandom-seed and urngd to default packages set
>
>  include/target.mk  |  2 +-
>  package/base-files/Makefile| 11 -
>  package/base-files/files/etc/init.d/urandom_seed   | 12 --
>  .../base-files/files/lib/preinit/81_urandom_seed   | 24 ---
>  package/base-files/files/sbin/urandom_seed | 20 -
>  package/system/ubox/Makefile   | 17 ++--
>  package/system/urandom-seed/Makefile   | 32 +++
>  .../urandom-seed/files/etc/init.d/urandom_seed | 12 ++
>  .../urandom-seed/files/lib/preinit/81_urandom_seed | 24 +++
>  .../system/urandom-seed/files/sbin/urandom_seed| 20 +
>  package/system/urngd/Makefile  | 48 
> ++
>  package/system/urngd/files/urngd.init  | 21 ++
>  12 files changed, 182 insertions(+), 61 deletions(-)
>  delete mode 100755 package/base-files/files/etc/init.d/urandom_seed
>  delete mode 100644 package/base-files/files/lib/preinit/81_urandom_seed
>  delete mode 100755 package/base-files/files/sbin/urandom_seed
>  create mode 100644 package/system/urandom-seed/Makefile
>  create mode 100755 package/system/urandom-seed/files/etc/init.d/urandom_seed
>  create mode 100644 
> 

Re: [OpenWrt-Devel] dnsmasq not leasing after a while. Sometimes more than 5 times a day

2019-05-27 Thread Russell Senior
> "Denis" == Denis Periša  writes:

Denis> There is no other dhcp in network, it's routed connection RB435G
Denis> with multiple cards wlan.  this is config example:

Denis> interface=eth0 except-interface=eth1 interface=wlan3
Denis> interface=wlan0 interface=wlan1 interface=wlan2

Denis> dhcp-range=172.17.3.20,172.17.3.253,255.255.255.0,1h
Denis> dhcp-range=172.17.4.20,172.17.4.253,255.255.255.0,1h
Denis> dhcp-range=172.17.5.20,172.17.5.253,255.255.255.0,1h
Denis> dhcp-range=172.17.6.20,172.17.6.253,255.255.255.0,1h
Denis> dhcp-range=172.17.7.20,172.17.7.253,255.255.255.0,1h

From experience, sometimes there are DHCP servers you don't know about.

This is what I see in my test bed:

   # cat /var/etc/dnsmasq.conf.cfg01411c

   # auto-generated config file from /etc/config/dhcp
   conf-file=/etc/dnsmasq.conf
   dhcp-authoritative
   read-ethers
   enable-ubus
   bind-dynamic
   local-service
   domain=localnet
   server=/lan/
   except-interface=eth1
   dhcp-leasefile=/tmp/dhcp.leases
   resolv-file=/tmp/resolv.conf.auto
   dhcp-broadcast=tag:needs-broadcast
   addn-hosts=/tmp/hosts
   conf-dir=/tmp/dnsmasq.d
   user=dnsmasq
   group=dnsmasq


   dhcp-ignore-names=tag:dhcp_bogus_hostname
   conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf


   dhcp-range=set:pub,10.11.24.5,10.11.24.30,255.255.255.224,1h
   no-dhcp-interface=eth1
   dhcp-range=set:priv,192.168.11.100,192.168.11.249,255.255.255.0,12h

Try turning on the force option.


-- 
Russell Senior, President
russ...@personaltelco.net

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


[OpenWrt-Devel] [PATCH 4/4] build: add urandom-seed and urngd to default packages set

2019-05-27 Thread Petr Štetiar
urandom-seed content was split from base-files into separate package so
in order to preserve the current functionality and to provide some
fallback mechanism in case jent-rng initialization fails in urngd we
need to add it back.

urngd is OpenWrt's micro non-physical true random number generator based
on timing jitter.

Signed-off-by: Petr Štetiar 
---
 include/target.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/target.mk b/include/target.mk
index 4f3bd43e6cb6..a813ba2d2d87 100644
--- a/include/target.mk
+++ b/include/target.mk
@@ -13,7 +13,7 @@ __target_inc=1
 DEVICE_TYPE?=router
 
 # Default packages - the really basic set
-DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd 
fstools uclient-fetch logd
+DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd 
fstools uclient-fetch logd urandom-seed urngd
 # For nas targets
 DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
 # For router targets
-- 
1.9.1


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


[OpenWrt-Devel] [PATCH 3/4] base-files: move urandom seed bits into separate package

2019-05-27 Thread Petr Štetiar
So it's possible to install or remove it as needed.

Signed-off-by: Petr Štetiar 
---
 package/base-files/Makefile| 11 +++-
 package/base-files/files/etc/init.d/urandom_seed   | 12 
 .../base-files/files/lib/preinit/81_urandom_seed   | 24 
 package/base-files/files/sbin/urandom_seed | 20 --
 package/system/urandom-seed/Makefile   | 32 ++
 .../urandom-seed/files/etc/init.d/urandom_seed | 12 
 .../urandom-seed/files/lib/preinit/81_urandom_seed | 24 
 .../system/urandom-seed/files/sbin/urandom_seed| 20 ++
 8 files changed, 98 insertions(+), 57 deletions(-)
 delete mode 100755 package/base-files/files/etc/init.d/urandom_seed
 delete mode 100644 package/base-files/files/lib/preinit/81_urandom_seed
 delete mode 100755 package/base-files/files/sbin/urandom_seed
 create mode 100644 package/system/urandom-seed/Makefile
 create mode 100755 package/system/urandom-seed/files/etc/init.d/urandom_seed
 create mode 100644 
package/system/urandom-seed/files/lib/preinit/81_urandom_seed
 create mode 100755 package/system/urandom-seed/files/sbin/urandom_seed

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 609ffa2c3891..91d677acb3be 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=197
+PKG_RELEASE:=198
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
@@ -43,6 +43,15 @@ define Package/base-files
   VERSION:=$(PKG_RELEASE)-$(REVISION)
 endef
 
+define Package/urandom-seed
+  SECTION:=base
+  CATEGORY:=Base system
+  DEPENDS:=+libc +ubox-getrandom
+  TITLE:=/etc/urandom.seed handling for OpenWrt
+  URL:=http://openwrt.org/
+  VERSION:=$(PKG_RELEASE)-$(REVISION)
+endef
+
 define Package/base-files/conffiles
 /etc/config/
 /etc/config/network
diff --git a/package/base-files/files/etc/init.d/urandom_seed 
b/package/base-files/files/etc/init.d/urandom_seed
deleted file mode 100755
index 17d9c1340078..
--- a/package/base-files/files/etc/init.d/urandom_seed
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh /etc/rc.common
-
-START=99
-USE_PROCD=1
-
-start_service() {
-procd_open_instance "urandom_seed"
-procd_set_param command "/sbin/urandom_seed"
-procd_set_param stdout 1
-procd_set_param stderr 1
-procd_close_instance
-}
diff --git a/package/base-files/files/lib/preinit/81_urandom_seed 
b/package/base-files/files/lib/preinit/81_urandom_seed
deleted file mode 100644
index 26212c60b5e0..
--- a/package/base-files/files/lib/preinit/81_urandom_seed
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-log_urandom_seed() {
-echo "urandom-seed: $1" > /dev/kmsg
-}
-
-_do_urandom_seed() {
-[ -f "$1" ] || { log_urandom_seed "Seed file not found ($1)"; return; }
-[ -O "$1" -a -G "$1" -a ! -x "$1" ] || { log_urandom_seed "Wrong owner / 
permissions for $1"; return; }
-
-log_urandom_seed "Seeding with $1"
-cat "$1" > /dev/urandom
-}
-
-do_urandom_seed() {
-[ -c /dev/urandom ] || { log_urandom_seed "Something is wrong with 
/dev/urandom"; return; }
-
-_do_urandom_seed "/etc/urandom.seed"
-
-SEED="$(uci -q get system.@system[0].urandom_seed)"
-[ "${SEED:0:1}" = "/" -a "$SEED" != "/etc/urandom.seed" ] && 
_do_urandom_seed "$SEED"
-}
-
-boot_hook_add preinit_main do_urandom_seed
diff --git a/package/base-files/files/sbin/urandom_seed 
b/package/base-files/files/sbin/urandom_seed
deleted file mode 100755
index 7043e8af4e6a..
--- a/package/base-files/files/sbin/urandom_seed
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-set -e
-
-trap '[ "$?" -eq 0 ] || echo "An error occured" >&2' EXIT
-
-save() {
-touch "$1.tmp"
-chown root:root "$1.tmp"
-chmod 600 "$1.tmp"
-getrandom 512 > "$1.tmp"
-mv "$1.tmp" "$1"
-echo "Seed saved ($1)"
-}
-
-SEED="$(uci -q get system.@system[0].urandom_seed || true)"
-[ "${SEED:0:1}" = "/" ] && save "$SEED"
-
-SEED=/etc/urandom.seed
-[ ! -f $SEED ] && save "$SEED"
-true
diff --git a/package/system/urandom-seed/Makefile 
b/package/system/urandom-seed/Makefile
new file mode 100644
index ..6bde2e0b8a42
--- /dev/null
+++ b/package/system/urandom-seed/Makefile
@@ -0,0 +1,32 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=urandom-seed
+PKG_VERSION:=1.0
+PKG_RELEASE:=1
+PKG_LICENSE:=GPL-2.0
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/$(PKG_NAME)
+  SECTION:=base
+  CATEGORY:=Base system
+  DEPENDS:=+getrandom
+  TITLE:=/etc/urandom.seed handling for OpenWrt
+  URL:=http://openwrt.org/
+endef
+
+define Build/Prepare
+   mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile/Default
+endef
+Build/Compile = $(Build/Compile/Default)
+
+define Package/$(PKG_NAME)/install
+   $(CP) ./files/* $(1)/
+endef
+

[OpenWrt-Devel] [PATCH 1/4] urng: add micro non-physical true RNG based on timing jitter

2019-05-27 Thread Petr Štetiar
μrngd is OpenWrt's micro non-physical true random number generator based
on timing jitter.

Using the Jitter RNG core, the rngd provides an entropy source that
feeds into the Linux /dev/random device if its entropy runs low. It
updates the /dev/random entropy estimator such that the newly provided
entropy unblocks /dev/random.

The seeding of /dev/random also ensures that /dev/urandom benefits from
entropy. Especially during boot time, when the entropy of Linux is low,
the Jitter RNGd provides a source of sufficient entropy.

Signed-off-by: Petr Štetiar 
---
 package/system/urngd/Makefile | 48 +++
 package/system/urngd/files/urngd.init | 21 +++
 2 files changed, 69 insertions(+)
 create mode 100644 package/system/urngd/Makefile
 create mode 100644 package/system/urngd/files/urngd.init

diff --git a/package/system/urngd/Makefile b/package/system/urngd/Makefile
new file mode 100644
index ..e57a5d60f748
--- /dev/null
+++ b/package/system/urngd/Makefile
@@ -0,0 +1,48 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=urngd
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=https://github.com/ynezz/openwrt-urngd
+PKG_SOURCE_DATE:=2019-05-27
+PKG_SOURCE_VERSION:=41e4163b2e7f4c1c1f51cdfa487d6052ff859cf2
+PKG_MIRROR_HASH:=839b1b23163bc907625ed6c6122faec9404cb72d8587ece796a9cec1422b6077
+
+PKG_LICENSE:=GPL-2.0 BSD-3-Clause
+PKG_LICENSE_FILES:=
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/$(PKG_NAME)
+  SECTION:=utils
+  CATEGORY:=Base system
+  TITLE:=OpenWrt non-physical true random number generator based on timing 
jitter
+  DEPENDS:=+libubox
+endef
+
+define Package/$(PKG_NAME)/description
+  urngd is OpenWrt's micro non-physical true random number generator based on
+  timing jitter.
+
+  Using the Jitter RNG core, the rngd provides an entropy source that feeds 
into
+  the Linux /dev/random device if its entropy runs low. It updates the
+  /dev/random entropy estimator such that the newly provided entropy unblocks
+  /dev/random.
+
+  The seeding of /dev/random also ensures that /dev/urandom benefits from
+  entropy. Especially during boot time, when the entropy of Linux is low, the
+  Jitter RNGd provides a source of sufficient entropy.
+endef
+
+define Package/$(PKG_NAME)/install
+   $(INSTALL_DIR) $(1)/etc/init.d
+   $(INSTALL_BIN) ./files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
+   $(INSTALL_DIR) $(1)/sbin
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/sbin/$(PKG_NAME)
+endef
+
+$(eval $(call BuildPackage,$(PKG_NAME)))
diff --git a/package/system/urngd/files/urngd.init 
b/package/system/urngd/files/urngd.init
new file mode 100644
index ..ab1d5cf9d46a
--- /dev/null
+++ b/package/system/urngd/files/urngd.init
@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+START=00
+
+USE_PROCD=1
+NAME=urngd
+PROG=/sbin/urngd
+
+start_service() {
+   procd_open_instance
+   procd_set_param command "$PROG"
+   procd_close_instance
+}
+
+stop() {
+   service_stop $PROG
+}
+
+reload() {
+   service_reload $PROG
+}
-- 
1.9.1


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


[OpenWrt-Devel] [PATCH 2/4] ubox: move getrandom into separate getrandom package

2019-05-27 Thread Petr Štetiar
So it's possible to install or remove it as needed.

Signed-off-by: Petr Štetiar 
---
 package/system/ubox/Makefile | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/package/system/ubox/Makefile b/package/system/ubox/Makefile
index 268fab9d74bb..ab79731a561a 100644
--- a/package/system/ubox/Makefile
+++ b/package/system/ubox/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ubox
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/ubox.git
@@ -27,18 +27,28 @@ define Package/ubox
   TITLE:=OpenWrt system helper toolbox
 endef
 
+define Package/getrandom
+  SECTION:=base
+  CATEGORY:=Base system
+  TITLE:=OpenWrt getrandom system helper
+endef
+
 define Package/logd
-SECTION:=base
+  SECTION:=base
   CATEGORY:=Base system
   DEPENDS:=+libubox +libubus +libblobmsg-json +USE_GLIBC:librt
   TITLE:=OpenWrt system log implementation
 endef
 
+define Package/getrandom/install
+   $(INSTALL_DIR) $(1)/usr/bin
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
+endef
+
 define Package/ubox/install
$(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin
 
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{kmodloader,validate_data} 
$(1)/sbin/
-   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libvalidate.so $(1)/lib
 
$(LN) kmodloader $(1)/sbin/rmmod
@@ -56,4 +66,5 @@ define Package/logd/install
 endef
 
 $(eval $(call BuildPackage,ubox))
+$(eval $(call BuildPackage,getrandom))
 $(eval $(call BuildPackage,logd))
-- 
1.9.1


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


[PATCH 0/4] add μrngd: true RNG based on timing jitter

2019-05-27 Thread Petr Štetiar
Hi,

this patch series fixes some of the current urandom-seed flaws and improves
situation with low entropy in the kernel during the boot.

First, simply writing to /dev/urandom does not increase the kernel's entropy
count, this casuses processes obtaining randomness to block.  Particularly
processes using OpenSSL's RAND_bytes() will block until the kernel emits
'random: crng init done'. This can take upwards of twenty minutes.

According to random(4) the entropy count is only increased when using the
RNDADDENTROPY ioctl, which urandom-seed currently doesn't use when feeding the
kernel RNG.

Second, urandom-seed is using /etc/urandom.seed file to seed the kernel's RNG
machinery upon every boot. The problem is, that this file is created only once
during first-boot and then reused on every consecutive boot, so pretty much
static.

So this patch series adds μrngd, which is a new micro non-physical true random
number generator (system service) based on timing jitter. On devices which
provide a reliable and precise enough timer, μrngd can provide sufficient
entropy.

μrngd is using the Jitter RNG core under the hood, which provides an entropy
source that μrngd feeds into the Linux /dev/random device if its entropy runs
low.  It updates the /dev/random entropy estimator such that the newly
provided entropy unblocks /dev/random.

The seeding of /dev/random also ensures that /dev/urandom benefits from
entropy. Especially during boot time, when the entropy of Linux is low, the
Jitter RNG based μrngd provides a source of sufficient entropy.

Some RNG init time numbers from qca9563 (TP-Link Archer C7 v5):

 [   12.045693] random: crng init done(μrngd)
 [  120.043132] random: crng init done(urandom-seed)

μrngd binary has 4579 bytes on ath79.

I'm creating separate packages for getrandom and urandom-seed, so they can be
removed easily on platforms where either μrngd or any other hardware based RNG
provides good entropy. I'm not removing urandom-seed package from the
defaults, because during the testing of μrngd I've found out, that for example
MediaTek MT7620A ver:2 eco:6 (MIPS 24KEc V5.0) doesn't provide high precision
timer which is needed for Jitter RNG so the initialization of Jitter RNG
inside μrngd ends with following error:

 jent-rng init failed, err: 2 (ECOARSETIME)

so on such platforms it might still be probably better to stick to
urandom-seed as a fallback. The Jitter RNG implements a startup test that is
intended to detect non-appropriate timers. If it identifies such
non-appropriate timers, the Jitter RNG will deactivate. Thus, the Jitter RNG
always tries to reach a secure state.

I believe, that μrngd is going to improve entropy situation on most of current
platforms OpenWrt supports, so I would like to enable it as default.  Having
another source of reliable noise in the system doesn't hurt, it only helps.

I would like to note, that most of this stuff is based on the amazing work
done[1] by Stephan Müller, I've just bend it over and packaged it for OpenWrt.

1. http://www.chronox.de/jent/doc/CPU-Jitter-NPTRNG.html

Petr Štetiar (4):
  urng: add micro non-physical true RNG based on timing jitter
  ubox: move getrandom into separate getrandom package
  base-files: move urandom seed bits into separate package
  build: add urandom-seed and urngd to default packages set

 include/target.mk  |  2 +-
 package/base-files/Makefile| 11 -
 package/base-files/files/etc/init.d/urandom_seed   | 12 --
 .../base-files/files/lib/preinit/81_urandom_seed   | 24 ---
 package/base-files/files/sbin/urandom_seed | 20 -
 package/system/ubox/Makefile   | 17 ++--
 package/system/urandom-seed/Makefile   | 32 +++
 .../urandom-seed/files/etc/init.d/urandom_seed | 12 ++
 .../urandom-seed/files/lib/preinit/81_urandom_seed | 24 +++
 .../system/urandom-seed/files/sbin/urandom_seed| 20 +
 package/system/urngd/Makefile  | 48 ++
 package/system/urngd/files/urngd.init  | 21 ++
 12 files changed, 182 insertions(+), 61 deletions(-)
 delete mode 100755 package/base-files/files/etc/init.d/urandom_seed
 delete mode 100644 package/base-files/files/lib/preinit/81_urandom_seed
 delete mode 100755 package/base-files/files/sbin/urandom_seed
 create mode 100644 package/system/urandom-seed/Makefile
 create mode 100755 package/system/urandom-seed/files/etc/init.d/urandom_seed
 create mode 100644 
package/system/urandom-seed/files/lib/preinit/81_urandom_seed
 create mode 100755 package/system/urandom-seed/files/sbin/urandom_seed
 create mode 100644 package/system/urngd/Makefile
 create mode 100644 package/system/urngd/files/urngd.init

-- 
1.9.1


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


Re: [OpenWrt-Devel] dnsmasq not leasing after a while. Sometimes more than 5 times a day

2019-05-27 Thread Denis Periša
There is no other dhcp in network, it's routed connection RB435G with
multiple cards wlan.
this is config example:

interface=eth0
except-interface=eth1
interface=wlan3
interface=wlan0
interface=wlan1
interface=wlan2

dhcp-range=172.17.3.20,172.17.3.253,255.255.255.0,1h
dhcp-range=172.17.4.20,172.17.4.253,255.255.255.0,1h
dhcp-range=172.17.5.20,172.17.5.253,255.255.255.0,1h
dhcp-range=172.17.6.20,172.17.6.253,255.255.255.0,1h
dhcp-range=172.17.7.20,172.17.7.253,255.255.255.0,1h

On Mon, May 27, 2019 at 9:03 PM Russell Senior 
wrote:

> > "Denis" == Denis Periša  writes:
>
> Denis> Yes, dnsmasq is still running but lease is not given.. I don't
> Denis> know how to debug it more.  Configuration is simple, one subnet
> Denis> range 192.168.0.10 to 192.168.0.200 on wlan0 interface for
> Denis> example. But it's not wifi issue, local also.  It sends mail as
> Denis> soon as error is detected and restarts dnsmasq after which it
> Denis> works. Device is not rebooting.  OpenWrt 18.06-SNAPSHOT,
> Denis> r7766-e9a7344550
>
> Denis> Also my scripts checkes two times just to rule out false
> Denis> negative.  Also, more public exposure or none is pretty much
> Denis> same.. I have device which gets maybe 1-2 person and one with 50
> Denis> .. behaving same. After a while it stops responding. Any more
> Denis> debug I could use somewhere?
>
> There may be another dhcp server detected on the network. See "force"
> option here:
>
>   https://openwrt.org/docs/guide-user/base-system/dhcp#dhcp_pools
>
> And/or post the contents of /var/etc/dnsmasq.conf.cfg*
>
>
> --
> Russell Senior, President
> russ...@personaltelco.net
>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Support for Edimax EW-7476RPC / EW-7478AC

2019-05-27 Thread Birger Koblitz
Hi Daniel,

On 27.05.19 18:43, Daniel Golle wrote:
> On Mon, May 27, 2019 at 06:35:30PM +0200, Daniel Golle wrote:
>> Hi Birger,
>>
>> thanks for submitting your work. In order to support the external
>> switch, existing generic features should be used in order to
>> implement the phy-reset via GPIO#39.
>> See my comments in the code (I commented the first device only, same
>> applies to the 2nd device as well).
>>
>> On Mon, May 27, 2019 at 05:55:24PM +0200, Birger Koblitz wrote:
>>> ramips: add Netgear EW-7476RPC
This is a typo (or better cut-and-paste which went wrong). The device is
from Edimax.
>>> SoC:   MediaTek MT7620a @ 580MHz
>>> RAM:   64M (Winbond W9751G6KB-25)
>>> FLASH: 8MB (Macronix)
>>> WiFi:  SoC-integrated: MediaTek MT76620a bgn
>> Typo, I supposed. MT7620a (or RT6352 to name the embedded WiFi IP)
Yep.
>>
>>> WiFi:  MediaTek MT7612EN nac
>>> GBE:   RTL8211E
>> Please mention how many phyical ports the device got and if all of
>> them support GbE.
> Sorry, that was stupid of me. I just realized we are talking about a
> wall-wart:
> https://fccid.io/NDD9574761501/Internal-Photos/Internal-Photos-2706172
>
> So it's a simple PHY with 1x GbE obviously ;)

So:

GbE:    1x (RTL8211E)

?

>
>>> +
>>> + {
>>> +   state_default: pinctrl0 {
>>> +   gpio {
>>> +    // might need pin 39: ;
>>> +   ralink,group = "i2c", "uartf", "nd_sd",
>>> "rgmii2", "spi refclk";
>>> +   ralink,function = "gpio";
>>> +   };
>>> +   };
>>> +};
>> A pinctrl group for the switch reset would be appropriate:
>> GPIO 39 is p4led_an, hence add:
>>  phy_reset_pins: phy-reset {
>>  gpio {
>>  ralink,group = "p4led_an";
>>  ralink,function = "gpio";
>>  };
>>  };
Ok.
>>> +
>>> +
>>> + {
>>> +
>>> +    status = "okay";
>>> +   mtd-mac-address = < 0x4>;
>>> +   pinctrl-names = "default";
>>> +   pinctrl-0 = <_pins _pins>;
>> Now use it here
>>  pinctrl-0 = <_pins _pins _reset_pins>;
OK.
>>> +   mediatek,portmap = "l";
>>> +    mediatek,mdio-mode = <1>;
>>> +   
>>> +   port@5 {
>>> +   status = "okay";
>>> +   mediatek,fixed-link = <1000 1 1 1>;
>>> +   phy-mode = "rgmii";
>> And why not use something like
>>  phy-reset-gpios = < 15 GPIO_ACTIVE_LOW>;
>> here and make sure it's taken care of, because this is imho where it
>> would belong.
>>
OK, but how do I take care of the phy-reset. Is it OK how it is done
directly in the gsw_mt7620.c driver code? Or is there a framework for
this, already? And if there is such a framework, then how do I make sure
the reset is made at the right point in time during the switch's
initialization?

>>
>>> diff --git
>>> a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
>>> b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
>>> index 5fc5080aaf..305ce18037 100644
>>> ---
>>> a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
>>> +++
>>> b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c
>>> @@ -84,6 +84,32 @@ static int mt7620_mdio_mode(struct device_node *eth_node)
>>>     return ret;
>>>  }
>>>  
>>> +void reset_realtek_phy(void){
>>> +#define RALINK_GPIO_DIR    0xB600+0x4C
>>> +#define RALINK_GPIO_DATA   0xB600+0x48
>>> +#define RALINK_RESETPHY_GPIO   (39-24)
>>> +    u32 gpiodir;
>>> +    u32 piodata;
>>> +    u32 reset_pin= RALINK_RESETPHY_GPIO;
>>> +   
>>> +    pr_info("gsw: Resetting RTL8211e using gpio 39\n");
>>> +    gpiodir =  le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DIR));
>>> +    /*set gpio1 to output*/
>>> +    gpiodir |= (1<>> +    *(volatile u32 *)(RALINK_GPIO_DIR) = cpu_to_le32(gpiodir);
>>> +
>>> +    piodata = le32_to_cpu(*(volatile u32 *)(RALINK_GPIO_DATA));
>>> +    /*set to low(0)*/
>>> +    piodata &= ~(1L << reset_pin);
>>> +    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
>>> +    /*delay 30ms*/
>>> +    mdelay(30);
>>> +    /*set to high(1)*/
>>> +    piodata |= (1L << reset_pin);
>>> +    *(volatile u32 *)(RALINK_GPIO_DATA) = cpu_to_le32(piodata);
>>> +}
>>> +
>>> +
>>>  static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
>>>  {
>>>     u32 i;
>>> @@ -220,6 +246,7 @@ int mtk_gsw_init(struct fe_priv *priv)
>>>     struct device_node *np = priv->switch_np;
>>>     struct platform_device *pdev = of_find_device_by_node(np);
>>>     struct mt7620_gsw *gsw;
>>> +    const char *rtl8211e_reset = NULL;
>>>  
>>>     if (!pdev)
>>>     return -ENODEV;
>>> @@ -231,6 +258,9 @@ int mtk_gsw_init(struct fe_priv *priv)
>>>     priv->soc->swpriv = gsw;
>>>  
>>>     mt7620_hw_init(gsw, mt7620_mdio_mode(priv->dev->of_node));
>>> +    of_property_read_string(np, "mediatek,rtl8211e-reset",
>>> _reset);
>>> +    if (rtl8211e_reset && !strcmp(rtl8211e_reset, "yes"))
>>> +    

Re: [OpenWrt-Devel] [PATCH] lantiq: net: wrong operator

2019-05-27 Thread Kevin 'ldir' Darbyshire-Bryant
This was a test - please ignore.  Already deleted from patchwork

> On 27 May 2019, at 18:44, Kevin 'ldir' Darbyshire-Bryant 
>  wrote:
> 
> Signed-off-by: Kevin Darbyshire-Bryant 
> ---
> .../patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch   | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git 
> a/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch 
> b/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
> index 7eaf0b7b7b..0d97b4742b 100644
> --- 
> a/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
> +++ 
> b/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
> @@ -934,8 +934,8 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
> +
> + link->duplex = xrx200sw_read_x(XRX200_MAC_PSTAT_FDUP, port);
> +
> -+link->rx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) && 
> 0x0010);
> -+link->tx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) && 
> 0x0020);
> ++link->rx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) & 
> 0x0010);
> ++link->tx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) & 
> 0x0020);
> + link->aneg = !(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port));
> +
> + link->speed = SWITCH_PORT_SPEED_10;
> -- 
> 2.20.1 (Apple Git-117)
> 


Cheers,

Kevin D-B

gpg: 012C ACB2 28C6 C53E 9775  9123 B3A2 389B 9DE2 334A


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


Re: [OpenWrt-Devel] [PATCH] restoring dscp on ingress

2019-05-27 Thread Kevin 'ldir' Darbyshire-Bryant
This was a test - please ignore.  Already deleted from patchwork

> On 27 May 2019, at 19:02, Kevin 'ldir' Darbyshire-Bryant 
>  wrote:
> 
> A combination of tc filter action act_ctinfo to do the restoration,
> a new savedscp option to iptables xt_connmark to store the DSCP
> 
> Signed-off-by: Kevin Darbyshire-Bryant 
> ---
> package/kernel/linux/modules/netsupport.mk|  10 +-
> ...-experimental-support-for-act_ctinfo.patch | 374 ++
> .../iptables/patches/0001-savedscp.patch  | 213 ++
> ...et-sched-Introduce-act_ctinfo-action.patch | 636 +
> ...etfilter-connmark-introduce-savedscp.patch | 107 +++
> ...et-sched-Introduce-act_ctinfo-action.patch | 658 ++
> ...etfilter-connmark-introduce-savedscp.patch | 142 
> 7 files changed, 2139 insertions(+), 1 deletion(-)
> create mode 100644 
> package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
> create mode 100644 package/network/utils/iptables/patches/0001-savedscp.patch
> create mode 100644 
> target/linux/generic/hack-4.14/0001-net-sched-Introduce-act_ctinfo-action.patch
> create mode 100644 
> target/linux/generic/hack-4.14/0001-netfilter-connmark-introduce-savedscp.patch
> create mode 100644 
> target/linux/generic/hack-4.19/0001-net-sched-Introduce-act_ctinfo-action.patch
> create mode 100644 
> target/linux/generic/hack-4.19/0001-netfilter-connmark-introduce-savedscp.patch
> 
> diff --git a/package/kernel/linux/modules/netsupport.mk 
> b/package/kernel/linux/modules/netsupport.mk
> index d92992e13f..7ab6d3b1b3 100644
> --- a/package/kernel/linux/modules/netsupport.mk
> +++ b/package/kernel/linux/modules/netsupport.mk
> @@ -803,7 +803,6 @@ endef
> 
> $(eval $(call KernelPackage,sched-mqprio))
> 
> -
> define KernelPackage/sched-connmark
>   SUBMENU:=$(NETWORK_SUPPORT_MENU)
>   TITLE:=Traffic shaper conntrack mark support
> @@ -814,6 +813,15 @@ define KernelPackage/sched-connmark
> endef
> $(eval $(call KernelPackage,sched-connmark))
> 
> +define KernelPackage/sched-ctinfo
> +  SUBMENU:=$(NETWORK_SUPPORT_MENU)
> +  TITLE:=Traffic shaper ctinfo support
> +  DEPENDS:=+kmod-sched-core +kmod-ipt-core +kmod-ipt-conntrack-extra
> +  KCONFIG:=CONFIG_NET_ACT_CTINFO
> +  FILES:=$(LINUX_DIR)/net/sched/act_ctinfo.ko
> +  AUTOLOAD:=$(call AutoLoad,71, act_ctinfo)
> +endef
> +$(eval $(call KernelPackage,sched-ctinfo))
> 
> define KernelPackage/sched-ipset
>   SUBMENU:=$(NETWORK_SUPPORT_MENU)
> diff --git 
> a/package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
>  
> b/package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
> new file mode 100644
> index 00..6983e7faed
> --- /dev/null
> +++ 
> b/package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
> @@ -0,0 +1,374 @@
> +From 5dd8945255b679246041866285faab2e4348362c Mon Sep 17 00:00:00 2001
> +From: Kevin Darbyshire-Bryant 
> +Date: Fri, 15 Mar 2019 09:35:37 +
> +Subject: [PATCH] initial experimental support for act_ctinfo
> +
> +switchtoctinfo
> +
> +Signed-off-by: Kevin Darbyshire-Bryant 
> +---
> + include/uapi/linux/pkt_cls.h  |   1 +
> + include/uapi/linux/tc_act/tc_ctinfo.h |  52 +
> + tc/Makefile   |   1 +
> + tc/m_ctinfo.c | 266 ++
> + 4 files changed, 320 insertions(+)
> + create mode 100644 include/uapi/linux/tc_act/tc_ctinfo.h
> + create mode 100644 tc/m_ctinfo.c
> +
> +diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
> +index 95d0db2a..7df0e808 100644
> +--- a/include/uapi/linux/pkt_cls.h
>  b/include/uapi/linux/pkt_cls.h
> +@@ -68,6 +68,7 @@ enum {
> + TCA_ID_UNSPEC=0,
> + TCA_ID_POLICE=1,
> + /* other actions go here */
> ++TCA_ID_CTINFO=27,
> + __TCA_ID_MAX=255
> + };
> + 
> +diff --git a/include/uapi/linux/tc_act/tc_ctinfo.h 
> b/include/uapi/linux/tc_act/tc_ctinfo.h
> +new file mode 100644
> +index ..48c40f65
> +--- /dev/null
>  b/include/uapi/linux/tc_act/tc_ctinfo.h
> +@@ -0,0 +1,52 @@
> ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> ++#ifndef __UAPI_TC_CTINFO_H
> ++#define __UAPI_TC_CTINFO_H
> ++
> ++#include 
> ++#include 
> ++
> ++struct tc_ctinfo {
> ++tc_gen;
> ++};
> ++
> ++struct tc_ctinfo_dscp {
> ++__u32 mask;
> ++__u32 statemask;
> ++};
> ++
> ++struct tc_ctinfo_cpmark {
> ++__u32 mask;
> ++};
> ++
> ++struct tc_ctinfo_stats_dscp {
> ++__u64 set;
> ++__u64 error;
> ++};
> ++
> ++struct tc_ctinfo_stats_cpmark {
> ++__u64 set;
> ++};
> ++
> ++enum {
> ++TCA_CTINFO_UNSPEC,
> ++TCA_CTINFO_PAD,
> ++TCA_CTINFO_TM,
> ++TCA_CTINFO_ACT,
> ++TCA_CTINFO_ZONE,
> ++TCA_CTINFO_PARMS_DSCP,
> ++TCA_CTINFO_PARMS_CPMARK,
> ++TCA_CTINFO_MODE_DSCP,
> ++TCA_CTINFO_MODE_CPMARK,
> ++TCA_CTINFO_STATS_DSCP,
> ++TCA_CTINFO_STATS_CPMARK,
> ++__TCA_CTINFO_MAX
> 

[OpenWrt-Devel] [PATCH] restoring dscp on ingress

2019-05-27 Thread Kevin 'ldir' Darbyshire-Bryant
A combination of tc filter action act_ctinfo to do the restoration,
a new savedscp option to iptables xt_connmark to store the DSCP

Signed-off-by: Kevin Darbyshire-Bryant 
---
 package/kernel/linux/modules/netsupport.mk|  10 +-
 ...-experimental-support-for-act_ctinfo.patch | 374 ++
 .../iptables/patches/0001-savedscp.patch  | 213 ++
 ...et-sched-Introduce-act_ctinfo-action.patch | 636 +
 ...etfilter-connmark-introduce-savedscp.patch | 107 +++
 ...et-sched-Introduce-act_ctinfo-action.patch | 658 ++
 ...etfilter-connmark-introduce-savedscp.patch | 142 
 7 files changed, 2139 insertions(+), 1 deletion(-)
 create mode 100644 
package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
 create mode 100644 package/network/utils/iptables/patches/0001-savedscp.patch
 create mode 100644 
target/linux/generic/hack-4.14/0001-net-sched-Introduce-act_ctinfo-action.patch
 create mode 100644 
target/linux/generic/hack-4.14/0001-netfilter-connmark-introduce-savedscp.patch
 create mode 100644 
target/linux/generic/hack-4.19/0001-net-sched-Introduce-act_ctinfo-action.patch
 create mode 100644 
target/linux/generic/hack-4.19/0001-netfilter-connmark-introduce-savedscp.patch

diff --git a/package/kernel/linux/modules/netsupport.mk 
b/package/kernel/linux/modules/netsupport.mk
index d92992e13f..7ab6d3b1b3 100644
--- a/package/kernel/linux/modules/netsupport.mk
+++ b/package/kernel/linux/modules/netsupport.mk
@@ -803,7 +803,6 @@ endef
 
 $(eval $(call KernelPackage,sched-mqprio))
 
-
 define KernelPackage/sched-connmark
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
   TITLE:=Traffic shaper conntrack mark support
@@ -814,6 +813,15 @@ define KernelPackage/sched-connmark
 endef
 $(eval $(call KernelPackage,sched-connmark))
 
+define KernelPackage/sched-ctinfo
+  SUBMENU:=$(NETWORK_SUPPORT_MENU)
+  TITLE:=Traffic shaper ctinfo support
+  DEPENDS:=+kmod-sched-core +kmod-ipt-core +kmod-ipt-conntrack-extra
+  KCONFIG:=CONFIG_NET_ACT_CTINFO
+  FILES:=$(LINUX_DIR)/net/sched/act_ctinfo.ko
+  AUTOLOAD:=$(call AutoLoad,71, act_ctinfo)
+endef
+$(eval $(call KernelPackage,sched-ctinfo))
 
 define KernelPackage/sched-ipset
   SUBMENU:=$(NETWORK_SUPPORT_MENU)
diff --git 
a/package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
 
b/package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
new file mode 100644
index 00..6983e7faed
--- /dev/null
+++ 
b/package/network/utils/iproute2/patches/0001-initial-experimental-support-for-act_ctinfo.patch
@@ -0,0 +1,374 @@
+From 5dd8945255b679246041866285faab2e4348362c Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant 
+Date: Fri, 15 Mar 2019 09:35:37 +
+Subject: [PATCH] initial experimental support for act_ctinfo
+
+switchtoctinfo
+
+Signed-off-by: Kevin Darbyshire-Bryant 
+---
+ include/uapi/linux/pkt_cls.h  |   1 +
+ include/uapi/linux/tc_act/tc_ctinfo.h |  52 +
+ tc/Makefile   |   1 +
+ tc/m_ctinfo.c | 266 ++
+ 4 files changed, 320 insertions(+)
+ create mode 100644 include/uapi/linux/tc_act/tc_ctinfo.h
+ create mode 100644 tc/m_ctinfo.c
+
+diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
+index 95d0db2a..7df0e808 100644
+--- a/include/uapi/linux/pkt_cls.h
 b/include/uapi/linux/pkt_cls.h
+@@ -68,6 +68,7 @@ enum {
+   TCA_ID_UNSPEC=0,
+   TCA_ID_POLICE=1,
+   /* other actions go here */
++  TCA_ID_CTINFO=27,
+   __TCA_ID_MAX=255
+ };
+ 
+diff --git a/include/uapi/linux/tc_act/tc_ctinfo.h 
b/include/uapi/linux/tc_act/tc_ctinfo.h
+new file mode 100644
+index ..48c40f65
+--- /dev/null
 b/include/uapi/linux/tc_act/tc_ctinfo.h
+@@ -0,0 +1,52 @@
++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
++#ifndef __UAPI_TC_CTINFO_H
++#define __UAPI_TC_CTINFO_H
++
++#include 
++#include 
++
++struct tc_ctinfo {
++  tc_gen;
++};
++
++struct tc_ctinfo_dscp {
++  __u32 mask;
++  __u32 statemask;
++};
++
++struct tc_ctinfo_cpmark {
++  __u32 mask;
++};
++
++struct tc_ctinfo_stats_dscp {
++  __u64 set;
++  __u64 error;
++};
++
++struct tc_ctinfo_stats_cpmark {
++  __u64 set;
++};
++
++enum {
++  TCA_CTINFO_UNSPEC,
++  TCA_CTINFO_PAD,
++  TCA_CTINFO_TM,
++  TCA_CTINFO_ACT,
++  TCA_CTINFO_ZONE,
++  TCA_CTINFO_PARMS_DSCP,
++  TCA_CTINFO_PARMS_CPMARK,
++  TCA_CTINFO_MODE_DSCP,
++  TCA_CTINFO_MODE_CPMARK,
++  TCA_CTINFO_STATS_DSCP,
++  TCA_CTINFO_STATS_CPMARK,
++  __TCA_CTINFO_MAX
++};
++
++#define TCA_CTINFO_MAX (__TCA_CTINFO_MAX - 1)
++
++enum {
++  CTINFO_MODE_DSCP= BIT(0),
++  CTINFO_MODE_CPMARK  = BIT(1)
++};
++
++#endif
+diff --git a/tc/Makefile b/tc/Makefile
+index 2edaf2c8..ec93a9a1 100644
+--- a/tc/Makefile
 b/tc/Makefile
+@@ -48,6 +48,7 @@ TCMODULES += m_csum.o
+ TCMODULES += m_simple.o
+ 

[OpenWrt-Devel] [PATCH] lantiq: net: wrong operator

2019-05-27 Thread Kevin 'ldir' Darbyshire-Bryant
Signed-off-by: Kevin Darbyshire-Bryant 
---
 .../patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch 
b/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
index 7eaf0b7b7b..0d97b4742b 100644
--- 
a/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
+++ 
b/target/linux/lantiq/patches-4.14/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
@@ -934,8 +934,8 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +
 +  link->duplex = xrx200sw_read_x(XRX200_MAC_PSTAT_FDUP, port);
 +
-+  link->rx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) && 
0x0010);
-+  link->tx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) && 
0x0020);
++  link->rx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) & 
0x0010);
++  link->tx_flow = !!(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port) & 
0x0020);
 +  link->aneg = !(xrx200sw_read_x(XRX200_MAC_CTRL_0_FCON, port));
 +
 +  link->speed = SWITCH_PORT_SPEED_10;
-- 
2.20.1 (Apple Git-117)

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


[OpenWrt-Devel] [PATCH v3] ramips: add support for Xiaomi Mi Router 4A (100M Edition)

2019-05-27 Thread Markus Scheck
- SoC:  MediaTek MT7628AN
- Flash:16MB (Winbond W25Q128JV)
- RAM:  64MB
- Serial:   As marked on PCB, 3V3 logic, baudrate is 115200
- Ethernet: 3x 10/100 Mbps (switched, 2x LAN + WAN)
- WIFI0:MT7628AN 2.4GHz 802.11b/g/n
- WIFI1:MT7612EN 5GHz 802.11ac
- Antennas: 4x external (2 per radio), non-detachable
- LEDs: Programmable power-LED (two-colored, yellow/blue)
Non-programmable internet-LED (shows WAN-activity)
- Buttons:  Reset

INSTALLATION:

1. Connect to the serial port of the router and power it up.
   If you get a prompt asking for boot-mode, go to step 3.
2. Unplug the router after
   > Erasing SPI Flash...
   > raspi_erase: offs:2 len:1
   occurs on the serial port. Plug the router back in.
3. At the prompt select option 2 (Load system code then
   write to Flash via TFTP.)
4. Enter 192.168.1.1 as the device IP and 192.168.1.2 as the
   Server-IP.
5. Connect your computer to LAN1 and assign it as 192.168.1.2/24.
6. Rename the sysupgrade image to test.bin and serve it via TFTP.
7. Enter test.bin on the serial console and press enter.

Signed-off-by: Markus Scheck 
---
 .../ramips/base-files/etc/board.d/02_network  |   4 +
 target/linux/ramips/dts/XIAOMI-MIR4A-100M.dts | 146 ++
 target/linux/ramips/image/mt76x8.mk   |   8 +
 3 files changed, 158 insertions(+)
 create mode 100644 target/linux/ramips/dts/XIAOMI-MIR4A-100M.dts

diff --git a/target/linux/ramips/base-files/etc/board.d/02_network 
b/target/linux/ramips/base-files/etc/board.d/02_network
index dcc7b4a747..d3fecbc2bd 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -454,6 +454,10 @@ ramips_setup_interfaces()
ucidef_add_switch "switch0" \
"1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
;;
+   xiaomi,mir4a-100m)
+   ucidef_add_switch "switch0" \
+   "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
+   ;;
zbtlink,zbt-we1226|\
y1)
ucidef_add_switch "switch0" \
diff --git a/target/linux/ramips/dts/XIAOMI-MIR4A-100M.dts 
b/target/linux/ramips/dts/XIAOMI-MIR4A-100M.dts
new file mode 100644
index 00..3bcb84d68b
--- /dev/null
+++ b/target/linux/ramips/dts/XIAOMI-MIR4A-100M.dts
@@ -0,0 +1,146 @@
+//SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "mt7628an.dtsi"
+
+#include 
+#include 
+
+/ {
+   compatible = "xiaomi,mir4a-100m", "mediatek,mt7628an-soc";
+   model = "Xiaomi Mi Router 4A (100M Edition)";
+
+   chosen {
+   bootargs = "console=ttyS0,115200";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x400>;
+   };
+
+   aliases {
+   led-boot = _yellow;
+   led-failsafe = _yellow;
+   led-running = _blue;
+   led-upgrade = _yellow;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   power_blue: power_blue {
+   label = "mir4a-100m:blue:power";
+   gpios = < 11 GPIO_ACTIVE_LOW>;
+   };
+
+   power_yellow: power_yellow {
+   label = "mir4a-100m:yellow:power";
+   gpios = < 12 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   keys {
+   compatible = "gpio-keys-polled";
+   poll-interval = <20>;
+
+   reset {
+   label = "reset";
+   gpios = < 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+};
+
+ {
+   status = "okay";
+
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <1000>;
+
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "bootloader";
+   reg = <0x0 0x2>;
+   read-only;
+   };
+
+   partition@2 {
+   label = "config";
+   reg = <0x2 0x1>;
+   read-only;
+   };
+
+   factory: partition@3 {
+   label = "factory";
+   reg = <0x3 0x1>;
+   read-only;
+   };
+
+   partition@4 {
+   label = "crash";
+   reg = <0x4 0x1>;
+   read-only;
+   };
+
+   partition@5 {
+   

Re: [OpenWrt-Devel] [PATCH] ath79: Add SUPPORTED_DEVICES for Archer C7 v1/v2

2019-05-27 Thread Adrian Schmutzler
Hi,

> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org] On 
> Behalf Of camden lindsay
> Sent: Donnerstag, 2. Mai 2019 05:38
> To: m...@adrianschmutzler.de
> Cc: Adrian Schmutzler ; OpenWrt Development 
> List ; Tomasz Maciej Nowak ; 
> David Bauer ; Christian Lamparter 
> Subject: Re: [OpenWrt-Devel] [PATCH] ath79: Add SUPPORTED_DEVICES for Archer 
> C7 v1/v2
>
> Hmmm; well, i've got this; Fresh 'firstboot' on an archer c7 V2, following 
> version info:

Thanks for all the testing!

Looks like there is a pull-request addressing the WiFi fix:

https://github.com/openwrt/openwrt/pull/2082

Best

Adrian


pgpD5JRzregTd.pgp
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Support for Edimax EW-7476RPC / EW-7478AC

2019-05-27 Thread Daniel Golle
On Mon, May 27, 2019 at 06:35:30PM +0200, Daniel Golle wrote:
> Hi Birger,
> 
> thanks for submitting your work. In order to support the external
> switch, existing generic features should be used in order to
> implement the phy-reset via GPIO#39.
> See my comments in the code (I commented the first device only, same
> applies to the 2nd device as well).
> 
> On Mon, May 27, 2019 at 05:55:24PM +0200, Birger Koblitz wrote:
> > ramips: add Netgear EW-7476RPC
> > 
> > SoC:   MediaTek MT7620a @ 580MHz
> > RAM:   64M (Winbond W9751G6KB-25)
> > FLASH: 8MB (Macronix)
> > WiFi:  SoC-integrated: MediaTek MT76620a bgn
> 
> Typo, I supposed. MT7620a (or RT6352 to name the embedded WiFi IP)
> 
> > WiFi:  MediaTek MT7612EN nac
> > GBE:   RTL8211E
> 
> Please mention how many phyical ports the device got and if all of
> them support GbE.

Sorry, that was stupid of me. I just realized we are talking about a
wall-wart:
https://fccid.io/NDD9574761501/Internal-Photos/Internal-Photos-2706172

So it's a simple PHY with 1x GbE obviously ;)

> 
> > BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
> > LED:    - Wifi 5g (blue)
> >     - Wifi 2g (blue)
> >     - Crossband (green)
> >     - Power (green)
> >     - WPS (green)
> >     - LAN (Green)
> > UART:  UART is present as Pads with throughholes on the PCB. They are
> >    located next to the switch for the wifi configuration
> >    3.3V - RX - GND - TX / 57600-8N1
> >    3.3V is the square pad
> > 
> > Installation
> > 
> > Update the factory image via the web-interfaces (by default:
> > 192.168.9.2/24).
> > http://192.168.9.2/index.asp
> > 
> > ramips: add Netgear EW-7478AC
> > 
> > SoC:   MediaTek MT7620a @ 580MHz
> > RAM:   64M (Winbond W9751G6KB-25)
> > FLASH: 8MB (Macronix)
> > WiFi:  SoC-integrated: MediaTek MT76620a bgn
> Same here
> 
> > WiFi:  MediaTek MT7612EN nac
> > GBE:   RTL8211E
> > BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
> > LED:    - Wifi 5g (blue)
> >     - Wifi 2g (blue)
> >     - Crossband (green)
> >     - Power (green)
> >     - WPS (green)
> >     - LAN (Green)
> > UART:  UART is present as Pads with throughholes on the PCB. They are
> >    located next to the switch for the wifi configuration
> >    3.3V - RX - GND - TX / 57600-8N1
> >    3.3V is the square pad
> > 
> > Installation
> > 
> > Update the factory image via the web-interfaces (by default:
> > http://edimaxext.setup)
> > Or push wpa button on power on and send firmware via tftp to 192.168.1.6
> > 
> > The EW-7478AC is identical to the EW-7476RPC, except instead of 2 internal
> > antennas it has 2 external ones.
> > 
> > 
> > diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds
> > b/target/linux/ramips/base-files/etc/board.d/01_leds
> > index b55ca0413e..78e93b557b 100755
> > --- a/target/linux/ramips/base-files/etc/board.d/01_leds
> > +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
> > @@ -146,6 +146,10 @@ dir-860l-b1)
> >  edimax,br-6478ac-v2)
> >     set_wifi_led "$boardname:blue:wlan"
> >     ;;
> > +edimax,ew-7476rpc|\
> > +edimax,ew-7478ac)
> > +    ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" 
> > "switch0" "0x20"
> > +    ;;
> >  ex2700|\
> >  wn3000rpv3)
> >     set_wifi_led "$boardname:green:router"
> > diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
> > b/target/linux/ramips/base-files/etc/board.d/02_network
> > index 2e56678cf5..bbdfe9b128 100755
> > --- a/target/linux/ramips/base-files/etc/board.d/02_network
> > +++ b/target/linux/ramips/base-files/etc/board.d/02_network
> > @@ -50,6 +50,8 @@ ramips_setup_interfaces()
> >     broadway|\
> >     dcs-930|\
> >     dcs-930l-b1|\
> > +   edimax,ew-7476rpc|\
> > +   edimax,ew-7478ac|\
> >     ht-tm02|\
> >     kimax,u35wf|\
> >     linkits7688 | \
> > diff --git a/target/linux/ramips/dts/EW-7476RPC.dts
> > b/target/linux/ramips/dts/EW-7476RPC.dts
> > new file mode 100644
> > index 00..7a1edf3e4d
> > --- /dev/null
> > +++ b/target/linux/ramips/dts/EW-7476RPC.dts
> > @@ -0,0 +1,238 @@
> > +/*
> > + * Device Tree file for the Edimax EW-7476RPC
> > + * based on Edimax BR-6478AC V2
> > + *
> > + * Copyright (C) 2016 Rohan Murch 
> > + * Copyright (C) 2016 Hans Ulli Kroll 
> > + * Copyright (C) 2017 James McKenzie 
> > + *
> > + * This file is licensed under the terms of the GNU General Public
> > + * License version 2.  This program is licensed "as is" without any
> > + * warranty of any kind, whether express or implied.
> > +
> > + The following definitions were found in the orignal GPL firmware source
> > + HW_LED_WIRELESS_ABAND_="71"
> > + HW_LED_WIRELESS_GBAND_="70"
> > + HW_LED_WIRELES_="69"
> > + HW_LED_POWER_="67"
> > + HW_LED_WPS_="68"
> > + HW_LED_LAN_="66"
> > + HW_BUTTON_APSWITCH_BUT_1_="62"
> > + HW_BUTTON_APSWITCH_BUT_2_="63"
> > + HW_BUTTON_RESET_="60"
> > +
> > + The device does not have a reset button (but there are solder pads for

Re: [OpenWrt-Devel] [PATCH] Support for Edimax EW-7476RPC / EW-7478AC

2019-05-27 Thread Daniel Golle
Hi Birger,

thanks for submitting your work. In order to support the external
switch, existing generic features should be used in order to
implement the phy-reset via GPIO#39.
See my comments in the code (I commented the first device only, same
applies to the 2nd device as well).

On Mon, May 27, 2019 at 05:55:24PM +0200, Birger Koblitz wrote:
> ramips: add Netgear EW-7476RPC
> 
> SoC:   MediaTek MT7620a @ 580MHz
> RAM:   64M (Winbond W9751G6KB-25)
> FLASH: 8MB (Macronix)
> WiFi:  SoC-integrated: MediaTek MT76620a bgn

Typo, I supposed. MT7620a (or RT6352 to name the embedded WiFi IP)

> WiFi:  MediaTek MT7612EN nac
> GBE:   RTL8211E

Please mention how many phyical ports the device got and if all of
them support GbE.

> BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
> LED:    - Wifi 5g (blue)
>     - Wifi 2g (blue)
>     - Crossband (green)
>     - Power (green)
>     - WPS (green)
>     - LAN (Green)
> UART:  UART is present as Pads with throughholes on the PCB. They are
>    located next to the switch for the wifi configuration
>    3.3V - RX - GND - TX / 57600-8N1
>    3.3V is the square pad
> 
> Installation
> 
> Update the factory image via the web-interfaces (by default:
> 192.168.9.2/24).
> http://192.168.9.2/index.asp
> 
> ramips: add Netgear EW-7478AC
> 
> SoC:   MediaTek MT7620a @ 580MHz
> RAM:   64M (Winbond W9751G6KB-25)
> FLASH: 8MB (Macronix)
> WiFi:  SoC-integrated: MediaTek MT76620a bgn
Same here

> WiFi:  MediaTek MT7612EN nac
> GBE:   RTL8211E
> BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
> LED:    - Wifi 5g (blue)
>     - Wifi 2g (blue)
>     - Crossband (green)
>     - Power (green)
>     - WPS (green)
>     - LAN (Green)
> UART:  UART is present as Pads with throughholes on the PCB. They are
>    located next to the switch for the wifi configuration
>    3.3V - RX - GND - TX / 57600-8N1
>    3.3V is the square pad
> 
> Installation
> 
> Update the factory image via the web-interfaces (by default:
> http://edimaxext.setup)
> Or push wpa button on power on and send firmware via tftp to 192.168.1.6
> 
> The EW-7478AC is identical to the EW-7476RPC, except instead of 2 internal
> antennas it has 2 external ones.
> 
> 
> diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds
> b/target/linux/ramips/base-files/etc/board.d/01_leds
> index b55ca0413e..78e93b557b 100755
> --- a/target/linux/ramips/base-files/etc/board.d/01_leds
> +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
> @@ -146,6 +146,10 @@ dir-860l-b1)
>  edimax,br-6478ac-v2)
>     set_wifi_led "$boardname:blue:wlan"
>     ;;
> +edimax,ew-7476rpc|\
> +edimax,ew-7478ac)
> +    ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" 
> "switch0" "0x20"
> +    ;;
>  ex2700|\
>  wn3000rpv3)
>     set_wifi_led "$boardname:green:router"
> diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
> b/target/linux/ramips/base-files/etc/board.d/02_network
> index 2e56678cf5..bbdfe9b128 100755
> --- a/target/linux/ramips/base-files/etc/board.d/02_network
> +++ b/target/linux/ramips/base-files/etc/board.d/02_network
> @@ -50,6 +50,8 @@ ramips_setup_interfaces()
>     broadway|\
>     dcs-930|\
>     dcs-930l-b1|\
> +   edimax,ew-7476rpc|\
> +   edimax,ew-7478ac|\
>     ht-tm02|\
>     kimax,u35wf|\
>     linkits7688 | \
> diff --git a/target/linux/ramips/dts/EW-7476RPC.dts
> b/target/linux/ramips/dts/EW-7476RPC.dts
> new file mode 100644
> index 00..7a1edf3e4d
> --- /dev/null
> +++ b/target/linux/ramips/dts/EW-7476RPC.dts
> @@ -0,0 +1,238 @@
> +/*
> + * Device Tree file for the Edimax EW-7476RPC
> + * based on Edimax BR-6478AC V2
> + *
> + * Copyright (C) 2016 Rohan Murch 
> + * Copyright (C) 2016 Hans Ulli Kroll 
> + * Copyright (C) 2017 James McKenzie 
> + *
> + * This file is licensed under the terms of the GNU General Public
> + * License version 2.  This program is licensed "as is" without any
> + * warranty of any kind, whether express or implied.
> +
> + The following definitions were found in the orignal GPL firmware source
> + HW_LED_WIRELESS_ABAND_="71"
> + HW_LED_WIRELESS_GBAND_="70"
> + HW_LED_WIRELES_="69"
> + HW_LED_POWER_="67"
> + HW_LED_WPS_="68"
> + HW_LED_LAN_="66"
> + HW_BUTTON_APSWITCH_BUT_1_="62"
> + HW_BUTTON_APSWITCH_BUT_2_="63"
> + HW_BUTTON_RESET_="60"
> +
> + The device does not have a reset button (but there are solder pads for
> a button), WPS and reset are swapped.
> +
> + */
> +
> +/dts-v1/;
> +
> +#include "mt7620a.dtsi"
> +
> +#include 
> +#include 
> +
> +/ {
> +   compatible = "edimax,ew-7476rpc", "ralink,mt7620a-soc";
> +   model = "Edimax EW-7476RPC";
> +
> +   aliases {
> +   led-boot = _power;
> +   led-failsafe = _power;
> +   led-running = _power;
> +   led-upgrade = _power;
> +   };
> +
> +   chosen {
> +   bootargs = "console=ttyS0,57600";
> +   };
> +
> 

Re: [OpenWrt-Devel] [PATCH 3/3] x86: add preinit hook for bootloader upgrade

2019-05-27 Thread Petr Štetiar
Tomasz Maciej Nowak  [2019-05-27 14:46:30]:

Hi,

> new file mode 100644
> index 00..3a4e756b1e
> --- /dev/null
> +++ b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader

makes me wonder if this couldn't be made more generic as for example current
sysupgrade.tgz restoration, maybe adding platform_do_bootloader_upgrade hook
which would get called in some generic preinit script or something along these
lines.  Otherwise we're likely risking copy of similar functionality
to other platforms.

> +upgrade_bootloader() {
> + local diskdev
> +
> + . /lib/upgrade/common.sh
> +
> + if [ ! -f /boot/grub/upgraded ] && export_bootdevice && 
> export_partdevice diskdev 0; then
> + echo "(hd0) /dev/$diskdev" > /tmp/device.map
> + /usr/sbin/grub-bios-setup \
> + -m "/tmp/device.map" \
> + -d "/boot/grub" \
> + -r "hd0,msdos1" \
> + "/dev/$diskdev" \
> + && touch /boot/grub/upgraded

This looks like almost same code used in two places, probably could be
refactored in some common function used in both places?

> diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh 
> b/target/linux/x86/base-files/lib/upgrade/platform.sh
> index 1a42fd3a11..05bbd97f3b 100644
> --- a/target/linux/x86/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
> @@ -106,7 +106,8 @@ platform_do_upgrade() {
>   -m "/tmp/device.map" \
>   -d "/tmp/boot/boot/grub" \
>   -r "hd0,msdos1" \
> - "/dev/$diskdev"
> + "/dev/$diskdev" \
> + && touch /boot/grub/upgraded

This probably should be in your other patch?

> Currently bootloader always stays on the same version as when first
> written to boot medium. That creates inconveniences as it always stays
> with same features or/and bugs. Users wishing to add support to
> additional modules or new version, would need to write the whole image,
> potentially destroying previous system configuration. To fix these, this
> commit adds additional routine to sysupgrade which upgrades
> unconditionally the bootloader to the latest state provided by OpenWrt.

[...]

> + #upgrade bootloader

This kind of comments are quite useless, I would rather use properly named
function for self documenting code, like:

 if export_partdevice bootpart 1; then
 upgrade_bootloader
 fi

> + if export_partdevice bootpart 1; then
> + mkdir -p /tmp/boot
> + mount -o rw,noatime "/dev/$bootpart" /tmp/boot
> + echo "(hd0) /dev/$diskdev" > /tmp/device.map
> +
> + echo "Upgrading bootloader on /dev/$diskdev..."
> + grub-bios-setup \
> + -m "/tmp/device.map" \
> + -d "/tmp/boot/boot/grub" \
> + -r "hd0,msdos1" \
> + "/dev/$diskdev"
> +
> + umount /tmp/boot
> + fi

This looks similar to the above, could be probably shared.

-- ynezz

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


[OpenWrt-Devel] [PATCH] Support for Edimax EW-7476RPC / EW-7478AC

2019-05-27 Thread Birger Koblitz
ramips: add Netgear EW-7476RPC

SoC:   MediaTek MT7620a @ 580MHz
RAM:   64M (Winbond W9751G6KB-25)
FLASH: 8MB (Macronix)
WiFi:  SoC-integrated: MediaTek MT76620a bgn
WiFi:  MediaTek MT7612EN nac
GBE:   RTL8211E
BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
LED:    - Wifi 5g (blue)
    - Wifi 2g (blue)
    - Crossband (green)
    - Power (green)
    - WPS (green)
    - LAN (Green)
UART:  UART is present as Pads with throughholes on the PCB. They are
   located next to the switch for the wifi configuration
   3.3V - RX - GND - TX / 57600-8N1
   3.3V is the square pad

Installation

Update the factory image via the web-interfaces (by default:
192.168.9.2/24).
http://192.168.9.2/index.asp

ramips: add Netgear EW-7478AC

SoC:   MediaTek MT7620a @ 580MHz
RAM:   64M (Winbond W9751G6KB-25)
FLASH: 8MB (Macronix)
WiFi:  SoC-integrated: MediaTek MT76620a bgn
WiFi:  MediaTek MT7612EN nac
GBE:   RTL8211E
BTN:   WPS - RFKILL/RF 50%/RF 100% toggle
LED:    - Wifi 5g (blue)
    - Wifi 2g (blue)
    - Crossband (green)
    - Power (green)
    - WPS (green)
    - LAN (Green)
UART:  UART is present as Pads with throughholes on the PCB. They are
   located next to the switch for the wifi configuration
   3.3V - RX - GND - TX / 57600-8N1
   3.3V is the square pad

Installation

Update the factory image via the web-interfaces (by default:
http://edimaxext.setup)
Or push wpa button on power on and send firmware via tftp to 192.168.1.6

The EW-7478AC is identical to the EW-7476RPC, except instead of 2 internal
antennas it has 2 external ones.


diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds
b/target/linux/ramips/base-files/etc/board.d/01_leds
index b55ca0413e..78e93b557b 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -146,6 +146,10 @@ dir-860l-b1)
 edimax,br-6478ac-v2)
    set_wifi_led "$boardname:blue:wlan"
    ;;
+edimax,ew-7476rpc|\
+edimax,ew-7478ac)
+    ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" 
"switch0" "0x20"
+    ;;
 ex2700|\
 wn3000rpv3)
    set_wifi_led "$boardname:green:router"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
b/target/linux/ramips/base-files/etc/board.d/02_network
index 2e56678cf5..bbdfe9b128 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -50,6 +50,8 @@ ramips_setup_interfaces()
    broadway|\
    dcs-930|\
    dcs-930l-b1|\
+   edimax,ew-7476rpc|\
+   edimax,ew-7478ac|\
    ht-tm02|\
    kimax,u35wf|\
    linkits7688 | \
diff --git a/target/linux/ramips/dts/EW-7476RPC.dts
b/target/linux/ramips/dts/EW-7476RPC.dts
new file mode 100644
index 00..7a1edf3e4d
--- /dev/null
+++ b/target/linux/ramips/dts/EW-7476RPC.dts
@@ -0,0 +1,238 @@
+/*
+ * Device Tree file for the Edimax EW-7476RPC
+ * based on Edimax BR-6478AC V2
+ *
+ * Copyright (C) 2016 Rohan Murch 
+ * Copyright (C) 2016 Hans Ulli Kroll 
+ * Copyright (C) 2017 James McKenzie 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+
+ The following definitions were found in the orignal GPL firmware source
+ HW_LED_WIRELESS_ABAND_="71"
+ HW_LED_WIRELESS_GBAND_="70"
+ HW_LED_WIRELES_="69"
+ HW_LED_POWER_="67"
+ HW_LED_WPS_="68"
+ HW_LED_LAN_="66"
+ HW_BUTTON_APSWITCH_BUT_1_="62"
+ HW_BUTTON_APSWITCH_BUT_2_="63"
+ HW_BUTTON_RESET_="60"
+
+ The device does not have a reset button (but there are solder pads for
a button), WPS and reset are swapped.
+
+ */
+
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include 
+#include 
+
+/ {
+   compatible = "edimax,ew-7476rpc", "ralink,mt7620a-soc";
+   model = "Edimax EW-7476RPC";
+
+   aliases {
+   led-boot = _power;
+   led-failsafe = _power;
+   led-running = _power;
+   led-upgrade = _power;
+   };
+
+   chosen {
+   bootargs = "console=ttyS0,57600";
+   };
+
+
+   keys {
+    compatible = "gpio-keys";
+
+    reset_wps {
+    label = "reset_wps";
+    gpios = < 20 GPIO_ACTIVE_LOW>;
+    linux,code = ;
+    };
+   switch_high {
+   label = "switch high";
+   gpios = < 22 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   linux,input-type = ;
+   };
+   switch_off {
+   label = "switch off";
+   gpios = < 23 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   linux,input-type = ;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+ 

[OpenWrt-Devel] [PATCH v2] opkg: add License info

2019-05-27 Thread Paul Spooren
show license in `opkg info `.

CC: Jo-Philipp Wich 
Signed-off-by: Paul Spooren 
---
 libopkg/opkg_cmd.c  |  3 +++
 libopkg/pkg.c   | 10 ++
 libopkg/pkg.h   |  1 +
 libopkg/pkg_parse.c |  5 +
 libopkg/pkg_parse.h |  1 +
 5 files changed, 20 insertions(+)

diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index c823df8..81f9a29 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -45,7 +45,10 @@ static void print_pkg(pkg_t * pkg)
 {
char *version = pkg_version_str_alloc(pkg);
char *description = pkg_get_string(pkg, PKG_DESCRIPTION);
+   char *license = pkg_get_string(pkg, PKG_LICENSE);
printf("%s - %s", pkg->name, version);
+   if (license)
+   printf(" - %s", license);
if (conf->size)
printf(" - %lu", (unsigned long) pkg_get_int(pkg, PKG_SIZE));
if (description)
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index e5bfe6f..1971689 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -777,6 +777,15 @@ void pkg_formatted_field(FILE * fp, pkg_t * pkg, const 
char *field)
}
}
break;
+   case 'l':
+   case 'L':
+   if (strcasecmp(field, "License") == 0) {
+   p = pkg_get_string(pkg, PKG_LICENSE);
+   if (p) {
+   fprintf(fp, "License: %s\n", p);
+   }
+   }
+   break;
case 'm':
case 'M':
if (strcasecmp(field, "Maintainer") == 0) {
@@ -926,6 +935,7 @@ void pkg_formatted_info(FILE * fp, pkg_t * pkg)
pkg_formatted_field(fp, pkg, "Package");
pkg_formatted_field(fp, pkg, "Version");
pkg_formatted_field(fp, pkg, "Depends");
+   pkg_formatted_field(fp, pkg, "License");
pkg_formatted_field(fp, pkg, "Recommends");
pkg_formatted_field(fp, pkg, "Suggests");
pkg_formatted_field(fp, pkg, "Provides");
diff --git a/libopkg/pkg.h b/libopkg/pkg.h
index 600fc9e..0065043 100644
--- a/libopkg/pkg.h
+++ b/libopkg/pkg.h
@@ -79,6 +79,7 @@ typedef enum pkg_state_status pkg_state_status_t;
 
 enum pkg_fields {
PKG_MAINTAINER,
+   PKG_LICENSE,
PKG_PRIORITY,
PKG_SOURCE,
PKG_TAGS,
diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c
index 0baa4db..a294258 100644
--- a/libopkg/pkg_parse.c
+++ b/libopkg/pkg_parse.c
@@ -269,6 +269,11 @@ int pkg_parse_line(void *ptr, char *line, uint mask)
pkg_set_int(pkg, PKG_INSTALLED_TIME, strtoul(line + 
strlen("Installed-Time") + 1, NULL, 0));
}
break;
+   case 'l':
+   case 'L':
+   if ((mask & PFM_LICENSE) && is_field("License", line))
+   pkg_set_string(pkg, PKG_LICENSE, line + 
strlen("License") + 1);
+   break;
 
case 'M':
if ((mask & PFM_MD5SUM) && (is_field("MD5sum:", line) || 
is_field("MD5Sum:", line)))
diff --git a/libopkg/pkg_parse.h b/libopkg/pkg_parse.h
index d1f901a..ccb97aa 100644
--- a/libopkg/pkg_parse.h
+++ b/libopkg/pkg_parse.h
@@ -54,6 +54,7 @@ int pkg_parse_line(void *ptr, char *line, uint mask);
 #define PFM_SUGGESTS   (1 << 25)
 #define PFM_TAGS   (1 << 26)
 #define PFM_VERSION(1 << 27)
+#define PFM_LICENSE(1 << 28)
 
 #define PFM_ALL(~(uint)0)
 
-- 
2.20.1


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


Re: [OpenWrt-Devel] dnsmasq not leasing after a while. Sometimes more than 5 times a day

2019-05-27 Thread Denis Periša
Yes, dnsmasq is still running but lease is not given.. I don't know how to
debug it more.
Configuration is simple, one subnet range 192.168.0.10 to 192.168.0.200 on
wlan0 interface for example. But it's not wifi issue, local also.
It sends mail as soon as error is detected and restarts dnsmasq after which
it works. Device is not rebooting.
 OpenWrt 18.06-SNAPSHOT, r7766-e9a7344550

Also my scripts checkes two times just to rule out false negative.
Also, more public exposure or none is pretty much same.. I have device
which gets maybe 1-2 person and one with 50 .. behaving same. After a while
it stops responding. Any more debug I could use somewhere?

On Mon, May 27, 2019 at 2:37 PM Vincent Wiemann 
wrote:

> Hi Denis,
>
> I don't have such problems. Please post your configuration and device
> setup and try to
> get some logs. As far as I understand dnsmasq is unresponsible, but still
> runs?!
> What do you mean with "restart messages"? Are your devices rebooting?
>
> Regards,
>
> Vincent Wiemann
>
> On 27.05.19 13:43, Denis Periša wrote:
> > Hi all,
> >
> > This "bug" is following me for some time now.. a year at least. I'm
> hoping day after day that someone might find reason and fix it. I've set a
> script that checks dnsmasq and restarts it.
> >
> > -->
> >  if ! ( dhcping -q -h 00:99:99:99:99:99 -s 10.0.0.1 ) #Jos jedna
> provjera
> > then
> > echo "DEAD dnsmasq! - `date` " >>
> /scripts/CRASH.log
> > killall dnsmasq
> > sleep 2
> > dnsmasq;
> >  .>. etc... CUT ---
> >
> > two checks to be sure... and I get a lot of restart messages. different
> nodes.
> > I run this via cron every half hour.
> >
> > Anyone have similar problem?
> >
> > ___
> > openwrt-devel mailing list
> > openwrt-devel@lists.openwrt.org
> > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> >
>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH RFC 0/5] ath79: add micro non-physical true RNG based on timing jitter

2019-05-27 Thread Etienne Champetier
Hi Petr,

Le lun. 27 mai 2019 à 10:00, Petr Štetiar  a écrit :
>
> Etienne Champetier  [2019-05-25 12:43:25]:
>
> > Just to be clear i'm 100% in favor of your effort to have random pool init
> > done fast on all devices, and your solution, based on Stephan awsome work,
> > seems really good I just want to be sure we don't make some devices worse /
> > are not missing something
>
> FYI, I've just added more devices to the testing before submitting the next
> round of patches, and got following on the MT7620A based device:
>
>  root@OpenWrt:/# cat /proc/cpuinfo
>  system type : MediaTek MT7620A ver:2 eco:6
>  machine : BDCOM WAP2100-SK
>  processor   : 0
>  cpu model   : MIPS 24KEc V5.0
>
>  root@OpenWrt:/# cat 
> /sys/devices/system/clocksource/clocksource0/available_clocksource
>  systick MIPS
>
>  root@OpenWrt:/# /sbin/urngd
>  jent-rng init failed, err: 2
>
> Where that error 2 is ECOARSETIME. It makes me wonder if there's something
> which could be tweaked on kernel side in order to provide better environment
> for jent-rng on this quite still popular SoC.

The fact that missing high precision timer is properly detected is a good news,
but now that means you really need to provide a fallback, else
removing urandom-seed is a regression

>
> -- ynezz

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


Re: [OpenWrt-Devel] [PATCH RFC 0/5] ath79: add micro non-physical true RNG based on timing jitter

2019-05-27 Thread Stephan Mueller
Am Montag, 27. Mai 2019, 15:00:23 CEST schrieb Petr Štetiar:

Hi Petr,

> Etienne Champetier  [2019-05-25 12:43:25]:
> > Just to be clear i'm 100% in favor of your effort to have random pool init
> > done fast on all devices, and your solution, based on Stephan awsome work,
> > seems really good I just want to be sure we don't make some devices worse
> > /
> > are not missing something
> 
> FYI, I've just added more devices to the testing before submitting the next
> round of patches, and got following on the MT7620A based device:
> 
>  root@OpenWrt:/# cat /proc/cpuinfo
>  system type : MediaTek MT7620A ver:2 eco:6
>  machine : BDCOM WAP2100-SK
>  processor   : 0
>  cpu model   : MIPS 24KEc V5.0
> 
>  root@OpenWrt:/# cat
> /sys/devices/system/clocksource/clocksource0/available_clocksource systick
> MIPS
> 
>  root@OpenWrt:/# /sbin/urngd
>  jent-rng init failed, err: 2
> 
> Where that error 2 is ECOARSETIME. It makes me wonder if there's something
> which could be tweaked on kernel side in order to provide better environment
> for jent-rng on this quite still popular SoC.

The Jitter RNG is dependent on the existence of a high-resolution timer. The 
mentioned system does not seem to have one.

Check /sys/devices/system/clocksource/clocksource0/current_clocksource and /
sys/devices/system/clocksource/clocksource0/available_clocksource


Ciao
Stephan



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


Re: [OpenWrt-Devel] [PATCH RFC 0/5] ath79: add micro non-physical true RNG based on timing jitter

2019-05-27 Thread Petr Štetiar
Etienne Champetier  [2019-05-25 12:43:25]:

> Just to be clear i'm 100% in favor of your effort to have random pool init
> done fast on all devices, and your solution, based on Stephan awsome work,
> seems really good I just want to be sure we don't make some devices worse /
> are not missing something

FYI, I've just added more devices to the testing before submitting the next
round of patches, and got following on the MT7620A based device:

 root@OpenWrt:/# cat /proc/cpuinfo
 system type : MediaTek MT7620A ver:2 eco:6
 machine : BDCOM WAP2100-SK
 processor   : 0
 cpu model   : MIPS 24KEc V5.0

 root@OpenWrt:/# cat 
/sys/devices/system/clocksource/clocksource0/available_clocksource
 systick MIPS

 root@OpenWrt:/# /sbin/urngd 
 jent-rng init failed, err: 2

Where that error 2 is ECOARSETIME. It makes me wonder if there's something
which could be tweaked on kernel side in order to provide better environment
for jent-rng on this quite still popular SoC.

-- ynezz

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


[OpenWrt-Devel] [PATCH 2/3] x86: add bootloader upgrade on sysupgrade

2019-05-27 Thread Tomasz Maciej Nowak
Currently bootloader always stays on the same version as when first
written to boot medium. That creates inconveniences as it always stays
with same features or/and bugs. Users wishing to add support to
additional modules or new version, would need to write the whole image,
potentially destroying previous system configuration. To fix these, this
commit adds additional routine to sysupgrade which upgrades
unconditionally the bootloader to the latest state provided by OpenWrt.

Signed-off-by: Tomasz Maciej Nowak 
---
 package/boot/grub2/Makefile   |  5 +
 .../x86/base-files/lib/upgrade/platform.sh| 20 ++-
 target/linux/x86/image/Makefile   |  7 ---
 3 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/Makefile
index d6af65128e..d3a347ce84 100644
--- a/package/boot/grub2/Makefile
+++ b/package/boot/grub2/Makefile
@@ -83,6 +83,11 @@ define Host/Configure
$(Host/Configure/Default)
 endef
 
+define Package/grub2/install
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-bios-setup $(1)/usr/sbin/
+endef
+
 define Package/grub2-editenv/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-editenv $(1)/usr/sbin/
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh 
b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 439ba8f512..1a42fd3a11 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -1,3 +1,5 @@
+RAMFS_COPY_BIN='grub-bios-setup'
+
 platform_check_image() {
local diskdev partdev diff
[ "$#" -gt 1 ] && return 1
@@ -45,7 +47,7 @@ platform_copy_config() {
 }
 
 platform_do_upgrade() {
-   local diskdev partdev diff
+   local diskdev partdev diff bootpart
 
export_bootdevice && export_partdevice diskdev 0 || {
echo "Unable to determine upgrade device"
@@ -92,4 +94,20 @@ platform_do_upgrade() {
#copy partition uuid
echo "Writing new UUID to /dev/$diskdev..."
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 
conv=fsync
+
+   #upgrade bootloader
+   if export_partdevice bootpart 1; then
+   mkdir -p /tmp/boot
+   mount -o rw,noatime "/dev/$bootpart" /tmp/boot
+   echo "(hd0) /dev/$diskdev" > /tmp/device.map
+
+   echo "Upgrading bootloader on /dev/$diskdev..."
+   grub-bios-setup \
+   -m "/tmp/device.map" \
+   -d "/tmp/boot/boot/grub" \
+   -r "hd0,msdos1" \
+   "/dev/$diskdev"
+
+   umount /tmp/boot
+   fi
 }
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index ca5fd72153..7f69f35ae8 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -67,11 +67,11 @@ ifneq ($(CONFIG_GRUB_IMAGES),)
grub-mkimage \
-p /boot/grub \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
-   -o $(KDIR)/grub2/core.img \
+   -o $(KDIR)/root.grub/boot/grub/core.img \
-O i386-pc \
-c ./grub-early.cfg \
$(GRUB2_MODULES)
-   $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/
+   $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img 
$(KDIR)/root.grub/boot/grub/
echo '(hd0) $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img' > 
$(KDIR)/grub2/device.map
sed \
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
@@ -81,6 +81,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),)
-e 's#@TITLE@#$(GRUB_TITLE)#g' \
./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
-$(CP) $(STAGING_DIR_ROOT)/boot/. $(KDIR)/root.grub/boot/
+   grub-bios-setup -V | cut -d' ' -f3 > $(KDIR)/root.grub/boot/grub/version
PADDING="$(CONFIG_TARGET_IMAGES_PAD)" SIGNATURE="$(SIGNATURE)" 
PATH="$(TARGET_PATH)" $(SCRIPT_DIR)/gen_image_generic.sh \
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \
@@ -88,7 +89,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),)
256
grub-bios-setup \
--device-map="$(KDIR)/grub2/device.map" \
-   -d "$(KDIR)/grub2" \
+   -d "$(KDIR)/root.grub/boot/grub" \
-r "hd0,msdos1" \
"$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img"
   endef
-- 
2.21.0


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


[OpenWrt-Devel] [PATCH 3/3] x86: add preinit hook for bootloader upgrade

2019-05-27 Thread Tomasz Maciej Nowak
The current OpenWrt installations lack the necessary bits to upgrade
bootloader on sysupgrade, therefore add preinit hook which will perform
upgrade of the bootloader on first boot after sysupgrade.

Signed-off-by: Tomasz Maciej Nowak 
---
 .../lib/preinit/81_upgrade_bootloader | 19 +++
 .../x86/base-files/lib/upgrade/platform.sh|  3 ++-
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 
target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader

diff --git a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader 
b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
new file mode 100644
index 00..3a4e756b1e
--- /dev/null
+++ b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+upgrade_bootloader() {
+   local diskdev
+
+   . /lib/upgrade/common.sh
+
+   if [ ! -f /boot/grub/upgraded ] && export_bootdevice && 
export_partdevice diskdev 0; then
+   echo "(hd0) /dev/$diskdev" > /tmp/device.map
+   /usr/sbin/grub-bios-setup \
+   -m "/tmp/device.map" \
+   -d "/boot/grub" \
+   -r "hd0,msdos1" \
+   "/dev/$diskdev" \
+   && touch /boot/grub/upgraded
+   fi
+}
+
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main upgrade_bootloader
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh 
b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 1a42fd3a11..05bbd97f3b 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -106,7 +106,8 @@ platform_do_upgrade() {
-m "/tmp/device.map" \
-d "/tmp/boot/boot/grub" \
-r "hd0,msdos1" \
-   "/dev/$diskdev"
+   "/dev/$diskdev" \
+   && touch /boot/grub/upgraded
 
umount /tmp/boot
fi
-- 
2.21.0


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


[OpenWrt-Devel] [PATCH 1/3] x86: image: cleanup before creating image

2019-05-27 Thread Tomasz Maciej Nowak
There can be some leftovers from other image recipes, if the same
directory names are used and multiply image types are selected.
Therefore remove directories used in the recipe, before contents for the
image are prepared.

Signed-off-by: Tomasz Maciej Nowak 
---
 target/linux/x86/image/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index 84a3d88a7f..ca5fd72153 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -61,6 +61,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),)
 
   define Image/Build/grub2
# left here because the image builder doesnt need these
+   rm -fR $(KDIR)/root.grub $(KDIR)/grub2
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
grub-mkimage \
@@ -98,6 +99,7 @@ define Image/Build/squashfs
 endef
 
 define Image/Build/iso
+   rm -fR $(KDIR)/root.grub $(KDIR)/grub2
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
grub-mkimage \
-- 
2.21.0


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


[OpenWrt-Devel] [PATCH 0/3] x86: upgrade bootloader on sysupgrade

2019-05-27 Thread Tomasz Maciej Nowak
After gotten bit more familiar with OpenWrt, I found less intrusive
method to implement upgrading of bootloader, instead of rewriting image
generation code like in my previous attempt [1]. It had some value in
itself, so if anyone will request it, I'll respin these patches as
separate series in near future.

https://patchwork.ozlabs.org/cover/1024165

Tomasz Maciej Nowak (3):
  x86: image: cleanup before creating image
  x86: add bootloader upgrade on sysupgrade
  x86: add preinit hook for bootloader upgrade

 package/boot/grub2/Makefile   |  5 +
 .../lib/preinit/81_upgrade_bootloader | 19 +
 .../x86/base-files/lib/upgrade/platform.sh| 21 ++-
 target/linux/x86/image/Makefile   |  9 +---
 4 files changed, 50 insertions(+), 4 deletions(-)
 create mode 100644 
target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader

-- 
2.21.0


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


Re: [OpenWrt-Devel] [PATCH v2] procd: add docker support

2019-05-27 Thread Petr Štetiar
Paul Spooren  [2019-05-27 11:33:29]:

> detects if running in a docker container, which then requires special
> treatment of mounts. OpenWrt within Docker is useful for CI testing.
> 
> Signed-off-by: Paul Spooren 

In case someone would like to take this together with some other procd
changes/patches:

 Acked-by: Petr Štetiar 

-- ynezz

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


Re: [OpenWrt-Devel] dnsmasq not leasing after a while. Sometimes more than 5 times a day

2019-05-27 Thread Vincent Wiemann
Hi Denis,

I don't have such problems. Please post your configuration and device setup and 
try to
get some logs. As far as I understand dnsmasq is unresponsible, but still runs?!
What do you mean with "restart messages"? Are your devices rebooting?

Regards,

Vincent Wiemann

On 27.05.19 13:43, Denis Periša wrote:
> Hi all,
> 
> This "bug" is following me for some time now.. a year at least. I'm hoping 
> day after day that someone might find reason and fix it. I've set a script 
> that checks dnsmasq and restarts it.
> 
> -->
>          if ! ( dhcping -q -h 00:99:99:99:99:99 -s 10.0.0.1 ) #Jos jedna 
> provjera
>                         then
>                                 echo "DEAD dnsmasq! - `date` " >> 
> /scripts/CRASH.log
>                                 killall dnsmasq
>                                 sleep 2
>                                 dnsmasq;
>  .>. etc... CUT ---
> 
> two checks to be sure... and I get a lot of restart messages. different nodes.
> I run this via cron every half hour.
> 
> Anyone have similar problem?
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> 

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


[OpenWrt-Devel] FS#2193 - netdev LED Trigger for pppoe-wan

2019-05-27 Thread Mauro Mozzarelli
This bug has been confirmed by a few reporters. I was wondering if 
anyone is looking into it and if any further feedback is needed.


I am happy to help with testing if a developer would like to get in touch.


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


[OpenWrt-Devel] dnsmasq not leasing after a while. Sometimes more than 5 times a day

2019-05-27 Thread Denis Periša
Hi all,

This "bug" is following me for some time now.. a year at least. I'm hoping
day after day that someone might find reason and fix it. I've set a script
that checks dnsmasq and restarts it.

-->
 if ! ( dhcping -q -h 00:99:99:99:99:99 -s 10.0.0.1 ) #Jos jedna
provjera
then
echo "DEAD dnsmasq! - `date` " >>
/scripts/CRASH.log
killall dnsmasq
sleep 2
dnsmasq;
 .>. etc... CUT ---

two checks to be sure... and I get a lot of restart messages. different
nodes.
I run this via cron every half hour.

Anyone have similar problem?
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2] procd: add docker support

2019-05-27 Thread Paul Spooren
detects if running in a docker container, which then requires special
treatment of mounts. OpenWrt within Docker is useful for CI testing.

Signed-off-by: Paul Spooren 
---
 container.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/container.h b/container.h
index d33fa32..dd2e432 100644
--- a/container.h
+++ b/container.h
@@ -16,9 +16,11 @@
 
 #include 
 #include 
+#include 
 
 static inline bool is_container() {
-   return !!getenv("container");
+   struct stat s;
+   return !!getenv("container") || !!stat("/.dockerenv", );
 }
 
 #endif
-- 
2.20.1


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


Re: [OpenWrt-Devel] [PATCH] kernel: Move some DSA config options to generic config

2019-05-27 Thread Linus Walleij
On Sun, May 26, 2019 at 11:46 PM Hauke Mehrtens  wrote:
> On 5/24/19 11:09 PM, Linus Walleij wrote:
> > Hi Hauke,
> >
> > this patch regresses my Gemini systems because I really need these switches
> > to come up and this patch:
>
> Sorry Linus,
>
> I didn't know that they are needed, I assumed that they were
> accidentally added for the gemini target, on the ath79 target these
> options were not defined by the build system for kernel 4.19 at all.

Don't worry I find all the bugs :)

For ath79 CONFIG_NET_DSA_VITESSE_VSC73XX it is however
pretty relevant I think!

The AR71xx v4.14 kernel at
ar71xx/files/drivers/spi/spi-vsc7385.c
there is some OpenWrt custom driver for the VSC7385 that is
used by the PB44 board and added in patch:
patches-4.14/606-MIPS-ath79-pb44-fixes.patch
this should be covered by the new upstream driver in v4.19, but
I don't have this router so I cannot really enable it. I think it
will be possible to just enable the driver for use without any
of the special firmware that is provided for PB44 in the
OpenWrt tree.

The best would be if PB44 would be converted to device tree to
use it, but I suppose it is also possible to patch
drivers/net/dsa/vitesse-vsc73xx.c to use the boardfile.

> Are both switches found on some of the gemini board? I will add them again.

Yep the RTL8366RB is on the DIR-685 and the Vitesse variants
are on the SQ201.

Yours,
Linus Walleij

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