[PATCH v3] ramips: add support for Huasifei WS1208V2

2023-02-03 Thread arinc9 . unal
From: Arınç ÜNAL 

The Huasifei WS1208V2 is an AC1200 router featuring 5 Ethernet ports with a
Quectel RM520N-GL cellular modem which supports QMI and MBIM modes.

Specifications:
- MT7621AT, 256 MiB RAM, 16 MiB SPI Flash
- MT7603EN 2.4 GHz & MT7612EN 5 GHz WLAN
- Quectel RM520N-GL Cellular Modem
- 2 WLAN & 4 Cellular Antennas
- 5 Gigabit Ethernet Ports
- 1 USB 2.0 port
- 1 PCI-E Slot
- 1 M.2 slot
- 1 SIM card slot
- 1 SD card slot

Installation:
- Install sysupgrade image via ROOter OS.

TFTP Recovery:
- Connect to serial console.
- Boot initramfs image by choosing option 1 when U-Boot prompts.
- Install sysupgrade image via OpenWrt.

Link: https://www.huasifei.com/a/Products/5G%20CPE/240.html
Signed-off-by: Arınç ÜNAL 
---

v3: Move definitions under factory, and stop removing wpad-basic-wolfssl.
v2: Add recovery information.

---
 .../ramips/dts/mt7621_huasifei_ws1208v2.dts   | 185 ++
 target/linux/ramips/image/mt7621.mk   |  12 ++
 .../mt7621/base-files/etc/board.d/01_leds |   3 +
 3 files changed, 200 insertions(+)
 create mode 100644 target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts

