Re: hostapd size issue

2024-04-05 Thread Felix Fietkau

On 05.04.24 05:12, e9hack wrote:

Hi,

I face a strange issue about the size of hostapd. If I build hostapd-openssl 
only, the size of the hostapd binary is 1061680 bytes. If I add wpad-openssl as 
module in addition, the size of hostapd is 798664 bytes only.


The dependencies in hostapd's Config.in were wrong. Because of that, 
leaving out wpad would prevent setting CONFIG_WPA_MSG_MIN_PRIORITY.

That increased the bloat by leaving in all debug messages.
I've pushed a fix to main.

- Felix

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


[PATCH v2 4/9] router: inherit user-assigned preferred_lifetime

2024-04-05 Thread Paul Donald
From: Paul Donald 

Inherit preferred_lifetime value irrespective of whether ra_useleasetime
is set or not.

User-provided values for preferred_lifetime are now assigned, instead of
ignored.


Before:
==
ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64)
Type: Prefix information (3)
Length: 4 (32 bytes)
Prefix Length: 64
Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
Valid Lifetime: Infinity (4294967295)
Preferred Lifetime: Infinity (4294967295)
Reserved
Prefix: fd51:1c2a:8909::
==After (preferred_lifetime set to 7 minutes):==
ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64)
Type: Prefix information (3)
Length: 4 (32 bytes)
Prefix Length: 64
Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
Valid Lifetime: Infinity (4294967295)
Preferred Lifetime: 420
Reserved
Prefix: fd51:1c2a:8909::
==

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/router.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/router.c b/src/router.c
index 335218f..3890c0b 100644
--- a/src/router.c
+++ b/src/router.c
@@ -590,9 +590,10 @@ static int send_router_advert(struct interface *iface, 
const struct in6_addr *fr
if (addr->preferred_lt > (uint32_t)now) {
preferred_lt = TIME_LEFT(addr->preferred_lt, now);
 
-   if (iface->ra_useleasetime &&
-   preferred_lt > iface->preferred_lifetime)
+   if (preferred_lt > iface->preferred_lifetime) {
+   // set to possibly user mandated preferred_lt
preferred_lt = iface->preferred_lifetime;
+   }
}
 
if (addr->valid_lt > (uint32_t)now) {
-- 
2.44.0


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


[PATCH v2 5/9] router: Limit prefix preferred_lt to valid_lt in accordance with RFC4861

2024-04-05 Thread Paul Donald
From: Paul Donald 

Follow-up fix for bc9d317f2921ae6b529f2c9f8de79b75992e206f

https://www.rfc-editor.org/rfc/rfc4861#page-44

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/router.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/router.c b/src/router.c
index 3890c0b..a1a7829 100644
--- a/src/router.c
+++ b/src/router.c
@@ -603,6 +603,13 @@ static int send_router_advert(struct interface *iface, 
const struct in6_addr *fr
valid_lt = iface->dhcp_leasetime;
}
 
+   if (preferred_lt > valid_lt) {
+   /* RFC4861 ?? 6.2.1
+   This value [AdvPreferredLifetime] MUST NOT be larger 
than AdvValidLifetime.
+   */
+   preferred_lt = valid_lt;
+   }
+
if (minvalid > valid_lt)
minvalid = valid_lt;
 
-- 
2.44.0


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


[PATCH v2 3/9] various: Comment spell-fixes and clarification

2024-04-05 Thread Paul Donald
From: Paul Donald 

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/dhcpv4.c| 2 +-
 src/dhcpv6-ia.c | 6 +++---
 src/netlink.c   | 2 +-
 src/router.c| 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 3191ff2..cb0484f 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -893,7 +893,7 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len,
struct arpreq arp = {.arp_flags = ATF_COM};
 
/*
-* send reply to the newly (in this proccess) allocated IP
+* send reply to the newly (in this process) allocated IP
 */
dest.sin_addr = reply.yiaddr;
dest.sin_port = htons(DHCPV4_CLIENT_PORT);
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 39a316a..dde224d 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -1142,11 +1142,11 @@ static size_t build_ia(uint8_t *buf, size_t buflen, 
uint16_t status,
}
 
if (!INFINITE_VALID(a->valid_until))
-   /* UINT32_MAX is considered as infinite leasetime */
+   /* UINT32_MAX is RFC defined as infinite lease-time */
a->valid_until = (valid_lt == UINT32_MAX) ? 0 : 
valid_lt + now;
 
if (!INFINITE_VALID(a->preferred_until))
-   /* UINT32_MAX is considered as infinite leasetime */
+   /* UINT32_MAX is RFC defined as infinite lease-time */
a->preferred_until = (preferred_lt == UINT32_MAX) ? 0 : 
preferred_lt + now;
 
o_ia.t1 = htonl((preferred_lt == UINT32_MAX) ? preferred_lt : 
preferred_lt * 5 / 10);
@@ -1570,7 +1570,7 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, 
struct interface *ifac
/* Set error status */
status = (is_pd) ? DHCPV6_STATUS_NOPREFIXAVAIL 
: DHCPV6_STATUS_NOADDRSAVAIL;
else if (hdr->msg_type == DHCPV6_MSG_REQUEST && 
!dhcpv6_ia_on_link(ia, a, iface)) {
-   /* Send NOTONLINK staus for the IA */
+   /* Send NOTONLINK status for the IA */
status = DHCPV6_STATUS_NOTONLINK;
assigned = false;
} else if (accept_reconf && assigned && !first &&
diff --git a/src/netlink.c b/src/netlink.c
index c33e3ea..368e69c 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -213,7 +213,7 @@ static void refresh_iface_addr6(int ifindex)
 
if (change) {
/*
-* Keep track on removed prefixes, so we could 
advertise them as invalid
+* Keep track of removed prefixes, so we could 
advertise them as invalid
 * for at least a couple of times.
 *
 * RFC7084 ?? 4.3 :
diff --git a/src/router.c b/src/router.c
index 6a9e19d..335218f 100644
--- a/src/router.c
+++ b/src/router.c
@@ -709,7 +709,7 @@ static int send_router_advert(struct interface *iface, 
const struct in6_addr *fr
iov[IOV_RA_SEARCH].iov_len = search_sz;
 
if (iface->pref64_length) {
-   /* RFC 8781 ?? 4.1 rounding up lifetime to multiply of 8 */
+   /* RFC 8781 ?? 4.1 rounding up lifetime to multiple of 8 */
uint16_t pref64_lifetime = lifetime < (UINT16_MAX - 7) ? 
lifetime + 7 : UINT16_MAX;
uint8_t prefix_length_code;
uint32_t mask_a1, mask_a2;
-- 
2.44.0


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


[PATCH v2 7/9] config: ra_management is deprecated comment

2024-04-05 Thread Paul Donald
From: Paul Donald 

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/config.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/config.c b/src/config.c
index 1cd4608..0368e74 100644
--- a/src/config.c
+++ b/src/config.c
@@ -892,6 +892,7 @@ int config_parse_interface(void *data, size_t len, const 
char *name, bool overwr
if ((c = tb[IFACE_ATTR_RA_DEFAULT]))
iface->default_router = blobmsg_get_u32(c);
 
+   /* IFACE_ATTR_RA_MANAGEMENT aka ra_management is deprecated since 2019 
*/
if (!tb[IFACE_ATTR_RA_FLAGS] && !tb[IFACE_ATTR_RA_SLAAC] &&
(c = tb[IFACE_ATTR_RA_MANAGEMENT])) {
switch (blobmsg_get_u32(c)) {
-- 
2.44.0


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


[PATCH v2 8/9] router: DNSRecursiveDNS and DNSSearchOpt Type comments

2024-04-05 Thread Paul Donald
From: Paul Donald 

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/router.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/router.c b/src/router.c
index 4239aa8..c87fd39 100644
--- a/src/router.c
+++ b/src/router.c
@@ -668,7 +668,7 @@ static int send_router_advert(struct interface *iface, 
const struct in6_addr *fr
uint8_t *search_domain = iface->search;
uint8_t search_buf[256];
 
-   /* DNS Recursive DNS */
+   /* DNS Recursive DNS aka RDNSS Type 25; RFC8106 */
if (iface->dns_cnt > 0) {
dns_addr = iface->dns;
dns_cnt = iface->dns_cnt;
@@ -688,7 +688,7 @@ static int send_router_advert(struct interface *iface, 
const struct in6_addr *fr
memcpy(dns->addr, dns_addr, sizeof(struct 
in6_addr)*dns_cnt);
}
 
-   /* DNS Search options */
+   /* DNS Search options aka DNSSL Type 31; RFC8106 */
if (!search_domain && !res_init() && _res.dnsrch[0] && 
_res.dnsrch[0][0]) {
int len = dn_comp(_res.dnsrch[0], search_buf,
sizeof(search_buf), NULL, NULL);
-- 
2.44.0


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


[PATCH v2 9/9] ndp: Comments (spelling)

2024-04-05 Thread Paul Donald
From: Paul Donald 

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/ndp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/ndp.c b/src/ndp.c
index dfbb111..0ec6fed 100644
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -39,7 +39,7 @@ static void setup_addr_for_relaying(struct in6_addr *addr, 
struct interface *ifa
 static void handle_solicit(void *addr, void *data, size_t len,
struct interface *iface, void *dest);
 
-/* Filter ICMPv6 messages of type neighbor soliciation */
+/* Filter ICMPv6 messages of type neighbor solicitation */
 static struct sock_filter bpf[] = {
BPF_STMT(BPF_LD | BPF_B | BPF_ABS, offsetof(struct ip6_hdr, ip6_nxt)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_ICMPV6, 0, 3),
@@ -343,7 +343,7 @@ static void handle_solicit(void *addr, void *data, size_t 
len,
return;
 
if (len < sizeof(*ip6) + sizeof(*req))
-   return; // Invalid reqicitation
+   return; // Invalid total length
 
if (IN6_IS_ADDR_LINKLOCAL(&req->nd_ns_target) ||
IN6_IS_ADDR_LOOPBACK(&req->nd_ns_target) ||
-- 
2.44.0


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


[PATCH v2 6/9] router: Apply updated values from RFC8319 (updates RFC4861) to RA/ND

2024-04-05 Thread Paul Donald
From: Paul Donald 

https://www.rfc-editor.org/rfc/rfc8319#section-4

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/router.c |  6 --
 src/router.h | 21 -
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/router.c b/src/router.c
index a1a7829..4239aa8 100644
--- a/src/router.c
+++ b/src/router.c
@@ -377,8 +377,10 @@ static uint32_t calc_ra_lifetime(struct interface *iface, 
uint32_t maxival)
lifetime = iface->ra_lifetime;
if (lifetime > 0 && lifetime < maxival)
lifetime = maxival;
-   else if (lifetime > 9000)
-   lifetime = 9000;
+   else if (lifetime > AdvDefaultLifetime)
+   lifetime = AdvDefaultLifetime;
+   else if (lifetime > RouterLifetime)
+   lifetime = RouterLifetime;
}
 
return lifetime;
diff --git a/src/router.h b/src/router.h
index 0444da8..b91c60a 100644
--- a/src/router.h
+++ b/src/router.h
@@ -32,8 +32,27 @@ struct icmpv6_opt {
 
 #define MaxInitialRtrAdvInterval   16
 #define MaxInitialRtAdvs   3
-#define MaxRtrAdvInterval  1800
+/* RFC8319 ??4
+   This document updates ??4.2 and 6.2.1 of [RFC4861] to change
+   the following router configuration variables.
+
+   In ??6.2.1, inside the paragraph that defines
+   MaxRtrAdvInterval, change 1800 to 65535 seconds.
+
+   In ??6.2.1, inside the paragraph that defines
+   AdvDefaultLifetime, change 9000 to 65535 seconds.
+*/
+#define MaxRtrAdvInterval  65535
 #define MinRtrAdvInterval  3
+#define AdvDefaultLifetime 65535
+/* RFC8319 ??4
+   This document updates ??4.2 and 6.2.1 of [RFC4861] to change
+   the following router configuration variables.
+
+   In ??4.2, inside the paragraph that defines Router Lifetime,
+   change 9000 to 65535 seconds.
+*/
+#define RouterLifetime  65535
 
 #define ND_RA_FLAG_PROXY   0x4
 #define ND_RA_PREF_HIGH(1 << 3)
-- 
2.44.0


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


[PATCH v2 2/9] various: refactor valid -> valid_lt (lifetime)

2024-04-05 Thread Paul Donald
From: Paul Donald 

Refactor "valid" (valid what?) to "valid_lt".

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/dhcpv6-ia.c | 62 -
 src/dhcpv6.c|  4 ++--
 src/dhcpv6.h|  4 ++--
 src/netlink.c   | 24 +--
 src/odhcpd.c|  2 +-
 src/odhcpd.h|  2 +-
 src/router.c| 38 +++---
 7 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 6a9098e..39a316a 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -226,7 +226,7 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
 
for (size_t i = 0; i < addrlen; ++i) {
struct in6_addr addr;
-   uint32_t preferred_lt, valid;
+   uint32_t preferred_lt, valid_lt;
int prefix = c->managed ? addrs[i].prefix : c->length;
 
if (!valid_addr(&addrs[i], now))
@@ -243,7 +243,7 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
 
addr = addrs[i].addr.in6;
preferred_lt = addrs[i].preferred_lt;
-   valid = addrs[i].valid;
+   valid_lt = addrs[i].valid_lt;
 
if (c->flags & OAF_DHCPV6_NA) {
if (!ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs))
@@ -268,13 +268,13 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
if (preferred_lt != UINT32_MAX)
preferred_lt -= now;
 
-   if (valid > (uint32_t)c->valid_until)
-   valid = c->valid_until;
+   if (valid_lt > (uint32_t)c->valid_until)
+   valid_lt = c->valid_until;
 
-   if (valid != UINT32_MAX)
-   valid -= now;
+   if (valid_lt != UINT32_MAX)
+   valid_lt -= now;
 
-   func(&addr, prefix, preferred_lt, valid, arg);
+   func(&addr, prefix, preferred_lt, valid_lt, arg);
}
 }
 
@@ -289,7 +289,7 @@ struct write_ctxt {
 };
 
 static void dhcpv6_write_ia_addrhosts(struct in6_addr *addr, int prefix, 
_unused uint32_t pref_lt,
-   _unused uint32_t valid, void *arg)
+   _unused uint32_t valid_lt, void *arg)
 {
struct write_ctxt *ctxt = (struct write_ctxt *)arg;
char ipbuf[INET6_ADDRSTRLEN];
@@ -309,7 +309,7 @@ static void dhcpv6_write_ia_addrhosts(struct in6_addr 
*addr, int prefix, _unused
 }
 
 static void dhcpv6_write_ia_addr(struct in6_addr *addr, int prefix, _unused 
uint32_t pref_lt,
-   _unused uint32_t valid, void *arg)
+   _unused uint32_t valid_lt, void *arg)
 {
struct write_ctxt *ctxt = (struct write_ctxt *)arg;
char ipbuf[INET6_ADDRSTRLEN];
@@ -682,10 +682,10 @@ static void managed_handle_pd_data(struct ustream *s, 
_unused int bytes_new)
continue;
 
x = strtok_r(NULL, ",", &saveptr2);
-   if (sscanf(x, "%u", &n->valid) < 1)
+   if (sscanf(x, "%u", &n->valid_lt) < 1)
continue;
 
-   if (n->preferred_lt > n->valid)
+   if (n->preferred_lt > n->valid_lt)
continue;
 
if (UINT32_MAX - now < n->preferred_lt)
@@ -693,10 +693,10 @@ static void managed_handle_pd_data(struct ustream *s, 
_unused int bytes_new)
else
n->preferred_lt += now;
 
-   if (UINT32_MAX - now < n->valid)
-   n->valid = UINT32_MAX;
+   if (UINT32_MAX - now < n->valid_lt)
+   n->valid_lt = UINT32_MAX;
else
-   n->valid += now;
+   n->valid_lt += now;
 
n->dprefix = 0;
 
@@ -1047,14 +1047,14 @@ static size_t build_ia(uint8_t *buf, size_t buflen, 
uint16_t status,
preferred_lt = iface->preferred_lifetime;
}
 
-   uint32_t valid = leasetime;
+   uint32_t valid_lt = leasetime;
 
struct odhcpd_ipaddr *addrs = (a->managed) ? a->managed : 
iface->addr6;
size_t addrlen = (a->managed) ? (size_t)a->managed_size : 
iface->addr6_len;
size_t m = get_preferred_addr(addrs, addrlen);
 
for (size_t i = 0; i < addrlen; ++i) {
-   uint32_t prefix_preferred_lt, prefix_valid;
+   uint32_t prefix_preferred_lt, prefix_valid_lt;
 
if (!valid_addr(&addrs[i], now))
continue;
@@ -1069,7 +1069,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen,

[PATCH v2 0/9] odhcpd patchset

2024-04-05 Thread Paul Donald
From: Paul Donald 

applies to odhcpd master HEAD d8118f6e76e5519881f9a37137c3a06b3cb60fd2

Before:
==
ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64)
Type: Prefix information (3)
Length: 4 (32 bytes)
Prefix Length: 64
Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
Valid Lifetime: Infinity (4294967295)
Preferred Lifetime: Infinity (4294967295)
Reserved
Prefix: fd51:1c2a:8909::
==After:==
ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64)
Type: Prefix information (3)
Length: 4 (32 bytes)
Prefix Length: 64
Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
Valid Lifetime: Infinity (4294967295)
Preferred Lifetime: 420
Reserved
Prefix: fd51:1c2a:8909::
==


changes:
v1: initial patch
v2: implemented feedback for commit messages


Paul Donald (9):
  various: refactor pref(erred) to preferred_lt (lifetime)
  various: refactor valid -> valid_lt (lifetime)
  various: Comment spell-fixes and clarification
  router: inherit user-assigned preferred_lifetime
  router: Limit prefix preferred_lt to valid_lt in accordance with
RFC4861
  router: Apply updated values from RFC8319 (updates RFC4861) to RA/ND
  config: ra_management is deprecated comment
  router: DNSRecursiveDNS and DNSSearchOpt Type comments
  ndp: Comments (spelling)

 src/config.c|   1 +
 src/dhcpv4.c|   2 +-
 src/dhcpv6-ia.c | 140 
 src/dhcpv6.c|   6 +--
 src/dhcpv6.h|   8 +--
 src/ndp.c   |   4 +-
 src/netlink.c   |  56 +--
 src/odhcpd.c|   8 +--
 src/odhcpd.h|   4 +-
 src/router.c|  72 ++---
 src/router.h|  21 +++-
 11 files changed, 176 insertions(+), 146 deletions(-)

-- 
2.44.0


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


[PATCH v2 1/9] various: refactor pref(erred) to preferred_lt (lifetime)

2024-04-05 Thread Paul Donald
From: Paul Donald 

Refactor "preferred" (preferred what?) and "pref" (obscure) to
"preferred_lt".

It is now more difficult to conflate prefix, preference and other "pref"
related terminology with preferred_lifetime.

Signed-off-by: Paul Donald 
Reviewed-by: Daniel Golle 
---
 src/dhcpv6-ia.c | 84 -
 src/dhcpv6.c|  2 +-
 src/dhcpv6.h|  4 +--
 src/netlink.c   | 34 ++--
 src/odhcpd.c|  6 ++--
 src/odhcpd.h|  2 +-
 src/router.c| 14 -
 7 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 1fbed44..6a9098e 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -120,7 +120,7 @@ static inline bool valid_prefix_length(const struct 
dhcp_assignment *a, const ui
 
 static inline bool valid_addr(const struct odhcpd_ipaddr *addr, time_t now)
 {
-   return (addr->prefix <= 96 && addr->preferred > (uint32_t)now);
+   return (addr->prefix <= 96 && addr->preferred_lt > (uint32_t)now);
 }
 
 static size_t get_preferred_addr(const struct odhcpd_ipaddr *addrs, const 
size_t addrlen)
@@ -128,8 +128,8 @@ static size_t get_preferred_addr(const struct odhcpd_ipaddr 
*addrs, const size_t
size_t i, m;
 
for (i = 0, m = 0; i < addrlen; ++i) {
-   if (addrs[i].preferred > addrs[m].preferred ||
-   (addrs[i].preferred == addrs[m].preferred &&
+   if (addrs[i].preferred_lt > addrs[m].preferred_lt ||
+   (addrs[i].preferred_lt == addrs[m].preferred_lt 
&&
memcmp(&addrs[i].addr, &addrs[m].addr, 16) > 0))
m = i;
}
@@ -226,7 +226,7 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
 
for (size_t i = 0; i < addrlen; ++i) {
struct in6_addr addr;
-   uint32_t pref, valid;
+   uint32_t preferred_lt, valid;
int prefix = c->managed ? addrs[i].prefix : c->length;
 
if (!valid_addr(&addrs[i], now))
@@ -242,7 +242,7 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
}
 
addr = addrs[i].addr.in6;
-   pref = addrs[i].preferred;
+   preferred_lt = addrs[i].preferred_lt;
valid = addrs[i].valid;
 
if (c->flags & OAF_DHCPV6_NA) {
@@ -259,14 +259,14 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
addr.s6_addr32[2] = addr.s6_addr32[3] = 0;
}
 
-   if (pref > (uint32_t)c->preferred_until)
-   pref = c->preferred_until;
+   if (preferred_lt > (uint32_t)c->preferred_until)
+   preferred_lt = c->preferred_until;
 
-   if (pref > (uint32_t)c->valid_until)
-   pref = c->valid_until;
+   if (preferred_lt > (uint32_t)c->valid_until)
+   preferred_lt = c->valid_until;
 
-   if (pref != UINT32_MAX)
-   pref -= now;
+   if (preferred_lt != UINT32_MAX)
+   preferred_lt -= now;
 
if (valid > (uint32_t)c->valid_until)
valid = c->valid_until;
@@ -274,7 +274,7 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct 
dhcp_assignment *c,
if (valid != UINT32_MAX)
valid -= now;
 
-   func(&addr, prefix, pref, valid, arg);
+   func(&addr, prefix, preferred_lt, valid, arg);
}
 }
 
@@ -288,7 +288,7 @@ struct write_ctxt {
int buf_idx;
 };
 
-static void dhcpv6_write_ia_addrhosts(struct in6_addr *addr, int prefix, 
_unused uint32_t pref,
+static void dhcpv6_write_ia_addrhosts(struct in6_addr *addr, int prefix, 
_unused uint32_t pref_lt,
_unused uint32_t valid, void *arg)
 {
struct write_ctxt *ctxt = (struct write_ctxt *)arg;
@@ -308,7 +308,7 @@ static void dhcpv6_write_ia_addrhosts(struct in6_addr 
*addr, int prefix, _unused
}
 }
 
-static void dhcpv6_write_ia_addr(struct in6_addr *addr, int prefix, _unused 
uint32_t pref,
+static void dhcpv6_write_ia_addr(struct in6_addr *addr, int prefix, _unused 
uint32_t pref_lt,
_unused uint32_t valid, void *arg)
 {
struct write_ctxt *ctxt = (struct write_ctxt *)arg;
@@ -629,7 +629,7 @@ static void set_border_assignment_size(struct interface 
*iface, struct dhcp_assi
if (ADDR_MATCH_PIO_FILTER(addr, iface))
continue;
 
-   if (addr->preferred > (uint32_t)now &&
+   if (addr->preferred_lt > (uint32_t)now &&
addr->prefix < 64 &&
addr->prefix > minprefix)
minprefix = addr->prefix;
@@ -678,20 +678,20 @@ static void manag

Re: [PATCH 0/9] odhcpd patchset

2024-04-05 Thread Paul D
On 2024-04-05 03:34, Daniel Golle wrote:
> On Fri, Apr 05, 2024 at 02:53:03AM +0200, Paul Donald wrote:
>> From: Paul Donald 
>>
>> refactor and fix limit prefix preferred_lt to valid_lt in accordance with 
>> RFC4861
> 
> All changes look good and I generally agree. Thank you!
> 

Good. Thank you. :) At this point (after amendments) is a new patch-set 
appropriate?
BTW who should one generally CC: for odhcpd?

> Please avoid duplicate commit titles ("various: refactor") as well as
> empty commit messages as that makes the project git history harder to
> read and understand.

Understood. I was at the risk of repeating myself, since the subject and 'body' 
line of the short commit message would basically be the same. The openwrt main 
repo has some automated checks on github that don't allow no body. 


> Also, in case of automated refactoring it would be great if you can
> include the method (e.g. sed script) used for carrying them out in the
> commit message. I know they are trivial and the those scripts can
> easily be inferred by reviewers, however, having a sed-script and
> apply that locally, then compare it with your suggested patch is
> easier than reviewing the patch itself (esp. when it comes to
> accidental ommissions).

I worked through it manually - it varied across files. Although I can see your 
value in automation.

Are there any you recommend?

>>
>> Tested on 23.05.0
> 
> I assume the patchset is intended to be applied on the current git
> HEAD of odhcpd.git, right? Also that is something worth mentioning in
> the cover letter.

Good point. Yes. odhcpd has not changed since I wrote the patchset.


Before:
==
ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64)
Type: Prefix information (3)
Length: 4 (32 bytes)
Prefix Length: 64
Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
Valid Lifetime: Infinity (4294967295)
Preferred Lifetime: Infinity (4294967295)
Reserved
Prefix: fd51:1c2a:8909::
==After:==
ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64)
Type: Prefix information (3)
Length: 4 (32 bytes)
Prefix Length: 64
Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
Valid Lifetime: Infinity (4294967295)
Preferred Lifetime: 420
Reserved
Prefix: fd51:1c2a:8909::
==


> For the whole series:
> Reviewed-by: Daniel Golle 



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


Orange PI R1 H3 WLAN DRIVER FOR LAST OPENWRT VERSION

2024-04-05 Thread w.hadife
Dear,

We are building our project on orange PI R1 H3 and we want to use openwrt os
last version.
It seems that we have a problem with the WLAN driver RTL8189ES ,


Is there a way to deploy a driver for this card using openwrt 23.05 last
version?
Can you help?
Do you have any method?
Can we use staging drivers, if yes how?

Regards


-
Wissam Hadife | PDG, Fondateur
Mobile France| +33 6 29 92 71 59
Mobile | +961 3 975 994
Email | w.hadife@crs-network.solutions
https://crs-network.solutions



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


Enforcing package source code integrity checks [Was: Re: Conclusions from CVE-2024-3094 (libxz disaster)]

2024-04-05 Thread Petr Štetiar
[removed openwrt-adm@ from the Cc: loop]

Petr Štetiar  [2024-04-01 14:49:46]:

> Perhaps this package source code integrity checks should be mandatory, not
> optional?

BTW I looked into this a bit and these are likely breakages caused by the
recent APK releated changes:

 $ curl -s https://buildbot.openwrt.org/images/api/v2/logs/1157227/raw | grep 
Wrong

 mdio-netlink-0~1.3.1.tar.xz: Wrong hash (probably caused by .gitattributes), 
expecting 97dfd25d8cdf5994eeb8cb0a5862c993b8aef373b280bca567d41d4113f494a9, got 
f72f170941430eb793902fc3f736839e362d53136bf0459aa98cd1b1152ad5e2
 v4l2loopback-0~v0.12.7.tar.xz: Wrong hash (probably caused by .gitattributes), 
expecting e5e5d897bdaa7f2fb0b897e503cecaeee234fcdc7f2f138aae501ef742f5b2b2, got 
09fcc9a66c820855136fae517c8102564eed7070dd07c272eb14bf2af9b536a3
 usb-serial-xr_usb_serial_common-2023.03.21~90ad5301.tar.xz: Wrong hash 
(probably caused by .gitattributes), expecting 
0cea56120542d3d546028d17389a3419ca930448005a9208728c40583ccf027d, got 
ca9e4f48a1a71e8d8e595ce8981a876d11a7d3d0f67b9e68c7825730f2f8756a
 dahdi-linux-2023.09.21~1bb9088f.tar.xz: Wrong hash (probably caused by 
.gitattributes), expecting 
b32eb405d64c981f64922840f616cf362636ccc93506986c0b92bd4dcca5ab30, got 
ca88184419f85e87e9b8fd89132a0cf441625230f694954c9a3315247c4adc4a

yet we still seems to be happily producing binary packages with those
theoretically tainted sources.

My understanding of the situation:

 1. tarball is downloaded from sources.openwrt.org, but the package hash
doesn't match (might be corrupted or malicious tarball)
 2. tarball is deleted, Git clone is performed and source code tarball
recreated
 3.  [ here is the possible blind spot, tarball hash is not checked again,
   although it should be ]
 4. build continues using Git cloned source tree from 2., which in case of
PKG_SOURCE_VERSION being a Git tag is not trustworthy enough

How to approach that?

 A. Add additional post Git clone hash check (implement 3. above) and fail the
build if the package hash still doesn't match.

 B. Turn the current hash check warnings into errors by default, making it
opt-out via config option, so if you enjoy JiaTanning, then be our guest.

 C. Forbid usage of Git tags in PKG_SOURCE_VERSION, but I find that a bit harsh.

 D. Combination of the above

 E. ?


Cheers,

Petr

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