Skip to content

Commit 7f555fd

Browse files
committed
confd: relocate /dhcp-client to /interfaces/interface/ipv4/dhcp
Please note, this change drops not only the global enabled flag, but also the per-interface enabled flag, converting it to a presence container. The name of the container is also shortened from dhcp-client -> dhcp. A pattern that expected to be reused also for the DHCPv6 client. Fixes #1109 Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 5496258 commit 7f555fd

File tree

24 files changed

+340
-302
lines changed

24 files changed

+340
-302
lines changed

board/aarch64/bananapi-bpi-r3/rootfs/usr/share/product/bananapi,bpi-r3/etc/factory-config.cfg

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,20 @@
9999
{
100100
"name": "wan",
101101
"type": "infix-if-type:ethernet",
102-
"ietf-ip:ipv6": {}
102+
"ietf-ip:ipv6": {},
103+
"ietf-ip:ipv4": {
104+
"infix-dhcp-client:dhcp": {
105+
"option": [
106+
{"id": "ntp-server"},
107+
{"id": "broadcast"},
108+
{"id": "domain"},
109+
{"id": "hostname"},
110+
{"id": "dns-server"},
111+
{"id": "router"},
112+
{"id": "netmask"}
113+
]
114+
}
115+
}
103116
},
104117
{
105118
"name": "wifi0",
@@ -221,36 +234,6 @@
221234
},
222235
"infix-system:motd-banner": "Li0tLS0tLS0uCnwgIC4gLiAgfCBJbmZpeCBPUyDigJQgSW1tdXRhYmxlLkZyaWVuZGx5LlNlY3VyZQp8LS4gdiAuLXwgaHR0cHM6Ly9rZXJuZWxraXQub3JnCictJy0tLSctJwo="
223236
},
224-
"infix-dhcp-client:dhcp-client": {
225-
"client-if": [
226-
{
227-
"if-name": "wan",
228-
"option": [
229-
{
230-
"id": "ntp-server"
231-
},
232-
{
233-
"id": "broadcast"
234-
},
235-
{
236-
"id": "domain"
237-
},
238-
{
239-
"id": "hostname"
240-
},
241-
{
242-
"id": "dns-server"
243-
},
244-
{
245-
"id": "router"
246-
},
247-
{
248-
"id": "netmask"
249-
}
250-
]
251-
}
252-
]
253-
},
254237
"infix-dhcp-server:dhcp-server": {
255238
"option": [
256239
{
@@ -311,7 +294,7 @@
311294
]
312295
},
313296
"infix-meta:meta": {
314-
"version": "1.5"
297+
"version": "1.6"
315298
},
316299
"infix-services:mdns": {
317300
"enabled": true

board/aarch64/friendlyarm-nanopi-r2s/rootfs/usr/share/product/friendlyarm,nanopi-r2s/etc/factory-config.cfg

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,20 @@
5858
{
5959
"name": "wan",
6060
"type": "infix-if-type:ethernet",
61-
"ietf-ip:ipv6": {}
61+
"ietf-ip:ipv6": {},
62+
"ietf-ip:ipv4": {
63+
"infix-dhcp-client:dhcp": {
64+
"option": [
65+
{"id": "ntp-server"},
66+
{"id": "broadcast"},
67+
{"id": "domain"},
68+
{"id": "hostname"},
69+
{"id": "dns-server"},
70+
{"id": "router"},
71+
{"id": "netmask"}
72+
]
73+
}
74+
}
6275
}
6376
]
6477
},
@@ -172,36 +185,6 @@
172185
},
173186
"infix-system:motd-banner": "Li0tLS0tLS0uCnwgIC4gLiAgfCBJbmZpeCBPUyDigJQgSW1tdXRhYmxlLkZyaWVuZGx5LlNlY3VyZQp8LS4gdiAuLXwgaHR0cHM6Ly9rZXJuZWxraXQub3JnCictJy0tLSctJwo="
174187
},
175-
"infix-dhcp-client:dhcp-client": {
176-
"client-if": [
177-
{
178-
"if-name": "wan",
179-
"option": [
180-
{
181-
"id": "ntp-server"
182-
},
183-
{
184-
"id": "broadcast"
185-
},
186-
{
187-
"id": "domain"
188-
},
189-
{
190-
"id": "hostname"
191-
},
192-
{
193-
"id": "dns-server"
194-
},
195-
{
196-
"id": "router"
197-
},
198-
{
199-
"id": "netmask"
200-
}
201-
]
202-
}
203-
]
204-
},
205188
"infix-dhcp-server:dhcp-server": {
206189
"option": [
207190
{
@@ -262,7 +245,7 @@
262245
]
263246
},
264247
"infix-meta:meta": {
265-
"version": "1.5"
248+
"version": "1.6"
266249
},
267250
"infix-services:mdns": {
268251
"enabled": true

board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-model-b/etc/factory-config.cfg

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,20 @@
3737
},
3838
{
3939
"name": "eth0",
40-
"type": "infix-if-type:ethernet"
40+
"type": "infix-if-type:ethernet",
41+
"ietf-ip:ipv4": {
42+
"infix-dhcp-client:dhcp": {
43+
"option": [
44+
{"id": "netmask"},
45+
{"id": "broadcast"},
46+
{"id": "router"},
47+
{"id": "domain"},
48+
{"id": "hostname"},
49+
{"id": "dns-server"},
50+
{"id": "ntp-server"}
51+
]
52+
}
53+
}
4154
},
4255
{
4356
"name": "wifi0",
@@ -157,38 +170,8 @@
157170
},
158171
"infix-system:motd-banner": "Li0tLS0tLS0uCnwgIC4gLiAgfCBJbmZpeCBPUyDigJQgSW1tdXRhYmxlLkZyaWVuZGx5LlNlY3VyZQp8LS4gdiAuLXwgaHR0cHM6Ly9rZXJuZWxraXQub3JnCictJy0tLSctJwo="
159172
},
160-
"infix-dhcp-client:dhcp-client": {
161-
"client-if": [
162-
{
163-
"if-name": "eth0",
164-
"option": [
165-
{
166-
"id": "netmask"
167-
},
168-
{
169-
"id": "broadcast"
170-
},
171-
{
172-
"id": "router"
173-
},
174-
{
175-
"id": "domain"
176-
},
177-
{
178-
"id": "hostname"
179-
},
180-
{
181-
"id": "dns-server"
182-
},
183-
{
184-
"id": "ntp-server"
185-
}
186-
]
187-
}
188-
]
189-
},
190173
"infix-meta:meta": {
191-
"version": "1.5"
174+
"version": "1.6"
192175
},
193176
"infix-services:mdns": {
194177
"enabled": true

doc/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes to the project are documented in this file.
99
### Changes
1010

1111
- Upgrade Linux kernel to 6.12.57 (LTS)
12+
- The DHCP client configuration has moved from `/infix-dhcp-client:dhcp-client`
13+
to `/interfaces/interface[name]/ipv4/infix-dhcp-client:dhcp`, issue #1109.
14+
The configuration is automatically migrated on upgrade. The DHCP client is
15+
now enabled using a presence container instead of a separate `enabled` leaf
1216
- Improvements to `sdcard.img` generation, useful for developers mostly:
1317
- The NanoPi R2S bootloader is now automatically built and uploaded to
1418
the [`latest-boot` release][lastest-boot] tag

doc/networking.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,9 @@ will be used, otherwise it falls back to the default algorithm.
10381038
![Using DHCP for IPv4 address assignment](img/ip-address-example-ipv4-dhcp.svg)
10391039

10401040
admin@example:/> configure
1041-
admin@example:/config/> edit dhcp-client
1042-
admin@example:/config/dhcp-client/> set client-if eth0
1043-
admin@example:/config/dhcp-client/> leave
1041+
admin@example:/config/> edit interface eth0 ipv4
1042+
admin@example:/config/interface/eth0/ipv4/> set dhcp
1043+
admin@example:/config/interface/eth0/ipv4/> leave
10441044
admin@example:/> show interfaces
10451045
INTERFACE PROTOCOL STATE DATA
10461046
eth0 ethernet UP 02:00:00:00:00:00
@@ -1053,6 +1053,31 @@ will be used, otherwise it falls back to the default algorithm.
10531053

10541054
The resulting address (10.1.2.100/24) is of type *dhcp*.
10551055

1056+
To configure DHCP client options, such as sending a specific hostname to the
1057+
server, you can specify options with values:
1058+
1059+
```
1060+
admin@example:/> configure
1061+
admin@example:/config/> edit interface eth0 ipv4 dhcp
1062+
admin@example:/config/interface/eth0/ipv4/dhcp/> set option hostname value myhost
1063+
admin@example:/config/interface/eth0/ipv4/dhcp/> show
1064+
option hostname {
1065+
value myhost;
1066+
}
1067+
admin@example:/config/interface/eth0/ipv4/dhcp/> leave
1068+
admin@example:/>
1069+
```
1070+
1071+
> [!TIP]
1072+
> The special value `auto` can be used with the hostname option to
1073+
> automatically use the configured system hostname.
1074+
1075+
Other useful DHCP options include:
1076+
1077+
- `client-id` - Send a specific client identifier to the server
1078+
- `route-preference` - Set the administrative distance for DHCP-learned routes (default: 5)
1079+
1080+
For advanced usage with vendor-specific options, see the YANG model.
10561081

10571082
#### Disabling IPv6 link-local address(es)
10581083

doc/scripting-sysrepocfg.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ Enabling DHCPv4 client on interface *e0*, with current default options.
173173
```
174174
~$ cat /tmp/file.json
175175
{
176-
"infix-dhcp-client:dhcp-client": {
177-
"enabled": true,
178-
"client-if": [
176+
"ietf-interfaces:interfaces": {
177+
"interface": [
179178
{
180-
"if-name": "e0"
179+
"name": "e0",
180+
"ietf-ip:ipv4": {
181+
"infix-dhcp-client:dhcp": {}
182+
}
181183
}
182184
]
183185
}
@@ -187,41 +189,27 @@ Enabling DHCPv4 client on interface *e0*, with current default options.
187189
~$
188190
```
189191

190-
Disabling DHCPv4 client.
192+
Disabling DHCPv4 client on interface *e0* (remove the dhcp container).
191193

192194
```
193195
~$ cat /tmp/file.json
194196
{
195-
"infix-dhcp-client:dhcp-client": {
196-
"enabled": false
197-
}
198-
}
199-
~$ scp file.json [email protected]:/tmp/file.json
200-
~$ ssh [email protected] 'sysrepocfg -E /tmp/file.json -fjson -d running'
201-
~$
202-
```
203-
204-
Configuration for client interface *e0* remains, but does not apply as
205-
DHCPv4 is disabled.
206-
207-
```
208-
admin@example:~$ sysrepocfg -X -fjson -d running -x "/infix-dhcp-client:dhcp-client"
209-
{
210-
"infix-dhcp-client:dhcp-client": {
211-
"enabled": false,
212-
"client-if": [
197+
"ietf-interfaces:interfaces": {
198+
"interface": [
213199
{
214-
"if-name": "e0"
200+
"name": "e0",
201+
"ietf-ip:ipv4": {}
215202
}
216203
]
217204
}
218205
}
219-
admin@example:~$
206+
~$ scp file.json [email protected]:/tmp/file.json
207+
~$ ssh [email protected] 'sysrepocfg -E /tmp/file.json -fjson -d running'
208+
~$
220209
```
221210

222-
To fully remove the DHCPv4 client configuration or a specific
223-
*client-if* with sysrepocfg, one would need to read out the full
224-
configuration, remove relevant parts and read back.
211+
To fully remove the DHCPv4 client configuration, remove the `infix-dhcp-client:dhcp`
212+
container from the interface's ipv4 configuration.
225213

226214
## Enable/Disable IPv6
227215

package/confd/confd.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
################################################################################
66

7-
CONFD_VERSION = 1.5
7+
CONFD_VERSION = 1.6
88
CONFD_SITE_METHOD = local
99
CONFD_SITE = $(BR2_EXTERNAL_INFIX_PATH)/src/confd
1010
CONFD_LICENSE = BSD-3-Clause

src/confd/bin/gen-interfaces

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ if [ -n "$bridge" ]; then
172172
"infix-ip:autoconf": {
173173
"enabled": $ipv4
174174
}
175+
EOF
176+
if [ "$dhcp" = "true" ]; then
177+
cat <<EOF
178+
,
179+
"infix-dhcp-client:dhcp": {}
180+
EOF
181+
fi
182+
cat <<EOF
175183
},
176184
"ietf-ip:ipv6": {
177185
"enabled": true,
@@ -195,18 +203,6 @@ $(for iface in $ifaces; do gen_iface_json "$iface"; done)
195203
$(for iface in $ports; do gen_iface_json "$iface" "$bridge"; done)
196204
]
197205
EOF
198-
if [ "$dhcp" = "true" ] && [ -n "$bridge" ]; then
199-
cat <<EOF
200-
},
201-
"infix-dhcp-client:dhcp-client": {
202-
"enabled": true,
203-
"client-if": [
204-
{
205-
"if-name": "$bridge"
206-
}
207-
]
208-
EOF
209-
fi
210206
cat <<EOF
211207
}
212208
}

src/confd/configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AC_PREREQ(2.61)
22
# confd version is same as system YANG model version, step on breaking changes
3-
AC_INIT([confd], [1.5], [https://github.com/kernelkit/infix/issues])
3+
AC_INIT([confd], [1.6], [https://github.com/kernelkit/infix/issues])
44
AM_INIT_AUTOMAKE(1.11 foreign subdir-objects)
55
AM_SILENT_RULES(yes)
66

@@ -19,6 +19,7 @@ AC_CONFIG_FILES([
1919
share/migrate/1.3/Makefile
2020
share/migrate/1.4/Makefile
2121
share/migrate/1.5/Makefile
22+
share/migrate/1.6/Makefile
2223
yang/Makefile
2324
yang/confd/Makefile
2425
yang/test-mode/Makefile

0 commit comments

Comments
 (0)