libnm: add "ip4-config-method" normalization parameter

I guess, to a certain point these normalization options are hardly used.
Still, it feels right to also support it for IPv4. These options make
sense to me to control normalization.
This commit is contained in:
Thomas Haller 2021-07-02 08:49:00 +02:00
parent ef6b942fd5
commit 93c6697413
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 27 additions and 6 deletions

View file

@ -1208,10 +1208,19 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters)
if (_supports_addr_family(self, AF_INET)) {
if (!s_ip4) {
const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
const char *default_ip4_method = NULL;
if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME))
default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
if (parameters) {
default_ip4_method =
g_hash_table_lookup(parameters,
NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD);
}
if (!default_ip4_method) {
if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME))
default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
else
default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
}
/* But if no IP4 setting was specified, assume the caller was just
* being lazy and use the default method.
@ -1255,10 +1264,11 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters)
if (!s_ip6) {
const char *default_ip6_method = NULL;
if (parameters)
if (parameters) {
default_ip6_method =
g_hash_table_lookup(parameters,
NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD);
}
if (!default_ip6_method) {
if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME))
default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;

View file

@ -28,10 +28,21 @@ G_BEGIN_DECLS
#define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
#define NM_CONNECTION_CHANGED "changed"
/*
* NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD: overwrite the ip4 method
* when normalizing ip4 configuration. This only takes effect, if the profile
* has no IPv4 settings and new settings are to be added. If omitted, this
* defaults depends on the profile type but usually it is "auto".
*
* Since: 1.34
*/
#define NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD "ip4-config-method"
/*
* NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
* when normalizing ip6 configuration. If omitted, this defaults to
* @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
* when normalizing ip6 configuration. This only takes effect, if the profile
* has no IPv6 settings and new settings are to be added. If omitted, this
* defaults depends on the profile type but usually it is "auto".
*/
#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"