Skip to content

Commit 34f4b9a

Browse files
Revert IPv6 patches
Signed-off-by: Nicholas Sun <nicholas-sun@outlook.com>
1 parent bd10dcc commit 34f4b9a

3 files changed

Lines changed: 82 additions & 92 deletions

File tree

PATCH/odhcpd/001-odhcpd-RFC-9096-compliance.patch renamed to PATCH/odhcpd/0001-config-allow-configuring-max-limit-for-preferred-and.patch

Lines changed: 47 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
From 62a8c0e6db9de52493842c982a723dd155ac7736 Mon Sep 17 00:00:00 2001
1+
From 9ee21c537eea6321ed644e284a1d9c13de342fef Mon Sep 17 00:00:00 2001
2+
From: skbeh <60107333+skbeh@users.noreply.github.com>
23
Date: Sat, 16 Sep 2023 15:04:12 +0000
3-
Subject: [PATCH] odhcpd: RFC 9096 compliance
4+
Subject: [PATCH] config: allow configuring max limit for preferred and valid
5+
lifetime
46

5-
and allow configuring upper limit for preferred and valid lifetime.
67
---
7-
README | 9 +++++----
8-
src/config.c | 34 +++++++++++++++++++++++++++++++++-
8+
README | 5 +++--
9+
src/config.c | 32 ++++++++++++++++++++++++++++++++
910
src/dhcpv6-ia.c | 9 +++++++++
1011
src/odhcpd.h | 6 ++++++
11-
src/router.c | 23 +++++++++++++++++------
12-
src/router.h | 2 +-
13-
6 files changed, 71 insertions(+), 12 deletions(-)
12+
src/router.c | 37 +++++++++++++++++++++++++++++--------
13+
5 files changed, 79 insertions(+), 10 deletions(-)
1414

1515
diff --git a/README b/README
16-
index 8f0e6a4..c899cd5 100644
16+
index 8f0e6a4..ddf8534 100644
1717
--- a/README
1818
+++ b/README
19-
@@ -126,12 +126,13 @@ ra_slaac bool 1 Announce slaac for a prefix
20-
ra_offlink bool 0 Announce prefixes off-link
21-
ra_preference string medium Route(r) preference
22-
[medium|high|low]
23-
-ra_maxinterval integer 600 Maximum time allowed between
24-
+ra_maxinterval integer 900 Maximum time allowed between
19+
@@ -130,8 +130,9 @@ ra_maxinterval integer 600 Maximum time allowed between
2520
sending unsolicited RA
26-
-ra_mininterval integer 200 Minimum time allowed between
27-
+ra_mininterval integer 300 Minimum time allowed between
21+
ra_mininterval integer 200 Minimum time allowed between
2822
sending unsolicited RA
2923
-ra_lifetime integer 1800 Value to be placed in Router
3024
- Lifetime field of RA
@@ -35,7 +29,7 @@ index 8f0e6a4..c899cd5 100644
3529
limit for the preferred and
3630
valid lifetime of a prefix
3731
diff --git a/src/config.c b/src/config.c
38-
index e631814..d8ff6f7 100644
32+
index e631814..3281b5f 100644
3933
--- a/src/config.c
4034
+++ b/src/config.c
4135
@@ -92,6 +92,8 @@ enum {
@@ -56,15 +50,6 @@ index e631814..d8ff6f7 100644
5650
[IFACE_ATTR_NTP] = { .name = "ntp", .type = BLOBMSG_TYPE_ARRAY },
5751
};
5852

59-
@@ -224,7 +228,7 @@ static void set_interface_defaults(struct interface *iface)
60-
iface->dns_service = true;
61-
iface->ra_flags = ND_RA_FLAG_OTHER;
62-
iface->ra_slaac = true;
63-
- iface->ra_maxinterval = 600;
64-
+ iface->ra_maxinterval = 900;
65-
iface->ra_mininterval = iface->ra_maxinterval/3;
66-
iface->ra_lifetime = -1;
67-
iface->ra_dns = true;
6853
@@ -648,6 +652,34 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
6954

