Skip to content

Commit 15a6f69

Browse files
committed
confd: drop 'enabled' node from IPv4 autoconf container
Neither the IPv6 autonconf container, nor the recently moved DHCP client container have an 'enabled' flag. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 7f555fd commit 15a6f69

File tree

11 files changed

+60
-29
lines changed

11 files changed

+60
-29
lines changed

doc/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ All notable changes to the project are documented in this file.
1313
to `/interfaces/interface[name]/ipv4/infix-dhcp-client:dhcp`, issue #1109.
1414
The configuration is automatically migrated on upgrade. The DHCP client is
1515
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
1618
- Improvements to `sdcard.img` generation, useful for developers mostly:
1719
- The NanoPi R2S bootloader is now automatically built and uploaded to
1820
the [`latest-boot` release][lastest-boot] tag

doc/networking.md

Lines changed: 9 additions & 8 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,15 +1020,18 @@ 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

src/confd/bin/gen-interfaces

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,20 @@ if [ -n "$bridge" ]; then
169169
"name": "$bridge",
170170
"type": "infix-if-type:bridge",
171171
"ietf-ip:ipv4": {
172-
"infix-ip:autoconf": {
173-
"enabled": $ipv4
174-
}
175172
EOF
176-
if [ "$dhcp" = "true" ]; then
173+
if [ "$ipv4" = "true" ]; then
177174
cat <<EOF
175+
"infix-ip:autoconf": {}
176+
EOF
177+
if [ "$dhcp" = "true" ]; then
178+
cat <<EOF
178179
,
179180
"infix-dhcp-client:dhcp": {}
181+
EOF
182+
fi
183+
elif [ "$dhcp" = "true" ]; then
184+
cat <<EOF
185+
"infix-dhcp-client:dhcp": {}
180186
EOF
181187
fi
182188
cat <<EOF
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
# Migrate IPv4 autoconf from enabled leaf to presence container
3+
# Remove the "enabled" leaf, keeping the container only if it was enabled
4+
5+
file=$1
6+
temp=${file}.tmp
7+
8+
jq '
9+
if .["ietf-interfaces:interfaces"] then
10+
.["ietf-interfaces:interfaces"].interface |= map(
11+
if .["ietf-ip:ipv4"]?."infix-ip:autoconf" then
12+
if .["ietf-ip:ipv4"]."infix-ip:autoconf".enabled == false then
13+
# Remove autoconf container if it was disabled
14+
.["ietf-ip:ipv4"] |= del(."infix-ip:autoconf")
15+
else
16+
# Keep autoconf but remove the enabled leaf
17+
.["ietf-ip:ipv4"]."infix-ip:autoconf" |= del(.enabled)
18+
end
19+
else
20+
.
21+
end
22+
)
23+
else
24+
.
25+
end
26+
' "$file" > "$temp" && mv "$temp" "$file"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
migratedir = $(pkgdatadir)/migrate/1.6
2-
dist_migrate_DATA = 10-dhcp-client-to-ipv4.sh
2+
dist_migrate_DATA = 10-dhcp-client-to-ipv4.sh \
3+
20-autoconf-to-presence.sh

src/confd/src/ietf-ip.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int netdag_gen_ipv4_autoconf(struct dagger *net, struct lyd_node *cif,
9494
* for various reasons: was bridge port, ipv4 was disabled...
9595
*/
9696
zcip = lydx_get_child(ipconf, "autoconf");
97-
if (zcip && lydx_is_enabled(zcip, "enabled")) {
97+
if (zcip) {
9898
struct lyd_node *node;
9999
const char *addr;
100100
int diff = 0;
@@ -105,9 +105,8 @@ int netdag_gen_ipv4_autoconf(struct dagger *net, struct lyd_node *cif,
105105
if (node) {
106106
const struct lyd_node *tmp;
107107

108-
tmp = lydx_get_child(node, "enabled");
109-
if (tmp)
110-
diff++;
108+
/* presence container created or deleted */
109+
diff++;
111110
tmp = lydx_get_child(node, "request-address");
112111
if (tmp)
113112
diff++;

src/confd/yang/confd.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ MODULES=(
2020
"[email protected] -e hardware-state -e hardware-sensor"
2121
2222
23-
"infix-ip@2024-09-16.yang"
23+
"infix-ip@2025-11-02.yang"
2424
2525
2626

src/confd/yang/confd/infix-ip.yang

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ module infix-ip {
1818

1919
description "This module augments ietf-ip with Infix extensions and deviations.";
2020

21+
revision 2025-11-02 {
22+
description "Change autoconf to presence container, removing enabled leaf.";
23+
reference "Internal, issue #1109.";
24+
}
2125
revision 2024-09-16 {
2226
description "Add support for IPv4LL request-address.";
2327
reference "Internal.";
@@ -36,14 +40,10 @@ module infix-ip {
3640
*/
3741
augment "/if:interfaces/if:interface/ip:ipv4" {
3842
container autoconf {
43+
presence "Enable IPv4 link-local address autoconfiguration for this interface.";
3944
description "Parameters to control the autoconfiguration of IPv4 address.";
4045
reference "RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses";
4146

42-
leaf enabled {
43-
description "Use a ZeroConf/IPv4LL agent to retrieve an 169.254/16 address.";
44-
type boolean;
45-
}
46-
4747
leaf request-address {
4848
description "Try to acquire the specified IP address, if available.
4949

test/case/ietf_interfaces/ipv4_autoconf/test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ def no_linklocal(target, iface):
5757
"name": tport,
5858
"enabled": True,
5959
"ipv4": {
60-
"autoconf": {
61-
"enabled": True
62-
}
60+
"infix-ip:autoconf": {}
6361
}
6462
}
6563
]
@@ -79,8 +77,7 @@ def no_linklocal(target, iface):
7977
"name": tport,
8078
"enabled": True,
8179
"ipv4": {
82-
"autoconf": {
83-
"enabled": True,
80+
"infix-ip:autoconf": {
8481
"request-address": "169.254.42.42"
8582
}
8683
}

0 commit comments

Comments
 (0)