Skip to content

Commit 764bd8e

Browse files
authored
Merge pull request #1223 from kernelkit/migrate-dhcp-client
Relocate /dhcp-client to /interfaces/interface/ipv4/dhcp
2 parents f01291b + 80e8ccf commit 764bd8e

File tree

32 files changed

+412
-331
lines changed

32 files changed

+412
-331
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ 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
16+
- The `enabled` nore for IPv4 autoconf (ZeroConf) has been dropped, `autoconf`
17+
is now a presence container. Configuration automatically migrated on upgrade
1218
- Improvements to `sdcard.img` generation, useful for developers mostly:
1319
- The NanoPi R2S bootloader is now automatically built and uploaded to
1420
the [`latest-boot` release][lastest-boot] tag

doc/networking.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -996,17 +996,15 @@ default.
996996
admin@example:/> configure
997997
admin@example:/config/> edit interface eth0 ipv4
998998
admin@example:/config/interface/eth0/ipv4/> set address 10.0.1.1 prefix-length 24
999-
admin@example:/config/interface/eth0/ipv4/> set autoconf enabled true
999+
admin@example:/config/interface/eth0/ipv4/> set autoconf
10001000
admin@example:/config/interface/eth0/ipv4/> diff
10011001
+interfaces {
10021002
+ interface eth0 {
10031003
+ ipv4 {
10041004
+ address 10.0.1.1 {
10051005
+ prefix-length 24;
10061006
+ }
1007-
+ autoconf {
1008-
+ enabled true;
1009-
+ }
1007+
+ autoconf;
10101008
+ }
10111009
+ }
10121010
+}
@@ -1022,25 +1020,28 @@ default.
10221020
ipv6 ::1/128 (static)
10231021
admin@example:/>
10241022

1025-
As shown, the link-local IPv4 address is configured with `set autconf
1026-
enabled true`. The resulting address (169.254.1.3/16) is of type
1027-
*random* ([ietf-ip.yang][2]).
1023+
As shown, the link-local IPv4 address is configured with `set autoconf`.
1024+
The presence of the `autoconf` container enables IPv4 link-local address
1025+
assignment. The resulting address (169.254.1.3/16) is of type *random*
1026+
([ietf-ip.yang][2]).
10281027

10291028
The IPv4LL client also supports a `request-address` setting which can be
10301029
used to "seed" the client's starting address. If the address is free it
10311030
will be used, otherwise it falls back to the default algorithm.
10321031

1033-
admin@example:/config/interface/eth0/ipv4/> set autoconf request-address 169.254.1.2
1032+
admin@example:/config/interface/eth0/ipv4/> edit autoconf
1033+
admin@example:/config/interface/eth0/ipv4/autoconf/> set request-address 169.254.1.2
1034+
admin@example:/config/interface/eth0/ipv4/autoconf/> leave
10341035

10351036

10361037
#### Use of DHCP for IPv4 address assignment
10371038

10381039
![Using DHCP for IPv4 address assignment](img/ip-address-example-ipv4-dhcp.svg)
10391040

10401041
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
1042+
admin@example:/config/> edit interface eth0 ipv4
1043+
admin@example:/config/interface/eth0/ipv4/> set dhcp
1044+
admin@example:/config/interface/eth0/ipv4/> leave
10441045
admin@example:/> show interfaces
10451046
INTERFACE PROTOCOL STATE DATA
10461047
eth0 ethernet UP 02:00:00:00:00:00
@@ -1053,6 +1054,31 @@ will be used, otherwise it falls back to the default algorithm.
10531054

10541055
The resulting address (10.1.2.100/24) is of type *dhcp*.
10551056

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

10571083
#### Disabling IPv6 link-local address(es)
10581084

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

0 commit comments

Comments
 (0)