Re: [PATCH] ipq40xx: google (gale) add LED aliases

2023-03-29 Thread Brian Norris
Hi,

On Mon, Mar 27, 2023 at 07:29:39AM +0200, open...@aiyionpri.me wrote:
> From: Jan-Niklas Burfeind 
> 
> this is similar to
> commit 583ac0e11df7 ("mpc85xx: update lp5521 led-controller node for
> 5.10")
> 
> Google uses white for running and red for an issue
> 
> Signed-off-by: Jan-Niklas Burfeind 
> ---
> Good morning.
> 
> Currently the tristate LED does not have an assigned function,
> while it does have several in stock firmware.
> 
> Once the multi-intensity section becomes active, the device should use
> white/blueish light as running indicator.
> For now blue is used for LED_RUNNING.
> 
> If there's a way to use white instead of blue, just let me know;
> I'd gladly fix that at once.

I'll admit, I wasn't familiar with these led-* aliases (and the custom
package/base-files/files/lib/functions/leds.sh that parses them) until
now. But it looks like they only support a single LED for a given
function, so while we might like to enable the red, blue and green (to
get white), that doesn't seem possible without switching over the to
full multi-color LED device tree binding. But then, I don't think LUCI
knows how to configure multi-color LEDs yet.

I guess the choices you made here are better than the "nothing" that is
currently here, so:

Reviewed-by: Brian Norris 

One more note below:

> --- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wifi.dts
> +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wifi.dts

> @@ -255,12 +259,13 @@
>   clock-mode = /bits/ 8 <1>;
>  
>  #if 1
> - led@0 {
> + led0_red: led@0 {
>   reg = <0>;
>   chan-name = "LED0_Red";
>   led-cur = /bits/ 8 <0x64>;
>   max-cur = /bits/ 8 <0x78>;
>   color = ;
> + function = LED_FUNCTION_FAULT;

Are you sure this 'function' property is actually doing anything? I know
the common DT bindings provide this, but I'm pretty sure the lp5523
driver doesn't actually use it for anything -- it derives its LED names
from either 'chan-name' or as a combination of a few other properties
('label', channel number, etc.).

I guess it's not wrong, per se, to include it, but I did purposely only
specify the properties that made sense for this driver.

Same comment applies to the other 'function' uses.

Brian

>   };
>  
>   led@1 {
> @@ -271,12 +276,13 @@
>   color = ;
>   };
>  
> - led@2 {
> + led0_blue: led@2 {
>   reg = <2>;
>   chan-name = "LED0_Blue";
>   led-cur = /bits/ 8 <0x64>;
>   max-cur = /bits/ 8 <0x78>;
>   color = ;
> + function = LED_FUNCTION_POWER;
>   };
>  #else
>   /*
> @@ -285,6 +291,7 @@
>* # echo 255 > /sys/class/leds/tricolor/brightness
>*/
>   multi-led@2 {
> + function = LED_FUNCTION_POWER;
>   reg = <2>;
>   color = ;
>   #address-cells = <1>;
> -- 
> 2.40.0
> 

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


Re: [PATCH v2] ipq40xx: google (gale) add reset button

2023-03-29 Thread Brian Norris
On Sun, Mar 26, 2023 at 10:50:42PM +0200, open...@aiyionpri.me wrote:
> From: Jan-Niklas Burfeind 
> 
> add the external button (GPIO 57) as reset button
> 
> Co-authored-by: Brian Norris 
> Signed-off-by: Jan-Niklas Burfeind 
> ---
> 
> I added the phandle for fw_pinmux and used it as you suggested.
> Furthermore added the function gpio similar to your referenced PR.
> 
> Hopefully this reflects your intentions.
> 
> I just compiled and tested it again, resetting still works with the
> added changes.
> 
> Have a nice evening everyone and thanks for reviewing this
> aiyion

Thanks for the v2. Looks and works fine for me:

Reviewed-by: Brian Norris 
Tested-by: Brian Norris 

I think you have an extra space in the patch subject, but presumably
somebody could fix that one up when committing it for real.

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


Meeting Notes March 2023

2023-03-29 Thread Paul Spooren
Hi,

Another month, another developer meeting - short and sweet:

https://openwrt.org/meetings/20230328

Best,
Paul

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


Re: [PATCH netifd v2] interface-ip: fix ipv6 routing loop

2023-03-29 Thread Hans Dedecker
Hi,

On Wed, Mar 29, 2023 at 4:44 PM Maxim Mikityanskiy  wrote:
>
> Hello Hans!
>
> On Sun, 03 Jan 2021 12:14:18 -0800, Hans Dedecker wrote:
> > In case of prefix delegation an upstream ISP will route the complete
> > delegated prefix (e.g 2001:DB8:BEEF::/56) to an OpenWrt device, OpenWrt
> > will route back the complete /56 not matching a local or subdelegated
> > prefix and with as source an address from the delegated prefix
> > causing a routing loop.
> > Fix this by using an ip rule which directs traffic matching the
> > subdelegated prefix and coming from the wan interface to the main or
> > user configured routing table.
> > An ip rule with lower priority will make sure the traffic not matching
> > the subdelegated prefix(es) will be dropped with an ICMPv6 unreachable
> > fixing the potential routing loop.
> >
> >
> > This will result into the following typical IPv6 rules :
> >
> > 0:  from all lookup local
> > 3:  from all to 2001:DB8:BEEF::/64 iif eth4 lookup main
> > 30001:  from all to 2001:DB8:BEEF::/56 iif eth4 unreachable
> > 32766:  from all lookup main
> > 42: from 2001:DB8:BEEF::1/64 iif br-lan unreachable
>
> Could you please hint me why the rule with ID 42 is useful? I
> understand the purpose of rule 30001 explained in this commit message,
> but I can't imagine the situation in which rule 42 would be
> triggered, because the main routing table has the default route that
> would be the final match.
If IPv6 source based routing is used the default route will only be
hit when the source IP matches the source attached to the default
route.
If this is not the case the unreachable ip rule will be hit if the
source IP matches the source attached to the rule

Hans
>
> Thanks,
> Max
>
> > 420001: from all iif lo failed_policy
> > 420011: from all iif eth0 failed_policy
> > 420015: from all iif eth4 failed_policy
> > 420015: from all iif eth4 failed_policy
> > 420019: from all iif br-lan failed_policy
> >
> > Signed-off-by: Hans Dedecker 
> > ---
> > v2: Keep unreachable route in the routing table dropping traffic from the 
> > lan
> > not matching any routing rules with an ICMPv6 unreachable

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


Re: [PATCH netifd v2] interface-ip: fix ipv6 routing loop

2023-03-29 Thread Maxim Mikityanskiy
Hello Hans!

On Sun, 03 Jan 2021 12:14:18 -0800, Hans Dedecker wrote:
> In case of prefix delegation an upstream ISP will route the complete
> delegated prefix (e.g 2001:DB8:BEEF::/56) to an OpenWrt device, OpenWrt
> will route back the complete /56 not matching a local or subdelegated
> prefix and with as source an address from the delegated prefix
> causing a routing loop.
> Fix this by using an ip rule which directs traffic matching the
> subdelegated prefix and coming from the wan interface to the main or
> user configured routing table.
> An ip rule with lower priority will make sure the traffic not matching
> the subdelegated prefix(es) will be dropped with an ICMPv6 unreachable
> fixing the potential routing loop.
> 
> 
> This will result into the following typical IPv6 rules :
> 
> 0:  from all lookup local
> 3:  from all to 2001:DB8:BEEF::/64 iif eth4 lookup main
> 30001:  from all to 2001:DB8:BEEF::/56 iif eth4 unreachable
> 32766:  from all lookup main
> 42: from 2001:DB8:BEEF::1/64 iif br-lan unreachable

Could you please hint me why the rule with ID 42 is useful? I
understand the purpose of rule 30001 explained in this commit message,
but I can't imagine the situation in which rule 42 would be
triggered, because the main routing table has the default route that
would be the final match.

Thanks,
Max

> 420001: from all iif lo failed_policy
> 420011: from all iif eth0 failed_policy
> 420015: from all iif eth4 failed_policy
> 420015: from all iif eth4 failed_policy
> 420019: from all iif br-lan failed_policy
> 
> Signed-off-by: Hans Dedecker 
> ---
> v2: Keep unreachable route in the routing table dropping traffic from the lan
> not matching any routing rules with an ICMPv6 unreachable

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


[PATCH][odhcpd] router: Add PREF64 (RFC 8781) RA option support

2023-03-29 Thread Ondřej Caletka
This adds support for RA option that signals NAT64 prefix used
in the network.

Signed-off-by: Ondřej Caletka 
---
 README   |  2 ++
 src/config.c | 20 +++
 src/odhcpd.h |  5 
 src/router.c | 70 +++-
 4 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/README b/README
index ef8758e..24e57d4 100644
--- a/README
+++ b/README
@@ -142,6 +142,8 @@ ra_mtu  integer -   
MTU to be advertised in
RA messages
 ra_dns bool1   Announce DNS 
configuration in
RA messages (RFC8106)
+ra_pref64  string  Announce PREF64 option
+   [IPv6 prefix]   for NAT64 prefix 
(RFC8781)
 ndproxy_routingbool1   Learn routes 
from NDP
 ndproxy_slave  bool0   NDProxy external slave
 prefix_filter  string  ::/0Only advertise on-link 
prefixes within
diff --git a/src/config.c b/src/config.c
index 27e7f03..7d54319 100644
--- a/src/config.c
+++ b/src/config.c
@@ -82,6 +82,7 @@ enum {
IFACE_ATTR_RA_HOPLIMIT,
IFACE_ATTR_RA_MTU,
IFACE_ATTR_RA_DNS,
+   IFACE_ATTR_RA_PREF64,
IFACE_ATTR_PD_MANAGER,
IFACE_ATTR_PD_CER,
IFACE_ATTR_NDPROXY_ROUTING,
@@ -135,6 +136,7 @@ static const struct blobmsg_policy 
iface_attrs[IFACE_ATTR_MAX] = {
[IFACE_ATTR_RA_HOPLIMIT] = { .name = "ra_hoplimit", .type = 
BLOBMSG_TYPE_INT32 },
[IFACE_ATTR_RA_MTU] = { .name = "ra_mtu", .type = BLOBMSG_TYPE_INT32 },
[IFACE_ATTR_RA_DNS] = { .name = "ra_dns", .type = BLOBMSG_TYPE_BOOL },
+   [IFACE_ATTR_RA_PREF64] = { .name = "ra_pref64", .type = 
BLOBMSG_TYPE_STRING },
[IFACE_ATTR_NDPROXY_ROUTING] = { .name = "ndproxy_routing", .type = 
BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = 
BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_PREFIX_FILTER] = { .name = "prefix_filter", .type = 
BLOBMSG_TYPE_STRING },
@@ -953,6 +955,24 @@ int config_parse_interface(void *data, size_t len, const 
char *name, bool overwr
if ((c = tb[IFACE_ATTR_RA_DNS]))
iface->ra_dns = blobmsg_get_bool(c);
 
+   if ((c = tb[IFACE_ATTR_RA_PREF64])) {
+   const char *str = blobmsg_get_string(c);
+   char *astr = malloc(strlen(str) + 1);
+   char *delim;
+   int l;
+
+   if (!astr || !strcpy(astr, str) ||
+   (delim = strchr(astr, '/')) == NULL || 
(*(delim++) = 0) ||
+   sscanf(delim, "%i", ) == 0 || l > 128 ||
+   inet_pton(AF_INET6, astr, >pref64_addr) 
== 0)
+   iface->pref64_length = 0;
+   else
+   iface->pref64_length = l;
+
+   if (astr)
+   free(astr);
+   }
+
if ((c = tb[IFACE_ATTR_RA_PREFERENCE])) {
const char *prio = blobmsg_get_string(c);
 
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 0550bc2..5dd35f8 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -34,6 +34,9 @@
 #define ND_OPT_RECURSIVE_DNS 25
 #define ND_OPT_DNS_SEARCH 31
 
+// RFC 8781 defines PREF64 option
+#define ND_OPT_PREF64 38
+
 #define INFINITE_VALID(x) ((x) == 0)
 
 #define _unused __attribute__((unused))
@@ -300,6 +303,8 @@ struct interface {
bool ra_advrouter;
bool ra_useleasetime;
bool ra_dns;
+   uint8_t pref64_length;
+   struct in6_addr pref64_addr;
bool no_dynamic_dhcp;
bool have_link_local;
uint8_t pio_filter_length;
diff --git a/src/router.c b/src/router.c
index eca0bf7..4422eb9 100644
--- a/src/router.c
+++ b/src/router.c
@@ -390,6 +390,7 @@ enum {
IOV_RA_ROUTES,
IOV_RA_DNS,
IOV_RA_SEARCH,
+   IOV_RA_PREF64,
IOV_RA_ADV_INTERVAL,
IOV_RA_TOTAL,
 };
@@ -427,6 +428,13 @@ struct nd_opt_route_info {
uint32_t addr[4];
 };
 
+struct nd_opt_pref64_info {
+   uint8_t type;
+   uint8_t len;
+   uint16_t lifetime_plc;
+   uint32_t addr[3];
+};
+
 /* Router Advert server mode */
 static int send_router_advert(struct interface *iface, const struct in6_addr 
*from)
 {
@@ -437,10 +445,12 @@ static int send_router_advert(struct interface *iface, 
const struct in6_addr *fr
struct nd_opt_dns_server *dns = NULL;
struct nd_opt_search_list *search = NULL;
struct nd_opt_route_info *routes = NULL;
+   struct nd_opt_pref64_info *pref64 = NULL;
struct nd_opt_adv_interval adv_interval;
struct iovec iov[IOV_RA_TOTAL];
struct sockaddr_in6 dest;
-   size_t dns_sz = 0, search_sz = 0, pfxs_cnt = 0, routes_cnt = 0;
+   size_t dns_sz = 0, 

Re: next OpenWrt 22.03 and 21.02 minor release

2023-03-29 Thread Joseph Mullally
On Tue, Mar 28, 2023 at 11:44 AM Paul Spooren  wrote:
> >
> > How should simple github PRs that are intended be applied to both
> > /master and /openwrt-22.03 be handled?
>
> Feel free to open both at the same time to have the CI running, however be 
> sure to mark the backport as “draft” and once committed to the main branch, 
> cherry-pick it with -x so we got a commit reference.
>
> > (Where the long way would be: first open a PR to /master then come
> > back and open another PR to cherry-pick back to /openwrt-22.03)
>
> We had issues with “trivial” locking backports, skipping a day or two of 
> waiting isn’t worth the risk in my opinion.

Thanks, I will do so now. My own recent PR is such an example, it
mistakenly includes a kernel patch for Linux 5.15 which doesn't exist
on /openwrt-22.03 , which the CI testing would probably catch :)

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


[PATCH netifd 1/2] treewide: fix multiple compiler warnings

2023-03-29 Thread Petr Štetiar
Fixes bunch of clang-15/gcc-10 compiler warnings, mostly related to
blobmsg_for_each_attr() usage:

 error: comparison of integers of different signs: 'int' and 'unsigned long' 
[-Werror,-Wsign-compare]
 error: comparison of integers of different signs: 'size_t' (aka 'unsigned 
long') and 'int' [-Werror,-Wsign-compare]
 error: format string is not a string literal [-Werror,-Wformat-nonliteral]

Cc: Hauke Mehrtens 
Signed-off-by: Petr Štetiar 
---
 bonding.c  |  2 +-
 bridge.c   |  5 +++--
 config.c   |  2 +-
 extdev.c   |  7 ---
 interface-ip.c |  4 ++--
 interface.c|  5 +++--
 main.c |  1 +
 proto-shell.c  | 10 +-
 proto.c|  6 +++---
 system-linux.c |  2 +-
 ubus.c |  2 +-
 vlandev.c  |  3 ++-
 wireless.c |  6 +++---
 13 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/bonding.c b/bonding.c
index f4005de059b4..402c71cb7a89 100644
--- a/bonding.c
+++ b/bonding.c
@@ -353,7 +353,7 @@ bonding_config_init(struct device *dev)
 {
struct bonding_device *bdev;
struct blob_attr *cur;
-   int rem;
+   size_t rem;
 
bdev = container_of(dev, struct bonding_device, dev);
 
diff --git a/bridge.c b/bridge.c
index f6e3f4b95bdc..cc833298b134 100644
--- a/bridge.c
+++ b/bridge.c
@@ -782,7 +782,7 @@ bridge_hotplug_set_member_vlans(struct bridge_state *bst, 
struct blob_attr *vlan
 {
struct bridge_vlan *vlan;
struct blob_attr *cur;
-   int rem;
+   size_t rem;
 
if (!vlans)
return;
@@ -1030,7 +1030,8 @@ bridge_config_init(struct device *dev)
struct bridge_state *bst;
struct bridge_vlan *vlan;
struct blob_attr *cur;
-   int i, rem;
+   size_t rem;
+   int i;
 
bst = container_of(dev, struct bridge_state, dev);
 
diff --git a/config.c b/config.c
index 9bbda39d3fb5..e1c01e12994b 100644
--- a/config.c
+++ b/config.c
@@ -337,7 +337,7 @@ config_parse_vlan(struct device *dev, struct uci_section *s)
char *name_buf;
int name_len = 0;
int n_ports = 0;
-   int rem;
+   size_t rem;
 
val = uci_lookup_option_string(uci_ctx, s, "vlan");
if (!val)
diff --git a/extdev.c b/extdev.c
index 5c5e76901d81..8d06228170e1 100644
--- a/extdev.c
+++ b/extdev.c
@@ -754,7 +754,7 @@ static void
 __buf_add_all(struct blob_attr *attr)
 {
struct blob_attr *cur;
-   int rem;
+   size_t rem;
 
blobmsg_for_each_attr(cur, attr, rem)
blobmsg_add_field(, blobmsg_type(cur), blobmsg_name(cur), 
blobmsg_data(cur),
@@ -1055,7 +1055,8 @@ error:
 static void
 __bridge_config_init(struct extdev_bridge *ebr)
 {
-   int rem, ret;
+   int ret;
+   size_t rem;
struct blob_attr *cur;
 
if (ebr->empty) {
@@ -1100,7 +1101,7 @@ extdev_config_init(struct device *dev)
 }
 
 static void
-extdev_buf_add_list(struct blob_attr *attr, int len, const char *name,
+extdev_buf_add_list(struct blob_attr *attr, size_t len, const char *name,
 struct blob_buf *buf, bool array)
 {
struct blob_attr *cur;
diff --git a/interface-ip.c b/interface-ip.c
index 7359db2696bc..a06a514b6dde 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -1429,7 +1429,7 @@ void
 interface_add_dns_server_list(struct interface_ip_settings *ip, struct 
blob_attr *list)
 {
struct blob_attr *cur;
-   int rem;
+   size_t rem;
 
blobmsg_for_each_attr(cur, list, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
@@ -1461,7 +1461,7 @@ void
 interface_add_dns_search_list(struct interface_ip_settings *ip, struct 
blob_attr *list)
 {
struct blob_attr *cur;
-   int rem;
+   size_t rem;
 
blobmsg_for_each_attr(cur, list, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
diff --git a/interface.c b/interface.c
index 89654f952c15..66e0e80d72ba 100644
--- a/interface.c
+++ b/interface.c
@@ -232,7 +232,8 @@ interface_add_data(struct interface *iface, const struct 
blob_attr *data)
 int interface_parse_data(struct interface *iface, const struct blob_attr *attr)
 {
struct blob_attr *cur;
-   int rem, ret;
+   size_t rem;
+   int ret;
 
iface->updated = 0;
 
@@ -517,7 +518,7 @@ static void
 interface_add_assignment_classes(struct interface *iface, struct blob_attr 
*list)
 {
struct blob_attr *cur;
-   int rem;
+   size_t rem;
 
blobmsg_for_each_attr(cur, list, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
diff --git a/main.c b/main.c
index e5260b5eafa9..ec7b1be03633 100644
--- a/main.c
+++ b/main.c
@@ -64,6 +64,7 @@ netifd_delete_process(struct netifd_process *proc)
 }
 
 void
+__attribute__((format(printf, 2, 0)))
 netifd_log_message(int priority, const char *format, ...)
 {
va_list vl;
diff --git a/proto-shell.c b/proto-shell.c
index 9cdbc7fde362..bc3c41dcba85 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -401,7 +401,7 @@ 

[PATCH netifd 2/2] cmake: fix build by reordering the cflags definitions

2023-03-29 Thread Petr Štetiar
I've noticed bunch of build errors being emitted by clang-15/gcc-10:

 netifd.h:83:33: error: unused parameter 'level' [-Werror,-Wunused-parameter]

and it seems, that the order of definitions matters as -Wextra probably
enables previously disabled warnings like -Wno-unused-parameter.

So lets fix it, by reordering the cflags definitions.

Cc: Hauke Mehrtens 
Fixes: 463a1207f076 ("netifd: Activate -Wextra compile warnings")
Signed-off-by: Petr Štetiar 
---
 CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b87c300fcc22..5ad86954707b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,11 +7,12 @@ IF(NOT ${CMAKE_VERSION} LESS 3.0)
   check_c_compiler_flag(-Wimplicit-fallthrough HAS_IMPLICIT_FALLTHROUGH)
 ENDIF()
 
-ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations 
-Wno-unused-parameter -Wno-unused-but-set-parameter)
+ADD_DEFINITIONS(-Wall -Werror)
 IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
add_definitions(-Wextra -Werror=implicit-function-declaration)
add_definitions(-Wformat -Werror=format-security 
-Werror=format-nonliteral)
 ENDIF()
+ADD_DEFINITIONS(-Os --std=gnu99 -Wmissing-declarations -Wno-unused-parameter 
-Wno-unused-but-set-parameter)
 
 IF(HAS_IMPLICIT_FALLTHROUGH)
   ADD_DEFINITIONS(-Wimplicit-fallthrough)

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