diff --git a/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts 
b/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts
new file mode 100644
index 00..fe77f65207
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts
@@ -0,0 +1,185 @@
+#include "mt7621.dtsi"
+
+#include 
+#include 
+
+/ {
+   compatible = "huasifei,ws1208v2", "mediatek,mt7621-soc";
+   model = "Huasifei WS1208V2";
+
+   aliases {
+   led-boot = _status;
+   led-failsafe = _status;
+   led-running = _status;
+   led-upgrade = _status;
+   label-mac-device = 
+   };
+
+   chosen {
+   bootargs = "console=ttyS0,115200";
+   };
+
+   keys {
+   compatible = "gpio-keys";
+
+   button-reset {
+   label = "Reset";
+   gpios = < 18 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_status: led-status {
+   label = "green:status";
+   gpios = < 12 GPIO_ACTIVE_LOW>;
+   };
+
+   led-cellular {
+   label = "green:cellular";
+   gpios = < 10 GPIO_ACTIVE_LOW>;
+   };
+
+   led-wlan5g {
+   label = "green:wlan5g";
+   gpios = < 14 GPIO_ACTIVE_LOW>;
+   linux,default-trigger = "phy1tpt";
+   };
+
+   led-wlan2g {
+   label = "green:wlan2g";
+   gpios = < 5 GPIO_ACTIVE_LOW>;
+   linux,default-trigger = "phy0tpt";
+   };
+
+   led-usb {
+   label = "green:usb";
+   gpios = < 11 GPIO_ACTIVE_HIGH>;
+   trigger-sources = <_ehci_port1>;
+   linux,default-trigger = "usbport";
+   };
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   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 = "u-boot";
+   reg = <0x0 0x3>;
+   read-only;
+   };
+
+   partition@3 {
+   label = "u-boot-env";
+   reg = <0x3 0x1>;
+   read-only;
+   };
+
+   factory: partition@4 {
+   label = "factory";
+   reg = <0x4 0x1>;
+   read-only;
+
+   compatible = "nvmem-cells";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_factory_e000: macaddr@e000 {
+   reg = <0xe000 0x6>;
+   };
+   };
+
+   partition@5 {
+   compatible = "denx,uimage";
+   reg = <0x5 0xfb>;
+   label = "firmware";
+   };
+   };
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   wifi@0,0 {
+   compatible = "pci14c3,7603";
+   reg = <0x 0 

Re: [PATCH v2] ramips: add support for Huasifei WS1208V2

2023-02-03 Thread Arınç ÜNAL

On 3.02.2023 16:03, Hauke Mehrtens wrote:

On 1/27/23 14:57, arinc9.u...@gmail.com wrote:

From: Arınç ÜNAL 

The Huasifei WS1208V2 is an AC1200 router featuring 5 Ethernet ports 
with a

Quectel RM520N-GL cellular modem which supports QMI and MBIM modes.

Specifications:
- MT7621AT, 256 MiB RAM, 16 MiB SPI Flash
- MT7603EN 2.4 GHz & MT7612EN 5 GHz WLAN
- Quectel RM520N-GL Cellular Modem
- 2 WLAN & 4 Cellular Antennas
- 5 Gigabit Ethernet Ports
- 1 USB 2.0 port
- 1 PCI-E Slot
- 1 M.2 slot
- 1 SIM card slot
- 1 SD card slot

Installation:
- Install sysupgrade image via ROOter OS.

TFTP Recovery:
- Connect to serial console.
- Boot initramfs image by choosing option 1 when U-Boot prompts.
- Install sysupgrade image via OpenWrt.

Link: https://www.huasifei.com/a/Products/5G%20CPE/240.html
Signed-off-by: Arınç ÜNAL 
---

v2: Add recovery information.

---
  .../ramips/dts/mt7621_huasifei_ws1208v2.dts   | 187 ++
  target/linux/ramips/image/mt7621.mk   |  12 ++
  .../mt7621/base-files/etc/board.d/01_leds |   3 +
  3 files changed, 202 insertions(+)
  create mode 100644 target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts

diff --git a/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts 
b/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts

new file mode 100644
index 00..c69f05a0f4
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts
@@ -0,0 +1,187 @@

.

+ {
+    compatible = "nvmem-cells";
+    #address-cells = <1>;
+    #size-cells = <1>;
+
+    macaddr_factory_e000: macaddr@e000 {
+    reg = <0xe000 0x6>;
+    };
+};


Please move this directly where you defined the factory partition in the 
partitions node.


Will do.



diff --git a/target/linux/ramips/image/mt7621.mk 
b/target/linux/ramips/image/mt7621.mk

index 2269833e48..bbd25e5be0 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -996,6 +996,18 @@ define Device/humax_e10
  endef
  TARGET_DEVICES += humax_e10
+define Device/huasifei_ws1208v2
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 16064k
+  DEVICE_VENDOR := Huasifei
+  DEVICE_MODEL := WS1208V2
+  DEVICE_PACKAGES := kmod-ata-ahci kmod-mt7603 kmod-mt76x2 
kmod-sdhci-mt7620 \

+    kmod-usb3 kmod-usb-net-cdc-mbim kmod-usb-net-qmi-wwan \
+    kmod-usb-serial-option -wpad-basic-wolfssl


Why do you remove wpad-basic-wolfssl?


This shouldn't be there, thanks for pointing it out.


What is kmod-usb-net-cdc-mbim needed for?


That's to manage the cellular modem using the MBIM specification. 
ModemManager or umbim can be used for this. Speaking of umbim, it would 
be great if you could apply these fixes on umbim.


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

Arınç

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


Re: 22.03.3 for mvebu (Turris Omnia)

2023-02-03 Thread Stefan Lippers-Hollmann
Hi


On 2023-02-03, Sebastian Moeller wrote:
> MVEBU devices are not supported in kernel 5.10 based OpenWrt22.03.3 due to a 
> bug.
> The fix is already in 5.15, but seems to intrusive to backport.
> Current snapshot builds are on kernel 5.15 already and the issue does not 
> exist anymore.
> So the easy ways forward are:
> 1) stick to 22.03.2
[...]

Just to be clear and explicit about it, 22.03.0, 22.03.1 and 22.03.2
are affected just the same as 22.03.3 would have been, so the decision
should be more about going back to 21.02.x or going forward to
(master-) snapshots, until the next kernel v5.15 based major stable
release arrives (23.xy.0) or until 22.03.x gets fixed eventually
(which doesn't appear to be very likely at the moment).

Regards
Stefan Lippers-Hollmann

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


[PATCH firmware-utils v1 07/10] tplink-safeloader: refactor image ingestion

2023-02-03 Thread Sander Vanheule
The tool supports three modes that ingest an existing safeloader image:
-i (image info), -x (extract payloads), and -z (convert to sysupgrade).
These modes all re-implement image parsing, so refactor the code to make
sure there is only one place this is performed.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 169 +++-
 1 file changed, 98 insertions(+), 71 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 51f6683c802a..ab08ad1f8580 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -127,6 +127,12 @@ struct __attribute__((__packed__)) soft_version {
uint32_t compat_level;
 };
 
+/* Internal representation of safeloader image data */
+struct safeloader_image_info {
+   size_t payload_offset;
+   struct flash_partition_entry entries[MAX_PARTITIONS];
+};
+
 #define SAFELOADER_PREAMBLE_SIZE   0x14
 #define SAFELOADER_HEADER_SIZE 0x1000
 #define SAFELOADER_PAYLOAD_OFFSET  (SAFELOADER_PREAMBLE_SIZE + 
SAFELOADER_HEADER_SIZE)
@@ -3795,6 +3801,46 @@ static int read_partition_table(
return 0;
 }
 
+static void safeloader_read_partition(FILE *input_file, size_t payload_offset,
+ struct flash_partition_entry *entry,
+ struct image_partition_entry *part)
+{
+   size_t part_size = entry->size;
+   void *part_data = malloc(part_size);
+
+   if (fseek(input_file, payload_offset, SEEK_SET))
+   error(1, errno, "Failed to seek to partition data");
+
+   if (!part_data)
+   error(1, ENOMEM, "Failed to allocate partition data");
+
+   if (fread(part_data, 1, part_size, input_file) < part_size)
+   error(1, errno, "Failed to read partition data");
+
+   part->data = part_data;
+   part->size = part_size;
+   part->name = entry->name;
+}
+
+static void safeloader_parse_image(FILE *input_file, struct 
safeloader_image_info *image)
+{
+   char buf[64];
+
+   if (!input_file)
+   return;
+
+   fseek(input_file, SAFELOADER_PREAMBLE_SIZE, SEEK_SET);
+
+   if (fread(buf, sizeof(buf), 1, input_file) != 1)
+   error(1, errno, "Can not read image header");
+
+   image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
+
+   /* Parse image partition table */
+   read_partition_table(input_file, image->payload_offset, 
>entries[0],
+MAX_PARTITIONS, PARTITION_TABLE_FWUP);
+}
+
 static void write_partition(
FILE *input_file,
size_t firmware_offset,
@@ -3844,12 +3890,9 @@ static int extract_firmware_partition(FILE *input_file, 
size_t firmware_offset,
 /** extract all partitions from the firmware file */
 static int extract_firmware(const char *input, const char *output_directory)
 {
-   struct flash_partition_entry entries[16] = { 0 };
-   size_t max_entries = 16;
-   size_t firmware_offset = SAFELOADER_PAYLOAD_OFFSET;
-   FILE *input_file;
-
+   struct safeloader_image_info info = {};
struct stat statbuf;
+   FILE *input_file;
 
/* check input file */
if (stat(input, )) {
@@ -3866,12 +3909,10 @@ static int extract_firmware(const char *input, const 
char *output_directory)
}
 
input_file = fopen(input, "rb");
+   safeloader_parse_image(input_file, );
 
-   if (read_partition_table(input_file, firmware_offset, entries, 16, 
PARTITION_TABLE_FWUP) != 0)
-   error(1, 0, "Error can not read the partition table 
(fwup-ptn)");
-
-   for (size_t i = 0; i < max_entries && entries[i].name; i++)
-   extract_firmware_partition(input_file, firmware_offset, 
[i], output_directory);
+   for (size_t i = 0; i < MAX_PARTITIONS && info.entries[i].name; i++)
+   extract_firmware_partition(input_file, info.payload_offset, 
[i], output_directory);
 
return 0;
 }
@@ -3894,39 +3935,33 @@ static struct flash_partition_entry *find_partition(
 
 static int firmware_info(const char *input)
 {
-   struct flash_partition_entry pointers[MAX_PARTITIONS] = { };
+   struct safeloader_image_info info = {};
+   struct image_partition_entry part = {};
struct flash_partition_entry *e;
-   FILE *fp;
-   int i;
+   FILE *input_file;
 
-   fp = fopen(input, "r");
+   input_file = fopen(input, "rb");
 
-   if (read_partition_table(fp, SAFELOADER_PAYLOAD_OFFSET, pointers, 
MAX_PARTITIONS, PARTITION_TABLE_FWUP))
-   error(1, 0, "Error can not read the partition table 
(fwup-ptn)");
+   safeloader_parse_image(input_file, );
 
printf("Firmware image partitions:\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
 
-   e = [0];
-   for (i = 0; i < MAX_PARTITIONS && e->name; i++, e++)
+   e = [0];
+   for (unsigned int i = 0; i < MAX_PARTITIONS && e->name; i++, e++)

[PATCH firmware-utils v1 09/10] tplink-safeloader: add QNEW image detection

2023-02-03 Thread Sander Vanheule
An incompatible image type is now used, e.g. for the TL-WPA8631P v4,
which has a header containing 0x3C extra bytes. This image type can be
identified by the first four bytes of the image header being "?NEW".

Only detection is implemented at this moment, as the full header format
is not yet understood, and the preamble checksum can no longer be
verified using the current md5sum salt. Devices still appear to accept
images in the "old" format, so image generation is not required at this
moment.

Cc: Andreas Böhler 
Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 693745704e87..71dfe7910dbb 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -142,10 +142,18 @@ struct __attribute__((__packed__)) soft_version {
  *   Header contains up to 0x1000 bytes of vendor data, starting with a big 
endian
  *   UINT32 size, followed by that number of bytes containing (text) data.
  *   Padded with 0xFF. Payload starts at offset 0x1014.
+ *
+ * SAFELOADER_TYPE_QNEW
+ *   Reversed order preamble, with (apparent) md5 checksum before the image
+ *   size. The size does not include the preamble length.
+ *   Header starts with 0x3C bytes, starting with the string '?NEW' (format not
+ *   understood). Then another 0x1000 bytes follow, with the data payload
+ *   starting at 0x1050.
  */
 enum safeloader_image_type {
SAFELOADER_TYPE_DEFAULT,
SAFELOADER_TYPE_VENDOR,
+   SAFELOADER_TYPE_QNEW,
 };
 
 /* Internal representation of safeloader image data */
@@ -159,6 +167,10 @@ struct safeloader_image_info {
 #define SAFELOADER_HEADER_SIZE 0x1000
 #define SAFELOADER_PAYLOAD_OFFSET  (SAFELOADER_PREAMBLE_SIZE + 
SAFELOADER_HEADER_SIZE)
 
+#define SAFELOADER_QNEW_HEADER_SIZE0x3C
+#define SAFELOADER_QNEW_PAYLOAD_OFFSET \
+   (SAFELOADER_PREAMBLE_SIZE + SAFELOADER_QNEW_HEADER_SIZE + 
SAFELOADER_HEADER_SIZE)
+
 #define SAFELOADER_PAYLOAD_TABLE_SIZE  0x800
 
 static const uint8_t jffs2_eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};
@@ -3846,6 +3858,8 @@ static void safeloader_read_partition(FILE *input_file, 
size_t payload_offset,
 
 static void safeloader_parse_image(FILE *input_file, struct 
safeloader_image_info *image)
 {
+   static const char *HEADER_ID_QNEW = "?NEW";
+
char buf[64];
 
if (!input_file)
@@ -3856,12 +3870,22 @@ static void safeloader_parse_image(FILE *input_file, 
struct safeloader_image_inf
if (fread(buf, sizeof(buf), 1, input_file) != 1)
error(1, errno, "Can not read image header");
 
-   if (ntohl(*((uint32_t *) [0])) <= SAFELOADER_HEADER_SIZE)
+   if (memcmp(HEADER_ID_QNEW, [0], strlen(HEADER_ID_QNEW)) == 0)
+   image->type = SAFELOADER_TYPE_QNEW;
+   else if (ntohl(*((uint32_t *) [0])) <= SAFELOADER_HEADER_SIZE)
image->type = SAFELOADER_TYPE_VENDOR;
else
image->type = SAFELOADER_TYPE_DEFAULT;
 
-   image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
+   switch (image->type) {
+   case SAFELOADER_TYPE_DEFAULT:
+   case SAFELOADER_TYPE_VENDOR:
+   image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
+   break;
+   case SAFELOADER_TYPE_QNEW:
+   image->payload_offset = SAFELOADER_QNEW_PAYLOAD_OFFSET;
+   break;
+   }
 
/* Parse image partition table */
read_partition_table(input_file, image->payload_offset, 
>entries[0],
-- 
2.39.0


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


[PATCH firmware-utils v1 10/10] tplink-safeloader: add Cloud image detection

2023-02-03 Thread Sander Vanheule
The vendor info in the safeloader header for some images (e.g. Archer
C60 v3) starts with "fw-type:Cloud" instead of a big endian data length.

Only detection is implemented at this moment, as the full header format
is not yet understood.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 71dfe7910dbb..f39e7fe15f2a 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -143,6 +143,11 @@ struct __attribute__((__packed__)) soft_version {
  *   UINT32 size, followed by that number of bytes containing (text) data.
  *   Padded with 0xFF. Payload starts at offset 0x1014.
  *
+ * SAFELOADER_TYPE_CLOUD
+ *   Standard preamble with size including preamble length, and checksum.
+ *   Followed by the 'fw-type:Cloud' string and some (unknown) data.
+ *   Payload starts at offset 0x1014.
+ *
  * SAFELOADER_TYPE_QNEW
  *   Reversed order preamble, with (apparent) md5 checksum before the image
  *   size. The size does not include the preamble length.
@@ -153,6 +158,7 @@ struct __attribute__((__packed__)) soft_version {
 enum safeloader_image_type {
SAFELOADER_TYPE_DEFAULT,
SAFELOADER_TYPE_VENDOR,
+   SAFELOADER_TYPE_CLOUD,
SAFELOADER_TYPE_QNEW,
 };
 
@@ -3858,6 +3864,7 @@ static void safeloader_read_partition(FILE *input_file, 
size_t payload_offset,
 
 static void safeloader_parse_image(FILE *input_file, struct 
safeloader_image_info *image)
 {
+   static const char *HEADER_ID_CLOUD = "fw-type:Cloud";
static const char *HEADER_ID_QNEW = "?NEW";
 
char buf[64];
@@ -3872,6 +3879,8 @@ static void safeloader_parse_image(FILE *input_file, 
struct safeloader_image_inf
 
if (memcmp(HEADER_ID_QNEW, [0], strlen(HEADER_ID_QNEW)) == 0)
image->type = SAFELOADER_TYPE_QNEW;
+   else if (memcmp(HEADER_ID_CLOUD, [0], strlen(HEADER_ID_CLOUD)) == 0)
+   image->type = SAFELOADER_TYPE_CLOUD;
else if (ntohl(*((uint32_t *) [0])) <= SAFELOADER_HEADER_SIZE)
image->type = SAFELOADER_TYPE_VENDOR;
else
@@ -3880,6 +3889,7 @@ static void safeloader_parse_image(FILE *input_file, 
struct safeloader_image_inf
switch (image->type) {
case SAFELOADER_TYPE_DEFAULT:
case SAFELOADER_TYPE_VENDOR:
+   case SAFELOADER_TYPE_CLOUD:
image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
break;
case SAFELOADER_TYPE_QNEW:
-- 
2.39.0


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


[PATCH firmware-utils v1 08/10] tplink-safeloader: add vendor info support

2023-02-03 Thread Sander Vanheule
Some images may contain ASCII vendor info at the start of the image
header. Detect this image type, and display the info when requested.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 42 +
 1 file changed, 42 insertions(+)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index ab08ad1f8580..693745704e87 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -127,8 +127,30 @@ struct __attribute__((__packed__)) soft_version {
uint32_t compat_level;
 };
 
+/*
+ * Safeloader image type
+ *   Safeloader images contain a 0x14 byte preamble with image size (big endian
+ *   UINT32) and md5 checksum (16 bytes).
+ *
+ * SAFEFLOADER_TYPE_DEFAULT
+ *   Standard preamble with size including preamble length, and checksum.
+ *   Header of 0x1000 bytes, contents of which are not specified.
+ *   Payload starts at offset 0x1014.
+ *
+ * SAFELOADER_TYPE_VENDOR
+ *   Standard preamble with size including preamble length, and checksum.
+ *   Header contains up to 0x1000 bytes of vendor data, starting with a big 
endian
+ *   UINT32 size, followed by that number of bytes containing (text) data.
+ *   Padded with 0xFF. Payload starts at offset 0x1014.
+ */
+enum safeloader_image_type {
+   SAFELOADER_TYPE_DEFAULT,
+   SAFELOADER_TYPE_VENDOR,
+};
+
 /* Internal representation of safeloader image data */
 struct safeloader_image_info {
+   enum safeloader_image_type type;
size_t payload_offset;
struct flash_partition_entry entries[MAX_PARTITIONS];
 };
@@ -3834,6 +3856,11 @@ static void safeloader_parse_image(FILE *input_file, 
struct safeloader_image_inf
if (fread(buf, sizeof(buf), 1, input_file) != 1)
error(1, errno, "Can not read image header");
 
+   if (ntohl(*((uint32_t *) [0])) <= SAFELOADER_HEADER_SIZE)
+   image->type = SAFELOADER_TYPE_VENDOR;
+   else
+   image->type = SAFELOADER_TYPE_DEFAULT;
+
image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
 
/* Parse image partition table */
@@ -3944,6 +3971,21 @@ static int firmware_info(const char *input)
 
safeloader_parse_image(input_file, );
 
+   if (info.type == SAFELOADER_TYPE_VENDOR) {
+   char buf[SAFELOADER_HEADER_SIZE] = {};
+   uint32_t vendor_size;
+
+   fseek(input_file, SAFELOADER_PREAMBLE_SIZE, SEEK_SET);
+   fread(_size, sizeof(uint32_t), 1, input_file);
+
+   vendor_size = ntohl(vendor_size);
+   fread(buf, vendor_size, 1, input_file);
+
+   printf("Firmware vendor string:\n");
+   fwrite(buf, strnlen(buf, vendor_size), 1, stdout);
+   printf("\n");
+   }
+
printf("Firmware image partitions:\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
 
-- 
2.39.0


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


[PATCH firmware-utils v1 06/10] tplink-safeloader: ignore NULLs in version info

2023-02-03 Thread Sander Vanheule
When the soft-version partition contents are checked for a text-format
version string, isascii() is used to check the contained bytes. This
also returns true on control characters, which includes terminating
NULL characters.

After checking if the data is a string, use the actual string length for
printing the contained data to avoid outputting NULLs to stdout.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 05b7ca17f786..51f6683c802a 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -3928,18 +3928,16 @@ static int firmware_info(const char *input)
if (fread(buf, data_len, 1, fp) != 1)
error(1, errno, "Can not read fwup-ptn data from the 
firmware");
 
-   /* Check for string ignoring padding character */
-   isstr = true;
-   for (i = 0; i < data_len - 1; i++) {
-   if (!isascii(buf[i])) {
-   isstr = false;
-   break;
-   }
-   }
+   /* Check for (null-terminated) string */
+   ascii_len = 0;
+   while (ascii_len < data_len && isascii(buf[ascii_len]))
+   ascii_len++;
+
+   isstr = ascii_len == data_len;
 
printf("\n[Software version]\n");
if (isstr) {
-   fwrite(buf, data_len, 1, stdout);
+   fwrite(buf, strnlen(buf, data_len), 1, stdout);
putchar('\n');
} else if (data_len >= offsetof(struct soft_version, rev)) {
s = (struct soft_version *)buf;
-- 
2.39.0


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


[PATCH firmware-utils v1 03/10] tplink-safeloader: replace hardcoded offsets

2023-02-03 Thread Sander Vanheule
A number of data offsets are used as plain numbers throughout the code.
This is a bit fragile, and the magic numbers make the code harder to
read. Use a set of macros instead.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 39 ++-
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 79aefd973232..0a6327b0d265 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -127,6 +127,11 @@ struct __attribute__((__packed__)) soft_version {
uint32_t compat_level;
 };
 
+#define SAFELOADER_PREAMBLE_SIZE   0x14
+#define SAFELOADER_HEADER_SIZE 0x1000
+#define SAFELOADER_PAYLOAD_OFFSET  (SAFELOADER_PREAMBLE_SIZE + 
SAFELOADER_HEADER_SIZE)
+
+#define SAFELOADER_PAYLOAD_TABLE_SIZE  0x800
 
 static const uint8_t jffs2_eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};
 
@@ -3184,7 +3189,7 @@ static void set_source_date_epoch() {
 /** Generates the partition-table partition */
 static struct image_partition_entry make_partition_table(const struct 
device_info *p)
 {
-   struct image_partition_entry entry = 
alloc_image_partition(p->partition_names.partition_table, 0x800);
+   struct image_partition_entry entry = 
alloc_image_partition(p->partition_names.partition_table, 
SAFELOADER_PAYLOAD_TABLE_SIZE);
 
char *s = (char *)entry.data, *end = (char *)(s+entry.size);
 
@@ -3347,9 +3352,9 @@ static struct image_partition_entry read_file(const char 
*part_name, const char
 */
 static void put_partitions(uint8_t *buffer, const struct flash_partition_entry 
*flash_parts, const struct image_partition_entry *parts) {
size_t i, j;
-   char *image_pt = (char *)buffer, *end = image_pt + 0x800;
+   char *image_pt = (char *)buffer, *end = image_pt + 
SAFELOADER_PAYLOAD_TABLE_SIZE;
 
-   size_t base = 0x800;
+   size_t base = SAFELOADER_PAYLOAD_TABLE_SIZE;
for (i = 0; parts[i].name; i++) {
for (j = 0; flash_parts[j].name; j++) {
if (!strcmp(flash_parts[j].name, parts[i].name)) {
@@ -3402,7 +3407,7 @@ static void put_md5(uint8_t *md5, uint8_t *buffer, 
unsigned int len) {
  1814-Firmware partitions
 */
 static void * generate_factory_image(struct device_info *info, const struct 
image_partition_entry *parts, size_t *len) {
-   *len = 0x1814;
+   *len = SAFELOADER_PAYLOAD_OFFSET + SAFELOADER_PAYLOAD_TABLE_SIZE;
 
size_t i;
for (i = 0; parts[i].name; i++)
@@ -3417,12 +3422,12 @@ static void * generate_factory_image(struct device_info 
*info, const struct imag
 
if (info->vendor) {
size_t vendor_len = strlen(info->vendor);
-   put32(image+0x14, vendor_len);
-   memcpy(image+0x18, info->vendor, vendor_len);
+   put32(image + SAFELOADER_PREAMBLE_SIZE, vendor_len);
+   memcpy(image + SAFELOADER_PREAMBLE_SIZE + 0x4, info->vendor, 
vendor_len);
}
 
-   put_partitions(image + 0x1014, info->partitions, parts);
-   put_md5(image+0x04, image+0x14, *len-0x14);
+   put_partitions(image + SAFELOADER_PAYLOAD_OFFSET, info->partitions, 
parts);
+   put_md5(image + 0x04, image + SAFELOADER_PREAMBLE_SIZE, *len - 
SAFELOADER_PREAMBLE_SIZE);
 
return image;
 }
@@ -3689,7 +3694,7 @@ static int read_partition_table(
struct flash_partition_entry *entries, size_t max_entries,
int type)
 {
-   char buf[2048];
+   char buf[SAFELOADER_PAYLOAD_TABLE_SIZE];
char *ptr, *end;
const char *parthdr = NULL;
const char *fwuphdr = "fwup-ptn";
@@ -3711,10 +3716,10 @@ static int read_partition_table(
if (fseek(file, offset, SEEK_SET) < 0)
error(1, errno, "Can not seek in the firmware");
 
-   if (fread(buf, 2048, 1, file) != 1)
+   if (fread(buf, sizeof(buf), 1, file) != 1)
error(1, errno, "Can not read fwup-ptn from the firmware");
 
-   buf[2047] = '\0';
+   buf[sizeof(buf) - 1] = '\0';
 
/* look for the partition header */
if (memcmp(buf, parthdr, strlen(parthdr)) != 0) {
@@ -3841,7 +3846,7 @@ static int extract_firmware(const char *input, const char 
*output_directory)
 {
struct flash_partition_entry entries[16] = { 0 };
size_t max_entries = 16;
-   size_t firmware_offset = 0x1014;
+   size_t firmware_offset = SAFELOADER_PAYLOAD_OFFSET;
FILE *input_file;
 
struct stat statbuf;
@@ -3902,7 +3907,7 @@ static int firmware_info(const char *input)
 
fp = fopen(input, "r");
 
-   if (read_partition_table(fp, 0x1014, pointers, MAX_PARTITIONS, 
PARTITION_TABLE_FWUP))
+   if (read_partition_table(fp, SAFELOADER_PAYLOAD_OFFSET, pointers, 
MAX_PARTITIONS, PARTITION_TABLE_FWUP))
error(1, 0, "Error can not read the partition table 
(fwup-ptn)");
 
printf("Firmware image partitions:\n");
@@ -3927,7 +3932,7 @@ 

[PATCH firmware-utils v1 05/10] tplink-safeloader: don't end-pad sysupgrade file

2023-02-03 Thread Sander Vanheule
To ensure the stock rootfs ends up at the correct offset, the preceding
kernel partition is padded with 0xff, corresponding to erased flash.
Since on sysupgrade all the required flash space is anyway rased before
writing the new image, it is not necessary to also pad after the second
and last part of the generated image. This can reduce the generated
image size by several MiB.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 5b19e8726821..05b7ca17f786 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -4071,7 +4071,6 @@ static void convert_firmware(const char *input, const 
char *output)
/* write file-system behind os_image */
fseek(output_file, flash_file_system->base - flash_os_image->base, 
SEEK_SET);
write_partition(input_file, firmware_offset, fwup_file_system, 
output_file);
-   write_ff(output_file, flash_file_system->size - fwup_file_system->size);
 
fclose(output_file);
fclose(input_file);
-- 
2.39.0


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


[PATCH firmware-utils v1 02/10] tplink-safeloader: use enum for table types

2023-02-03 Thread Sander Vanheule
The partition table parser supports two table types, which only differ
in the starting ID of a table entry. Selection of which type to parse is
performed with a plain integer, but this makes code harder to read.
Replace the integer by an enum to make type selection more obvious.

While touching the code, also fix the switch-case indentation.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 6c4689c2f67c..79aefd973232 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -3679,6 +3679,11 @@ static int add_flash_partition(
 }
 
 /** read the partition table into struct flash_partition_entry */
+enum PARTITION_TABLE_TYPE {
+   PARTITION_TABLE_FWUP,
+   PARTITION_TABLE_FLASH,
+};
+
 static int read_partition_table(
FILE *file, long offset,
struct flash_partition_entry *entries, size_t max_entries,
@@ -3693,14 +3698,14 @@ static int read_partition_table(
/* TODO: search for the partition table */
 
switch(type) {
-   case 0:
-   parthdr = fwuphdr;
-   break;
-   case 1:
-   parthdr = flashhdr;
-   break;
-   default:
-   error(1, 0, "Invalid partition table");
+   case PARTITION_TABLE_FWUP:
+   parthdr = fwuphdr;
+   break;
+   case PARTITION_TABLE_FLASH:
+   parthdr = flashhdr;
+   break;
+   default:
+   error(1, 0, "Invalid partition table");
}
 
if (fseek(file, offset, SEEK_SET) < 0)
@@ -3857,9 +3862,8 @@ static int extract_firmware(const char *input, const char 
*output_directory)
 
input_file = fopen(input, "rb");
 
-   if (read_partition_table(input_file, firmware_offset, entries, 16, 0) 
!= 0) {
+   if (read_partition_table(input_file, firmware_offset, entries, 16, 
PARTITION_TABLE_FWUP) != 0)
error(1, 0, "Error can not read the partition table 
(fwup-ptn)");
-   }
 
for (size_t i = 0; i < max_entries; i++) {
if (entries[i].name == NULL &&
@@ -3898,9 +3902,8 @@ static int firmware_info(const char *input)
 
fp = fopen(input, "r");
 
-   if (read_partition_table(fp, 0x1014, pointers, MAX_PARTITIONS, 0)) {
+   if (read_partition_table(fp, 0x1014, pointers, MAX_PARTITIONS, 
PARTITION_TABLE_FWUP))
error(1, 0, "Error can not read the partition table 
(fwup-ptn)");
-   }
 
printf("Firmware image partitions:\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
@@ -3980,11 +3983,11 @@ static int firmware_info(const char *input)
 
e = find_partition(pointers, MAX_PARTITIONS, "partition-table", NULL);
if (e) {
+   size_t flash_table_offset = 0x1014 + e->base + 4;
struct flash_partition_entry parts[MAX_PARTITIONS] = { };
 
-   if (read_partition_table(fp, 0x1014 + e->base + 4, parts, 
MAX_PARTITIONS, 1)) {
+   if (read_partition_table(fp, flash_table_offset, parts, 
MAX_PARTITIONS, PARTITION_TABLE_FLASH))
error(1, 0, "Error can not read the partition table 
(partition)");
-   }
 
printf("\n[Partition table]\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
@@ -4032,6 +4035,7 @@ static void convert_firmware(const char *input, const 
char *output)
struct flash_partition_entry *fwup_partition_table = NULL;
size_t firmware_offset = 0x1014;
FILE *input_file, *output_file;
+   size_t flash_table_offset;
 
struct stat statbuf;
 
@@ -4060,7 +4064,8 @@ static void convert_firmware(const char *input, const 
char *output)
"partition-table", "Error can not find partition-table 
partition");
 
/* the flash partition table has a 0x0004 magic haeder */
-   if (read_partition_table(input_file, firmware_offset + 
fwup_partition_table->base + 4, flash, MAX_PARTITIONS, 1) != 0)
+   flash_table_offset = firmware_offset + fwup_partition_table->base + 4;
+   if (read_partition_table(input_file, flash_table_offset, flash, 
MAX_PARTITIONS, PARTITION_TABLE_FLASH) != 0)
error(1, 0, "Error can not read the partition table (flash)");
 
flash_os_image = find_partition(flash, MAX_PARTITIONS,
-- 
2.39.0


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


[PATCH firmware-utils v1 01/10] tplink-safeloader: stricter free_image_partition()

2023-02-03 Thread Sander Vanheule
Instead of only free()-ing the allocated data block, also clear the name
and size of a payload entry to indicate that it's become invalid.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index d9e16058883c..6c4689c2f67c 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -3156,8 +3156,15 @@ static void set_partition_names(struct device_info *info)
 }
 
 /** Frees an image partition */
-static void free_image_partition(struct image_partition_entry entry) {
-   free(entry.data);
+static void free_image_partition(struct image_partition_entry *entry)
+{
+   void *data = entry->data;
+
+   entry->name = NULL;
+   entry->size = 0;
+   entry->data = NULL;
+
+   free(data);
 }
 
 static time_t source_date_epoch = -1;
@@ -3598,7 +3605,7 @@ static void build_image(const char *output,
free(image);
 
for (i = 0; parts[i].name; i++)
-   free_image_partition(parts[i]);
+   free_image_partition([i]);
 }
 
 /** Usage output */
-- 
2.39.0


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


[PATCH firmware-utils v1 00/10] Refactor image ingestion to support new formats

2023-02-03 Thread Sander Vanheule
TP-Link is playing fast and loose with the safeloader format, having
resulted in different types of images with their specific quirks.

A new incompatible format is currently used in the wild, which places
the payload partition table at a different offset, causing the image
parsers to fail. [1]

This series starts by fixing a bug or two and cleaning up the code a
tiny bit, and then refactors the different image ingestion options to
use one common parser.

Finally, support for the QNEW and Cloud images types is added through the
new parser. The latter doesn't really need explicit support at the
moment, so the patch serves mostly as documentation.

[1] https://forum.openwrt.org/t/148982

Best,
Sander

Sander Vanheule (10):
  tplink-safeloader: stricter free_image_partition()
  tplink-safeloader: use enum for table types
  tplink-safeloader: replace hardcoded offsets
  tplink-safeloader: stop at nameless partition
  tplink-safeloader: don't end-pad sysupgrade file
  tplink-safeloader: ignore NULLs in version info
  tplink-safeloader: refactor image ingestion
  tplink-safeloader: add vendor info support
  tplink-safeloader: add QNEW image detection
  tplink-safeloader: add Cloud image detection

 src/tplink-safeloader.c | 341 ++--
 1 file changed, 222 insertions(+), 119 deletions(-)

-- 
2.39.0


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


[PATCH firmware-utils v1 04/10] tplink-safeloader: stop at nameless partition

2023-02-03 Thread Sander Vanheule
Current code only skips all-zero partition table entries, but nameless
partitions with zero size don't make much sense either. Assume that any
entry without a partition name is invalid, and stop processing entry
lists at that point.

Signed-off-by: Sander Vanheule 
---
 src/tplink-safeloader.c | 28 +++-
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c
index 0a6327b0d265..5b19e8726821 100644
--- a/src/tplink-safeloader.c
+++ b/src/tplink-safeloader.c
@@ -3870,14 +3870,8 @@ static int extract_firmware(const char *input, const 
char *output_directory)
if (read_partition_table(input_file, firmware_offset, entries, 16, 
PARTITION_TABLE_FWUP) != 0)
error(1, 0, "Error can not read the partition table 
(fwup-ptn)");
 
-   for (size_t i = 0; i < max_entries; i++) {
-   if (entries[i].name == NULL &&
-   entries[i].base == 0 &&
-   entries[i].size == 0)
-   continue;
-
+   for (size_t i = 0; i < max_entries && entries[i].name; i++)
extract_firmware_partition(input_file, firmware_offset, 
[i], output_directory);
-   }
 
return 0;
 }
@@ -3912,14 +3906,10 @@ static int firmware_info(const char *input)
 
printf("Firmware image partitions:\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
-   for (i = 0; i < MAX_PARTITIONS; i++) {
-   e = [i];
-
-   if (!e->name && !e->base && !e->size)
-   continue;
 
-   printf("%08x %08x %s\n", e->base, e->size, e->name ? e->name : 
"");
-   }
+   e = [0];
+   for (i = 0; i < MAX_PARTITIONS && e->name; i++, e++)
+   printf("%08x %08x %s\n", e->base, e->size, e->name);
 
e = find_partition(pointers, MAX_PARTITIONS, "soft-version", NULL);
if (e) {
@@ -3996,14 +3986,10 @@ static int firmware_info(const char *input)
 
printf("\n[Partition table]\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
-   for (i = 0; i < MAX_PARTITIONS; i++) {
-   e = [i];
-
-   if (!e->name && !e->base && !e->size)
-   continue;
 
-   printf("%08x %08x %s\n", e->base, e->size, e->name ? 
e->name : "");
-   }
+   e = [0];
+   for (i = 0; i < MAX_PARTITIONS && e->name; i++, e++)
+   printf("%08x %08x %s\n", e->base, e->size, e->name);
}
 
fclose(fp);
-- 
2.39.0


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


Re: 22.03.3 for mvebu (Turris Omnia)

2023-02-03 Thread Sebastian Moeller
MVEBU devices are not supported in kernel 5.10 based OpenWrt22.03.3 due to a 
bug.
The fix is already in 5.15, but seems to intrusive to backport.
Current snapshot builds are on kernel 5.15 already and the issue does not exist 
anymore.
So the easy ways forward are:
1) stick to 22.03.2 
2) switch (back) to turrisOS 6 (based on OpenWrt21, but with the fixed kernel 
5.15)
3) simply use the typically pretty stable snapshots

Regards
Sebastian




> On Feb 3, 2023, at 21:53, Mark Thurston  wrote:
> 
> The latest image available for Turris Omnia (mvebu) is 22.03.2 
> (https://openwrt.org/toh/turris/turris_omnia). I was surprised to see 22.03.3 
> is not available for this target. Is there anything that I can do to help 
> make a built 22.03.3 image available for general download?
> 
> I'm happy to put in some legwork, if someone can point me in the right 
> direction (I'm new here).
> 
> Bw
> 
> Mark
> 
> ___
> 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: 22.03.3 for mvebu (Turris Omnia)

2023-02-03 Thread Kabuli Chana

Flagged broken:

 
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=a0bae2fef8bdd4f76767e1b29deb1adf279403e9

due to broken switch behaviour, which is resolved with kernel 5.15, 
backport ID'ed but too invasive.


On 2023-02-03 13:53, Mark Thurston wrote:

The latest image available for Turris Omnia (mvebu) is 22.03.2 
(https://openwrt.org/toh/turris/turris_omnia). I was surprised to see 22.03.3 
is not available for this target. Is there anything that I can do to help make 
a built 22.03.3 image available for general download?

I'm happy to put in some legwork, if someone can point me in the right 
direction (I'm new here).

Bw

Mark

___
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


22.03.3 for mvebu (Turris Omnia)

2023-02-03 Thread Mark Thurston
The latest image available for Turris Omnia (mvebu) is 22.03.2 
(https://openwrt.org/toh/turris/turris_omnia). I was surprised to see 22.03.3 
is not available for this target. Is there anything that I can do to help make 
a built 22.03.3 image available for general download?

I'm happy to put in some legwork, if someone can point me in the right 
direction (I'm new here).

Bw

Mark

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


Re: Unloading unused kernel modules (NAT speed)

2023-02-03 Thread Florian Fainelli

On 2/3/23 08:18, Rafał Miłecki wrote:

Another step in my NAT performance debugging.

I realized that my OpenWrt 21.02 based bcm53xx builds can't reach 940
Mb/s because I have qos-scripts installed.

It happens even with QoS interface disabled:
qos.wan.enabled='0'
and with QoS disabled in general:
/etc/init.d/qos stop
(disable & reboot don't help neither)

After quite some debugging I discovered that:
1. qos-scripts selects iptables-mod-conntrack-extra
2. iptables-mod-conntrack-extra selects kmod-ipt-raw
3. kmod-ipt-raw provides iptable_raw.ko
4. iptable_raw.ko slows down NAT


I can bump NAT speed from 880 Mb/s to 940 Mb/s by doing:

# rmmod iptable_raw
unloading the module failed
# /etc/init.d/firewall stop > /dev/null 2>&1
# rmmod iptable_raw
# /etc/init.d/firewall start > /dev/null 2>&1


I'm wondering if there is any good solution to that. I can't think of
anything clean and generic. Handling modprobe & rmmod directly in
/etc/init.d/qos sounds really hacky. Any good ideas?


Have you managed to get a `perf record` or `perf top` capture to see 
whether we might be going a little too far into iptables-raw code rather 
than bailing out early if we are not utilizing it?

--
Florian


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


Re: Anyone working on porting OpenSSL to v3.x?

2023-02-03 Thread Eneas U de Queiroz
On Fri, Feb 3, 2023 at 5:02 PM Paul Spooren  wrote:
>
> Hey all,
>
> We’re still using OpenSSL 1.1.x within OpenWrt and during the last developer 
> meeting we were wondering if anyone is working on porting it over to v3.x? If 
> so please share your status, thanks!

It's been on my to-do list for ages.  I can start working on it now.
Cheers,
Eneas

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


Anyone working on porting OpenSSL to v3.x?

2023-02-03 Thread Paul Spooren
Hey all,

We’re still using OpenSSL 1.1.x within OpenWrt and during the last developer 
meeting we were wondering if anyone is working on porting it over to v3.x? If 
so please share your status, thanks!

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


Re: [PATCH fstools v2] partname: Correct fstools_partname_fallback_scan comparison

2023-02-03 Thread Brian Norris
Hi Ansuel (or others),

On Wed, Jan 25, 2023 at 10:18 PM Brian Norris
 wrote:
>
> Commit 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan
> option") had two problems:
>
> 1. The strcmp() aborted when the param *matched* 1; we wanted the
>inverse
> 2. It was too aggressive about skipping the fallback behavior. For
>devices that had no root= parameter, they would always attempt the
>fallback scan.
>
> Fix both of those.
>
> Fixes: 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan 
> option")
> Signed-off-by: Brian Norris 

Would you be able to look at this soon? Your emergency fix broke
multiple things, and I'd like to get TP-Link OnHub back in shape so
others can rely on snapshot builds.

Thanks,
Brian

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


Re: Unloading unused kernel modules (NAT speed)

2023-02-03 Thread Dave Taht
I dont use qos-scripts, but sqm-scripts. That said, cake peers into
the nat table to balance the traffic better.

On Fri, Feb 3, 2023 at 8:23 AM Rafał Miłecki  wrote:
>
> Another step in my NAT performance debugging.
>
> I realized that my OpenWrt 21.02 based bcm53xx builds can't reach 940
> Mb/s because I have qos-scripts installed.
>
> It happens even with QoS interface disabled:
> qos.wan.enabled='0'
> and with QoS disabled in general:
> /etc/init.d/qos stop
> (disable & reboot don't help neither)
>
> After quite some debugging I discovered that:
> 1. qos-scripts selects iptables-mod-conntrack-extra
> 2. iptables-mod-conntrack-extra selects kmod-ipt-raw
> 3. kmod-ipt-raw provides iptable_raw.ko
> 4. iptable_raw.ko slows down NAT
>
>
> I can bump NAT speed from 880 Mb/s to 940 Mb/s by doing:
>
> # rmmod iptable_raw
> unloading the module failed
> # /etc/init.d/firewall stop > /dev/null 2>&1
> # rmmod iptable_raw
> # /etc/init.d/firewall start > /dev/null 2>&1
>
>
> I'm wondering if there is any good solution to that. I can't think of
> anything clean and generic. Handling modprobe & rmmod directly in
> /etc/init.d/qos sounds really hacky. Any good ideas?
>
> --
> Rafał
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel



-- 
This song goes out to all the folk that thought Stadia would work:
https://www.linkedin.com/posts/dtaht_the-mushroom-song-activity-698135607352320-FXtz
Dave Täht CEO, TekLibre, LLC

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


Unloading unused kernel modules (NAT speed)

2023-02-03 Thread Rafał Miłecki
Another step in my NAT performance debugging.

I realized that my OpenWrt 21.02 based bcm53xx builds can't reach 940
Mb/s because I have qos-scripts installed.

It happens even with QoS interface disabled:
qos.wan.enabled='0'
and with QoS disabled in general:
/etc/init.d/qos stop
(disable & reboot don't help neither)

After quite some debugging I discovered that:
1. qos-scripts selects iptables-mod-conntrack-extra
2. iptables-mod-conntrack-extra selects kmod-ipt-raw
3. kmod-ipt-raw provides iptable_raw.ko
4. iptable_raw.ko slows down NAT


I can bump NAT speed from 880 Mb/s to 940 Mb/s by doing:

# rmmod iptable_raw
unloading the module failed
# /etc/init.d/firewall stop > /dev/null 2>&1
# rmmod iptable_raw
# /etc/init.d/firewall start > /dev/null 2>&1


I'm wondering if there is any good solution to that. I can't think of
anything clean and generic. Handling modprobe & rmmod directly in
/etc/init.d/qos sounds really hacky. Any good ideas?

-- 
Rafał

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


Re: [PATCH v2] ramips: add support for Huasifei WS1208V2

2023-02-03 Thread Hauke Mehrtens

On 1/27/23 14:57, arinc9.u...@gmail.com wrote:

From: Arınç ÜNAL 

The Huasifei WS1208V2 is an AC1200 router featuring 5 Ethernet ports with a
Quectel RM520N-GL cellular modem which supports QMI and MBIM modes.

Specifications:
- MT7621AT, 256 MiB RAM, 16 MiB SPI Flash
- MT7603EN 2.4 GHz & MT7612EN 5 GHz WLAN
- Quectel RM520N-GL Cellular Modem
- 2 WLAN & 4 Cellular Antennas
- 5 Gigabit Ethernet Ports
- 1 USB 2.0 port
- 1 PCI-E Slot
- 1 M.2 slot
- 1 SIM card slot
- 1 SD card slot

Installation:
- Install sysupgrade image via ROOter OS.

TFTP Recovery:
- Connect to serial console.
- Boot initramfs image by choosing option 1 when U-Boot prompts.
- Install sysupgrade image via OpenWrt.

Link: https://www.huasifei.com/a/Products/5G%20CPE/240.html
Signed-off-by: Arınç ÜNAL 
---

v2: Add recovery information.

---
  .../ramips/dts/mt7621_huasifei_ws1208v2.dts   | 187 ++
  target/linux/ramips/image/mt7621.mk   |  12 ++
  .../mt7621/base-files/etc/board.d/01_leds |   3 +
  3 files changed, 202 insertions(+)
  create mode 100644 target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts

diff --git a/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts 
b/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts
new file mode 100644
index 00..c69f05a0f4
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_huasifei_ws1208v2.dts
@@ -0,0 +1,187 @@

.

+ {
+   compatible = "nvmem-cells";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_factory_e000: macaddr@e000 {
+   reg = <0xe000 0x6>;
+   };
+};


Please move this directly where you defined the factory partition in the 
partitions node.



diff --git a/target/linux/ramips/image/mt7621.mk 
b/target/linux/ramips/image/mt7621.mk
index 2269833e48..bbd25e5be0 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -996,6 +996,18 @@ define Device/humax_e10
  endef
  TARGET_DEVICES += humax_e10
  
+define Device/huasifei_ws1208v2

+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 16064k
+  DEVICE_VENDOR := Huasifei
+  DEVICE_MODEL := WS1208V2
+  DEVICE_PACKAGES := kmod-ata-ahci kmod-mt7603 kmod-mt76x2 kmod-sdhci-mt7620 \
+   kmod-usb3 kmod-usb-net-cdc-mbim kmod-usb-net-qmi-wwan \
+   kmod-usb-serial-option -wpad-basic-wolfssl


Why do you remove wpad-basic-wolfssl?
What is kmod-usb-net-cdc-mbim needed for?



+endef
+TARGET_DEVICES += huasifei_ws1208v2
+
  define Device/iodata_wn-ax1167gr
$(Device/dsa-migration)
$(Device/uimage-lzma-loader)




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


Re: [PATCH] fw4: add a range of icmpv6 types

2023-02-03 Thread Jo-Philipp Wich
Hi,

the patch was white-space mangled and the Signed-off-by didn't match the
author. It also introduced syntax errors in fw4.uc so it seems it hasn't been
runtime tested at all.

Superseded by https://git.openwrt.org/e6e82a5 and 
https://git.openwrt.org/30ee17a.



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


Re: [PATCH] fw4: fix ipset comment field from bool to string

2023-02-03 Thread Jo-Philipp Wich
Hi,

the patch was whitespace mangled and didn't apply. After fixing it up
manually, the Signed-off-by didn't match the author. Also the fixed option
wasn't use anywhere so the fix was rather incomplete (or not useful by itself).

It is superseded by https://git.openwrt.org/39e8c70 now.

Regards,
Jo



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