mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2026-06-21 00:07:16 +03:00
nocloud: add route-metric support
This commit is contained in:
parent
584551e331
commit
e7175bd9c1
@ -71,8 +71,9 @@ set_network_config_v2() {
|
||||
|
||||
local iface configured= target_name macaddress
|
||||
for iface in $ethernets; do
|
||||
local stanza= dhcp4= dhcp6= accept_ra=
|
||||
local stanza= dhcp4= dhcp6= accept_ra= dhcp_program= dhcp_opts=
|
||||
local address= gateway= nameservers= server=
|
||||
local route_metric=
|
||||
|
||||
target_name="$(get_network_config ethernets/$iface/set-name)"
|
||||
macaddress="$(get_network_config ethernets/$iface/match/macaddress)"
|
||||
@ -89,6 +90,11 @@ set_network_config_v2() {
|
||||
case "$dhcp4" in
|
||||
true|yes)
|
||||
stanza="$stanza\tuse dhcp\n"
|
||||
route_metric="$(get_network_config ethernets/$iface/dhcp4-overrides/route-metric)"
|
||||
if [ -n "$route_metric" ]; then
|
||||
dhcp_program="dhcpcd"
|
||||
dhcp_opts="$dhcp_opts -m $route_metric"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -96,12 +102,20 @@ set_network_config_v2() {
|
||||
true|yes)
|
||||
case "$dhcp4" in
|
||||
true|yes)
|
||||
:
|
||||
route_metric="$(get_network_config ethernets/$iface/dhcp6-overrides/route-metric)"
|
||||
if [ -n "$route_metric" ]; then
|
||||
dhcp_program="dhcpcd"
|
||||
dhcp_opts="$dhcp_opts -m $route_metric"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
stanza="$stanza\tuse dhcp\n"
|
||||
stanza="$stanza\tdhcp-program dhcpcd\n"
|
||||
stanza="$stanza\tdhcp-opts -6\n"
|
||||
dhcp_program="dhcpcd"
|
||||
dhcp_opts="$dhcp_opts -6"
|
||||
route_metric="$(get_network_config ethernets/$iface/dhcp6-overrides/route-metric)"
|
||||
if [ -n "$route_metric" ]; then
|
||||
dhcp_opts="$dhcp_opts -m $route_metric"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
@ -128,6 +142,13 @@ set_network_config_v2() {
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$dhcp_program" ]; then
|
||||
stanza="$stanza\tdhcp-program $dhcp_program\n"
|
||||
fi
|
||||
if [ -n "$dhcp_opts" ]; then
|
||||
stanza="$stanza\tdhcp-opts${dhcp_opts}\n"
|
||||
fi
|
||||
|
||||
[ -n "$stanza" ] || continue
|
||||
|
||||
printf "%s\n%s\n%b\n" \
|
||||
|
||||
@ -18,6 +18,8 @@ init_tests \
|
||||
set_network_config_v2_static_ipv6 \
|
||||
set_network_config_v2_dhcp6 \
|
||||
set_network_config_v2_accept_ra \
|
||||
set_network_config_v2_dhcp4_route_metric \
|
||||
set_network_config_v2_dhcp6_route_metric \
|
||||
set_network_config_auto \
|
||||
userdata_user_name \
|
||||
userdata_user_homedir \
|
||||
@ -301,6 +303,60 @@ set_network_config_v2_accept_ra_body() {
|
||||
cat etc/network/interfaces
|
||||
}
|
||||
|
||||
set_network_config_v2_dhcp4_route_metric_body() {
|
||||
fake_network_config_nocloud <<-EOF
|
||||
version: 2
|
||||
ethernets:
|
||||
net0:
|
||||
match:
|
||||
macaddress: 52:55:55:1d:2a:0b
|
||||
set-name: lima0
|
||||
dhcp4: true
|
||||
dhcp4-overrides:
|
||||
route-metric: 200
|
||||
EOF
|
||||
|
||||
atf_check \
|
||||
-o ignore \
|
||||
-e match:"set_network_interfaces: done" \
|
||||
tiny-cloud boot
|
||||
|
||||
atf_check \
|
||||
-o match:"auto lima0" \
|
||||
-o match:"iface lima0" \
|
||||
-o match:"use dhcp" \
|
||||
-o match:"dhcp-program dhcpcd" \
|
||||
-o match:"dhcp-opts -m 200" \
|
||||
cat etc/network/interfaces
|
||||
}
|
||||
|
||||
set_network_config_v2_dhcp6_route_metric_body() {
|
||||
fake_network_config_nocloud <<-EOF
|
||||
version: 2
|
||||
ethernets:
|
||||
net0:
|
||||
match:
|
||||
macaddress: 52:55:55:1d:2a:0b
|
||||
set-name: lima0
|
||||
dhcp6: true
|
||||
dhcp6-overrides:
|
||||
route-metric: 100
|
||||
EOF
|
||||
|
||||
atf_check \
|
||||
-o ignore \
|
||||
-e match:"set_network_interfaces: done" \
|
||||
tiny-cloud boot
|
||||
|
||||
atf_check \
|
||||
-o match:"auto lima0" \
|
||||
-o match:"iface lima0" \
|
||||
-o match:"use dhcp" \
|
||||
-o match:"dhcp-program dhcpcd" \
|
||||
-o match:"dhcp-opts -6 -m 100" \
|
||||
cat etc/network/interfaces
|
||||
}
|
||||
|
||||
set_network_config_auto_body() {
|
||||
fake_metadata_nocloud <<-EOF
|
||||
resolv_conf:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user