Browse Source

update to openwrt-19.07

pull/62/head
Mart 2 months ago
parent
commit
663d07d981
32 changed files with 216 additions and 4517 deletions
  1. 1
    1
      README.md
  2. 4
    3
      feeds.conf
  3. 1
    1
      files/etc/config/freifunk
  4. 2
    0
      files/etc/crontabs/root
  5. 118
    12
      files/etc/uci-defaults/50_freifunk-setup
  6. 4
    4
      files/www/lan/network.js
  7. 2
    2
      patches/openwrt/0001-hostapd-prevent-channel-switch-for-5GHz.patch
  8. 0
    115
      patches/openwrt/0001-procd-add-support-for-alternative-rc.d-directories.patch
  9. 0
    50
      patches/openwrt/0002-base-files-disable-reset-button-handling.patch
  10. 2
    2
      patches/openwrt/0002-kernel-ebtables-add-support-for-ICMP-IGMP-type-match.patch
  11. 2
    2
      patches/openwrt/0003-ath10k-ct-reduce-memory-consumption.patch
  12. 0
    117
      patches/openwrt/0004-libjson-c-Add-support-for-custom-format-strings-for-.patch
  13. 4
    4
      patches/openwrt/0004-tools-mktplinkfw2-add-split-uboot-layout.patch
  14. 0
    77
      patches/openwrt/0005-dropbear-add-a-failsafe-mode-that-will-always-allow-.patch
  15. 2
    2
      patches/openwrt/0005-mac80211-ath10k-support-for-multicast-and-management.patch
  16. 2
    2
      patches/openwrt/0006-ath10k-ct-support-for-multicast-and-management-rate-.patch
  17. 0
    478
      patches/openwrt/0006-generic-vxlan-backport-support-for-VXLAN-over-link-l.patch
  18. 2
    2
      patches/openwrt/0007-ath10k-ct-fix-incorrect-multicast-broadcast-rate-set.patch
  19. 0
    1048
      patches/openwrt/0008-ipq40xx-add-support-for-the-ZyXEL-NBG6617.patch
  20. 2
    2
      patches/openwrt/0008-mac80211-ath10k-fix-incorrect-multicast-broadcast-ra.patch
  21. 0
    796
      patches/openwrt/0009-build-add-mkrasimage.patch
  22. 65
    0
      patches/openwrt/0009-firmware-utils-tplink-safeloader-Add-CPE210-v3.patch
  23. 0
    33
      patches/openwrt/0010-ipq40xx-fix-NBG6617-LED-mapping.patch
  24. 0
    384
      patches/openwrt/0013-ramips-add-support-for-Archer-C50-v4.patch
  25. 0
    283
      patches/openwrt/0016-ramips-add-support-for-Netgear-R6120.patch
  26. 0
    489
      patches/openwrt/0017-tools-add-zip-utility.patch
  27. 0
    479
      patches/openwrt/0018-firmware-utils-add-sercomm-netgear-tool.patch
  28. 0
    32
      patches/openwrt/0021-ramips-fix-R6120-factory-image.patch
  29. 0
    45
      patches/openwrt/0022-extend-small-flash-option.patch
  30. 0
    24
      patches/openwrt/0023-remove-default-selection-of-ppp.patch
  31. 3
    3
      patches/routing/0001-alfred-adjust-intervals.patch
  32. 0
    25
      patches/routing/0001-batman-adv-set-routing_algo-in-etc-config-batman-adv.patch

+ 1
- 1
README.md View File

