package/odhcp6c: backport patches

This commit is contained in:
Liangbin Lian 2025-11-17 14:15:09 +08:00
parent e645005fe6
commit 02aa31c8bd
4 changed files with 103 additions and 15 deletions

View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=odhcp6c
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcp6c.git

View File

@ -0,0 +1,63 @@
From a877f98e949e4c791e401c9e7a928db828281e1f Mon Sep 17 00:00:00 2001
From: Gasper Stukelj <gstukelj@plume.com>
Date: Mon, 8 Apr 2024 11:48:09 +0200
Subject: [PATCH] script: don't ignore RA with zero router lifetime
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As per RFC 4861 (section 4.2), 0 is a valid value for
Router Lifetime field in Router Advertisement messages.
To quote from the RFC:
> A Lifetime of 0 indicates that the router is not a
> default router and SHOULD NOT appear on the default
> router list.
In fact, this is the mechanism by which a router,
previously advertising itself as a default router must
invalidate itself. From the RFC 7084 (4.1, G-5):
> By default, if the IPv6 CE router is an advertising
> router and loses its IPv6 default router(s) and/or
> detects loss of connectivity on the WAN interface,
> it MUST explicitly invalidate itself as an IPv6
> default router on each of its advertising interfaces
> by immediately transmitting one or more Router
> Advertisement messages with the "Router Lifetime"
> field set to zero [RFC4861].
Given that Router Lifetime is stored in the `valid`
field of the `struct odhcp6c_entry`, entries with
the field set to 0 shouldn't be ignored when entry
type is `ENTRY_ROUTE`.
Signed-off-by: Gasper Stukelj <gstukelj@plume.com>
Link: https://github.com/openwrt/odhcp6c/pull/84
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
(cherry picked from commit 70f7467db3010af421a2ca528c92313dd3fb2dcc)
---
src/script.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
--- a/src/script.c
+++ b/src/script.c
@@ -180,11 +180,14 @@ static void entry_to_env(const char *nam
for (size_t i = 0; i < len / sizeof(*e); ++i) {
/*
- * The only invalid entries allowed to be passed to the script are prefix entries.
- * This will allow immediate removal of the old ipv6-prefix-assignment that might
- * otherwise be kept for up to 2 hours (see L-13 requirement of RFC 7084).
+ * The only invalid entries allowed to be passed to the script are prefix and RA
+ * entries. This will allow immediate removal of the old ipv6-prefix-assignment
+ * that might otherwise be kept for up to 2 hours (see L-13 requirement of RFC 7084).
+ * Similarly, a RA with router lifetime set to 0 indicates that the advertising
+ * router "is not a default router and SHOULD NOT appear on the default router list"
+ * (see RFC 4861, section 4.2).
*/
- if (!e[i].valid && type != ENTRY_PREFIX)
+ if (!e[i].valid && type != ENTRY_PREFIX && type != ENTRY_ROUTE)
continue;
inet_ntop(AF_INET6, &e[i].target, &buf[buf_len], INET6_ADDRSTRLEN);

View File

@ -0,0 +1,36 @@
From 00dac46811b2ab37ccfe26e9689d5d8441fdc720 Mon Sep 17 00:00:00 2001
From: Nicolas BESNARD <nicolas.besnard_ext@softathome.com>
Date: Fri, 11 Apr 2025 09:50:07 +0000
Subject: [PATCH] dhcpv6: fix incorrect IA type being printed in syslog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem: If a status error code is received, "IA_NA" is always written
to syslog.
Cause: IA header type is not converted from network byte order to host
byte order.
Solution: Use ntohs() to convert to host byte order.
Signed-off-by: Nicolas BESNARD <nicolas.besnard_ext@softathome.com>
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Link: https://github.com/openwrt/odhcp6c/pull/106
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
(cherry picked from commit 1051cabb4da3283a58e1504513946130c007ebdf)
---
src/dhcpv6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1585,7 +1585,7 @@ static void dhcpv6_handle_ia_status_code
const void *status_msg, const int len,
bool handled_status_codes[_DHCPV6_Status_Max], int *ret)
{
- dhcpv6_log_status_code(code, ia_hdr->type == DHCPV6_OPT_IA_NA ?
+ dhcpv6_log_status_code(code, ntohs(ia_hdr->type) == DHCPV6_OPT_IA_NA ?
"IA_NA" : "IA_PD", status_msg, len);
switch (code) {

View File

@ -1,4 +1,4 @@
From 59d35b1cdf45205ba430003317c2b68f4d65e304 Mon Sep 17 00:00:00 2001
From 9a7f1a99b5a92c03118684107811a47c24b609a8 Mon Sep 17 00:00:00 2001
From: jjm2473 <jjm2473@gmail.com>
Date: Mon, 29 Sep 2025 12:36:45 +0800
Subject: [PATCH] dhcpv6: restart on RA updated
@ -11,8 +11,6 @@ Signed-off-by: jjm2473 <jjm2473@gmail.com>
src/ra.c | 5 ++++-
4 files changed, 95 insertions(+), 3 deletions(-)
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index c1603f5..ce96a98 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -115,6 +115,9 @@ static uint8_t reconf_key[16];
@ -69,7 +67,7 @@ index c1603f5..ce96a98 100644
for (struct cmsghdr *ch = CMSG_FIRSTHDR(&msg); ch != NULL;
ch = CMSG_NXTHDR(&msg, ch)) {
@@ -1571,7 +1601,8 @@ static void dhcpv6_handle_status_code(const enum dhcpv6_msg orig,
@@ -1571,7 +1601,8 @@ static void dhcpv6_handle_status_code(co
case DHCPV6_NoAddrsAvail:
case DHCPV6_NoPrefixAvail:
@ -79,8 +77,6 @@ index c1603f5..ce96a98 100644
*ret = 0; // Failure
break;
diff --git a/src/odhcp6c.c b/src/odhcp6c.c
index 20b4040..8c7c1a7 100644
--- a/src/odhcp6c.c
+++ b/src/odhcp6c.c
@@ -59,6 +59,7 @@ static volatile bool signal_io = false;
@ -91,7 +87,7 @@ index 20b4040..8c7c1a7 100644
static int urandom_fd = -1, allow_slaac_only = 0;
static bool bound = false, release = true, ra = false;
@@ -688,11 +689,53 @@ static uint8_t* odhcp6c_resize_state(enum odhcp6c_state state, ssize_t len)
@@ -688,11 +689,53 @@ static uint8_t* odhcp6c_resize_state(enu
return n;
}
@ -172,8 +168,6 @@ index 20b4040..8c7c1a7 100644
void odhcp6c_clear_state(enum odhcp6c_state state)
{
state_len[state] = 0;
diff --git a/src/odhcp6c.h b/src/odhcp6c.h
index 7904946..47d9436 100644
--- a/src/odhcp6c.h
+++ b/src/odhcp6c.h
@@ -417,6 +417,7 @@ uint64_t odhcp6c_get_milli_time(void);
@ -184,8 +178,6 @@ index 7904946..47d9436 100644
// State manipulation
void odhcp6c_clear_state(enum odhcp6c_state state);
diff --git a/src/ra.c b/src/ra.c
index 01a8b72..e6adf58 100644
--- a/src/ra.c
+++ b/src/ra.c
@@ -353,6 +353,7 @@ bool ra_process(void)
@ -207,6 +199,3 @@ index 01a8b72..e6adf58 100644
changed |= odhcp6c_update_entry(STATE_RA_PREFIX, entry,
7200, ra_holdoff_interval);
} else if (opt->type == ND_OPT_RECURSIVE_DNS && opt->len > 2) {
--
2.46.0