Skip to content

Commit 8dddaee

Browse files
committed
odhcpd: update to latest HEAD
1 parent 139afb6 commit 8dddaee

5 files changed

Lines changed: 130 additions & 47 deletions

File tree

package/network/services/odhcpd/Makefile

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2013-2015 OpenWrt.org
2+
# Copyright (C) 2013-2025 OpenWrt.org
33
#
44
# This is free software, licensed under the GNU General Public License v2.
55
# See /LICENSE for more information.
@@ -8,18 +8,17 @@
88
include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=odhcpd
11-
PKG_RELEASE:=$(AUTORELEASE)
11+
PKG_RELEASE:=2
1212

1313
PKG_SOURCE_PROTO:=git
1414
PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcpd.git
15-
PKG_SOURCE_DATE:=2021-06-19
16-
PKG_SOURCE_VERSION:=564d25e53fad925fa3ed56e3004c107d40925fa4
17-
PKG_MIRROR_HASH:=a0644d31f99f20e5c2cee74153b81a0c2eae9ebeb644662cc76b0984b44dd490
15+
PKG_MIRROR_HASH:=c1346cc5a05ad68f57bc3526c4f76c65a3c7bb673f6b22328c08f9a5632eb0e4
16+
PKG_SOURCE_DATE:=2026-06-14
17+
PKG_SOURCE_VERSION:=c6792bac3905d4bf726d914e9994f6d4b98c5b57
1818

19-
PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
19+
PKG_MAINTAINER:=Álvaro Fernández Rojas <noltari@gmail.com>
2020
PKG_LICENSE:=GPL-2.0
2121

22-
PKG_CONFIG_DEPENDS:=CONFIG_PACKAGE_odhcpd_$(BUILD_VARIANT)_ext_cer_id
2322
PKG_ASLR_PIE_REGULAR:=1
2423

2524
include $(INCLUDE_DIR)/package.mk
@@ -28,8 +27,7 @@ include $(INCLUDE_DIR)/cmake.mk
2827
define Package/odhcpd/default
2928
SECTION:=net
3029
CATEGORY:=Network
31-
TITLE:=OpenWrt DHCPv6(-PD)/RA Server & Relay
32-
DEPENDS:=+libubox +libuci +libubus +libnl-tiny
30+
DEPENDS:=+libjson-c +libubox +libuci +libubus +libnl-tiny
3331
endef
3432

3533
define Package/odhcpd/default/description
@@ -38,48 +36,33 @@ define Package/odhcpd/default/description
3836
requirements for IPv6 home routers.
3937
endef
4038

41-
define Package/odhcpd/default/config
42-
menu "Configuration"
43-
depends on PACKAGE_$(1)
44-
45-
config PACKAGE_odhcpd_$(2)_ext_cer_id
46-
int
47-
default 0
48-
prompt "CER-ID Extension ID (0 = disabled)"
49-
endmenu
50-
endef
51-
5239
define Package/odhcpd
53-
$(call Package/odhcpd/default)
54-
TITLE += and DHCPv4 server
40+
$(Package/odhcpd/default)
41+
TITLE:=OpenWrt DHCPv4/DHCPv6/NDP/RA server
5542
VARIANT:=full
5643
endef
5744

58-
Package/odhcpd/config=$(call Package/odhcpd/default/config,odhcpd,full)
59-
6045
define Package/odhcpd/description
61-
$(call Package/odhcpd/default/description)
46+
$(Package/odhcpd/default/description)
6247

63-
This is a variant providing server services for DHCPv4, RA, stateless and
64-
stateful DHCPv6, prefix delegation and can be used to relay RA, DHCPv6 and
65-
NDP between routed (non-bridged) interfaces in case no delegated prefixes
66-
are available.
48+
This is a variant with support for RA, DHCPv4 and DHCPv6. It can also be used
49+
to relay RA, DHCPv6 and NDP messages between routed (non-bridged) interfaces
50+
in case no delegated prefixes are available.
6751
endef
6852

6953
define Package/odhcpd-ipv6only
70-
$(call Package/odhcpd/default)
54+
$(Package/odhcpd/default)
55+
TITLE:=OpenWrt DHCPv6/NDP/RA server (without DHCPv4)
7156
VARIANT:=ipv6only
72-
DEPENDS+= @IPV6
57+
DEPENDS+=@IPV6
7358
endef
7459

75-
Package/odhcpd-ipv6only/config=$(call Package/odhcpd/default/config,odhcpd-ipv6only,ipv6only)
76-
7760
define Package/odhcpd-ipv6only/description
78-
$(call Package/odhcpd/default/description)
61+
$(Package/odhcpd/default/description)
7962

80-
This is a variant providing server services for RA, stateless and stateful
81-
DHCPv6, prefix delegation and can be used to relay RA, DHCPv6 and NDP between
82-
routed (non-bridged) interfaces in case no delegated prefixes are available.
63+
This is a variant with support for RA and DHCPv6. It can also be used to
64+
relay RA, DHCPv6 and NDP messages between routed (non-bridged) interfaces
65+
in case no delegated prefixes are available.
8366
endef
8467

8568
CMAKE_OPTIONS += -DUBUS=1
@@ -88,10 +71,6 @@ ifeq ($(BUILD_VARIANT),full)
8871
CMAKE_OPTIONS += -DDHCPV4_SUPPORT=1
8972
endif
9073

91-
ifneq ($(CONFIG_PACKAGE_odhcpd_$(BUILD_VARIANT)_ext_cer_id),0)
92-
CMAKE_OPTIONS += -DEXT_CER_ID=$(CONFIG_PACKAGE_odhcpd_$(BUILD_VARIANT)_ext_cer_id)
93-
endif
94-
9574
define Package/odhcpd/install
9675
$(INSTALL_DIR) $(1)/usr/sbin/
9776
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/odhcpd $(1)/usr/sbin/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22
# Make dnsmasq reread hostfile by sending SIGHUP signal
33