@@ -25,7 +25,7 @@ Build commands for the console:
```bash
git clone git://git.openwrt.org/source.git
cd source
git reset --hard fc1dae5be797f54d45f5a61ae17fe548e108dd0d
git reset --hard a941d39460b67d2d21e86d9c73d3e9b099b2d7fb
git clone https://github.com/ffbsee/ffbsee-firmware.git
cp -rf ffbsee-firmware/files ffbsee-firmware/package ffbsee-firmware/feeds.conf .

+ 4
- 3
feeds.conf View File

@@ -1,3 +1,4 @@
src-git packages https://github.com/openwrt/packages.git^5d3cb594e49132158ca7b41f4246421078e8f92a
src-git luci https://github.com/openwrt/luci.git^b99e77d5c36a9d51559bae3bb61a138695d60b95
src-git routing https://github.com/openwrt-routing/packages.git^7589804a56baac804421b492c93004c28a627abb
src-git packages https://git.openwrt.org/feed/packages.git^42a98950b8ecd47706275ac3601ecc5525075580
src-git luci https://git.openwrt.org/project/luci.git^a4dc8f0d8da7da7a3eacce226c5f131431a2409a
src-git routing https://git.openwrt.org/feed/routing.git^66c20292c63a450a6f9926ccc6468d1b417f5306
src-git telephony https://git.openwrt.org/feed/telephony.git^956289cb103e3c44aab183770b765a4af25dd5a3

+ 1
- 1
files/etc/config/freifunk View File

@@ -5,7 +5,7 @@ config settings
option longitude ''
option contact ''
option community 'bodensee'
option version '2.0.0'
option version '2.0.1'
option publish_map 'more'
option ipv6_only 'both'
option allow_access_from 'lan'

+ 2
- 0
files/etc/crontabs/root View File

@@ -4,3 +4,5 @@
*/5 * * * * /usr/sbin/print_map.sh -p
# Publish service data
*/5 * * * * /usr/sbin/print_service.sh -p
# Reboot every 5 days at 04:05
5 4 */5 * * /sbin/reboot

+ 118
- 12
files/etc/uci-defaults/50_freifunk-setup View File

@@ -61,8 +61,8 @@ initial_wifi_setup()
n="network.${wifi_device}_mesh"
uci set $n="interface"
uci set $n.mtu=1532
uci set $n.proto="batadv"
uci set $n.mesh="bat0"
uci set $n.proto="batadv_hardif"
uci set $n.master="bat0"

#ap interface
p="wireless.${wifi_device}_ap"
@@ -175,6 +175,8 @@ initial_local_node_setup()
EOF
}



initial_wan_setup()
{
echo "(I) Setup WAN network."
@@ -212,6 +214,39 @@ initial_wan_setup()
uci set network.wan6_unreachable.interface="loopback"
}

initial_batman_setup()
{
local n

echo "(I) Add network sections to add fastd to batman-adv and set MTU."

n=network.fastd_mesh
uci set $n=interface
uci set $n.ifname='fastd_mesh'
uci set $n.mtu=1406
uci set $n.proto='batadv_hardif'
uci set $n.master='bat0'

n=network.bat0
uci set $n=interface
uci set $n.proto='batadv'
uci set $n.routing_algo='BATMAN_V'
uci set $n.orig_interval=30000
uci set $n.gw_mode='off'
uci set $n.multicast_mode=1

#config mesh 'bat0'
# option orig_interval 30000
# option multicast_mode 1
# option distributed_arp_table 1
# option bridge_loop_avoidance 1
# option aggregated_ogms 1
# option gw_mode 'client'
# option routing_algo 'BATMAN_V'
}



initial_setup()
{
local prefix="fdef:1701:b5ee:23::/64"
@@ -282,16 +317,9 @@ initial_setup()
# B A T M A N S E T U P #
# ------------------------------------- #

echo "(I) Add network sections to add fastd to batman-adv and set MTU."
local n=network.fastd_mesh
uci set $n=interface
uci set $n.ifname=fastd_mesh
uci set $n.mtu=1406
uci set $n.proto="batadv"
uci set $n.mesh="bat0"
uci set $n.mesh_no_rebroadcast="1"

# ------------------------------------- #
initial_batman_setup
# ------------------------------------ #
# M I S C S E T U P #
# ------------------------------------- #

@@ -662,6 +690,61 @@ update_122() {
}

update_200() {

# Preserve self signed certificates
cp /rom/etc/uhttpd.crt /etc/ 2> /dev/null
cp /rom/etc/uhttpd.key /etc/ 2> /dev/null

cp /rom/etc/profile /rom/etc/profile
cp /rom/etc/group /rom/etc/group

# Preserve self signed certificates
cp /rom/etc/uhttpd.crt /etc/ 2> /dev/null
cp /rom/etc/uhttpd.key /etc/ 2> /dev/null

cp /rom/etc/profile /rom/etc/profile
cp /rom/etc/group /rom/etc/group

# Preserve self signed certificates
cp /rom/etc/uhttpd.crt /etc/ 2> /dev/null
cp /rom/etc/uhttpd.key /etc/ 2> /dev/null

cp /rom/etc/profile /rom/etc/profile
cp /rom/etc/group /rom/etc/group


# Rebuild /etc/config/system
local hostname="$(uci get system.@system[0].hostname)"
rm /etc/config/system
/bin/config_generate
uci set system.@system[0].hostname="$hostname"
uci commit system

# Not needed anymore
rm -f /etc/config/batman-adv

# batman-adv config migration
network_bat0_migration() {
local cfg="$1" proto

config_get proto $cfg "proto"
if [ "$proto" = "batadv" -a $cfg != "bat0" ]; then
uci set network.$cfg.proto='batadv_hardif'
uci delete network.$cfg.mesh
uci set network.$cfg.master='bat0'
fi
}

config_load network
config_foreach network_bat0_migration interface

uci -q delete network.fastd_mesh
initial_batman_setup

uci commit network
}

start()
{
echo "(I) Start freifunk_setup"
@@ -695,6 +778,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.0.3*)
@@ -710,6 +794,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.0.4*)
@@ -724,6 +809,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.0.5*)
@@ -737,6 +823,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.0.6*)
@@ -749,6 +836,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.1.0*)
@@ -761,6 +849,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.6.0*)
@@ -772,6 +861,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.6.1*)
@@ -783,6 +873,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.6.2*)
@@ -794,6 +885,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.6.3*)
@@ -805,6 +897,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.6.4*)
@@ -816,6 +909,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
0.7.0*)
@@ -826,6 +920,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
1.0.3*)
@@ -835,6 +930,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
1.0.5*)
@@ -843,6 +939,7 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
1.1.1*)
@@ -850,19 +947,28 @@ start()
update_111
update_114
update_122
update_200
update_version
;;
1.1.4*)
echo "(I) Apply 1.1.4 update."
update_114
update_122
update_200
update_version
;;
1.2.2*)
echo "(I) Apply 1.2.2 update."
update_122
update_200
update_version
;;
2.0.0*)
echo "(I) Apply 2.0.0 update."
update_200
update_version
;;

"")
echo "(I) Start initial setup."
initial_setup

+ 4
- 4
files/www/lan/network.js View File

@@ -156,7 +156,7 @@ function appendSetting(p, path, value, mode)
var val = (src.data || src.value);
if (val != value) {
if (val == "1") {
uci.network['wan_mesh'] = {"stype":"interface", "ifname" : "@wan", "proto" : "batadv", "mesh" : "bat0", "mesh_no_rebroadcast" : "1"};
uci.network['wan_mesh'] = {stype:'interface', ifname : '@wan', proto : 'batadv_hardif', master : 'bat0'};
} else {
delete uci.network['wan_mesh'];
}
@@ -194,7 +194,7 @@ function getInterfaceMode(ifname)
if (inArray(ifname, split(n.wan.ifname)))
return "wan";

if (config_find(n, {"ifname" : ifname, "proto" : "batadv"}))
if (config_find(n, {'ifname' : ifname, 'proto' : 'batadv_hardif'}))
return "mesh";

return "none";
@@ -323,7 +323,7 @@ function addNetSection(ifname, mode)
break;
case "mesh":
var net = ifname.replace(".", "_");
n[net] = {"stype":"interface","ifname":ifname,"mtu":"1406","proto":"batadv","mesh":"bat0","mesh_no_rebroadcast":"1"};
n[net] = {stype: 'interface',ifname: ifname,mtu: '1406',proto: 'batadv_hardif',master: 'bat0'};
break;
case "none":
var net = ifname.replace(".", "_");
@@ -381,7 +381,7 @@ function addWifiSection(device, mode)
// 802.11s
w[ifname] = {"device":device,"stype":"wifi-iface","mode":"mesh","mesh_id":s.default_mesh_id,"mesh_fwding":0,"network":net};
// Connected via option network
n[net] = {"stype":"interface","mtu":"1532","proto":"batadv","mesh":"bat0"};
n[net] = {stype: 'interface',mtu: '1532',proto: 'batadv_hardif',master: 'bat0'};
n.pchanged = true;
break;
case "freifunk":

patches/openwrt/0003-hostapd-prevent-channel-switch-for-5GHz.patch → patches/openwrt/0001-hostapd-prevent-channel-switch-for-5GHz.patch View File

@@ -1,7 +1,7 @@
From 91ddaf27e8f206be1c1ae6a8a653d5d86734905a Mon Sep 17 00:00:00 2001
From a7e511ac9722d67a8358b859afb8324b3def0c36 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Mon, 27 Jul 2015 20:42:50 +0200
Subject: [PATCH 03/23] hostapd: prevent channel switch for 5GHz
Subject: [PATCH 01/10] hostapd: prevent channel switch for 5GHz

hostapd would switch the primary and secondary channel on 5GHz networks in
certain circumstances, completely breaking the adhoc interfaces of the WLAN

+ 0
- 115
patches/openwrt/0001-procd-add-support-for-alternative-rc.d-directories.patch View File

@@ -1,116 +0,0 @@
From 2b16fad74cb31146778e016bf7b7ba00d013a5db Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Wed, 6 Aug 2014 19:12:00 +0200
Subject: [PATCH 01/23] procd: add support for alternative rc.d directories

---
...ort-for-alternative-rc.d-directories.patch | 97 +++++++++++++++++++
1 file changed, 97 insertions(+)
create mode 100644 package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch

diff --git a/package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch b/package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch
new file mode 100644
index 0000000000..bc24342003
--- /dev/null
+++ b/package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch
@@ -0,0 +1,97 @@
+From 03a2bc70e4260ec9f669391c47b9a7a9ecd0b75d Mon Sep 17 00:00:00 2001
+Message-Id: <03a2bc70e4260ec9f669391c47b9a7a9ecd0b75d.1407329621.git.mschiffer@universe-factory.net>
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Wed, 6 Aug 2014 14:51:49 +0200
+Subject: [PATCH] Add support for alternative rc.d directories
+
+---
+ initd/preinit.c | 38 ++++++++++++++++++++++++++++++++++++++
+ rcS.c | 2 +-
+ 2 files changed, 39 insertions(+), 1 deletion(-)
+
+diff --git a/initd/preinit.c b/initd/preinit.c
+index fb94527..8b832a7 100644
+--- a/initd/preinit.c
++++ b/initd/preinit.c
+@@ -12,6 +12,8 @@
+ * GNU General Public License for more details.
+ */
+
++#define _GNU_SOURCE
++
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/mount.h>
+@@ -46,6 +48,35 @@ check_dbglvl(void)
+ debug = lvl;
+ }
+
++static char*
++get_rc_d(void)
++{
++ size_t n = 0;
++ ssize_t len;
++ char *ret = NULL;
++
++ FILE *fp = fopen("/tmp/rc_d_path", "r");
++
++ if (!fp)
++ return NULL;
++
++ len = getline(&ret, &n, fp);
++
++ fclose(fp);
++
++ unlink("/tmp/rc_d_path");
++
++ if (len <= 0) {
++ free(ret);
++ return NULL;
++ }
++
++ if (ret[len-1] == '\n')
++ ret[len-1] = 0;
++
++ return ret;
++}
++
+ static void
+ spawn_procd(struct uloop_process *proc, int ret)
+ {
+@@ -53,6 +84,7 @@ spawn_procd(struct uloop_process *proc, int ret)
+ char *argv[] = { "/sbin/procd", NULL};
+ struct stat s;
+ char dbg[2];
++ char *rc_d_path;
+
+ if (plugd_proc.pid > 0)
+ kill(plugd_proc.pid, SIGKILL);
+@@ -72,6 +104,12 @@ spawn_procd(struct uloop_process *proc, int ret)
+ setenv("DBGLVL", dbg, 1);
+ }
+
++ rc_d_path = get_rc_d();
++ if (rc_d_path) {
++ setenv("RC_D_PATH", rc_d_path, 1);
++ free(rc_d_path);
++ }
++
+ execvp(argv[0], argv);
+ }
+
+diff --git a/rcS.c b/rcS.c
+index 0e1b0ba..1b00831 100644
+--- a/rcS.c
++++ b/rcS.c
+@@ -150,7 +150,7 @@ int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
+ q.empty_cb = q_empty;
+ q.max_running_tasks = 1;
+
+- return _rc(&q, "/etc/rc.d", pattern, "*", param);
++ return _rc(&q, getenv("RC_D_PATH") ?: "/etc/rc.d", pattern, "*", param);
+ }
+
+ int rc(const char *file, char *param)
+--
+2.0.4
+
2.22.0


+ 0
- 50
patches/openwrt/0002-base-files-disable-reset-button-handling.patch View File

@@ -1,51 +0,0 @@
From cc5676f0adfabb86639be27e9f21a5a2542ce207 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sat, 21 Mar 2015 16:40:52 +0100
Subject: [PATCH 02/23] base-files: disable reset button handling

This conflicts with our reset button usage.
---
package/base-files/files/etc/rc.button/reset | 31 --------------------
1 file changed, 31 deletions(-)
delete mode 100755 package/base-files/files/etc/rc.button/reset

diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
deleted file mode 100755
index 2403122ad2..0000000000
--- a/package/base-files/files/etc/rc.button/reset
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-. /lib/functions.sh
-
-OVERLAY="$( grep ' /overlay ' /proc/mounts )"
-
-case "$ACTION" in
-pressed)
- [ -z "$OVERLAY" ] && return 0
-
- return 5
-;;
-timeout)
- . /etc/diag.sh
- set_state failsafe
-;;
-released)
- if [ "$SEEN" -lt 1 ]
- then
- echo "REBOOT" > /dev/console
- sync
- reboot
- elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ]
- then
- echo "FACTORY RESET" > /dev/console
- jffs2reset -y && reboot &
- fi
-;;
-esac
-
-return 0
2.22.0


patches/openwrt/0007-kernel-ebtables-add-support-for-ICMP-IGMP-type-match.patch → patches/openwrt/0002-kernel-ebtables-add-support-for-ICMP-IGMP-type-match.patch View File

@@ -1,7 +1,7 @@
From 0f5b0c334cb8ba46e39ac35fe260e4a37872d439 Mon Sep 17 00:00:00 2001
From 9ffd7fa013ac8437f3147db0fb6cdf482b14a022 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Thu, 12 Apr 2018 07:50:02 +0200
Subject: [PATCH 07/23] kernel: ebtables: add support for ICMP/IGMP type
Subject: [PATCH 02/10] kernel: ebtables: add support for ICMP/IGMP type
matches

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

patches/openwrt/0011-ath10k-ct-reduce-memory-consumption.patch → patches/openwrt/0003-ath10k-ct-reduce-memory-consumption.patch View File

@@ -1,7 +1,7 @@
From 615aaef2c52d828d7a9662df6e2ec731f98614c3 Mon Sep 17 00:00:00 2001
From ed795c6b868c7a30e0744f93db212fecb6a21874 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 18 Jun 2018 21:03:37 +0200
Subject: [PATCH 11/23] ath10k-ct: reduce memory consumption
Subject: [PATCH 03/10] ath10k-ct: reduce memory consumption

ath10k uses a rather high number of buffers to communicate with the QCA
firmware. Especially the HTC (host-target-communication) and HTT

+ 0
- 117
patches/openwrt/0004-libjson-c-Add-support-for-custom-format-strings-for-.patch View File

@@ -1,118 +0,0 @@
From 517a1b3a30334a3f0d7808941adedb9b8f81df86 Mon Sep 17 00:00:00 2001
From: Jan-Philipp Litza <janphilipp@litza.de>
Date: Fri, 6 May 2016 16:44:29 +0200
Subject: [PATCH 04/23] libjson-c: Add support for custom format strings for
doubles

---
.../patches/002-custom-format-string.patch | 98 +++++++++++++++++++
1 file changed, 98 insertions(+)
create mode 100644 package/libs/libjson-c/patches/002-custom-format-string.patch

diff --git a/package/libs/libjson-c/patches/002-custom-format-string.patch b/package/libs/libjson-c/patches/002-custom-format-string.patch
new file mode 100644
index 0000000000..2f454c560f
--- /dev/null
+++ b/package/libs/libjson-c/patches/002-custom-format-string.patch
@@ -0,0 +1,98 @@
+From 21dc5dc92bd56f5f4dc2c90b9ea6bf1e1407714e Mon Sep 17 00:00:00 2001
+From: Jan-Philipp Litza <janphilipp@litza.de>
+Date: Fri, 6 May 2016 16:12:44 +0200
+Subject: [PATCH] Export json_object_double_to_json_string() and use custom
+ format string
+BCC: janphilipp@litza.de
+
+---
+ json_object.c | 12 ++++++------
+ json_object.h | 28 ++++++++++++++++++++++++++++
+ 2 files changed, 34 insertions(+), 6 deletions(-)
+
+diff --git a/json_object.c b/json_object.c
+index 7d60884..46701e7 100644
+--- a/json_object.c
++++ b/json_object.c
+@@ -55,7 +55,6 @@ static struct json_object* json_object_new(enum json_type o_type);
+ static json_object_to_json_string_fn json_object_object_to_json_string;
+ static json_object_to_json_string_fn json_object_boolean_to_json_string;
+ static json_object_to_json_string_fn json_object_int_to_json_string;
+-static json_object_to_json_string_fn json_object_double_to_json_string;
+ static json_object_to_json_string_fn json_object_string_to_json_string;
+ static json_object_to_json_string_fn json_object_array_to_json_string;
+
+@@ -644,10 +643,10 @@ int64_t json_object_get_int64(const struct json_object *jso)
+
+ /* json_object_double */
+
+-static int json_object_double_to_json_string(struct json_object* jso,
+- struct printbuf *pb,
+- int level,
+- int flags)
++int json_object_double_to_json_string(struct json_object* jso,
++ struct printbuf *pb,
++ int level,
++ int flags)
+ {
+ char buf[128], *p, *q;
+ int size;
+@@ -663,7 +662,8 @@ static int json_object_double_to_json_string(struct json_object* jso,
+ else
+ size = snprintf(buf, sizeof(buf), "-Infinity");
+ else
+- size = snprintf(buf, sizeof(buf), "%.17g", jso->o.c_double);
++ size = snprintf(buf, sizeof(buf),
++ jso->_userdata ? (const char*) jso->_userdata : "%.17g", jso->o.c_double);
+
+ p = strchr(buf, ',');
+ if (p) {
+diff --git a/json_object.h b/json_object.h
+index 2bce454..a89de44 100644
+--- a/json_object.h
++++ b/json_object.h
+@@ -614,6 +614,9 @@ extern int64_t json_object_get_int64(const struct json_object *obj);
+ /* double type methods */
+
+ /** Create a new empty json_object of type json_type_double
++ *
++ * @see json_object_double_to_json_string() for how to set a custom format string.
++ *
+ * @param d the double
+ * @returns a json_object of type json_type_double
+ */
+@@ -642,6 +645,31 @@ extern struct json_object* json_object_new_double(double d);
+ */
+ extern struct json_object* json_object_new_double_s(double d, const char *ds);
+
++
++/** Serialize a json_object of type json_type_double to a string.
++ *
++ * This function isn't meant to be called directly. Instead, you can set a
++ * custom format string for the serialization of this double using the
++ * following call (where "%.17g" actually is the default):
++ *
++ * @code
++ * jso = json_object_new_double(d);
++ * json_object_set_serializer(jso, json_object_double_to_json_string,
++ * "%.17g", NULL);
++ * @endcode
++ *
++ * @see printf(3) man page for format strings
++ *
++ * @param jso The json_type_double object that is serialized.
++ * @param pb The destination buffer.
++ * @param level Ignored.
++ * @param flags Ignored.
++ */
++extern int json_object_double_to_json_string(struct json_object* jso,
++ struct printbuf *pb,
++ int level,
++ int flags);
++
+ /** Get the double floating point value of a json_object
+ *
+ * The type is coerced to a double if the passed object is not a double.
+--
+2.7.4
+
2.22.0


patches/openwrt/0012-tools-mktplinkfw2-add-split-uboot-layout.patch → patches/openwrt/0004-tools-mktplinkfw2-add-split-uboot-layout.patch View File

@@ -1,7 +1,7 @@
From df25ccc519ebd697796c1f07cc7485215169b498 Mon Sep 17 00:00:00 2001
From 9a791878aefec9f7604c4d1559f137b470b3f22f Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Wed, 28 Nov 2018 23:56:31 +0100
Subject: [PATCH 12/23] tools: mktplinkfw2: add split-uboot layout
Subject: [PATCH 04/10] tools: mktplinkfw2: add split-uboot layout

This commit adds the split-uboot partition layout used by the
Archer C50 v4 to mktplinkfw2.
@@ -12,10 +12,10 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
1 file changed, 6 insertions(+)

diff --git a/tools/firmware-utils/src/mktplinkfw2.c b/tools/firmware-utils/src/mktplinkfw2.c
index dead49e7af..35db848bba 100644
index 102d72b1cc..1b0736e1b7 100644
--- a/tools/firmware-utils/src/mktplinkfw2.c
+++ b/tools/firmware-utils/src/mktplinkfw2.c
@@ -146,6 +146,12 @@ static struct flash_layout layouts[] = {
@@ -152,6 +152,12 @@ static struct flash_layout layouts[] = {
.kernel_la = 0x80000000,
.kernel_ep = 0x80000000,
.rootfs_ofs = 0x140000,

+ 0
- 77
patches/openwrt/0005-dropbear-add-a-failsafe-mode-that-will-always-allow-.patch View File

@@ -1,78 +0,0 @@
From 114b42cb8af665806bf5b729dd5c20a7c938b350 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 27 Sep 2016 03:55:55 +0200
Subject: [PATCH 05/23] dropbear: add a failsafe mode that will always allow
password-less root login

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
.../dropbear/patches/700-failsafe-mode.patch | 57 +++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 package/network/services/dropbear/patches/700-failsafe-mode.patch

diff --git a/package/network/services/dropbear/patches/700-failsafe-mode.patch b/package/network/services/dropbear/patches/700-failsafe-mode.patch
new file mode 100644
index 0000000000..d379da0d0a
--- /dev/null
+++ b/package/network/services/dropbear/patches/700-failsafe-mode.patch
@@ -0,0 +1,57 @@
+--- a/runopts.h
++++ b/runopts.h
+@@ -98,6 +98,8 @@ typedef struct svr_runopts {
+ int allowblankpass;
+ unsigned int maxauthtries;
+
++ int failsafe_mode;
++
+ #ifdef ENABLE_SVR_REMOTETCPFWD
+ int noremotetcp;
+ #endif
+--- a/svr-auth.c
++++ b/svr-auth.c
+@@ -149,10 +149,11 @@ void recv_msg_userauth_request() {
+ AUTH_METHOD_NONE_LEN) == 0) {
+ TRACE(("recv_msg_userauth_request: 'none' request"))
+ if (valid_user
+- && (svr_opts.allowblankpass || !strcmp(ses.authstate.pw_name, "root"))
+- && !svr_opts.noauthpass
+- && !(svr_opts.norootpass && ses.authstate.pw_uid == 0)
+- && ses.authstate.pw_passwd[0] == '\0')
++ && ((svr_opts.failsafe_mode && !strcmp(ses.authstate.pw_name, "root"))
++ || ((svr_opts.allowblankpass || !strcmp(ses.authstate.pw_name, "root"))
++ && !svr_opts.noauthpass
++ && !(svr_opts.norootpass && ses.authstate.pw_uid == 0)
++ && ses.authstate.pw_passwd[0] == '\0')))
+ {
+ dropbear_log(LOG_NOTICE,
+ "Auth succeeded with blank password for '%s' from %s",
+--- a/svr-runopts.c
++++ b/svr-runopts.c
+@@ -72,6 +72,7 @@ static void printhelp(const char * progn
+ "-s Disable password logins\n"
+ "-g Disable password logins for root\n"
+ "-B Allow blank password logins\n"
++ "-f Failsafe mode: always allow password-less root login\n"
+ #endif
+ "-T <1 to %d> Maximum authentication tries (default %d)\n"
+ #ifdef ENABLE_SVR_LOCALTCPFWD
+@@ -133,6 +134,7 @@ void svr_getopts(int argc, char ** argv)
+ svr_opts.noauthpass = 0;
+ svr_opts.norootpass = 0;
+ svr_opts.allowblankpass = 0;
++ svr_opts.failsafe_mode = 0;
+ svr_opts.maxauthtries = DEFAULT_AUTH_TRIES;
+ svr_opts.inetdmode = 0;
+ svr_opts.portcount = 0;
+@@ -251,6 +253,9 @@ void svr_getopts(int argc, char ** argv)
+ case 'B':
+ svr_opts.allowblankpass = 1;
+ break;
++ case 'f':
++ svr_opts.failsafe_mode = 1;
++ break;
+ #endif
+ case 'h':
+ printhelp(argv[0]);
2.22.0


patches/openwrt/0014-mac80211-ath10k-support-for-multicast-and-management.patch → patches/openwrt/0005-mac80211-ath10k-support-for-multicast-and-management.patch View File

@@ -1,7 +1,7 @@
From 50d7d0cfe20cb090296caa40603362da2aeba62b Mon Sep 17 00:00:00 2001
From 0554a9c101d8e5c24dfe6b1eab20db2a8bd45f9c Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 8 Feb 2019 21:20:20 +0100
Subject: [PATCH 14/23] mac80211: ath10k: support for multicast and management
Subject: [PATCH 05/10] mac80211: ath10k: support for multicast and management
rate control

Drivers with software rate control can directly use the selected multicast

patches/openwrt/0015-ath10k-ct-support-for-multicast-and-management-rate-.patch → patches/openwrt/0006-ath10k-ct-support-for-multicast-and-management-rate-.patch View File

@@ -1,7 +1,7 @@
From a2b95335c227d25e4ee31737892049f6b0b75d70 Mon Sep 17 00:00:00 2001
From 41a614385235e04b80c45eca8373092618ae148f Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 8 Feb 2019 21:20:20 +0100
Subject: [PATCH 15/23] ath10k-ct: support for multicast and management rate
Subject: [PATCH 06/10] ath10k-ct: support for multicast and management rate
control

Drivers with software rate control can directly use the selected multicast

+ 0
- 478
patches/openwrt/0006-generic-vxlan-backport-support-for-VXLAN-over-link-l.patch View File

@@ -1,479 +0,0 @@
From 96d2a0bc6875c1cfab3602132d7cc3d57e8ebc9f Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 9 Jan 2018 22:38:19 +0100
Subject: [PATCH 06/23] generic: vxlan: backport support for VXLAN over
link-local IPv6 to 4.9

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
...lidation-of-address-family-configura.patch | 73 +++++++
...valid-combinations-of-address-scopes.patch | 91 +++++++++
...ooping-for-link-local-IPv6-addresses.patch | 88 +++++++++
...iple-VXLANs-with-same-VNI-for-IPv6-l.patch | 182 ++++++++++++++++++
4 files changed, 434 insertions(+)
create mode 100644 target/linux/generic/backport-4.9/095-0001-vxlan-improve-validation-of-address-family-configura.patch
create mode 100644 target/linux/generic/backport-4.9/095-0002-vxlan-check-valid-combinations-of-address-scopes.patch
create mode 100644 target/linux/generic/backport-4.9/095-0003-vxlan-fix-snooping-for-link-local-IPv6-addresses.patch
create mode 100644 target/linux/generic/backport-4.9/095-0004-vxlan-allow-multiple-VXLANs-with-same-VNI-for-IPv6-l.patch

diff --git a/target/linux/generic/backport-4.9/095-0001-vxlan-improve-validation-of-address-family-configura.patch b/target/linux/generic/backport-4.9/095-0001-vxlan-improve-validation-of-address-family-configura.patch
new file mode 100644
index 0000000000..2114562536
--- /dev/null
+++ b/target/linux/generic/backport-4.9/095-0001-vxlan-improve-validation-of-address-family-configura.patch
@@ -0,0 +1,73 @@
+From f45ba82cd83d27b5d44d3dc417e0e480ba0d3703 Mon Sep 17 00:00:00 2001
+Message-Id: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Mon, 19 Jun 2017 10:03:57 +0200
+Subject: [PATCH 1/4] vxlan: improve validation of address family configuration
+
+Address families of source and destination addresses must match, and
+changelink operations can't change the address family.
+
+In addition, always use the VXLAN_F_IPV6 to check if a VXLAN device uses
+IPv4 or IPv6.
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[Matthias Schiffer: rebase to v4.9.y]
+---
+ drivers/net/vxlan.c | 23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
+index 983e941bdf29..fbe8da7fa296 100644
+--- a/drivers/net/vxlan.c
++++ b/drivers/net/vxlan.c
+@@ -2867,12 +2867,20 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
+
+ memcpy(&dst->remote_ip, &conf->remote_ip, sizeof(conf->remote_ip));
+
+- /* Unless IPv6 is explicitly requested, assume IPv4 */
+- if (!dst->remote_ip.sa.sa_family)
++ if (!dst->remote_ip.sa.sa_family && !conf->saddr.sa.sa_family) {
++ /* Unless IPv6 is explicitly requested, assume IPv4 */
+ dst->remote_ip.sa.sa_family = AF_INET;
++ conf->saddr.sa.sa_family = AF_INET;
++ } else if (!dst->remote_ip.sa.sa_family) {
++ dst->remote_ip.sa.sa_family = conf->saddr.sa.sa_family;
++ } else if (!conf->saddr.sa.sa_family) {
++ conf->saddr.sa.sa_family = dst->remote_ip.sa.sa_family;
++ }
++
++ if (conf->saddr.sa.sa_family != dst->remote_ip.sa.sa_family)
++ return -EINVAL;
+
+- if (dst->remote_ip.sa.sa_family == AF_INET6 ||
+- vxlan->cfg.saddr.sa.sa_family == AF_INET6) {
++ if (conf->saddr.sa.sa_family == AF_INET6) {
+ if (!IS_ENABLED(CONFIG_IPV6))
+ return -EPFNOSUPPORT;
+ use_ipv6 = true;
+@@ -2938,11 +2946,9 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
+
+ list_for_each_entry(tmp, &vn->vxlan_list, next) {
+ if (tmp->cfg.vni == conf->vni &&
+- (tmp->default_dst.remote_ip.sa.sa_family == AF_INET6 ||
+- tmp->cfg.saddr.sa.sa_family == AF_INET6) == use_ipv6 &&
+ tmp->cfg.dst_port == vxlan->cfg.dst_port &&
+- (tmp->flags & VXLAN_F_RCV_FLAGS) ==
+- (vxlan->flags & VXLAN_F_RCV_FLAGS)) {
++ (tmp->flags & (VXLAN_F_RCV_FLAGS | VXLAN_F_IPV6)) ==
++ (vxlan->flags & (VXLAN_F_RCV_FLAGS | VXLAN_F_IPV6))) {
+ pr_info("duplicate VNI %u\n", be32_to_cpu(conf->vni));
+ return -EEXIST;
+ }
+@@ -2987,6 +2993,7 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev,
+
+ if (data[IFLA_VXLAN_GROUP]) {
+ conf.remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]);
++ conf.remote_ip.sa.sa_family = AF_INET;
+ } else if (data[IFLA_VXLAN_GROUP6]) {
+ if (!IS_ENABLED(CONFIG_IPV6))
+ return -EPFNOSUPPORT;
+--
+2.15.1
+
diff --git a/target/linux/generic/backport-4.9/095-0002-vxlan-check-valid-combinations-of-address-scopes.patch b/target/linux/generic/backport-4.9/095-0002-vxlan-check-valid-combinations-of-address-scopes.patch
new file mode 100644
index 0000000000..b38b9977bc
--- /dev/null
+++ b/target/linux/generic/backport-4.9/095-0002-vxlan-check-valid-combinations-of-address-scopes.patch
@@ -0,0 +1,91 @@
+From 0eb4ccfc77e07fb4bfc7b1778a7ecb136b47aba4 Mon Sep 17 00:00:00 2001
+Message-Id: <0eb4ccfc77e07fb4bfc7b1778a7ecb136b47aba4.1515533863.git.mschiffer@universe-factory.net>
+In-Reply-To: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+References: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Mon, 19 Jun 2017 10:03:58 +0200
+Subject: [PATCH 2/4] vxlan: check valid combinations of address scopes
+
+* Multicast addresses are never valid as local address
+* Link-local IPv6 unicast addresses may only be used as remote when the
+ local address is link-local as well
+* Don't allow link-local IPv6 local/remote addresses without interface
+
+We also store in the flags field if link-local addresses are used for the
+follow-up patches that actually make VXLAN over link-local IPv6 work.
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[Matthias Schiffer: rebase to v4.9.y]
+---
+ drivers/net/vxlan.c | 29 +++++++++++++++++++++++++++++
+ include/net/vxlan.h | 1 +
+ 2 files changed, 30 insertions(+)
+
+diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
+index fbe8da7fa296..863d9528b900 100644
+--- a/drivers/net/vxlan.c
++++ b/drivers/net/vxlan.c
+@@ -2880,11 +2880,35 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
+ if (conf->saddr.sa.sa_family != dst->remote_ip.sa.sa_family)
+ return -EINVAL;
+
++ if (vxlan_addr_multicast(&conf->saddr))
++ return -EINVAL;
++
+ if (conf->saddr.sa.sa_family == AF_INET6) {
+ if (!IS_ENABLED(CONFIG_IPV6))
+ return -EPFNOSUPPORT;
+ use_ipv6 = true;
+ vxlan->flags |= VXLAN_F_IPV6;
++
++ if (!(conf->flags & VXLAN_F_COLLECT_METADATA)) {
++ int local_type =
++ ipv6_addr_type(&conf->saddr.sin6.sin6_addr);
++ int remote_type =
++ ipv6_addr_type(&dst->remote_ip.sin6.sin6_addr);
++
++ if (local_type & IPV6_ADDR_LINKLOCAL) {
++ if (!(remote_type & IPV6_ADDR_LINKLOCAL) &&
++ (remote_type != IPV6_ADDR_ANY))
++ return -EINVAL;
++
++ vxlan->flags |= VXLAN_F_IPV6_LINKLOCAL;
++ } else {
++ if (remote_type ==
++ (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL))
++ return -EINVAL;
++
++ vxlan->flags &= ~VXLAN_F_IPV6_LINKLOCAL;
++ }
++ }
+ }
+
+ if (conf->label && !use_ipv6) {
+@@ -2918,6 +2942,11 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
+ } else if (vxlan_addr_multicast(&dst->remote_ip)) {
+ pr_info("multicast destination requires interface to be specified\n");
+ return -EINVAL;
++ } else {
++#if IS_ENABLED(CONFIG_IPV6)
++ if (vxlan->flags & VXLAN_F_IPV6_LINKLOCAL)
++ return -EINVAL;
++#endif
+ }
+
+ if (conf->mtu) {
+diff --git a/include/net/vxlan.h b/include/net/vxlan.h
+index 9fce47e3e13e..c1c0d03e3456 100644
+--- a/include/net/vxlan.h
++++ b/include/net/vxlan.h
+@@ -267,6 +267,7 @@ struct vxlan_dev {
+ #define VXLAN_F_REMCSUM_NOPARTIAL 0x1000
+ #define VXLAN_F_COLLECT_METADATA 0x2000
+ #define VXLAN_F_GPE 0x4000
++#define VXLAN_F_IPV6_LINKLOCAL 0x8000
+
+ /* Flags that are used in the receive path. These flags must match in
+ * order for a socket to be shareable
+--
+2.15.1
+
diff --git a/target/linux/generic/backport-4.9/095-0003-vxlan-fix-snooping-for-link-local-IPv6-addresses.patch b/target/linux/generic/backport-4.9/095-0003-vxlan-fix-snooping-for-link-local-IPv6-addresses.patch
new file mode 100644
index 0000000000..89523ac027
--- /dev/null
+++ b/target/linux/generic/backport-4.9/095-0003-vxlan-fix-snooping-for-link-local-IPv6-addresses.patch
@@ -0,0 +1,88 @@
+From 010b2b541d958e12d78ba1c79734c700f169610b Mon Sep 17 00:00:00 2001
+Message-Id: <010b2b541d958e12d78ba1c79734c700f169610b.1515533863.git.mschiffer@universe-factory.net>
+In-Reply-To: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+References: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Mon, 19 Jun 2017 10:03:59 +0200
+Subject: [PATCH 3/4] vxlan: fix snooping for link-local IPv6 addresses
+
+If VXLAN is run over link-local IPv6 addresses, it is necessary to store
+the ifindex in the FDB entries. Otherwise, the used interface is undefined
+and unicast communication will most likely fail.
+
+Support for link-local IPv4 addresses should be possible as well, but as
+the semantics aren't as well defined as for IPv6, and there doesn't seem to
+be much interest in having the support, it's not implemented for now.
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[Matthias Schiffer: rebase to v4.9.y]
+---
+ drivers/net/vxlan.c | 20 +++++++++++++++-----
+ 1 file changed, 15 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/vxlan.c
++++ b/drivers/net/vxlan.c
+@@ -917,16 +917,25 @@ out:
+ * Return true if packet is bogus and should be dropped.
+ */
+ static bool vxlan_snoop(struct net_device *dev,
+- union vxlan_addr *src_ip, const u8 *src_mac)
++ union vxlan_addr *src_ip, const u8 *src_mac,
++ u32 src_ifindex)
+ {
+ struct vxlan_dev *vxlan = netdev_priv(dev);
+ struct vxlan_fdb *f;
++ u32 ifindex = 0;
++
++#if IS_ENABLED(CONFIG_IPV6)
++ if (src_ip->sa.sa_family == AF_INET6 &&
++ (ipv6_addr_type(&src_ip->sin6.sin6_addr) & IPV6_ADDR_LINKLOCAL))
++ ifindex = src_ifindex;
++#endif
+
+ f = vxlan_find_mac(vxlan, src_mac);
+ if (likely(f)) {
+ struct vxlan_rdst *rdst = first_remote_rcu(f);
+
+- if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip)))
++ if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) &&
++ rdst->remote_ifindex == ifindex))
+ return false;
+
+ /* Don't migrate static entries, drop packets */
+@@ -952,7 +961,7 @@ static bool vxlan_snoop(struct net_devic
+ NLM_F_EXCL|NLM_F_CREATE,
+ vxlan->cfg.dst_port,
+ vxlan->default_dst.remote_vni,
+- 0, NTF_SELF);
++ ifindex, NTF_SELF);
+ spin_unlock(&vxlan->hash_lock);
+ }
+
+@@ -1223,6 +1232,7 @@ static bool vxlan_set_mac(struct vxlan_d
+ struct sk_buff *skb)
+ {
+ union vxlan_addr saddr;
++ u32 ifindex = skb->dev->ifindex;
+
+ skb_reset_mac_header(skb);
+ skb->protocol = eth_type_trans(skb, vxlan->dev);
+@@ -1244,7 +1254,7 @@ static bool vxlan_set_mac(struct vxlan_d
+ }
+
+ if ((vxlan->flags & VXLAN_F_LEARN) &&
+- vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source))
++ vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex))
+ return false;
+
+ return true;
+@@ -1939,7 +1949,7 @@ static void vxlan_encap_bypass(struct sk
+ }
+
+ if (dst_vxlan->flags & VXLAN_F_LEARN)
+- vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source);
++ vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0);
+
+ u64_stats_update_begin(&tx_stats->syncp);
+ tx_stats->tx_packets++;
diff --git a/target/linux/generic/backport-4.9/095-0004-vxlan-allow-multiple-VXLANs-with-same-VNI-for-IPv6-l.patch b/target/linux/generic/backport-4.9/095-0004-vxlan-allow-multiple-VXLANs-with-same-VNI-for-IPv6-l.patch
new file mode 100644
index 0000000000..18ae230a3b
--- /dev/null
+++ b/target/linux/generic/backport-4.9/095-0004-vxlan-allow-multiple-VXLANs-with-same-VNI-for-IPv6-l.patch
@@ -0,0 +1,182 @@
+From 95583c75a95449dade713e1dad4ed0a8dcc1b391 Mon Sep 17 00:00:00 2001
+Message-Id: <95583c75a95449dade713e1dad4ed0a8dcc1b391.1515533863.git.mschiffer@universe-factory.net>
+In-Reply-To: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+References: <f45ba82cd83d27b5d44d3dc417e0e480ba0d3703.1515533863.git.mschiffer@universe-factory.net>
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Mon, 19 Jun 2017 10:04:00 +0200
+Subject: [PATCH 4/4] vxlan: allow multiple VXLANs with same VNI for IPv6
+ link-local addresses
+
+As link-local addresses are only valid for a single interface, we can allow
+to use the same VNI for multiple independent VXLANs, as long as the used
+interfaces are distinct. This way, VXLANs can always be used as a drop-in
+replacement for VLANs with greater ID space.
+
+This also extends VNI lookup to respect the ifindex when link-local IPv6
+addresses are used, so using the same VNI on multiple interfaces can
+actually work.
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[Matthias Schiffer: rebase to v4.9.y]
+---
+ drivers/net/vxlan.c | 60 ++++++++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 41 insertions(+), 19 deletions(-)
+
+diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
+index c28c6f34b3b3..9208e3d9ec43 100644
+--- a/drivers/net/vxlan.c
++++ b/drivers/net/vxlan.c
+@@ -225,7 +225,8 @@ static struct vxlan_sock *vxlan_find_sock(struct net *net, sa_family_t family,
+ return NULL;
+ }
+
+-static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, __be32 vni)
++static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, int ifindex,
++ __be32 vni)
+ {
+ struct vxlan_dev_node *node;
+
+@@ -234,17 +235,27 @@ static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, __be32 vni)
+ vni = 0;
+
+ hlist_for_each_entry_rcu(node, vni_head(vs, vni), hlist) {
+- if (node->vxlan->default_dst.remote_vni == vni)
+- return node->vxlan;
++ if (node->vxlan->default_dst.remote_vni != vni)
++ continue;
++
++ if (IS_ENABLED(CONFIG_IPV6)) {
++ const struct vxlan_config *cfg = &node->vxlan->cfg;
++
++ if ((node->vxlan->flags & VXLAN_F_IPV6_LINKLOCAL) &&
++ cfg->remote_ifindex != ifindex)
++ continue;
++ }
++
++ return node->vxlan;
+ }
+
+ return NULL;
+ }
+
+ /* Look up VNI in a per net namespace table */
+-static struct vxlan_dev *vxlan_find_vni(struct net *net, __be32 vni,
+- sa_family_t family, __be16 port,
+- u32 flags)
++static struct vxlan_dev *vxlan_find_vni(struct net *net, int ifindex,
++ __be32 vni, sa_family_t family,
++ __be16 port, u32 flags)
+ {
+ struct vxlan_sock *vs;
+
+@@ -252,7 +263,7 @@ static struct vxlan_dev *vxlan_find_vni(struct net *net, __be32 vni,
+ if (!vs)
+ return NULL;
+
+- return vxlan_vs_find_vni(vs, vni);
++ return vxlan_vs_find_vni(vs, ifindex, vni);
+ }
+
+ /* Fill in neighbour message in skbuff. */
+@@ -1317,7 +1328,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
+ if (!vs)
+ goto drop;
+
+- vxlan = vxlan_vs_find_vni(vs, vxlan_vni(vxlan_hdr(skb)->vx_vni));
++ vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex,
++ vxlan_vni(vxlan_hdr(skb)->vx_vni));
+ if (!vxlan)
+ goto drop;
+
+@@ -1976,6 +1988,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ __be32 vni, label;
+ __be16 df = 0;
+ __u8 tos, ttl;
++ int ifindex;
+ int err;
+ u32 flags = vxlan->flags;
+ bool udp_sum = false;
+@@ -1987,6 +2000,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ if (rdst) {
+ dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port;
+ vni = rdst->remote_vni;
++ ifindex = rdst->remote_ifindex;
+ dst = &rdst->remote_ip;
+ local_ip = vxlan->cfg.saddr;
+ dst_cache = &rdst->dst_cache;
+@@ -1998,6 +2012,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ }
+ dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port;
+ vni = tunnel_id_to_key32(info->key.tun_id);
++ ifindex = 0;
+ remote_ip.sa.sa_family = ip_tunnel_info_af(info);
+ if (remote_ip.sa.sa_family == AF_INET) {
+ remote_ip.sin.sin_addr.s_addr = info->key.u.ipv4.dst;
+@@ -2053,7 +2068,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ sk = sock4->sock->sk;
+
+ rt = vxlan_get_route(vxlan, skb,
+- rdst ? rdst->remote_ifindex : 0, tos,
++ ifindex, tos,
+ dst->sin.sin_addr.s_addr,
+ &local_ip.sin.sin_addr.s_addr,
+ dst_cache, info);
+@@ -2077,7 +2092,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ struct vxlan_dev *dst_vxlan;
+
+ ip_rt_put(rt);
+- dst_vxlan = vxlan_find_vni(vxlan->net, vni,
++ dst_vxlan = vxlan_find_vni(vxlan->net, ifindex, vni,
+ dst->sa.sa_family, dst_port,
+ vxlan->flags);
+ if (!dst_vxlan)
+@@ -2112,7 +2127,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ sk = sock6->sock->sk;
+
+ ndst = vxlan6_get_route(vxlan, skb,
+- rdst ? rdst->remote_ifindex : 0, tos,
++ ifindex, tos,
+ label, &dst->sin6.sin6_addr,
+ &local_ip.sin6.sin6_addr,
+ dst_cache, info);
+@@ -2138,7 +2153,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
+ struct vxlan_dev *dst_vxlan;
+
+ dst_release(ndst);
+- dst_vxlan = vxlan_find_vni(vxlan->net, vni,
++ dst_vxlan = vxlan_find_vni(vxlan->net, ifindex, vni,
+ dst->sa.sa_family, dst_port,
+ vxlan->flags);
+ if (!dst_vxlan)
+@@ -2984,13 +2999,20 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
+ vxlan->cfg.age_interval = FDB_AGE_DEFAULT;
+
+ list_for_each_entry(tmp, &vn->vxlan_list, next) {
+- if (tmp->cfg.vni == conf->vni &&
+- tmp->cfg.dst_port == vxlan->cfg.dst_port &&
+- (tmp->flags & (VXLAN_F_RCV_FLAGS | VXLAN_F_IPV6)) ==
+- (vxlan->flags & (VXLAN_F_RCV_FLAGS | VXLAN_F_IPV6))) {
+- pr_info("duplicate VNI %u\n", be32_to_cpu(conf->vni));
+- return -EEXIST;
+- }
++ if (tmp->cfg.vni != conf->vni)
++ continue;
++ if (tmp->cfg.dst_port != vxlan->cfg.dst_port)
++ continue;
++ if ((tmp->flags & (VXLAN_F_RCV_FLAGS | VXLAN_F_IPV6)) !=
++ (vxlan->flags & (VXLAN_F_RCV_FLAGS | VXLAN_F_IPV6)))
++ continue;
++
++ if ((vxlan->flags & VXLAN_F_IPV6_LINKLOCAL) &&
++ tmp->cfg.remote_ifindex != vxlan->cfg.remote_ifindex)
++ continue;
++
++ pr_info("duplicate VNI %u\n", be32_to_cpu(conf->vni));
++ return -EEXIST;
+ }
+
+ dev->ethtool_ops = &vxlan_ethtool_ops;
+--
+2.15.1
+
2.22.0


patches/openwrt/0019-ath10k-ct-fix-incorrect-multicast-broadcast-rate-set.patch → patches/openwrt/0007-ath10k-ct-fix-incorrect-multicast-broadcast-rate-set.patch View File

@@ -1,7 +1,7 @@
From 1d0d146c5968314343df607950014949b3c5ea00 Mon Sep 17 00:00:00 2001
From 31ff611a7895e4e3f709f42b4f41c8e1819508db Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 25 Feb 2019 20:42:28 +0100
Subject: [PATCH 19/23] ath10k-ct: fix incorrect multicast/broadcast rate
Subject: [PATCH 07/10] ath10k-ct: fix incorrect multicast/broadcast rate
setting

If no mcast_rate is set for the wifi-iface then there is no rate_idx (0)

+ 0
- 1048
patches/openwrt/0008-ipq40xx-add-support-for-the-ZyXEL-NBG6617.patch
File diff suppressed because it is too large
View File


patches/openwrt/0020-mac80211-ath10k-fix-incorrect-multicast-broadcast-ra.patch → patches/openwrt/0008-mac80211-ath10k-fix-incorrect-multicast-broadcast-ra.patch View File

@@ -1,7 +1,7 @@
From ea0ab4212617f746c669fde25c8e596ba5a67367 Mon Sep 17 00:00:00 2001
From 12465fb31697cb49c6a910c95c549a9bc2493c7a Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 25 Feb 2019 20:42:28 +0100
Subject: [PATCH 20/23] mac80211: ath10k: fix incorrect multicast/broadcast
Subject: [PATCH 08/10] mac80211: ath10k: fix incorrect multicast/broadcast
rate setting

If no mcast_rate is set for the wifi-iface then there is no rate_idx (0)

+ 0
- 796
patches/openwrt/0009-build-add-mkrasimage.patch View File

@@ -1,797 +0,0 @@
From f13e3ba0b3609f8fec53eb82544625fe702706b7 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Wed, 22 Aug 2018 17:30:44 +0200
Subject: [PATCH 09/23] build: add mkrasimage

The current make-ras.sh image generation script for the ZyXEL NBG6617
has portability issues with bash. Because of this, factory images are
currently not built correctly by the OpenWRT buildbots.

This commit replaces the make-ras.sh by C-written mkrasimage.

The new mkrasimage is also compatible with other ZyXEL devices using
the ras image-format.
This is not tested with the NBG6616 but it correctly builds the
header for ZyXEL factory image.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
include/image-commands.mk | 18 +-
scripts/make-ras.sh | 196 -----------
target/linux/ar71xx/image/generic.mk | 6 +-
target/linux/ipq40xx/image/Makefile | 2 +-
target/linux/ipq806x/image/Makefile | 6 +-
tools/firmware-utils/Makefile | 1 +
tools/firmware-utils/src/mkrasimage.c | 459 ++++++++++++++++++++++++++
7 files changed, 480 insertions(+), 208 deletions(-)
delete mode 100755 scripts/make-ras.sh
create mode 100644 tools/firmware-utils/src/mkrasimage.c

diff --git a/include/image-commands.mk b/include/image-commands.mk
index 28b39c310e..552d8db1cb 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -49,17 +49,17 @@ define Build/eva-image
mv $@.new $@
endef
-define Build/make-ras
+define Build/zyxel-ras-image
let \
newsize="$(subst k,* 1024,$(RAS_ROOTFS_SIZE))"; \
- $(TOPDIR)/scripts/make-ras.sh \
- --board $(RAS_BOARD) \
- --version $(RAS_VERSION) \
- --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
- --rootfs $@ \
- --rootfssize $$newsize \
- $@.new
- @mv $@.new $@
+ $(STAGING_DIR_HOST)/bin/mkrasimage \
+ -b $(RAS_BOARD) \
+ -v $(RAS_VERSION) \
+ -r $@ \
+ -s $$newsize \
+ -o $@.new \
+ $(if $(findstring separate-kernel,$(word 1,$(1))),-k $(IMAGE_KERNEL)) \
+ && mv $@.new $@
endef
define Build/netgear-chk
diff --git a/scripts/make-ras.sh b/scripts/make-ras.sh
deleted file mode 100755
index ccddaa0016..0000000000
--- a/scripts/make-ras.sh
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/env bash
-#
-# --- ZyXEL header format ---
-# Original Version by Benjamin Berg <benjamin@sipsolutions.net>
-#
-# The firmware image prefixed with a header (which is written into the MTD device).
-# The header is one erase block (~64KiB) in size, but the checksum only convers the
-# first 2KiB. Padding is 0xff. All integers are in big-endian.
-#
-# The checksum is always a 16-Bit System V checksum (sum -s) stored in a 32-Bit integer.
-#
-# 4 bytes: checksum of the rootfs image
-# 4 bytes: length of the contained rootfs image file (big endian)
-# 32 bytes: Firmware Version string (NUL terminated, 0xff padded)
-# 4 bytes: checksum over the header partition (big endian - see below)
-# 32 bytes: Model (e.g. "NBG6617", NUL termiated, 0xff padded)
-# 4 bytes: checksum of the kernel partition
-# 4 bytes: length of the contained kernel image file (big endian)
-# rest: 0xff padding
-#
-# The checksums are calculated by adding up all bytes and if a 16bit
-# overflow occurs, one is added and the sum is masked to 16 bit:
-# csum = csum + databyte; if (csum > 0xffff) { csum += 1; csum &= 0xffff };
-# Should the file have an odd number of bytes then the byte len-0x800 is
-# used additionally.
-#
-# The checksum for the header is calculated over the first 2048 bytes with
-# the rootfs image checksum as the placeholder during calculation.
-#
-# The header is padded with 0xff to the erase block size of the device.
-#
-board=""
-version=""
-kernel=""
-rootfs=""
-outfile=""
-err=""
-
-while [ "$1" ]; do
- case "$1" in
- "--board")
- board="$2"
- shift
- shift
- continue
- ;;
- "--version")
- version="$2"
- shift
- shift
- continue
- ;;
- "--kernel")
- kernel="$2"
- shift
- shift
- continue
- ;;
- "--rootfs")
- rootfs="$2"
- shift
- shift
- continue
- ;;
- "--rootfssize")
- rootfssize="$2"
- shift
- shift
- continue
- ;;
- *)
- if [ ! "$outfile" ]; then
- outfile=$1
- shift
- continue
- fi
- ;;
- esac
-done
-
-if [ ! -n "$board" -o ! -n "$version" -o ! -r "$kernel" -o ! -r "$rootfs" -o ! "$rootfssize" -o ! "$outfile" ]; then
- echo "syntax: $0 [--board ras-boardname] [--version ras-version] [--kernel kernelimage] [--rootfs rootfs] out"
- exit 1
-fi
-
-rootfs_len=$(wc -c < "$rootfs")
-
-if [ "$rootfs_len" -lt "$rootfssize" ]; then
- dd if=$rootfs of=$rootfs.new bs=$rootfssize conv=sync
- mv $rootfs.new $rootfs
-fi
-
-if [ ${#version} -ge 28 ]; then
- echo "version: '$version' is too long"
- exit 1
-fi
-
-tmpdir="$( mktemp -d 2> /dev/null )"
-if [ -z "$tmpdir" ]; then
- # try OSX signature
- tmpdir="$( mktemp -t 'ubitmp' -d )"
-fi
-
-if [ -z "$tmpdir" ]; then
- exit 1
-fi
-
-to_be() {
- local val="$1"
- local size="$2"
-
- case "$size" in
- 4)
- echo $(( "$val" >> 24 | ("$val" & 0xff0000) >> 8 | ("$val" & 0xff00) << 8 | ("$val" & 0xff) << 24 ))
- ;;
- 2)
- echo $(( "$val" >> 8 | ("$val" & 0xff) << 8))
- ;;
- esac
-}
-
-checksum_file() {
- local file=$1
-
- # ZyXEL seems to use System V sum mode... Now this is classy, who would have thought?!
- echo $(sum -s ${file} | cut -f1 -d" ")
-}
-
-append_bin() {
- local val=$1
- local size=$2
- local file=$3
-
- while [ "$size" -ne 0 ]; do
- printf \\$(printf %o $(("$val" & 0xff))) >> "$file"
- val=$(($val >> 8))
- let size-=1
- done
- return
-}
-
-tf=${tmpdir}/out
-pad=$(printf '%0.1s' $(printf "\xff"){1..64})
-
-rootfs_header_file="$tmpdir/rootfs_header"
-rootfs_chksum=$(to_be $(checksum_file ${rootfs}) 4)
-rootfs_len=$(to_be $(wc -c < "$rootfs") 4)
-
-versionpadlen=$(( 32 - ( ${#version} + 1) ))
-
-# 4 bytes: checksum of the rootfs image
-append_bin "$rootfs_chksum" 4 "$rootfs_header_file"
-# 4 bytes: length of the contained rootfs image file (big endian)
-append_bin "$rootfs_len" 4 "$rootfs_header_file"
-# 32 bytes: Firmware Version string (NUL terminated, 0xff padded)
-printf "%s\x00%.*s" "$version" "$versionpadlen" "$pad" >> "$rootfs_header_file"
-
-kernel_header_file="$tmpdir/kernel_header"
-kernel_chksum=$(to_be $(checksum_file ${kernel}) 4)
-kernel_len=$(to_be $(wc -c < "$kernel") 4)
-
-# 4 bytes: checksum of the kernel image
-append_bin "$kernel_chksum" 4 "$kernel_header_file"
-# 4 bytes: length of the contained kernel image file (big endian)
-append_bin "$kernel_len" 4 "$kernel_header_file"
-
-board_header_file="$tmpdir/board_header"
-board_file="$tmpdir/board"
-boardpadlen=$(( 64 - ( ${#board} + 1) ))
-# 32 bytes: Model (e.g. "NBG6617", NUL termiated, 0xff padded)
-printf "%s\x00%.*s" "$board" "$boardpadlen" "$pad" > "$board_file"
-cat "$kernel_header_file" >> "$board_file"
-printf "%.12s" "$pad" >> "$board_file"
-# rest: 0xff padding
-for i in {1..511}; do
- printf "%s%s" "$pad" "$pad" >> "$board_file"
-done
-
-tmp_board_file="$tmpdir/tmp_board_file"
-cat "$rootfs_header_file" > "$tmp_board_file"
-
-# The checksum for the header is calculated over the first 2048 bytes with
-# the rootfs image checksum as the placeholder during calculation.
-append_bin "$rootfs_chksum" 4 "$tmp_board_file"
-cat "$board_file" >> "$tmp_board_file"
-
-truncate -s 2048 $tmp_board_file
-board_chksum=$(to_be $(checksum_file ${tmp_board_file}) 4)
-
-# 4 bytes: checksum over the header partition (big endian)
-append_bin "$board_chksum" 4 "$board_header_file"
-cat "$board_file" >> "$board_header_file"
-
-cat "$rootfs_header_file" "$board_header_file" "$rootfs" "$kernel" > "$outfile"
-
-rm -rf "$tmpdir"
diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index 640557532c..4568b65621 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -1086,8 +1086,12 @@ define Device/NBG6616
IMAGE_SIZE := 15323k
MTDPARTS := spi0.0:192k(u-boot)ro,64k(env)ro,64k(RFdata)ro,384k(zyxel_rfsd),384k(romd),64k(header),2048k(kernel),13184k(rootfs),15232k@0x120000(firmware)
CMDLINE += mem=128M
- IMAGES := sysupgrade.bin
+ RAS_BOARD := NBG6616
+ RAS_ROOTFS_SIZE := 14464k
+ RAS_VERSION := "$(VERSION_DIST) $(REVISION)"
+ IMAGES := factory.bin sysupgrade.bin
KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | jffs2 boot/vmlinux.lzma.uImage
+ IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | pad-to 64k | check-size $$$$(IMAGE_SIZE) | zyxel-ras-image
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
# We cannot currently build a factory image. It is the sysupgrade image
# prefixed with a header (which is actually written into the MTD device).
diff --git a/target/linux/ipq40xx/image/Makefile b/target/linux/ipq40xx/image/Makefile
index cb79baccd2..a0f81f7d63 100644
--- a/target/linux/ipq40xx/image/Makefile
+++ b/target/linux/ipq40xx/image/Makefile
@@ -221,7 +221,7 @@ define Device/zyxel_nbg6617
# at least as large as the one of the initial firmware image (not the current
# one on the device). This only applies to the Web-UI, the bootlaoder ignores
# this minimum-size. However, the larger image can be flashed both ways.
- IMAGE/factory.bin := append-rootfs | pad-rootfs | check-size $$$$(ROOTFS_SIZE) | make-ras
+ IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k | check-size $$$$(ROOTFS_SIZE) | zyxel-ras-image separate-kernel
IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-rootfs | check-size $$$$(ROOTFS_SIZE) | sysupgrade-tar rootfs=$$$$@ | append-metadata
DEVICE_PACKAGES := ipq-wifi-zyxel_nbg6617 uboot-envtools
endef
diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile
index 2902af3231..a7f740ff62 100644
--- a/target/linux/ipq806x/image/Makefile
+++ b/target/linux/ipq806x/image/Makefile
@@ -67,7 +67,8 @@ define Device/ZyXELImage
KERNEL_SUFFIX := -uImage
KERNEL = kernel-bin | append-dtb | uImage none | pad-to $${KERNEL_SIZE}
KERNEL_NAME := zImage
- IMAGES := sysupgrade.bin mmcblk0p5-rootfs.bin mmcblk0p4-kernel.bin
+ IMAGES := factory.bin sysupgrade.bin mmcblk0p5-rootfs.bin mmcblk0p4-kernel.bin
+ IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to $$$$(BLOCKSIZE) | zyxel-ras-image separate-kernel
IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to $$$${BLOCKSIZE} | sysupgrade-tar rootfs=$$$$@ | append-metadata
IMAGE/mmcblk0p5-rootfs.bin := append-rootfs | pad-rootfs | pad-to $$$${BLOCKSIZE}
IMAGE/mmcblk0p4-kernel.bin := append-kernel
@@ -245,6 +246,9 @@ define Device/zyxel_nbg6817
KERNEL_SIZE := 4096k
BLOCKSIZE := 64k
BOARD_NAME := nbg6817
+ RAS_BOARD := NBG6817
+ RAS_ROOTFS_SIZE := 20934k
+ RAS_VERSION := "V1.99(OWRT.9999)C0"
SUPPORTED_DEVICES += nbg6817
DEVICE_TITLE := ZyXEL NBG6817
DEVICE_PACKAGES := ath10k-firmware-qca9984 e2fsprogs kmod-fs-ext4 losetup
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 4b4af99908..a6379e35eb 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -70,6 +70,7 @@ define Host/Compile
$(call cc,fix-u-media-header cyg_crc32,-Wall)
$(call cc,hcsmakeimage bcmalgo)
$(call cc,mkporayfw, -Wall)
+ $(call cc,mkrasimage, --std=gnu99)
$(call cc,mkhilinkfw, -lcrypto)
$(call cc,mkdcs932, -Wall)
$(call cc,mkheader_gemtek,-lz)
diff --git a/tools/firmware-utils/src/mkrasimage.c b/tools/firmware-utils/src/mkrasimage.c
new file mode 100644
index 0000000000..8eee29cc08
--- /dev/null
+++ b/tools/firmware-utils/src/mkrasimage.c
@@ -0,0 +1,459 @@
+/*
+ * --- ZyXEL header format ---
+ * Original Version by Benjamin Berg <benjamin@sipsolutions.net>
+ * C implementation based on generation-script by Christian Lamparter <chunkeey@gmail.com>
+ *
+ * The firmware image prefixed with a header (which is written into the MTD device).
+ * The header is one erase block (~64KiB) in size, but the checksum only convers the
+ * first 2KiB. Padding is 0xff. All integers are in big-endian.
+ *
+ * The checksum is always a 16-Bit System V checksum (sum -s) stored in a 32-Bit integer.
+ *
+ * 4 bytes: checksum of the rootfs image
+ * 4 bytes: length of the contained rootfs image file (big endian)
+ * 32 bytes: Firmware Version string (NUL terminated, 0xff padded)
+ * 4 bytes: checksum over the header partition (big endian - see below)
+ * 64 bytes: Model (e.g. "NBG6617", NUL termiated, 0xff padded)
+ * 4 bytes: checksum of the kernel partition
+ * 4 bytes: length of the contained kernel image file (big endian)
+ * rest: 0xff padding (To erase block size)
+ *
+ * The kernel partition checksum and length is not used for every device.
+ * If it's notused, pad those 8 bytes with 0xFF.
+ *
+ * The checksums are calculated by adding up all bytes and if a 16bit
+ * overflow occurs, one is added and the sum is masked to 16 bit:
+ * csum = csum + databyte; if (csum > 0xffff) { csum += 1; csum &= 0xffff };
+ * Should the file have an odd number of bytes then the byte len-0x800 is
+ * used additionally.
+ *
+ * The checksum for the header is calculated over the first 2048 bytes with
+ * the rootfs image checksum as the placeholder during calculation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+#include <fcntl.h>
+#include <getopt.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include <arpa/inet.h>
+
+#define VERSION_STRING_LEN 31
+#define ROOTFS_HEADER_LEN 40
+
+#define KERNEL_HEADER_LEN 8
+
+#define BOARD_NAME_LEN 64
+#define BOARD_HEADER_LEN 68
+
+#define HEADER_PARTITION_CALC_LENGTH 2048
+#define HEADER_PARTITION_LENGTH 0x10000
+
+struct file_info {
+ char *name; /* name of the file */
+ char *data; /* file content */
+ size_t size; /* length of the file */
+};
+
+static char *progname;
+
+static char *board_name = 0;
+static char *version_name = 0;
+static unsigned int rootfs_size = 0;
+
+static struct file_info kernel = { NULL, NULL, 0 };
+static struct file_info rootfs = { NULL, NULL, 0 };
+static struct file_info rootfs_out = { NULL, NULL, 0 };
+static struct file_info out = { NULL, NULL, 0 };
+
+#define ERR(fmt, ...) do { \
+ fprintf(stderr, "[%s] *** error: " fmt "\n", \
+ progname, ## __VA_ARGS__ ); \
+} while (0)
+
+void map_file(struct file_info *finfo)
+{
+ struct stat file_stat = {0};
+ int fd;
+
+ fd = open(finfo->name, O_RDONLY, (mode_t)0600);
+ if (fd == -1) {
+ ERR("Error while opening file %s.", finfo->name);
+ exit(EXIT_FAILURE);
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ ERR("Error getting file size for %s.", finfo->name);
+ exit(EXIT_FAILURE);
+ }
+
+ finfo->size = file_stat.st_size;
+ finfo->data = mmap(0, finfo->size, PROT_READ, MAP_SHARED, fd, 0);
+
+ if (finfo->data == MAP_FAILED) {
+ ERR("Error mapping file %s.", finfo->name);
+ exit(EXIT_FAILURE);
+ }
+
+ close(fd);
+}
+
+void unmap_file(struct file_info *finfo)
+{
+ if(munmap(finfo->data, finfo->size) == -1) {
+ ERR("Error unmapping file %s.", finfo->name);
+ exit(EXIT_FAILURE);
+ }
+}
+
+void write_file(struct file_info *finfo)
+{
+ FILE *fout = fopen(finfo->name, "w");
+
+ fwrite(finfo->data, finfo->size, 1, fout);
+
+ if (ferror(fout)) {
+ ERR("Wanted to write, but something went wrong.");
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(fout);
+}
+
+void usage(int status)
+{
+ FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
+
+ fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
+ fprintf(stream,
+ "\n"
+ "Options:\n"
+ " -k <kernel> path for kernel image\n"
+ " -r <rootfs> path for rootfs image\n"
+ " -s <rfssize> size of output rootfs\n"
+ " -v <version> version string\n"
+ " -b <boardname> name of board to generate image for\n"
+ " -o <out_name> name of output image\n"
+ " -h show this screen\n"
+ );
+
+ exit(status);
+}
+
+static int sysv_chksm(const unsigned char *data, int size)
+{
+ int r;
+ int checksum;
+ unsigned int s = 0; /* The sum of all the input bytes, modulo (UINT_MAX + 1). */
+
+
+ for (int i = 0; i < size; i++) {
+ s += data[i];
+ }
+
+ r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
+ checksum = (r & 0xffff) + (r >> 16);
+
+ return checksum;
+}
+
+static int zyxel_chksm(const unsigned char *data, int size)
+{
+ return htonl(sysv_chksm(data, size));
+}
+
+char *generate_rootfs_header(struct file_info filesystem, char *version)
+{
+ size_t version_string_length;
+ unsigned int chksm, size;
+ char *rootfs_header;
+ size_t ptr = 0;
+
+ rootfs_header = malloc(ROOTFS_HEADER_LEN);
+ if (!rootfs_header) {
+ ERR("Couldn't allocate memory for rootfs header!");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Prepare padding for firmware-version string here */
+ memset(rootfs_header, 0xff, ROOTFS_HEADER_LEN);
+
+ chksm = zyxel_chksm((const unsigned char *)filesystem.data, filesystem.size);
+ size = htonl(filesystem.size);
+
+ /* 4 bytes: checksum of the rootfs image */
+ memcpy(rootfs_header + ptr, &chksm, 4);
+ ptr += 4;
+
+ /* 4 bytes: length of the contained rootfs image file (big endian) */
+ memcpy(rootfs_header + ptr, &size, 4);
+ ptr += 4;
+
+ /* 32 bytes: Firmware Version string (NUL terminated, 0xff padded) */
+ version_string_length = strlen(version) <= VERSION_STRING_LEN ? strlen(version) : VERSION_STRING_LEN;
+ memcpy(rootfs_header + ptr, version, version_string_length);
+ ptr += version_string_length;
+ /* Add null-terminator */
+ rootfs_header[ptr] = 0x0;
+
+ return rootfs_header;
+}
+
+char *generate_kernel_header(struct file_info kernel)
+{
+ unsigned int chksm, size;
+ char *kernel_header;
+ size_t ptr = 0;
+
+ kernel_header = malloc(KERNEL_HEADER_LEN);
+ if (!kernel_header) {
+ ERR("Couldn't allocate memory for kernel header!");
+ exit(EXIT_FAILURE);
+ }
+
+ chksm = zyxel_chksm((const unsigned char *)kernel.data, kernel.size);
+ size = htonl(kernel.size);
+
+ /* 4 bytes: checksum of the kernel image */
+ memcpy(kernel_header + ptr, &chksm, 4);
+ ptr += 4;
+
+ /* 4 bytes: length of the contained kernel image file (big endian) */
+ memcpy(kernel_header + ptr, &size, 4);
+
+ return kernel_header;
+}
+
+unsigned int generate_board_header_checksum(char *kernel_hdr, char *rootfs_hdr, char *boardname)
+{
+ char *board_hdr_tmp;
+ unsigned int sum;
+ size_t ptr = 0;
+
+ /*
+ * The checksum of the board header is calculated over the first 2048 bytes of
+ * the header partition with the rootfs checksum used as a placeholder for then
+ * board checksum we calculate in this step. The checksum gained from this step
+ * is then used for the final board header partition.
+ */
+
+ board_hdr_tmp = malloc(HEADER_PARTITION_CALC_LENGTH);
+ if (!board_hdr_tmp) {
+ ERR("Couldn't allocate memory for temporary board header!");
+ exit(EXIT_FAILURE);
+ }
+ memset(board_hdr_tmp, 0xff, HEADER_PARTITION_CALC_LENGTH);
+
+ /* 40 bytes: RootFS header */
+ memcpy(board_hdr_tmp, rootfs_hdr, ROOTFS_HEADER_LEN);
+ ptr += ROOTFS_HEADER_LEN;
+
+ /* 4 bytes: RootFS checksum (BE) as placeholder for board-header checksum */
+ memcpy(board_hdr_tmp + ptr, rootfs_hdr, 4);
+ ptr += 4;
+
+ /* 32 bytes: Model (e.g. "NBG6617", NUL termiated, 0xff padded) */
+ memcpy(board_hdr_tmp + ptr, boardname, strlen(boardname));
+ ptr += strlen(boardname);
+ /* Add null-terminator */
+ board_hdr_tmp[ptr] = 0x0;
+ ptr = ROOTFS_HEADER_LEN + 4 + BOARD_NAME_LEN;
+
+ /* 8 bytes: Kernel header */
+ if (kernel_hdr)
+ memcpy(board_hdr_tmp + ptr, kernel_hdr, 8);
+
+ /* Calculate the checksum over the first 2048 bytes */
+ sum = zyxel_chksm((const unsigned char *)board_hdr_tmp, HEADER_PARTITION_CALC_LENGTH);
+ free(board_hdr_tmp);
+ return sum;
+}
+
+char *generate_board_header(char *kernel_hdr, char *rootfs_hdr, char *boardname)
+{
+ unsigned int board_checksum;
+ char *board_hdr;
+
+ board_hdr = malloc(BOARD_HEADER_LEN);
+ if (!board_hdr) {
+ ERR("Couldn't allocate memory for board header!");
+ exit(EXIT_FAILURE);
+ }
+ memset(board_hdr, 0xff, BOARD_HEADER_LEN);
+
+ /* 4 bytes: checksum over the header partition (big endian) */
+ board_checksum = generate_board_header_checksum(kernel_hdr, rootfs_hdr, boardname);
+ memcpy(board_hdr, &board_checksum, 4);
+
+ /* 32 bytes: Model (e.g. "NBG6617", NUL termiated, 0xff padded) */
+ memcpy(board_hdr + 4, boardname, strlen(boardname));
+ board_hdr[4 + strlen(boardname)] = 0x0;
+
+ return board_hdr;
+}
+
+int build_image()
+{
+ char *rootfs_header = NULL;
+ char *kernel_header = NULL;
+ char *board_header = NULL;
+
+ size_t ptr;
+
+ /* Load files */
+ if (kernel.name)
+ map_file(&kernel);
+ map_file(&rootfs);
+
+ /*
+ * Allocate memory and copy input rootfs for temporary output rootfs.
+ * This is important as we have to generate the rootfs checksum over the
+ * entire rootfs partition. As we might have to pad the partition to allow
+ * for flashing via ZyXEL's Web-GUI, we prepare the rootfs partition for the
+ * output image here (and also use it for calculating the rootfs checksum).
+ *
+ * The roofs padding has to be done with 0x00.
+ */
+ rootfs_out.data = calloc(rootfs_out.size, sizeof(char));
+ memcpy(rootfs_out.data, rootfs.data, rootfs.size);
+
+ /* Prepare headers */
+ rootfs_header = generate_rootfs_header(rootfs_out, version_name);
+ if (kernel.name)
+ kernel_header = generate_kernel_header(kernel);
+ board_header = generate_board_header(kernel_header, rootfs_header, board_name);
+
+ /* Prepare output file */
+ out.size = HEADER_PARTITION_LENGTH + rootfs_out.size;
+ if (kernel.name)
+ out.size += kernel.size;
+ out.data = malloc(out.size);
+ memset(out.data, 0xFF, out.size);
+
+ /* Build output image */
+ memcpy(out.data, rootfs_header, ROOTFS_HEADER_LEN);
+ memcpy(out.data + ROOTFS_HEADER_LEN, board_header, BOARD_HEADER_LEN);
+ if (kernel.name)
+ memcpy(out.data + ROOTFS_HEADER_LEN + BOARD_HEADER_LEN, kernel_header, KERNEL_HEADER_LEN);
+ ptr = HEADER_PARTITION_LENGTH;
+ memcpy(out.data + ptr, rootfs_out.data, rootfs_out.size);
+ ptr += rootfs_out.size;
+ if (kernel.name)
+ memcpy(out.data + ptr, kernel.data, kernel.size);
+
+ /* Write back output image */
+ write_file(&out);
+
+ /* Free allocated memory */
+ if (kernel.name)
+ unmap_file(&kernel);
+ unmap_file(&rootfs);
+ free(out.data);
+ free(rootfs_out.data);
+
+ free(rootfs_header);
+ if (kernel.name)
+ free(kernel_header);
+ free(board_header);
+
+ return 0;
+}
+
+int check_options()
+{
+ if (!rootfs.name) {
+ ERR("No rootfs filename supplied");
+ return -2;
+ }
+
+ if (!out.name) {
+ ERR("No output filename supplied");
+ return -3;
+ }
+
+ if (!board_name) {
+ ERR("No board-name supplied");
+ return -4;
+ }
+
+ if (!version_name) {
+ ERR("No version supplied");
+ return -5;
+ }
+
+ if (rootfs_size <= 0) {
+ ERR("Invalid rootfs size supplied");
+ return -6;
+ }
+
+ if (strlen(board_name) > 31) {
+ ERR("Board name is to long");
+ return -7;
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ progname = basename(argv[0]);
+ while (1) {
+ int c;
+
+ c = getopt(argc, argv, "b:k:o:r:s:v:h");
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'b':
+ board_name = optarg;
+ break;
+ case 'h':
+ usage(EXIT_SUCCESS);
+ break;
+ case 'k':
+ kernel.name = optarg;
+ break;
+ case 'o':
+ out.name = optarg;
+ break;
+ case 'r':
+ rootfs.name = optarg;
+ break;
+ case 's':