Commit cfba0f86 authored by Dan Winship's avatar Dan Winship
Browse files

ifcfg-rh: add support for ifcfg alias files (rh #1067170)

parents f27c0145 12d3a790
......@@ -56,6 +56,7 @@ libnm_util_include_HEADERS = \
libnm_util_la_private_headers = \
crypto.h \
nm-param-spec-specialized.h \
nm-util-private.h \
nm-utils-private.h \
nm-setting-private.h
......@@ -90,6 +91,7 @@ libnm_util_la_csources = \
nm-setting-wireless.c \
nm-setting-wireless-security.c \
nm-setting-vpn.c \
nm-util-private.c \
nm-utils-enum-types.c \
nm-utils.c \
nm-value-transforms.c
......
......@@ -600,6 +600,7 @@ global:
nm_setting_wireless_security_remove_proto;
nm_setting_wireless_security_remove_proto_by_value;
nm_setting_wireless_security_set_wep_key;
nm_util_get_private;
nm_utils_ap_mode_security_valid;
nm_utils_bin2hexstr;
nm_utils_check_virtual_device_compatibility;
......
......@@ -78,6 +78,7 @@ typedef struct {
GArray *dns; /* array of guint32; elements in network byte order */
GSList *dns_search; /* list of strings */
GSList *addresses; /* array of NMIP4Address */
GSList *address_labels; /* list of strings */
GSList *routes; /* array of NMIP4Route */
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
......@@ -94,6 +95,7 @@ enum {
PROP_DNS,
PROP_DNS_SEARCH,
PROP_ADDRESSES,
PROP_ADDRESS_LABELS,
PROP_ROUTES,
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
......@@ -440,6 +442,19 @@ nm_setting_ip4_config_get_address (NMSettingIP4Config *setting, guint32 i)
return (NMIP4Address *) g_slist_nth_data (priv->addresses, i);
}
const char *
nm_setting_ip4_config_get_address_label (NMSettingIP4Config *setting, guint32 i)
{
NMSettingIP4ConfigPrivate *priv;
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
g_return_val_if_fail (i <= g_slist_length (priv->address_labels), NULL);
return (const char *) g_slist_nth_data (priv->address_labels, i);
}
/**
* nm_setting_ip4_config_add_address:
* @setting: the #NMSettingIP4Config
......@@ -454,6 +469,14 @@ nm_setting_ip4_config_get_address (NMSettingIP4Config *setting, guint32 i)
gboolean
nm_setting_ip4_config_add_address (NMSettingIP4Config *setting,
NMIP4Address *address)
{
return nm_setting_ip4_config_add_address_with_label (setting, address, NULL);
}
gboolean
nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *setting,
NMIP4Address *address,
const char *label)
{
NMSettingIP4ConfigPrivate *priv;
NMIP4Address *copy;
......@@ -472,6 +495,8 @@ nm_setting_ip4_config_add_address (NMSettingIP4Config *setting,
g_return_val_if_fail (copy != NULL, FALSE);
priv->addresses = g_slist_append (priv->addresses, copy);
priv->address_labels = g_slist_append (priv->address_labels, g_strdup (label));
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
return TRUE;
}
......@@ -487,16 +512,21 @@ void
nm_setting_ip4_config_remove_address (NMSettingIP4Config *setting, guint32 i)
{
NMSettingIP4ConfigPrivate *priv;
GSList *elt;
GSList *addr, *label;
g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
elt = g_slist_nth (priv->addresses, i);
g_return_if_fail (elt != NULL);
addr = g_slist_nth (priv->addresses, i);
label = g_slist_nth (priv->address_labels, i);
g_return_if_fail (addr != NULL && label != NULL);
nm_ip4_address_unref ((NMIP4Address *) addr->data);
priv->addresses = g_slist_delete_link (priv->addresses, addr);
if (label->data)
g_free (label->data);
priv->address_labels = g_slist_delete_link (priv->address_labels, label);
nm_ip4_address_unref ((NMIP4Address *) elt->data);
priv->addresses = g_slist_delete_link (priv->addresses, elt);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
}
......@@ -548,6 +578,8 @@ nm_setting_ip4_config_clear_addresses (NMSettingIP4Config *setting)
g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
priv->addresses = NULL;
g_slist_free_full (priv->address_labels, g_free);
priv->address_labels = NULL;
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
}
......@@ -821,11 +853,35 @@ nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting)
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->may_fail;
}
static gboolean
verify_label (const char *label)
{
const char *p;
char *iface;
p = strchr (label, ':');
if (!p)
return FALSE;
iface = g_strndup (label, p - label);
if (!nm_utils_iface_valid_name (iface)) {
g_free (iface);
return FALSE;
}
g_free (iface);
for (p++; *p; p++) {
if (!g_ascii_isalnum (*p) && *p != '_')
return FALSE;
}
return TRUE;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
GSList *iter;
GSList *iter, *l_iter;
int i;
if (!priv->method) {
......@@ -912,8 +968,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
/* Validate addresses */
for (iter = priv->addresses, i = 0; iter; iter = g_slist_next (iter), i++) {
for (iter = priv->addresses, l_iter = priv->address_labels, i = 0;
iter && l_iter;
iter = g_slist_next (iter), l_iter = g_slist_next (l_iter), i++) {
NMIP4Address *addr = (NMIP4Address *) iter->data;
const char *label = (const char *) l_iter->data;
guint32 prefix = nm_ip4_address_get_prefix (addr);
if (!nm_ip4_address_get_address (addr)) {
......@@ -935,6 +994,27 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES);
return FALSE;
}
if (label && !verify_label (label)) {
g_set_error (error,
NM_SETTING_IP4_CONFIG_ERROR,
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
_("%d. IPv4 address has invalid label '%s'"),
i+1, label);
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, "address-labels");
return FALSE;
}
}
if (iter || l_iter) {
g_set_error (error,
NM_SETTING_IP4_CONFIG_ERROR,
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
_("IPv4 address / label count mismatch (%d vs %d)"),
g_slist_length (priv->addresses),
g_slist_length (priv->address_labels));
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, "address-labels");
return FALSE;
}
/* Validate routes */
......@@ -990,6 +1070,7 @@ finalize (GObject *object)
g_slist_free_full (priv->dns_search, g_free);
g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
g_slist_free_full (priv->address_labels, g_free);
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
G_OBJECT_CLASS (nm_setting_ip4_config_parent_class)->finalize (object);
......@@ -1001,6 +1082,7 @@ set_property (GObject *object, guint prop_id,
{
NMSettingIP4Config *setting = NM_SETTING_IP4_CONFIG (object);
NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
GSList *iter;
switch (prop_id) {
case PROP_METHOD:
......@@ -1020,6 +1102,24 @@ set_property (GObject *object, guint prop_id,
case PROP_ADDRESSES:
g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
priv->addresses = nm_utils_ip4_addresses_from_gvalue (value);
if (g_slist_length (priv->addresses) != g_slist_length (priv->address_labels)) {
g_slist_free_full (priv->address_labels, g_free);
priv->address_labels = NULL;
for (iter = priv->addresses; iter; iter = iter->next)
priv->address_labels = g_slist_prepend (priv->address_labels, NULL);
}
break;
case PROP_ADDRESS_LABELS:
g_slist_free_full (priv->address_labels, g_free);
priv->address_labels = g_value_dup_boxed (value);
/* NULLs get converted to "" when this is sent over D-Bus. */
for (iter = priv->address_labels; iter; iter = iter->next) {
if (!g_strcmp0 (iter->data, "")) {
g_free (iter->data);
iter->data = NULL;
}
}
break;
case PROP_ROUTES:
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
......@@ -1074,6 +1174,9 @@ get_property (GObject *object, guint prop_id,
case PROP_ADDRESSES:
nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
break;
case PROP_ADDRESS_LABELS:
g_value_set_boxed (value, priv->address_labels);
break;
case PROP_ROUTES:
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
break;
......@@ -1239,6 +1342,14 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
g_object_class_install_property
(object_class, PROP_ADDRESS_LABELS,
_nm_param_spec_specialized ("address-labels",
"Address labels",
"Internal use only",
DBUS_TYPE_G_LIST_OF_STRING,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP4Config:routes:
*
......
......@@ -21,6 +21,7 @@
#ifndef NM_SETTING_PRIVATE_H
#define NM_SETTING_PRIVATE_H
#include "nm-setting.h"
#include "nm-glib-compat.h"
#define NM_SETTING_SECRET_FLAGS_ALL \
......@@ -86,5 +87,10 @@ static void __attribute__((constructor)) register_setting (void) \
NMSetting *nm_setting_find_in_list (GSList *settings_list, const char *setting_name);
/* Private NMSettingIP4Config methods */
#include "nm-setting-ip4-config.h"
const char *nm_setting_ip4_config_get_address_label (NMSettingIP4Config *setting, guint32 i);
gboolean nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *setting, NMIP4Address *address, const char *label);
#endif /* NM_SETTING_PRIVATE_H */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2014 Red Hat, Inc.
*/
#include "nm-util-private.h"
static const NMUtilPrivateData data = {
.nm_setting_ip4_config_get_address_label = nm_setting_ip4_config_get_address_label,
.nm_setting_ip4_config_add_address_with_label = nm_setting_ip4_config_add_address_with_label,
};
/**
* nm_util_get_private:
*
* Entry point for NetworkManager-internal API. Although this symbol is exported,
* it is only useful if you have access to "nm-util-private.h", which is only
* available inside the NetworkManager tree.
*
* Return value: Who knows? It's a mystery.
*
* Since: 0.9.10
*/
const NMUtilPrivateData *
nm_util_get_private (void)
{
return &data;
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2014 Red Hat, Inc.
*/
#ifndef __NM_UTIL_PRIVATE_H__
#define __NM_UTIL_PRIVATE_H__
#include <glib.h>
#include "nm-setting-private.h"
G_BEGIN_DECLS
typedef struct NMUtilPrivateData {
const char * (*nm_setting_ip4_config_get_address_label) (NMSettingIP4Config *setting,
guint32 i);
gboolean (*nm_setting_ip4_config_add_address_with_label) (NMSettingIP4Config *setting,
NMIP4Address *address,
const char *label);
} NMUtilPrivateData;
const NMUtilPrivateData *nm_util_get_private (void);
/**
* NM_UTIL_PRIVATE_CALL:
* @call: a call to a private libnm-util function
*
* Used to call private libnm-util functions. Eg, if there was a
* private function called nm_foo_get_bar(), you could call it like:
*
* bar = NM_UTIL_PRIVATE_CALL (nm_foo_get_bar (foo, x, y, z));
*
* This macro only exists inside the NetworkManager source tree and
* is not part of the public API.
*
* Since: 0.9.10
*/
#define NM_UTIL_PRIVATE_CALL(call) (nm_util_get_private ()->call)
G_END_DECLS
#endif
......@@ -42,6 +42,7 @@
#include "nm-setting-vlan.h"
#include "nm-setting-bond.h"
#include "nm-utils.h"
#include "nm-util-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
......@@ -272,6 +273,153 @@ test_setting_vpn_modify_during_foreach (void)
g_object_unref (s_vpn);
}
static void
test_setting_ip4_config_labels (void)
{
NMSettingIP4Config *s_ip4;
NMIP4Address *addr;
const char *label;
GPtrArray *addrs;
GSList *labels;
GError *error = NULL;
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
g_object_set (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
NULL);
/* addr 1 */
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, 0x01010101);
nm_ip4_address_set_prefix (addr, 24);
nm_setting_ip4_config_add_address (s_ip4, addr);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0));
g_assert_cmpstr (label, ==, NULL);
/* addr 2 */
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, 0x02020202);
nm_ip4_address_set_prefix (addr, 24);
NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, "eth0:1"));
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1));
g_assert_cmpstr (label, ==, "eth0:1");
/* addr 3 */
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, 0x03030303);
nm_ip4_address_set_prefix (addr, 24);
NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, NULL));
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 2));
g_assert_cmpstr (label, ==, NULL);
/* Remove addr 1 and re-verify remaining addresses */
nm_setting_ip4_config_remove_address (s_ip4, 0);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
addr = nm_setting_ip4_config_get_address (s_ip4, 0);
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0));
g_assert_cmpstr (label, ==, "eth0:1");
addr = nm_setting_ip4_config_get_address (s_ip4, 1);
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1));
g_assert_cmpstr (label, ==, NULL);
/* Test explicit property assignment */
g_object_get (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_ADDRESSES, &addrs,
"address-labels", &labels,
NULL);
nm_setting_ip4_config_clear_addresses (s_ip4);
g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 0);
/* Setting addrs but not labels will result in empty labels */
g_object_set (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_ADDRESSES, addrs,
NULL);
g_boxed_free (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT, addrs);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 2);
addr = nm_setting_ip4_config_get_address (s_ip4, 0);
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0));
g_assert_cmpstr (label, ==, NULL);
addr = nm_setting_ip4_config_get_address (s_ip4, 1);
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1));
g_assert_cmpstr (label, ==, NULL);
/* Setting labels now will leave addresses untouched */
g_object_set (G_OBJECT (s_ip4),
"address-labels", labels,
NULL);
g_boxed_free (DBUS_TYPE_G_LIST_OF_STRING, labels);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 2);
addr = nm_setting_ip4_config_get_address (s_ip4, 0);
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0));
g_assert_cmpstr (label, ==, "eth0:1");
addr = nm_setting_ip4_config_get_address (s_ip4, 1);
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303);
label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1));
g_assert_cmpstr (label, ==, NULL);
/* Setting labels to a value that's too short or too long will result in
* the setting not verifying.
*/
labels = g_slist_append (NULL, "eth0:2");
g_object_set (G_OBJECT (s_ip4),
"address-labels", labels,
NULL);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_error (error, NM_SETTING_IP4_CONFIG_ERROR, NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "ipv4.address-labels:"));
g_clear_error (&error);
labels = g_slist_append (labels, "eth0:3");
g_object_set (G_OBJECT (s_ip4),
"address-labels", labels,
NULL);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_no_error (error);
labels = g_slist_append (labels, "eth0:4");
g_object_set (G_OBJECT (s_ip4),
"address-labels", labels,
NULL);
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
g_assert_error (error, NM_SETTING_IP4_CONFIG_ERROR, NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY);
g_assert (g_str_has_prefix (error->message, "ipv4.address-labels:"));
g_clear_error (&error);
g_object_unref (s_ip4);
}
#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
......@@ -1197,6 +1345,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_IP4_CONFIG_DNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DNS_SEARCH, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_ADDRESSES, NM_SETTING_DIFF_RESULT_IN_A },
{ "address-labels", NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
......@@ -2232,6 +2381,7 @@ int main (int argc, char **argv)
test_setting_vpn_items ();
test_setting_vpn_update_secrets ();
test_setting_vpn_modify_during_foreach ();
test_setting_ip4_config_labels ();
test_setting_ip6_config_old_address_array ();
test_setting_gsm_apn_spaces ();
test_setting_gsm_apn_bad_chars ();
......
......@@ -30,7 +30,7 @@
#include "nm-dbus-glib-types.h"
#include "nm-ip4-config-glue.h"
#include "NetworkManagerUtils.h"
#include "nm-util-private.h"
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, G_TYPE_OBJECT)
......@@ -333,6 +333,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting)
/* Addresses */
for (i = 0; i < naddresses; i++) {
NMIP4Address *s_addr = nm_setting_ip4_config_get_address (setting, i);
const char *label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (setting, i));
NMPlatformIP4Address address;
memset (&address, 0, sizeof (address));
......@@ -341,6 +342,8 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting)
address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
address.preferred = NM_PLATFORM_LIFETIME_PERMANENT;
address.source = NM_PLATFORM_SOURCE_USER;
if (label)
g_strlcpy (address.label, label, sizeof (address.label));
nm_ip4_config_add_address (config, &address);
}
......@@ -418,7 +421,10 @@ nm_ip4_config_update_setting (const NMIP4Config *config, NMSettingIP4Config *set
if (same_prefix (address->address, gateway, address->plen))
nm_ip4_address_set_gateway (s_addr, gateway);
nm_setting_ip4_config_add_address (setting, s_addr);
if (*address->label)
NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (setting, s_addr, address->label));
else
nm_setting_ip4_config_add_address (setting, s_addr);
nm_ip4_address_unref (s_addr);
}
......
......@@ -738,7 +738,8 @@ ip6_address_get_all (NMPlatform *platform, int ifindex)
static gboolean
ip4_address_add (NMPlatform *platform, int ifindex,
in_addr_t addr, in_addr_t peer_addr,
int plen, guint32 lifetime, guint32 preferred)
int plen, guint32 lifetime, guint32 preferred,
const char *label)
{
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
NMPlatformIP4Address address;
......@@ -752,6 +753,8 @@ ip4_address_add (NMPlatform *platform, int ifindex,