4+
initscript=$0
5+
46
. /lib/functions/procd.sh
57

68
procd_send_signal dnsmasq

package/network/services/odhcpd/files/odhcpd.defaults

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,94 @@
11
#!/bin/sh
2-
uci -q get dhcp.odhcpd && exit 0
3-
touch /etc/config/dhcp
42

53
. /usr/share/libubox/jshn.sh
64

5+
pio_file_check() {
6+
local file valid
7+
8+
file=$1
9+
valid=0
10+
11+
json_init
12+
json_load_file $file 2> /dev/null
13+
14+
if json_is_a slaac array; then
15+
local keys len
16+
17+
json_select slaac
18+
json_get_keys keys
19+
20+
len=$(echo $keys | wc -w)
21+
if [ $len -gt 0 ]; then
22+
valid=1
23+
fi
24+
fi
25+
26+
echo $valid
27+
}
28+
29+
pio_folder_migrate() {
30+
local piodir piofolder
31+
32+
piofolder=$1
33+
piodir=$2
34+
35+
[ -d $piofolder ] || return
36+
[ -d $piodir ] || mkdir -p $piodir
37+
38+
for file in $piofolder/*; do
39+
[ -e "$file" ] || continue
40+
if [ $(pio_file_check $file) -eq 1 ]; then
41+
mv $file $piodir/odhcpd.pio.$(basename $file)
42+
fi
43+
done
44+
}
45+
46+
if [ -n "$(uci -q get dhcp.odhcpd)" ]; then
47+
local commit hostsfile piodir piofolder
48+
49+
commit=0
50+
51+
piodir=$(uci -q get dhcp.odhcpd.piodir)
52+
if [ -z "$piodir" ]; then
53+
piodir=/tmp/odhcpd-piodir
54+
uci set dhcp.odhcpd.piodir=$piodir
55+
commit=1
56+
fi
57+
58+
piofolder=$(uci -q get dhcp.odhcpd.piofolder)
59+
if [ -n "$piofolder" ]; then
60+
pio_folder_migrate $piofolder $piodir
61+
uci delete dhcp.odhcpd.piofolder
62+
commit=1
63+
fi
64+
65+
if [ -n "$(uci -q get dhcp.odhcpd.legacy)" ]; then
66+
uci delete dhcp.odhcpd.legacy
67+
commit=1
68+
fi
69+
70+
hostsfile=$(uci -q get dhcp.odhcpd.hostsfile)
71+
if [ -n "$hostsfile" ]; then
72+
uci delete dhcp.odhcpd.hostsfile
73+
uci set dhcp.odhcpd.hostsdir="$(dirname $hostsfile)"
74+
commit=1
75+
elif [ -z "$(uci -q get dhcp.odhcpd.hostsdir)" ]; then
76+
uci set dhcp.odhcpd.hostsdir=/tmp/hosts
77+
commit=1
78+
fi
79+
80+
if [ "$(uci -q get dhcp.odhcpd.leasefile)" == "/tmp/hosts/odhcpd" ]; then
81+
uci set dhcp.odhcpd.leasefile=/tmp/odhcpd.leases
82+
commit=1
83+
fi
84+
85+
[ "$commit" -eq 1 ] && uci commit dhcp
86+
87+
exit 0
88+
fi
89+
90+
touch /etc/config/dhcp
91+
792
json_load "$(cat /etc/board.json)"
893
json_select network
994
json_select lan
@@ -25,7 +110,7 @@ case "$protocol" in
25110
;;
26111
esac
27112

28-
uci get dhcp.lan 1>/dev/null 2>/dev/null || {
113+
uci -q get dhcp.lan || {
29114
uci batch <<EOF
30115
set dhcp.lan=dhcp
31116
set dhcp.lan.interface='lan'
@@ -39,9 +124,11 @@ EOF
39124
uci batch <<EOF
40125
set dhcp.odhcpd=odhcpd
41126
set dhcp.odhcpd.maindhcp=$ODHCPDONLY
42-
set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
127+
set dhcp.odhcpd.leasefile=/tmp/odhcpd.leases
43128
set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
44129
set dhcp.odhcpd.loglevel=4
130+
set dhcp.odhcpd.piodir=/tmp/odhcpd-piodir
131+
set dhcp.odhcpd.hostsdir=/tmp/hosts
45132
set dhcp.lan.dhcpv4=$V4MODE
46133
set dhcp.lan.dhcpv6=$V6MODE
47134
set dhcp.lan.ra=$V6MODE

package/network/services/odhcpd/files/odhcpd.init

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ reload_service() {
1717

1818
service_triggers()
1919
{
20-
procd_add_reload_trigger "dhcp"
20+
procd_add_reload_trigger "dhcp" "network" "system"
2121
}
22-
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- a/src/router.c
2+
+++ b/src/router.c
3+
@@ -871,11 +871,11 @@
4+
} else {
5+
adv.h.nd_ra_router_lifetime = 0;
6+
7+
- if (default_route)
8+
+ /* if (default_route)
9+
warn("A default route is present but there is no public prefix "
10+
"on %s thus we announce no default route by setting ra_lifetime to 0!", iface->name);
11+
else
12+
- warn("No default route present, setting ra_lifetime to 0!");
13+
+ warn("No default route present, setting ra_lifetime to 0!"); */
14+
}
15+
16+
debug("Using a RA lifetime of %d seconds on %s", ntohs(adv.h.nd_ra_router_lifetime), iface->name);

0 commit comments

Comments
 (0)