return 0;
}
+_public_ int sd_network_link_get_activation_policy(int ifindex, char **policy) {
+ _cleanup_free_ char *s = NULL;
+ int r;
+
+ assert_return(policy, -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;
+ }
+
+ *policy = TAKE_PTR(s);
+ return 0;
+}
+
_public_ int sd_network_link_get_llmnr(int ifindex, char **llmnr) {
return network_link_get_string(ifindex, "LLMNR", llmnr);
}
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL;
_cleanup_free_ char *t = NULL, *network = NULL, *iaid = NULL, *duid = NULL,
- *setup_state = NULL, *operational_state = NULL, *lease_file = NULL;
+ *setup_state = NULL, *operational_state = NULL, *lease_file = NULL, *activation_policy = NULL;
const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL,
*on_color_operational, *off_color_operational, *on_color_setup, *off_color_setup;
_cleanup_free_ int *carrier_bound_to = NULL, *carrier_bound_by = NULL;
if (r < 0)
return r;
+ r = sd_network_link_get_activation_policy(info->ifindex, &activation_policy);
+ if (r >= 0) {
+ r = table_add_many(table,
+ TABLE_EMPTY,
+ TABLE_STRING, "Activation Policy:",
+ TABLE_STRING, activation_policy);
+ if (r < 0)
+ return table_log_add_error(r);
+ }
+
if (lease) {
const void *client_id;
size_t client_id_len;
st.max != LINK_OPERSTATE_RANGE_DEFAULT.max ? ":" : "",
st.max != LINK_OPERSTATE_RANGE_DEFAULT.max ? strempty(link_operstate_to_string(st.max)) : "");
+ fprintf(f, "ACTIVATION_POLICY=%s\n",
+ activation_policy_to_string(link->network->activation_policy));
+
fprintf(f, "NETWORK_FILE=%s\n", link->network->filename);
/************************************************************/
*/
int sd_network_link_get_required_for_online(int ifindex);
+/* Get activation policy for ifindex.
+ * Possible values are as specified for ActivationPolicy=
+ */
+int sd_network_link_get_activation_policy(int ifindex, char **policy);
+
/* Get path to .network file applied to link */
int sd_network_link_get_network_file(int ifindex, char **filename);
self.assertRegex(data, r'OPER_STATE=routable')
self.assertRegex(data, r'REQUIRED_FOR_ONLINE=yes')
self.assertRegex(data, r'REQUIRED_OPER_STATE_FOR_ONLINE=routable')
+ self.assertRegex(data, r'ACTIVATION_POLICY=up')
self.assertRegex(data, r'NETWORK_FILE=/run/systemd/network/state-file-tests.network')
self.assertRegex(data, r'DNS=10.10.10.10#aaa.com 10.10.10.11:1111#bbb.com \[1111:2222::3333\]:1234#ccc.com')
self.assertRegex(data, r'NTP=0.fedora.pool.ntp.org 1.fedora.pool.ntp.org')