Skip to content

Commit 20eb94d

Browse files
AlphixNoltari
authored andcommitted
config: allow minimum PD len up to 64
The current limit of [1,62] doesn't really seem to be justified. With things like RFC9762 (DHCPv6-PD preferred), it isn't unlikely that we'll see more DHCPv6-PD requests in the future, and not just from actual routers. The smallest realistic PD that can be allocated is a /64, so make that the minimum. Also, fix a bug in the logic (note that the PD_MIN_LEN_MAX actually isn't enforced). Closes: openwrt#352 (cherry picked from commit 62113d0) Signed-off-by: David Härdeman <david@hardeman.nu> Link: openwrt#357 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
1 parent 7ebd960 commit 20eb94d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ and may also receive information from ubus
8989
| dhcpv6_na |bool | 1 | DHCPv6 stateful addressing hands out IA_NA - Internet Address - Network Address |
9090
| dhcpv6_pd |bool | 1 | DHCPv6 stateful addressing hands out IA_PD - Internet Address - Prefix Delegation (PD) |
9191
| dhcpv6_pd_preferred |bool | 0 | Set the DHCPv6-PD Preferred (P) flag in outgoing ICMPv6 RA message PIOs (RFC9762); requires `dhcpv6` and `dhcpv6_pd`. |
92-
| dhcpv6_pd_min_len |integer| - | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length). Range [1,62] |
92+
| dhcpv6_pd_min_len |integer| - | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length). Range [1,64] |
9393
| router |list |`<local address>`| IPv4 addresses of routers on a given subnet (provided via DHCPv4, should be in order of preference) |
9494
| dns |list |`<local address>`| DNS servers to announce, accepts IPv4 and IPv6 |
9595
| dnr |list |disabled| Encrypted DNS servers to announce, `<priority> <domain name> [<comma separated IP addresses> <SvcParams (key=value)>...]` |

src/config.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct sys_conf sys_conf = {
6969
#define HOSTID_LEN_MAX 64
7070
#define HOSTID_LEN_DEFAULT HOSTID_LEN_MIN
7171

72-
#define PD_MIN_LEN_MAX (64-2) // must delegate at least 2 bits of prefix
72+
#define PD_MIN_LEN_MAX 64
7373

7474
#define OAF_DHCPV6 (OAF_DHCPV6_NA | OAF_DHCPV6_PD)
7575

@@ -1456,12 +1456,14 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
14561456

14571457
if ((c = tb[IFACE_ATTR_DHCPV6_PD_MIN_LEN])) {
14581458
uint32_t pd_min_len = blobmsg_get_u32(c);
1459-
if (pd_min_len > PD_MIN_LEN_MAX)
1460-
iface->dhcpv6_pd_min_len = PD_MIN_LEN_MAX;
1461-
iface->dhcpv6_pd_min_len = pd_min_len;
1462-
if (pd_min_len > PD_MIN_LEN_MAX)
1459+
1460+
if (pd_min_len > PD_MIN_LEN_MAX) {
1461+
pd_min_len = PD_MIN_LEN_MAX;
14631462
warn("Clamped invalid %s value configured for interface '%s' to %d",
1464-
iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, iface->dhcpv6_pd_min_len);
1463+
iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, pd_min_len);
1464+
}
1465+
1466+
iface->dhcpv6_pd_min_len = pd_min_len;
14651467
}
14661468

14671469
if ((c = tb[IFACE_ATTR_DHCPV6_NA]))

0 commit comments

Comments
 (0)