summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd/sd-network/sd-network.c69
-rw-r--r--src/network/wait-online/link.c10
2 files changed, 9 insertions, 70 deletions
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index 9d00470fe1..4fd4c2502b 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -173,23 +173,7 @@ int sd_network_link_get_operational_state(int ifindex, char **ret) {
}
int sd_network_link_get_required_family_for_online(int ifindex, char **ret) {
- _cleanup_free_ char *s = NULL;
- int r;
-
- assert_return(ret, -EINVAL);
-
- r = network_link_get_string(ifindex, "REQUIRED_FAMILY_FOR_ONLINE", &s);
- if (r < 0) {
- if (r != -ENODATA)
- return r;
-
- s = strdup("any");
- if (!s)
- return -ENOMEM;
- }
-
- *ret = TAKE_PTR(s);
- return 0;
+ return network_link_get_string(ifindex, "REQUIRED_FAMILY_FOR_ONLINE", ret);
}
int sd_network_link_get_carrier_state(int ifindex, char **ret) {
@@ -221,60 +205,15 @@ int sd_network_link_get_dhcp6_client_duid_string(int ifindex, char **ret) {
}
int sd_network_link_get_required_for_online(int ifindex) {
- _cleanup_free_ char *s = NULL;
- int r;
-
- r = network_link_get_string(ifindex, "REQUIRED_FOR_ONLINE", &s);
- if (r < 0) {
- /* Handle -ENODATA as RequiredForOnline=yes, for compatibility */
- if (r == -ENODATA)
- return true;
- return r;
- }
-
- return parse_boolean(s);
+ return network_link_get_boolean(ifindex, "REQUIRED_FOR_ONLINE");
}
int sd_network_link_get_required_operstate_for_online(int ifindex, char **ret) {
- _cleanup_free_ char *s = NULL;
- int r;
-
- assert_return(ret, -EINVAL);
-
- r = network_link_get_string(ifindex, "REQUIRED_OPER_STATE_FOR_ONLINE", &s);
- if (r < 0) {
- if (r != -ENODATA)
- return r;
-
- /* For compatibility, assuming degraded. */
- s = strdup("degraded");
- if (!s)
- return -ENOMEM;
- }
-
- *ret = TAKE_PTR(s);
- return 0;
+ return network_link_get_string(ifindex, "REQUIRED_OPER_STATE_FOR_ONLINE", ret);
}
int sd_network_link_get_activation_policy(int ifindex, char **ret) {
- _cleanup_free_ char *s = NULL;
- int r;
-
- assert_return(ret, -EINVAL);
-
- r = network_link_get_string(ifindex, "ACTIVATION_POLICY", &s);
- if (r < 0) {
- if (r != -ENODATA)
- return r;
-
- /* For compatibility, assuming up. */
- s = strdup("up");
- if (!s)
- return -ENOMEM;
- }
-
- *ret = TAKE_PTR(s);
- return 0;
+ return network_link_get_string(ifindex, "ACTIVATION_POLICY", ret);
}
int sd_network_link_get_llmnr(int ifindex, char **ret) {
diff --git a/src/network/wait-online/link.c b/src/network/wait-online/link.c
index ce6c8b181c..836d713f79 100644
--- a/src/network/wait-online/link.c
+++ b/src/network/wait-online/link.c
@@ -107,14 +107,14 @@ int link_update_monitor(Link *l) {
r = sd_network_link_get_required_for_online(l->ifindex);
if (r < 0)
ret = log_link_debug_errno(l, r, "Failed to determine whether the link is required for online or not, "
- "ignoring: %m");
- else
- l->required_for_online = r > 0;
+ "assuming required: %m");
+ l->required_for_online = r != 0;
r = sd_network_link_get_required_operstate_for_online(l->ifindex, &required_operstate);
- if (r < 0)
+ if (r < 0) {
ret = log_link_debug_errno(l, r, "Failed to get required operational state, ignoring: %m");
- else if (isempty(required_operstate))
+ l->required_operstate = LINK_OPERSTATE_RANGE_DEFAULT;
+ } else if (isempty(required_operstate))
l->required_operstate = LINK_OPERSTATE_RANGE_DEFAULT;
else {
r = parse_operational_state_range(required_operstate, &l->required_operstate);