7055
}
@@ -145,28 +130,27 @@ index 08b4920..58ab155 100644
145130
// DHCP
146131
uint32_t dhcp_leasetime;
147132
diff --git a/src/router.c b/src/router.c
148-
index d5ef7f8..b4d52aa 100644
133+
index d5ef7f8..55eaa6d 100644
149134
--- a/src/router.c
150135
+++ b/src/router.c
151-
@@ -371,7 +371,7 @@ static int calc_adv_interval(struct interface *iface, uint32_t minvalid,
152-
153-
static uint32_t calc_ra_lifetime(struct interface *iface, uint32_t maxival)
154-
{
155-
- uint32_t lifetime = 3*maxival;
156-
+ uint32_t lifetime = maxival * 3;
157-
158-
if (iface->ra_lifetime >= 0) {
159-
lifetime = iface->ra_lifetime;
160-
@@ -452,7 +452,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
136+
@@ -452,7 +452,8 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
161137
size_t dns_sz = 0, search_sz = 0, pref64_sz = 0;
162138
size_t pfxs_cnt = 0, routes_cnt = 0;
163139
ssize_t valid_addr_cnt = 0, invalid_addr_cnt = 0;
164140
- uint32_t minvalid = UINT32_MAX, maxival, lifetime;
165-
+ uint32_t minvalid = ND_VALID_LIMIT, maxival, lifetime;
141+
+ uint32_t minvalid = UINT32_MAX, maxival, lifetime, max_prefix_vlt = ND_VALID_LIMIT;
142+
+ uint32_t calculated_ra_lifetime;
166143
int msecs, mtu = iface->ra_mtu, hlim = iface->ra_hoplimit;
167144
bool default_route = false;
168145
bool valid_prefix = false;
169-
@@ -602,6 +602,17 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
146+
@@ -598,10 +599,24 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
147+
if (addr->valid > (uint32_t)now) {
148+
valid = TIME_LEFT(addr->valid, now);
149+
150+
+ if (valid < max_prefix_vlt)
151+
+ max_prefix_vlt = valid;
152+
+
153+
if (iface->ra_useleasetime && valid > iface->dhcp_leasetime)
170154
valid = iface->dhcp_leasetime;
171155
}
172156

@@ -184,13 +168,25 @@ index d5ef7f8..b4d52aa 100644
184168
if (minvalid > valid)
185169
minvalid = valid;
186170

187-
@@ -637,15 +648,15 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
171+
@@ -629,24 +644,30 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
172+
173+
/* Calculate periodic transmit */
174+
msecs = calc_adv_interval(iface, minvalid, &maxival);
175+
- lifetime = calc_ra_lifetime(iface, maxival);
176+
+ calculated_ra_lifetime = min(calc_ra_lifetime(iface, maxival), UINT16_MAX);
177+
+ lifetime = min(calculated_ra_lifetime, max_prefix_vlt);
178+
179+
if (!iface->have_link_local) {
180+
syslog(LOG_NOTICE, "Skip sending a RA on %s as no link local address is available", iface->name);
181+
goto out;
188182
}
189183

190-
if (default_route && valid_prefix) {
184+
- if (default_route && valid_prefix) {
191185
- adv.h.nd_ra_router_lifetime = htons(lifetime < UINT16_MAX ? lifetime : UINT16_MAX);
192-
+ adv.h.nd_ra_router_lifetime = htons(lifetime);
193-
} else {
186+
- } else {
187+
+ /* RFC9096: CE routers SHOULD set the "Router Lifetime" of Router Advertisement (RA) messages to ND_PREFERRED_LIMIT. */
188+
+ adv.h.nd_ra_router_lifetime = htons(ND_PREFERRED_LIMIT);
189+
+ if (!(default_route && valid_prefix)) {
194190
adv.h.nd_ra_router_lifetime = 0;
195191

196192
if (default_route) {
@@ -201,9 +197,15 @@ index d5ef7f8..b4d52aa 100644
201197
- syslog(LOG_WARNING, "No default route present, overriding ra_lifetime!");
202198
+ syslog(LOG_WARNING, "No default route present, setting ra_lifetime to zero!");
203199
}
200+
+ } else if (iface->ra_lifetime >= 0) {
201+
+ adv.h.nd_ra_router_lifetime = htons(calculated_ra_lifetime);
202+
+ if (calculated_ra_lifetime == 0)
203+
+ syslog(LOG_WARNING, "A default route is present and there is public prefix "
204+
+ "but ra_lifetime on iface was set to zero, setting ra_lifetime to zero!");
204205
}
205206

206-
@@ -710,7 +721,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
207+
syslog(LOG_DEBUG, "Using a RA lifetime of %d seconds on %s", ntohs(adv.h.nd_ra_router_lifetime), iface->name);
208+
@@ -710,7 +731,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
207209

208210
if (iface->pref64_length) {
209211
/* RFC 8781 § 4.1 rounding up lifetime to multiply of 8 */
@@ -212,18 +214,5 @@ index d5ef7f8..b4d52aa 100644
212214
uint8_t prefix_length_code;
213215
uint32_t mask_a1, mask_a2;
214216

215-
diff --git a/src/router.h b/src/router.h
216-
index 0444da8..a994892 100644
217-
--- a/src/router.h
218-
+++ b/src/router.h
219-
@@ -32,7 +32,7 @@ struct icmpv6_opt {
220-
221-
#define MaxInitialRtrAdvInterval 16
222-
#define MaxInitialRtAdvs 3
223-
-#define MaxRtrAdvInterval 1800
224-
+#define MaxRtrAdvInterval 2700
225-
#define MinRtrAdvInterval 3
226-
227-
#define ND_RA_FLAG_PROXY 0x4
228217
--
229218
2.42.0

SCRIPTS/02_prepare_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ git clone --depth 1 https://github.com/fullcone-nat-nftables/nft-fullcone packag
4242
# Odhcp
4343
patch -p1 <../PATCH/odhcp6c/1002-odhcp6c-support-dhcpv6-hotplug.patch
4444
mkdir -p package/network/services/odhcpd/patches
45-
cp -f ../PATCH/odhcpd/001-odhcpd-RFC-9096-compliance.patch ./package/network/services/odhcpd/patches/001-odhcpd-RFC-9096-compliance.patch
45+
cp -f ../PATCH/odhcpd/0001-config-allow-configuring-max-limit-for-preferred-and.patch ./package/network/services/odhcpd/patches/0001-config-allow-configuring-max-limit-for-preferred-and.patch
4646
# Remove obsolete options
4747
sed -i 's/syn_flood/synflood_protect/g' package/network/config/firewall/files/firewall.config
4848
# BBRv3

SCRIPTS/03_convert_translation.sh

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
11
#!/bin/bash
2-
# [CTCGFW]Immortalwrt
2+
# [CTCGFW]immortalwrt
33
# Use it under GPLv3, please.
44
# --------------------------------------------------------
55
# Convert translation files zh-cn to zh_Hans
66
# The script is still in testing, welcome to report bugs.
77

8-
po_file="$({ find -type f |grep -E "[a-z0-9]+\.zh\-cn.+po"; } 2>"/dev/null")"
9-
for a in ${po_file}
10-
do
11-
[ -n "$(grep "Language: zh_CN" "$a")" ] && sed -i "s/Language: zh_CN/Language: zh_Hans/g" "$a"
12-
po_new_file="$(echo -e "$a"|sed "s/zh-cn/zh_Hans/g")"
13-
mv "$a" "${po_new_file}" 2>"/dev/null"
8+
po_file="$({ find -type f | grep -E "[a-z0-9]+\.zh\-cn.+po"; } 2>"/dev/null")"
9+
for a in ${po_file}; do
10+
[ -n "$(grep "Language: zh_CN" "$a")" ] && sed -i "s/Language: zh_CN/Language: zh_Hans/g" "$a"
11+
po_new_file="$(echo -e "$a" | sed "s/zh-cn/zh_Hans/g")"
12+
mv "$a" "${po_new_file}" 2>"/dev/null"
1413
done
1514

16-
po_file2="$({ find -type f |grep "/zh-cn/" |grep "\.po"; } 2>"/dev/null")"
17-
for b in ${po_file2}
18-
do
19-
[ -n "$(grep "Language: zh_CN" "$b")" ] && sed -i "s/Language: zh_CN/Language: zh_Hans/g" "$b"
20-
po_new_file2="$(echo -e "$b"|sed "s/zh-cn/zh_Hans/g")"
21-
mv "$b" "${po_new_file2}" 2>"/dev/null"
15+
po_file2="$({ find -type f | grep "/zh-cn/" | grep "\.po"; } 2>"/dev/null")"
16+
for b in ${po_file2}; do
17+
[ -n "$(grep "Language: zh_CN" "$b")" ] && sed -i "s/Language: zh_CN/Language: zh_Hans/g" "$b"
18+
po_new_file2="$(echo -e "$b" | sed "s/zh-cn/zh_Hans/g")"
19+
mv "$b" "${po_new_file2}" 2>"/dev/null"
2220
done
2321

24-
lmo_file="$({ find -type f |grep -E "[a-z0-9]+\.zh_Hans.+lmo"; } 2>"/dev/null")"
25-
for c in ${lmo_file}
26-
do
27-
lmo_new_file="$(echo -e "$c"|sed "s/zh_Hans/zh-cn/g")"
28-
mv "$c" "${lmo_new_file}" 2>"/dev/null"
22+
lmo_file="$({ find -type f | grep -E "[a-z0-9]+\.zh_Hans.+lmo"; } 2>"/dev/null")"
23+
for c in ${lmo_file}; do
24+
lmo_new_file="$(echo -e "$c" | sed "s/zh_Hans/zh-cn/g")"
25+
mv "$c" "${lmo_new_file}" 2>"/dev/null"
2926
done
3027

31-
lmo_file2="$({ find -type f |grep "/zh_Hans/" |grep "\.lmo"; } 2>"/dev/null")"
32-
for d in ${lmo_file2}
33-
do
34-
lmo_new_file2="$(echo -e "$d"|sed "s/zh_Hans/zh-cn/g")"
35-
mv "$d" "${lmo_new_file2}" 2>"/dev/null"
28+
lmo_file2="$({ find -type f | grep "/zh_Hans/" | grep "\.lmo"; } 2>"/dev/null")"
29+
for d in ${lmo_file2}; do
30+
lmo_new_file2="$(echo -e "$d" | sed "s/zh_Hans/zh-cn/g")"
31+
mv "$d" "${lmo_new_file2}" 2>"/dev/null"
3632
done
3733

38-
po_dir="$({ find -type d |grep "/zh-cn" |sed "/\.po/d" |sed "/\.lmo/d"; } 2>"/dev/null")"
39-
for e in ${po_dir}
40-
do
41-
po_new_dir="$(echo -e "$e"|sed "s/zh-cn/zh_Hans/g")"
42-
mv "$e" "${po_new_dir}" 2>"/dev/null"
34+
po_dir="$({ find -type d | grep "/zh-cn" | sed "/\.po/d" | sed "/\.lmo/d"; } 2>"/dev/null")"
35+
for e in ${po_dir}; do
36+
po_new_dir="$(echo -e "$e" | sed "s/zh-cn/zh_Hans/g")"
37+
mv "$e" "${po_new_dir}" 2>"/dev/null"
4338
done
4439

45-
makefile_file="$({ find -type f |grep Makefile |sed "/Makefile./d"; } 2>"/dev/null")"
46-
for f in ${makefile_file}
47-
do
48-
[ -n "$(grep "zh-cn" "$f")" ] && sed -i "s/zh-cn/zh_Hans/g" "$f"
49-
[ -n "$(grep "zh_Hans.lmo" "$f")" ] && sed -i "s/zh_Hans.lmo/zh-cn.lmo/g" "$f"
40+
makefile_file="$({ find -type f | grep Makefile | sed "/Makefile./d"; } 2>"/dev/null")"
41+
for f in ${makefile_file}; do
42+
[ -n "$(grep "zh-cn" "$f")" ] && sed -i "s/zh-cn/zh_Hans/g" "$f"
43+
[ -n "$(grep "zh_Hans.lmo" "$f")" ] && sed -i "s/zh_Hans.lmo/zh-cn.lmo/g" "$f"
5044
done
45+
46+
makefile_file="$({ find package -type f | grep Makefile | sed "/Makefile./d"; } 2>"/dev/null")"
47+
for g in ${makefile_file}; do
48+
[ -n "$(grep "golang-package.mk" "$g")" ] && sed -i "s|\.\./\.\.|$\(TOPDIR\)/feeds/packages|g" "$g"
49+
[ -n "$(grep "luci.mk" "$g")" ] && sed -i "s|\.\./\.\.|$\(TOPDIR\)/feeds/luci|g" "$g"
50+
done
51+
5152
exit 0

0 commit comments

Comments
 (0)