Lines Matching refs:config
46 static LinkConfig* link_config_free(LinkConfig *config) { in link_config_free() argument
47 if (!config) in link_config_free()
50 free(config->filename); in link_config_free()
52 net_match_clear(&config->match); in link_config_free()
53 condition_free_list(config->conditions); in link_config_free()
55 free(config->description); in link_config_free()
56 free(config->name_policy); in link_config_free()
57 free(config->name); in link_config_free()
58 strv_free(config->alternative_names); in link_config_free()
59 free(config->alternative_names_policy); in link_config_free()
60 free(config->alias); in link_config_free()
61 free(config->wol_password_file); in link_config_free()
62 erase_and_free(config->wol_password); in link_config_free()
64 ordered_hashmap_free_with_destructor(config->sr_iov_by_section, sr_iov_free); in link_config_free()
66 return mfree(config); in link_config_free()
77 LIST_FOREACH(configs, config, ctx->configs) in link_configs_free()
78 link_config_free(config); in link_configs_free()
109 static int link_parse_wol_password(LinkConfig *config, const char *str) { in link_parse_wol_password() argument
113 assert(config); in link_parse_wol_password()
127 erase_and_free(config->wol_password); in link_parse_wol_password()
128 config->wol_password = TAKE_PTR(p); in link_parse_wol_password()
132 static int link_read_wol_password_from_file(LinkConfig *config) { in link_read_wol_password_from_file() argument
136 assert(config); in link_read_wol_password_from_file()
138 if (!config->wol_password_file) in link_read_wol_password_from_file()
142 AT_FDCWD, config->wol_password_file, UINT64_MAX, SIZE_MAX, in link_read_wol_password_from_file()
148 return link_parse_wol_password(config, password); in link_read_wol_password_from_file()
151 static int link_read_wol_password_from_cred(LinkConfig *config) { in link_read_wol_password_from_cred() argument
156 assert(config); in link_read_wol_password_from_cred()
157 assert(config->filename); in link_read_wol_password_from_cred()
159 if (config->wol == UINT32_MAX) in link_read_wol_password_from_cred()
161 if (!FLAGS_SET(config->wol, WAKE_MAGICSECURE)) in link_read_wol_password_from_cred()
163 if (config->wol_password) in link_read_wol_password_from_cred()
165 if (config->wol_password_file) in link_read_wol_password_from_cred()
168 r = path_extract_filename(config->filename, &base); in link_read_wol_password_from_cred()
182 return link_parse_wol_password(config, password); in link_read_wol_password_from_cred()
185 static int link_adjust_wol_options(LinkConfig *config) { in link_adjust_wol_options() argument
188 assert(config); in link_adjust_wol_options()
190 r = link_read_wol_password_from_file(config); in link_adjust_wol_options()
194 …ning_errno(r, "Failed to read WakeOnLan password from %s, ignoring: %m", config->wol_password_file… in link_adjust_wol_options()
196 r = link_read_wol_password_from_cred(config); in link_adjust_wol_options()
202 if (config->wol != UINT32_MAX && config->wol_password) in link_adjust_wol_options()
206 config->wol |= WAKE_MAGICSECURE; in link_adjust_wol_options()
212 _cleanup_(link_config_freep) LinkConfig *config = NULL; in link_load_one()
234 config = new(LinkConfig, 1); in link_load_one()
235 if (!config) in link_load_one()
238 *config = (LinkConfig) { in link_load_one()
255 for (i = 0; i < ELEMENTSOF(config->features); i++) in link_load_one()
256 config->features[i] = -1; in link_load_one()
267 CONFIG_PARSE_WARN, config, &stats_by_path); in link_load_one()
278 if (net_match_is_empty(&config->match) && !config->conditions) { in link_load_one()
285 if (!condition_test_list(config->conditions, environ, NULL, NULL, NULL)) { in link_load_one()
290 …if (IN_SET(config->mac_address_policy, MAC_ADDRESS_POLICY_PERSISTENT, MAC_ADDRESS_POLICY_RANDOM) && in link_load_one()
291 config->hw_addr.length > 0) in link_load_one()
296 r = link_adjust_wol_options(config); in link_load_one()
300 r = sr_iov_drop_invalid_sections(config->sr_iov_num_vfs, config->sr_iov_by_section); in link_load_one()
306 LIST_PREPEND(configs, ctx->configs, TAKE_PTR(config)); in link_load_one()
435 LIST_FOREACH(configs, config, ctx->configs) { in link_get_config()
437 &config->match, in link_get_config()
454 …if (config->match.ifname && !strv_contains(config->match.ifname, "*") && link->name_assign_type ==… in link_get_config()
456 config->filename); in link_get_config()
458 log_link_debug(link, "Config file %s is applied", config->filename); in link_get_config()
460 link->config = config; in link_get_config()
468 LinkConfig *config; in link_apply_ethtool_settings() local
473 assert(link->config); in link_apply_ethtool_settings()
476 config = link->config; in link_apply_ethtool_settings()
480 config->autonegotiation, config->advertise, in link_apply_ethtool_settings()
481 config->speed, config->duplex, config->port, config->mdi); in link_apply_ethtool_settings()
483 if (config->autonegotiation >= 0) in link_apply_ethtool_settings()
485 enable_disable(config->autonegotiation)); in link_apply_ethtool_settings()
487 if (!eqzero(config->advertise)) in link_apply_ethtool_settings()
490 if (config->speed > 0) in link_apply_ethtool_settings()
492 DIV_ROUND_UP(config->speed, 1000000)); in link_apply_ethtool_settings()
494 if (config->duplex >= 0) in link_apply_ethtool_settings()
496 duplex_to_string(config->duplex)); in link_apply_ethtool_settings()
498 if (config->port >= 0) in link_apply_ethtool_settings()
500 port_to_string(config->port)); in link_apply_ethtool_settings()
502 if (config->mdi != ETH_TP_MDI_INVALID) in link_apply_ethtool_settings()
504 mdi_to_string(config->mdi)); in link_apply_ethtool_settings()
507 r = ethtool_set_wol(ethtool_fd, name, config->wol, config->wol_password); in link_apply_ethtool_settings()
511 (void) wol_options_to_string_alloc(config->wol, &str); in link_apply_ethtool_settings()
516 r = ethtool_set_features(ethtool_fd, name, config->features); in link_apply_ethtool_settings()
520 r = ethtool_set_channels(ethtool_fd, name, &config->channels); in link_apply_ethtool_settings()
524 r = ethtool_set_nic_buffer_size(ethtool_fd, name, &config->ring); in link_apply_ethtool_settings()
528 …r = ethtool_set_flow_control(ethtool_fd, name, config->rx_flow_control, config->tx_flow_control, c… in link_apply_ethtool_settings()
532 r = ethtool_set_nic_coalesce_settings(ethtool_fd, name, &config->coalesce); in link_apply_ethtool_settings()
567 assert(link->config); in link_generate_new_hw_addr()
574 if (link->config->mac_address_policy == MAC_ADDRESS_POLICY_NONE) { in link_generate_new_hw_addr()
576 hw_addr = link->config->hw_addr; in link_generate_new_hw_addr()
599 …if ((link->config->mac_address_policy == MAC_ADDRESS_POLICY_RANDOM) == (link->addr_assign_type == … in link_generate_new_hw_addr()
601 mac_address_policy_to_string(link->config->mac_address_policy)); in link_generate_new_hw_addr()
622 if (link->config->mac_address_policy == MAC_ADDRESS_POLICY_RANDOM) in link_generate_new_hw_addr()
663 … link->config->mac_address_policy == MAC_ADDRESS_POLICY_NONE ? "static" : in link_generate_new_hw_addr()
664 mac_address_policy_to_string(link->config->mac_address_policy), in link_generate_new_hw_addr()
673 LinkConfig *config; in link_apply_rtnl_settings() local
677 assert(link->config); in link_apply_rtnl_settings()
680 config = link->config; in link_apply_rtnl_settings()
684 r = rtnl_set_link_properties(rtnl, link->ifindex, config->alias, &hw_addr, in link_apply_rtnl_settings()
685 config->txqueues, config->rxqueues, config->txqueuelen, in link_apply_rtnl_settings()
686 config->mtu, config->gso_max_size, config->gso_max_segments); in link_apply_rtnl_settings()
718 LinkConfig *config; in link_generate_new_name() local
722 assert(link->config); in link_generate_new_name()
725 config = link->config; in link_generate_new_name()
740 if (enable_name_policy() && config->name_policy) in link_generate_new_name()
741 … for (NamePolicy *policy = config->name_policy; *policy != _NAMEPOLICY_INVALID; policy++) { in link_generate_new_name()
785 if (link->config->name) { in link_generate_new_name()
786 …log_link_debug(link, "Policies didn't yield a name, using specified Name=%s.", link->config->name); in link_generate_new_name()
787 link->new_name = link->config->name; in link_generate_new_name()
799 LinkConfig *config; in link_apply_alternative_names() local
804 assert(link->config); in link_apply_alternative_names()
808 config = link->config; in link_apply_alternative_names()
811 if (config->alternative_names) { in link_apply_alternative_names()
812 altnames = strv_copy(config->alternative_names); in link_apply_alternative_names()
817 if (config->alternative_names_policy) in link_apply_alternative_names()
818 … for (NamePolicy *p = config->alternative_names_policy; *p != _NAMEPOLICY_INVALID; p++) { in link_apply_alternative_names()
903 assert(link->config); in link_apply_sr_iov_config()
906 …r = sr_iov_set_num_vfs(link->device, link->config->sr_iov_num_vfs, link->config->sr_iov_by_section… in link_apply_sr_iov_config()
910 if (ordered_hashmap_isempty(link->config->sr_iov_by_section)) in link_apply_sr_iov_config()
923 ORDERED_HASHMAP_FOREACH(sr_iov, link->config->sr_iov_by_section) { in link_apply_sr_iov_config()
1096 LinkConfig *config = userdata; in config_parse_wol_password() local
1105 config->wol_password = erase_and_free(config->wol_password); in config_parse_wol_password()
1106 config->wol_password_file = mfree(config->wol_password_file); in config_parse_wol_password()
1111 config->wol_password = erase_and_free(config->wol_password); in config_parse_wol_password()
1112 return free_and_strdup_warn(&config->wol_password_file, rvalue); in config_parse_wol_password()
1117 r = link_parse_wol_password(config, rvalue); in config_parse_wol_password()
1126 config->wol_password_file = mfree(config->wol_password_file); in config_parse_wol_password()