save link activation policy to state file and display in networkctl

This commit is contained in:
Dan Streetman
2021-01-21 12:05:17 -05:00
parent 2236d75df9
commit a853652ae9
5 changed files with 41 additions and 1 deletions
+11 -1
View File
@@ -1387,7 +1387,7 @@ static int link_status_one(
_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;
@@ -2062,6 +2062,16 @@ static int link_status_one(
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;
+3
View File
@@ -3011,6 +3011,9 @@ int link_save(Link *link) {
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);
/************************************************************/