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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-11-02 14:12:10 +01:00
parent d53a35b867
commit 918353dcc7
11 changed files with 60 additions and 29 deletions
+2
View File
@@ -12,6 +12,8 @@ All notable changes to the project are documented in this file.
to `/interfaces/interface[name]/ipv4/infix-dhcp-client:dhcp`, issue #1109.
The configuration is automatically migrated on upgrade. The DHCP client is
now enabled using a presence container instead of a separate `enabled` leaf
- The `enabled` nore for IPv4 autoconf (ZeroConf) has been dropped, `autoconf`
is now a presence container. Configuration automatically migrated on upgrade
- Improvements to `sdcard.img` generation, useful for developers mostly:
- The NanoPi R2S bootloader is now automatically built and uploaded to
the [`latest-boot` release][lastest-boot] tag
+9 -8
View File
@@ -996,7 +996,7 @@ default.
admin@example:/> configure
admin@example:/config/> edit interface eth0 ipv4
admin@example:/config/interface/eth0/ipv4/> set address 10.0.1.1 prefix-length 24
admin@example:/config/interface/eth0/ipv4/> set autoconf enabled true
admin@example:/config/interface/eth0/ipv4/> set autoconf
admin@example:/config/interface/eth0/ipv4/> diff
+interfaces {
+ interface eth0 {
@@ -1004,9 +1004,7 @@ default.
+ address 10.0.1.1 {
+ prefix-length 24;
+ }
+ autoconf {
+ enabled true;
+ }
+ autoconf;
+ }
+ }
+}
@@ -1022,15 +1020,18 @@ default.
ipv6 ::1/128 (static)
admin@example:/>
As shown, the link-local IPv4 address is configured with `set autconf
enabled true`. The resulting address (169.254.1.3/16) is of type
*random* ([ietf-ip.yang][2]).
As shown, the link-local IPv4 address is configured with `set autoconf`.
The presence of the `autoconf` container enables IPv4 link-local address
assignment. The resulting address (169.254.1.3/16) is of type *random*
([ietf-ip.yang][2]).
The IPv4LL client also supports a `request-address` setting which can be
used to "seed" the client's starting address. If the address is free it
will be used, otherwise it falls back to the default algorithm.
admin@example:/config/interface/eth0/ipv4/> set autoconf request-address 169.254.1.2
admin@example:/config/interface/eth0/ipv4/> edit autoconf
admin@example:/config/interface/eth0/ipv4/autoconf/> set request-address 169.254.1.2
admin@example:/config/interface/eth0/ipv4/autoconf/> leave
#### Use of DHCP for IPv4 address assignment
+10 -4
View File
@@ -169,14 +169,20 @@ if [ -n "$bridge" ]; then
"name": "$bridge",
"type": "infix-if-type:bridge",
"ietf-ip:ipv4": {
"infix-ip:autoconf": {
"enabled": $ipv4
}
EOF
if [ "$dhcp" = "true" ]; then
if [ "$ipv4" = "true" ]; then
cat <<EOF
"infix-ip:autoconf": {}
EOF
if [ "$dhcp" = "true" ]; then
cat <<EOF
,
"infix-dhcp-client:dhcp": {}
EOF
fi
elif [ "$dhcp" = "true" ]; then
cat <<EOF
"infix-dhcp-client:dhcp": {}
EOF
fi
cat <<EOF
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# Migrate IPv4 autoconf from enabled leaf to presence container
# Remove the "enabled" leaf, keeping the container only if it was enabled
file=$1
temp=${file}.tmp
jq '
if .["ietf-interfaces:interfaces"] then
.["ietf-interfaces:interfaces"].interface |= map(
if .["ietf-ip:ipv4"]?."infix-ip:autoconf" then
if .["ietf-ip:ipv4"]."infix-ip:autoconf".enabled == false then
# Remove autoconf container if it was disabled
.["ietf-ip:ipv4"] |= del(."infix-ip:autoconf")
else
# Keep autoconf but remove the enabled leaf
.["ietf-ip:ipv4"]."infix-ip:autoconf" |= del(.enabled)
end
else
.
end
)
else
.
end
' "$file" > "$temp" && mv "$temp" "$file"
+2 -1
View File
@@ -1,2 +1,3 @@
migratedir = $(pkgdatadir)/migrate/1.6
dist_migrate_DATA = 10-dhcp-client-to-ipv4.sh
dist_migrate_DATA = 10-dhcp-client-to-ipv4.sh \
20-autoconf-to-presence.sh
+3 -4
View File
@@ -94,7 +94,7 @@ int netdag_gen_ipv4_autoconf(struct dagger *net, struct lyd_node *cif,
* for various reasons: was bridge port, ipv4 was disabled...
*/
zcip = lydx_get_child(ipconf, "autoconf");
if (zcip && lydx_is_enabled(zcip, "enabled")) {
if (zcip) {
struct lyd_node *node;
const char *addr;
int diff = 0;
@@ -105,9 +105,8 @@ int netdag_gen_ipv4_autoconf(struct dagger *net, struct lyd_node *cif,
if (node) {
const struct lyd_node *tmp;
tmp = lydx_get_child(node, "enabled");
if (tmp)
diff++;
/* presence container created or deleted */
diff++;
tmp = lydx_get_child(node, "request-address");
if (tmp)
diff++;
+1 -1
View File
@@ -20,7 +20,7 @@ MODULES=(
"ietf-hardware@2018-03-13.yang -e hardware-state -e hardware-sensor"
"infix-hardware@2025-10-30.yang"
"ieee802-dot1q-types@2022-10-29.yang"
"infix-ip@2024-09-16.yang"
"infix-ip@2025-11-02.yang"
"infix-if-type@2025-02-12.yang"
"infix-routing@2024-11-27.yang"
"ieee802-dot1ab-lldp@2022-03-15.yang"
+5 -5
View File
@@ -18,6 +18,10 @@ module infix-ip {
description "This module augments ietf-ip with Infix extensions and deviations.";
revision 2025-11-02 {
description "Change autoconf to presence container, removing enabled leaf.";
reference "Internal, issue #1109.";
}
revision 2024-09-16 {
description "Add support for IPv4LL request-address.";
reference "Internal.";
@@ -36,14 +40,10 @@ module infix-ip {
*/
augment "/if:interfaces/if:interface/ip:ipv4" {
container autoconf {
presence "Enable IPv4 link-local address autoconfiguration for this interface.";
description "Parameters to control the autoconfiguration of IPv4 address.";
reference "RFC 3927: Dynamic Configuration of IPv4 Link-Local Addresses";
leaf enabled {
description "Use a ZeroConf/IPv4LL agent to retrieve an 169.254/16 address.";
type boolean;
}
leaf request-address {
description "Try to acquire the specified IP address, if available.
@@ -57,9 +57,7 @@ with infamy.Test() as test:
"name": tport,
"enabled": True,
"ipv4": {
"autoconf": {
"enabled": True
}
"infix-ip:autoconf": {}
}
}
]
@@ -79,8 +77,7 @@ with infamy.Test() as test:
"name": tport,
"enabled": True,
"ipv4": {
"autoconf": {
"enabled": True,
"infix-ip:autoconf": {
"request-address": "169.254.42.42"
}
}
@@ -212,7 +212,6 @@ table ip nat {
"enabled": True,
"forwarding": True,
"infix-ip:autoconf": {
"enabled": True,
"request-address": "169.254.1.1"
}
},