[RFC PATCH 14/14] config: clamp dhcpv6_pd_min_len
From: Paul Donald Attempt to be helpful. Signed-off-by: Paul Donald --- src/config.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 4d35548..7484519 100644 --- a/src/config.c +++ b/src/config.c @@ -883,11 +883,11 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_DHCPV6_PD_MIN_LEN])) { uint32_t pd_min_len = blobmsg_get_u32(c); - if (pd_min_len != 0 && pd_min_len <= PD_MIN_LEN_MAX) - iface->dhcpv6_pd_min_len = pd_min_len; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name); + + iface->dhcpv6_pd_min_len = (pd_min_len >= PD_MIN_LEN_MAX) ? PD_MIN_LEN_MAX : pd_min_len; + if (pd_min_len >= PD_MIN_LEN_MAX) + syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, iface->dhcpv6_pd_min_len); } if ((c = tb[IFACE_ATTR_DHCPV6_NA])) -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 11/14] config: clamp ra_retranstime
From: Paul Donald Attempt to be helpful. Signed-off-by: Paul Donald --- src/config.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index e0f2d80..160d7db 100644 --- a/src/config.c +++ b/src/config.c @@ -951,11 +951,10 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_RETRANSTIME])) { uint32_t ra_retranstime = blobmsg_get_u32(c); - if (ra_retranstime <= 6) - iface->ra_retranstime = ra_retranstime; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_RA_RETRANSTIME].name, iface->name); + iface->ra_retranstime = (ra_retranstime <= 6) ? ra_retranstime : 6; + if (ra_retranstime > 6) + syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_RA_RETRANSTIME].name, iface->name, iface->ra_retranstime); } if ((c = tb[IFACE_ATTR_RA_HOPLIMIT])) { -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 12/14] config: clamp ra_mtu into 1280-65535 range
From: Paul Donald (ipv6 packets can be up to 4GB in size...) The old logic had a logic error of || instead of && Signed-off-by: Paul Donald --- src/config.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 160d7db..f4eaa3b 100644 --- a/src/config.c +++ b/src/config.c @@ -971,11 +971,10 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_MTU])) { uint32_t ra_mtu = blobmsg_get_u32(c); - if (ra_mtu >= 1280 || ra_mtu <= 65535) - iface->ra_mtu = ra_mtu; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_RA_MTU].name, iface->name); + iface->ra_mtu = (ra_mtu < 1280) ? 1280 : (ra_mtu > 65535) ? 65535 : ra_mtu; + if (!(ra_mtu >= 1280 && ra_mtu <= 65535)) + syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_RA_MTU].name, iface->name, iface->ra_mtu); } if ((c = tb[IFACE_ATTR_RA_SLAAC])) -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 00/14] odhcpd config value clamping
Clamp values read from config to RFC mandated sane values instead of just complaining. We also now implement valid_lifetime for ULA prefixes. This is useful if you need to sunset or remove one from circulation. ( Interestingly, if you spin up dev devices frequently which spam the network with new ULA each time, which have no expiry, interesting things start to happen. ) Fixed also a bug in MTU handling. Paul Donald (14): config: refactor parse_leasetime() - branch amount remains same router: Apply updated values from RFC8319 (updates RFC4861) to RA/ND config: clamp ra_mininterval, ra_maxinterval, ra_lifetime at load time router: refactor calc_ra_lifetime, and define ra_lifetime as uint32_t router: redefine ra_mininterval and ra_maxinterval as uint32_t config: implement RFC4861 AdvValidLifetime (make configurable) config: lease times are all UINT32_MAX; drop double size handling router: clamp prefix valid_lt to interface valid_lifetime config: clamp ra_reachabletime to RFC maximum (instead of complaining) config: clamp ra_hoplimit to maximum (instead of complaining) config: clamp ra_retranstime config: clamp ra_mtu into 1280-65535 range config: clamp dhcpv6_hostid_len config: clamp dhcpv6_pd_min_len README | 2 + src/config.c | 162 +-- src/odhcpd.h | 7 ++- src/router.c | 34 +-- src/router.h | 25 +++- 5 files changed, 148 insertions(+), 82 deletions(-) -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 09/14] config: clamp ra_reachabletime to RFC maximum (instead of complaining)
From: Paul Donald Attempt to be helpful. Signed-off-by: Paul Donald --- src/config.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 6b3cb01..54fb9b5 100644 --- a/src/config.c +++ b/src/config.c @@ -939,11 +939,13 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_REACHABLETIME])) { uint32_t ra_reachabletime = blobmsg_get_u32(c); - if (ra_reachabletime <= 360) - iface->ra_reachabletime = ra_reachabletime; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_RA_REACHABLETIME].name, iface->name); + /* rfc4861#section-6.2.1 : AdvReachableTime : +* MUST be no greater than 3,600,000 msec +*/ + iface->ra_reachabletime = (ra_reachabletime <= 360)? ra_reachabletime : 360; + if(ra_reachabletime > 360) + syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_RA_REACHABLETIME].name, iface->name, iface->ra_reachabletime); } if ((c = tb[IFACE_ATTR_RA_RETRANSTIME])) { -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 04/14] router: refactor calc_ra_lifetime, and define ra_lifetime as uint32_t
From: Paul Donald ra_lifetime no longer holds negative values, because we no longer do 'init' when we do calc_ra_lifetime. Signed-off-by: Paul Donald --- src/odhcpd.h | 2 +- src/router.c | 19 --- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/odhcpd.h b/src/odhcpd.h index 7a82e98..09cd4f1 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -314,7 +314,7 @@ struct interface { int route_preference; int ra_maxinterval; int ra_mininterval; - int ra_lifetime; + uint32_t ra_lifetime; uint32_t ra_reachabletime; uint32_t ra_retranstime; uint32_t ra_hoplimit; diff --git a/src/router.c b/src/router.c index 96237d6..b859c46 100644 --- a/src/router.c +++ b/src/router.c @@ -366,17 +366,14 @@ static int calc_adv_interval(struct interface *iface, uint32_t lowest_found_life static uint32_t calc_ra_lifetime(struct interface *iface, uint32_t maxival) { - uint32_t lifetime = 3*maxival; - - if (iface->ra_lifetime >= 0) { - lifetime = iface->ra_lifetime; - if (lifetime > 0 && lifetime < maxival) - lifetime = maxival; - /* // RouterLifetime is a 16 bit packet field: skip this check - else if (lifetime > RouterLifetime_MAX) - lifetime = RouterLifetime_MAX; - */ - } + uint32_t lifetime = iface->ra_lifetime; + + if (lifetime > 0 && lifetime < maxival) + lifetime = maxival; + /* // RouterLifetime is a 16 bit packet field: skip this check + else if (lifetime > RouterLifetime_MAX) + lifetime = RouterLifetime_MAX; + */ return lifetime; } -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 03/14] config: clamp ra_mininterval, ra_maxinterval, ra_lifetime at load time
From: Paul Donald Signed-off-by: Paul Donald --- src/config.c | 48 +--- src/router.c | 10 -- src/router.h | 2 +- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/config.c b/src/config.c index 346d74a..2ccf742 100644 --- a/src/config.c +++ b/src/config.c @@ -18,6 +18,7 @@ #include #include "odhcpd.h" +#include "router.h" static struct blob_buf b; static int reload_pipe[2] = { -1, -1 }; @@ -227,8 +228,12 @@ static void set_interface_defaults(struct interface *iface) iface->ra_flags = ND_RA_FLAG_OTHER; iface->ra_slaac = true; iface->ra_maxinterval = 600; + /* +* RFC4861: MinRtrAdvInterval: Default: 0.33 * MaxRtrAdvInterval If +* MaxRtrAdvInterval >= 9 seconds; otherwise, the Default is MaxRtrAdvInterval. +*/ iface->ra_mininterval = iface->ra_maxinterval/3; - iface->ra_lifetime = -1; + iface->ra_lifetime = 3 * iface->ra_maxinterval; /* RFC4861: AdvDefaultLifetime: Default: 3 * MaxRtrAdvInterval */ iface->ra_dns = true; } @@ -966,14 +971,43 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_ADVROUTER])) iface->ra_advrouter = blobmsg_get_bool(c); - if ((c = tb[IFACE_ATTR_RA_MININTERVAL])) - iface->ra_mininterval = blobmsg_get_u32(c); + /* +* RFC4861: MaxRtrAdvInterval: MUST be no less than 4 seconds and no greater than 1800 seconds. +* RFC8319: MaxRtrAdvInterval: MUST be no less than 4 seconds and no greater than 65535 seconds. +* Default: 600 seconds +*/ + if ((c = tb[IFACE_ATTR_RA_MAXINTERVAL])){ + uint32_t ra_maxinterval = blobmsg_get_u32(c); + iface->ra_maxinterval = (ra_maxinterval < 4) ? 4 : + (ra_maxinterval > MaxRtrAdvInterval_CEILING) ? + MaxRtrAdvInterval_CEILING : ra_maxinterval; + } - if ((c = tb[IFACE_ATTR_RA_MAXINTERVAL])) - iface->ra_maxinterval = blobmsg_get_u32(c); + /* +* RFC4861: MinRtrAdvInterval: MUST be no less than 3 seconds and no greater than .75 * MaxRtrAdvInterval. +* Default: 0.33 * MaxRtrAdvInterval If MaxRtrAdvInterval >= 9 seconds; otherwise, the +* Default is MaxRtrAdvInterval. +*/ + if ((c = tb[IFACE_ATTR_RA_MININTERVAL])){ + uint32_t ra_mininterval = blobmsg_get_u32(c); + iface->ra_mininterval = (ra_mininterval < MinRtrAdvInterval_FLOOR) ? // clamp min + MinRtrAdvInterval_FLOOR : (ra_mininterval > 0.75 * (uint32_t)iface->ra_maxinterval) ? // clamp max + 0.75 * (uint32_t)iface->ra_maxinterval : ra_mininterval; + } - if ((c = tb[IFACE_ATTR_RA_LIFETIME])) - iface->ra_lifetime = blobmsg_get_u32(c); + /* +* RFC4861: AdvDefaultLifetime: MUST be either zero or between MaxRtrAdvInterval and 9000 seconds. +* RFC8319: AdvDefaultLifetime: MUST be either zero or between MaxRtrAdvInterval and 65535 seconds. +* Default: 3 * MaxRtrAdvInterval +* i.e. 3 * 65535 => 65535 seconds. +*/ + if ((c = tb[IFACE_ATTR_RA_LIFETIME])){ + uint32_t ra_lifetime = blobmsg_get_u32(c); + iface->ra_lifetime = (ra_lifetime == 0) ? 0 : // leave at 0 + (ra_lifetime < (uint32_t)iface->ra_maxinterval) ? (uint32_t)iface->ra_maxinterval : // clamp min + (ra_lifetime > AdvDefaultLifetime_CEILING) ? + AdvDefaultLifetime_CEILING : ra_lifetime; // clamp max + } if ((c = tb[IFACE_ATTR_RA_USELEASETIME])) iface->ra_useleasetime = blobmsg_get_bool(c); diff --git a/src/router.c b/src/router.c index ae0c545..96237d6 100644 --- a/src/router.c +++ b/src/router.c @@ -350,16 +350,6 @@ static int calc_adv_interval(struct interface *iface, uint32_t lowest_found_life if (*maxival > lowest_found_lifetime/3) *maxival = lowest_found_lifetime/3; - if (*maxival > MaxRtrAdvInterval) - *maxival = MaxRtrAdvInterval; - else if (*maxival < 4) - *maxival = 4; - - if (minival < MinRtrAdvInterval) - minival = MinRtrAdvInterval; - else if (minival > (*maxival * 3)/4) - minival = (*maxival >= 9 ? *maxival/3 : *maxival); - odhcpd_urandom(, sizeof(msecs)); msecs = (labs(msecs) % ((*maxival != minival) ? (*maxival - minival)*1000 : 500)) + minival*1000; diff --git a/src/router.h b/src/router.h index 1f8d156..8e9499e 100644 --- a/src/router.h +++ b/src/router.h @@ -43,7 +43,7 @@ struct icmpv6_opt { AdvDefaultLifetime, change 9000 to 65535 seconds. */ #define MaxRtrAdvInterval_CEILING 65535 -#define
[RFC PATCH 08/14] router: clamp prefix valid_lt to interface valid_lifetime
From: Paul Donald Before: == ICMPv6 Option (Prefix information : fd26:3c30:a222::/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: fd26:3c30:a222:: ==After (valid_lifetime set to 6 hours):== ICMPv6 Option (Prefix information : fd26:3c30:a222::/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: 21600 (6 hours) Preferred Lifetime: 21600 (6 hours) Reserved Prefix: fd26:3c30:a222:: == Signed-off-by: Paul Donald --- src/router.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/router.c b/src/router.c index b859c46..00752af 100644 --- a/src/router.c +++ b/src/router.c @@ -600,6 +600,13 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr if (iface->ra_useleasetime && valid_lt > iface->dhcp_leasetime) valid_lt = iface->dhcp_leasetime; + + /* currently the only way to control ULA valid_lifetime */ + if (valid_lt > iface->valid_lifetime) { + // set to possibly user mandated valid_lifetime + valid_lt = iface->valid_lifetime; + } + } if (preferred_lt > valid_lt) { -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 10/14] config: clamp ra_hoplimit to maximum (instead of complaining)
From: Paul Donald Attempt to be helpful. Signed-off-by: Paul Donald --- src/config.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 54fb9b5..e0f2d80 100644 --- a/src/config.c +++ b/src/config.c @@ -961,11 +961,12 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_HOPLIMIT])) { uint32_t ra_hoplimit = blobmsg_get_u32(c); - if (ra_hoplimit <= 255) - iface->ra_hoplimit = ra_hoplimit; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_RA_HOPLIMIT].name, iface->name); + /* rfc4861#section-6.2.1 : AdvCurHopLimit */ + iface->ra_hoplimit = (ra_hoplimit <= 255)? ra_hoplimit : 255; + if(ra_hoplimit > 255) + syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_RA_HOPLIMIT].name, iface->name, iface->ra_hoplimit); + } if ((c = tb[IFACE_ATTR_RA_MTU])) { -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 06/14] config: implement RFC4861 AdvValidLifetime (make configurable)
From: Paul Donald In accordance with RFC4861. Enables control of ULA. The new config variable is valid_lifetime. e.g.: config dhcp 'lan' ... option valid_lifetime '6h' Signed-off-by: Paul Donald --- README | 2 ++ src/config.c | 14 ++ src/odhcpd.h | 1 + 3 files changed, 17 insertions(+) diff --git a/README b/README index c8f2eb4..4d1956c 100644 --- a/README +++ b/README @@ -155,6 +155,8 @@ prefix_filter string ::/0 Only advertise on-link prefixes within filtered out. ntplist NTP servers to announce accepts IPv4 and IPv6 +valid_lifetime string 30d Value for the valid lifetime + for a prefix Sections of type host (static leases) diff --git a/src/config.c b/src/config.c index a3bf1ba..285e3a1 100644 --- a/src/config.c +++ b/src/config.c @@ -93,6 +93,7 @@ enum { IFACE_ATTR_NDPROXY_SLAVE, IFACE_ATTR_PREFIX_FILTER, IFACE_ATTR_PREFERRED_LIFETIME, + IFACE_ATTR_VALID_LIFETIME, IFACE_ATTR_NTP, IFACE_ATTR_MAX }; @@ -146,6 +147,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = BLOBMSG_TYPE_BOOL }, [IFACE_ATTR_PREFIX_FILTER] = { .name = "prefix_filter", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_PREFERRED_LIFETIME] = { .name = "preferred_lifetime", .type = BLOBMSG_TYPE_STRING }, + [IFACE_ATTR_VALID_LIFETIME] = { .name = "valid_lifetime", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_NTP] = { .name = "ntp", .type = BLOBMSG_TYPE_ARRAY }, }; @@ -217,6 +219,7 @@ static void set_interface_defaults(struct interface *iface) iface->learn_routes = 1; iface->dhcp_leasetime = 43200; iface->preferred_lifetime = 604800; /* rfc4861#section-6.2.1: AdvPreferredLifetime 7 days */ + iface->valid_lifetime = 2592000; /* rfc4861#section-6.2.1: AdvValidLifetime 30 days */ iface->dhcpv4_start.s_addr = htonl(START_DEFAULT); iface->dhcpv4_end.s_addr = htonl(START_DEFAULT + LIMIT_DEFAULT - 1); iface->dhcpv6_assignall = true; @@ -659,6 +662,17 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr } + if ((c = tb[IFACE_ATTR_VALID_LIFETIME])) { + uint32_t time = (uint32_t)parse_leasetime(c); + + if (time >= 0) + iface->valid_lifetime = time; + else + syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", + iface_attrs[IFACE_ATTR_VALID_LIFETIME].name, iface->name); + + } + if ((c = tb[IFACE_ATTR_START])) { iface->dhcpv4_start.s_addr = htonl(blobmsg_get_u32(c)); iface->dhcpv4_end.s_addr = htonl(ntohl(iface->dhcpv4_start.s_addr) + diff --git a/src/odhcpd.h b/src/odhcpd.h index fecd77e..ddbc6b3 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -320,6 +320,7 @@ struct interface { uint32_t ra_hoplimit; int ra_mtu; uint32_t preferred_lifetime; + uint32_t valid_lifetime; // DHCP uint32_t dhcp_leasetime; -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 02/14] router: Apply updated values from RFC8319 (updates RFC4861) to RA/ND
From: Paul Donald https://www.rfc-editor.org/rfc/rfc8319#section-4 Signed-off-by: Paul Donald --- src/router.c | 6 -- src/router.h | 23 ++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/router.c b/src/router.c index 7f5658b..ae0c545 100644 --- a/src/router.c +++ b/src/router.c @@ -382,8 +382,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; + /* // RouterLifetime is a 16 bit packet field: skip this check + else if (lifetime > RouterLifetime_MAX) + lifetime = RouterLifetime_MAX; + */ } return lifetime; diff --git a/src/router.h b/src/router.h index 0444da8..1f8d156 100644 --- a/src/router.h +++ b/src/router.h @@ -32,8 +32,29 @@ 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_CEILING 65535 #define MinRtrAdvInterval 3 +#define AdvDefaultLifetime_CEILING 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. + + Note: this is 16 bit Router Lifetime field in RA packets +*/ +#define RouterLifetime_MAX 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
[RFC PATCH 07/14] config: lease times are all UINT32_MAX; drop double size handling
From: Paul Donald This now prevents implicit 64 bit->32 bit truncation which may flag compiler errors later on down the road. All of the variables receiving from parse_leasetime() are uint32_t anyway, so max 136 years of valid lease time will have to suffice :) Signed-off-by: Paul Donald --- src/config.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/config.c b/src/config.c index 285e3a1..6b3cb01 100644 --- a/src/config.c +++ b/src/config.c @@ -359,9 +359,9 @@ static void set_config(struct uci_section *s) } } -static double parse_leasetime(struct blob_attr *c) { +static uint32_t parse_leasetime(struct blob_attr *c) { char *val = blobmsg_get_string(c), *endptr = NULL; - double time = strcmp(val, "infinite") ? strtod(val, ) : UINT32_MAX; + uint32_t time = strcmp(val, "infinite") ? (uint32_t)strtod(val, ) : UINT32_MAX; if (time && endptr && endptr[0]) { switch(endptr[0]) { @@ -380,7 +380,7 @@ static double parse_leasetime(struct blob_attr *c) { return time; err: - return -1; + return 0; } static void free_lease(struct lease *l) @@ -443,8 +443,8 @@ int set_lease_from_blobmsg(struct blob_attr *ba) } if ((c = tb[LEASE_ATTR_LEASETIME])) { - double time = parse_leasetime(c); - if (time < 0) + uint32_t time = parse_leasetime(c); + if (time == 0) goto err; l->leasetime = time; @@ -641,9 +641,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr iface->no_dynamic_dhcp = !blobmsg_get_bool(c); if ((c = tb[IFACE_ATTR_LEASETIME])) { - double time = parse_leasetime(c); + uint32_t time = parse_leasetime(c); - if (time >= 0) + if (time > 0) iface->dhcp_leasetime = time; else syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", @@ -652,9 +652,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr } if ((c = tb[IFACE_ATTR_PREFERRED_LIFETIME])) { - double time = parse_leasetime(c); + uint32_t time = parse_leasetime(c); - if (time >= 0) + if (time > 0) iface->preferred_lifetime = time; else syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", @@ -663,9 +663,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr } if ((c = tb[IFACE_ATTR_VALID_LIFETIME])) { - uint32_t time = (uint32_t)parse_leasetime(c); + uint32_t time = parse_leasetime(c); - if (time >= 0) + if (time > 0) iface->valid_lifetime = time; else syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 05/14] router: redefine ra_mininterval and ra_maxinterval as uint32_t
From: Paul Donald They never store negative values. Signed-off-by: Paul Donald --- src/config.c | 6 +++--- src/odhcpd.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 2ccf742..a3bf1ba 100644 --- a/src/config.c +++ b/src/config.c @@ -991,8 +991,8 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_MININTERVAL])){ uint32_t ra_mininterval = blobmsg_get_u32(c); iface->ra_mininterval = (ra_mininterval < MinRtrAdvInterval_FLOOR) ? // clamp min - MinRtrAdvInterval_FLOOR : (ra_mininterval > 0.75 * (uint32_t)iface->ra_maxinterval) ? // clamp max - 0.75 * (uint32_t)iface->ra_maxinterval : ra_mininterval; + MinRtrAdvInterval_FLOOR : (ra_mininterval > 0.75 * iface->ra_maxinterval) ? // clamp max + 0.75 * iface->ra_maxinterval : ra_mininterval; } /* @@ -1004,7 +1004,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_LIFETIME])){ uint32_t ra_lifetime = blobmsg_get_u32(c); iface->ra_lifetime = (ra_lifetime == 0) ? 0 : // leave at 0 - (ra_lifetime < (uint32_t)iface->ra_maxinterval) ? (uint32_t)iface->ra_maxinterval : // clamp min + (ra_lifetime < iface->ra_maxinterval) ? iface->ra_maxinterval : // clamp min (ra_lifetime > AdvDefaultLifetime_CEILING) ? AdvDefaultLifetime_CEILING : ra_lifetime; // clamp max } diff --git a/src/odhcpd.h b/src/odhcpd.h index 09cd4f1..fecd77e 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -312,8 +312,8 @@ struct interface { struct in6_addr pio_filter_addr; int default_router; int route_preference; - int ra_maxinterval; - int ra_mininterval; + uint32_t ra_maxinterval; + uint32_t ra_mininterval; uint32_t ra_lifetime; uint32_t ra_reachabletime; uint32_t ra_retranstime; -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 01/14] config: refactor parse_leasetime() - branch amount remains same
From: Paul Donald Also make 's' value a noop. Signed-off-by: Paul Donald --- src/config.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/config.c b/src/config.c index 62d4857..346d74a 100644 --- a/src/config.c +++ b/src/config.c @@ -356,18 +356,14 @@ static double parse_leasetime(struct blob_attr *c) { double time = strcmp(val, "infinite") ? strtod(val, ) : UINT32_MAX; if (time && endptr && endptr[0]) { - if (endptr[0] == 's') - time *= 1; - else if (endptr[0] == 'm') - time *= 60; - else if (endptr[0] == 'h') - time *= 3600; - else if (endptr[0] == 'd') - time *= 24 * 3600; - else if (endptr[0] == 'w') - time *= 7 * 24 * 3600; - else - goto err; + switch(endptr[0]) { + case 's': break; + case 'm': time *= 60; break; + case 'h': time *= 3600; break; + case 'd': time *= 24 * 3600; break; + case 'w': time *= 7 * 24 * 3600; break; + default: goto err; + } } if (time < 60) -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC PATCH 13/14] config: clamp dhcpv6_hostid_len
From: Paul Donald Attempt to be helpful. Signed-off-by: Paul Donald --- src/config.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index f4eaa3b..4d35548 100644 --- a/src/config.c +++ b/src/config.c @@ -896,11 +896,12 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_DHCPV6_HOSTID_LEN])) { uint32_t hostid_len = blobmsg_get_u32(c); - if (hostid_len >= HOSTID_LEN_MIN && hostid_len <= HOSTID_LEN_MAX) - iface->dhcpv6_hostid_len = hostid_len; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_DHCPV6_HOSTID_LEN].name, iface->name); + iface->dhcpv6_hostid_len = (hostid_len < HOSTID_LEN_MIN) ? + HOSTID_LEN_MIN : (hostid_len > HOSTID_LEN_MAX) ? + HOSTID_LEN_MAX : hostid_len; + if (!(hostid_len >= HOSTID_LEN_MIN && hostid_len <= HOSTID_LEN_MAX)) + syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_DHCPV6_HOSTID_LEN].name, iface->name, iface->dhcpv6_hostid_len); } -- 2.44.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[PATCH 23.05 1/2] mt76: update to Git HEAD (2024-01-18)
From: Felix Fietkau 83e3947e2c52 linux-firmware: update firmware for MT7922 WiFi device ddaa8cb6e81a linux-firmware: update firmware for MT7921 WiFi device f83b1601cc10 linux-firmware: update firmware for MT7922 WiFi device 61d334ab0f33 linux-firmware: add firmware for MT7925 a7836e4c8a60 wifi: mt76: disable HW AMSDU when using fixed rate a8571ebbcd95 wifi: mt76: check txs format before getting skb by pid 3d5890e2cab3 wifi: mt76: mt7915: fix error recovery with WED enabled 703c26d01197 wifi: mt76: mt7915: add locking for accessing mapped registers f77188160441 wifi: mt76: mt7915: update mt798x_wmac_adie_patch_7976 Signed-off-by: Felix Fietkau (cherry picked from commit a28cedbdab96be9bee39bb70098a1508c0252a8a) --- package/kernel/mt76/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 65f6ca1e8e..1fea3bd0e9 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -8,9 +8,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2023-12-18 -PKG_SOURCE_VERSION:=bebd9cffc2aeb2cecb40aadbb8c6eab3bdf7971b -PKG_MIRROR_HASH:=580261755bc3f251b8bc5f7f610274693c067432187570694d2f2ccab0edb62b +PKG_SOURCE_DATE:=2024-01-18 +PKG_SOURCE_VERSION:=f77188160441d5f77f08dd517632ae3f60c653b0 +PKG_MIRROR_HASH:=133a5e44624fe1933c893ee0b8ac75a847753f3490c26518c2ed9798f9ef53e0 PKG_MAINTAINER:=Felix Fietkau PKG_USE_NINJA:=0 -- 2.35.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[PATCH 23.05 2/2] mt76: update to Git HEAD (2024-02-03)
From: Felix Fietkau a9693e1979c2 linux-firmware: add firmware for MT7996 0258dc90e3a1 wifi: mt76: mt7603: fix reading target power from eeprom 3e81173d9e2b wifi: mt76: mt7603: initialize chainmask 786a339bac36 wifi: mt76: mt7996: fix fortify warning bc37a7ebc267 wifi: mt76: mt7996: fix fw loading timeout 027bab6a88a3 wifi: mt76: usb: create a dedicated queue for psd traffic e8909c610c3b wifi: mt76: usb: store usb endpoint in mt76_queue 8b3d96fa4ead wifi: mt76: mt792xu: enable dmashdl support 7864d7ad0ed0 wifi: mt76: mt76x2u: add netgear wdna3100v3 to device table 27c81f7c1480 wifi: mt76: mt7925: fix connect to 80211b mode fail in 2Ghz band b7443c63069a wifi: mt76: mt7925: fix SAP no beacon issue in 5Ghz and 6Ghz band bab721a65f5a wifi: mt76: mt7925: fix mcu query command fail 1f0f71ed81e8 wifi: mt76: mt7925: fix wmm queue mapping bcfe2ad966f3 wifi: mt76: mt7925: fix fw download fail f982c3d67a29 wifi: mt76: mt7925: fix WoW failed in encrypted mode 6a72716ec213 wifi: mt76: mt7925: fix the wrong header translation config 50928b7e1359 wifi: mt76: mt7925: add flow to avoid chip bt function fail 762ab4530e8f wifi: mt76: mt7925: add support to set ifs time by mcu command 87deaf82efa4 wifi: mt76: mt7925: update PCIe DMA settings c190c1576522 wifi: mt76: mt7925: support temperature sensor 025d5734caba wifi: mt76: mt7996: check txs format before getting skb by pid 4768bfa2baca wifi: mt76: mt7996: fix TWT issues a65e3eced907 wifi: mt76: mt7996: disable AMSDU for non-data frames d71716d93aee wifi: mt76: mt7996: fix incorrect interpretation of EHT MCS caps f21728f3f4bd wifi: mt76: mt7996: ensure 4-byte alignment for beacon commands 68dad7dacd2a wifi: mt76: mt7996: fix HE beamformer phy cap for station vif 66a28f340cdc wifi: mt76: mt7996: mark GCMP IGTK unsupported b47ad8a7764e wifi: mt76: mt7996: fix efuse reading issue c2fc7dae7b72 wifi: mt76: mt7996: remove TXS queue setting e0f1ed168ed5 wifi: mt76: mt7996: add locking for accessing mapped registers d0cc92c1fd08 wifi: mt76: connac: set correct muar_idx for mt799x chipsets ae0c62279adc wifi: mt76: mt7996: fix HIF_TXD_V2_1 value ecc14276af54 wifi: mt76: mt792x: fix ethtool warning 9827df56b241 wifi: mt76: move wed common utilities in wed.c dccbd2598505 wifi: mt76: mt7925: fix the wrong data type for scan command 9907f4f20261 wifi: mt76: mt792x: add the illegal value check for mtcl table of acpi 1b088a7ac06d wifi: mt76: mt7921e: fix use-after-free in free_irq() f3c5b4820d7f wifi: mt76: mt7925e: fix use-after-free in free_irq() d75eac9f5531 wifi: mt76: mt7921: fix incorrect type conversion for CLC command 7bd5401f5bb1 wifi: mt76: mt792x: fix a potential loading failure of the 6Ghz channel config from ACPI ea55196bc4a0 wifi: mt76: mt792x: update the country list of EU for ACPI SAR 6124ea9135ed wifi: mt76: mt7921: fix the unfinished command of regd_notifier before suspend Signed-off-by: Felix Fietkau (cherry picked from commit 114190d8ae61fb3a7671852fbd7f0ca3279a5625) --- package/kernel/mt76/Makefile | 24 +++- ...wifi-mt76-mt7996-fix-fortify-warning.patch | 26 ...i-mt76-mt7996-fix-fw-loading-timeout.patch | 38 ...-check-txs-format-before-getting-skb.patch | 60 --- ...-fix-incorrect-type-conversion-for-C.patch | 38 5 files changed, 21 insertions(+), 165 deletions(-) delete mode 100644 package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-fortify-warning.patch delete mode 100644 package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-fw-loading-timeout.patch delete mode 100644 package/kernel/mt76/patches/0005-wifi-mt76-mt7996-check-txs-format-before-getting-skb.patch delete mode 100644 package/kernel/mt76/patches/0006-wifi-mt76-mt7921-fix-incorrect-type-conversion-for-C.patch diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 1fea3bd0e9..4f0fb5f69d 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -8,9 +8,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2024-01-18 -PKG_SOURCE_VERSION:=f77188160441d5f77f08dd517632ae3f60c653b0 -PKG_MIRROR_HASH:=133a5e44624fe1933c893ee0b8ac75a847753f3490c26518c2ed9798f9ef53e0 +PKG_SOURCE_DATE:=2024-02-03 +PKG_SOURCE_VERSION:=6124ea9135ed512671933f5520c46842906c78bc +PKG_MIRROR_HASH:=acc326d7b15c9c72b494ed601300be329553f896e65c7f045e6a09327304c34a PKG_MAINTAINER:=Felix Fietkau PKG_USE_NINJA:=0 @@ -323,6 +323,12 @@ define KernelPackage/mt7996e AUTOLOAD:=$(call AutoProbe,mt7996e) endef +define KernelPackage/mt7996-firmware + $(KernelPackage/mt76-default) + TITLE:=MediaTek MT7996 firmware + DEPENDS+=+kmod-mt7996e +endef + define KernelPackage/mt7925-common $(KernelPackage/mt76-default) TITLE:=MediaTek MT7925 wireless driver common code @@ -610,6 +616,17 @@ define KernelPackage/mt7922-firmware/install $(1)/lib/firmware/mediatek endef +define KernelPackage/mt7996-firmware/install +
[PATCH 23.05 0/2] mt76: firmwares, minor power fixes, mt7925/mt7996 stability
From: Rafał Miłecki Update 23.05 mt76 to the 3 months old version which should we well tested by now. There are minor fixes, updated firmwares and mt7996 out of box support thanks to the included firmware files. Felix Fietkau (2): mt76: update to Git HEAD (2024-01-18) mt76: update to Git HEAD (2024-02-03) package/kernel/mt76/Makefile | 24 +++- ...wifi-mt76-mt7996-fix-fortify-warning.patch | 26 ...i-mt76-mt7996-fix-fw-loading-timeout.patch | 38 ...-check-txs-format-before-getting-skb.patch | 60 --- ...-fix-incorrect-type-conversion-for-C.patch | 38 5 files changed, 21 insertions(+), 165 deletions(-) delete mode 100644 package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-fortify-warning.patch delete mode 100644 package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-fw-loading-timeout.patch delete mode 100644 package/kernel/mt76/patches/0005-wifi-mt76-mt7996-check-txs-format-before-getting-skb.patch delete mode 100644 package/kernel/mt76/patches/0006-wifi-mt76-mt7921-fix-incorrect-type-conversion-for-C.patch -- 2.35.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel