device: merge branch 'th/device-mtu-bgo777251'

https://bugzilla.gnome.org/show_bug.cgi?id=777251
This commit is contained in:
Thomas Haller 2017-01-16 17:34:14 +01:00
commit 2b51d39671
26 changed files with 471 additions and 466 deletions

View file

@ -482,10 +482,10 @@ act_stage3_ip4_config_start (NMDevice *device,
&& nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_adsl_get_username (s_adsl),
30, 0, &err)) {
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED,
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, "ip4-config",
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
@ -577,7 +577,7 @@ set_property (GObject *object, guint prop_id,
{
switch (prop_id) {
case PROP_ATM_INDEX:
/* construct only */
/* construct-only */
NM_DEVICE_ADSL_GET_PRIVATE ((NMDeviceAdsl *) object)->atm_index = g_value_get_int (value);
break;
default:

View file

@ -1077,7 +1077,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PATH:
/* construct only */
/* construct-only */
priv->path = g_value_dup_string (value);
break;
default:

View file

@ -281,7 +281,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PATH:
/* construct only */
/* construct-only */
priv->path = g_value_dup_string (value);
break;
default:

View file

@ -383,25 +383,6 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
return ret;
}
static void
ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_applied_connection (self);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
/* MTU override */
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
}
}
static gboolean
enslave_slave (NMDevice *device,
NMDevice *slave,
@ -523,7 +504,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
parent_class->create_and_realize = create_and_realize;
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
parent_class->enslave_slave = enslave_slave;
parent_class->release_slave = release_slave;

View file

@ -445,6 +445,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->enslave_slave = enslave_slave;
parent_class->release_slave = release_slave;
parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
NMDBUS_TYPE_DEVICE_BRIDGE_SKELETON,

View file

@ -1055,10 +1055,10 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas
&& nm_ppp_manager_start (priv->ppp_manager, req,
nm_setting_pppoe_get_username (s_pppoe),
30, 0, &err)) {
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED,
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, "ip4-config",
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
@ -1391,26 +1391,14 @@ act_stage3_ip4_config_start (NMDevice *device,
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
static guint32
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
/* MTU only set for plain ethernet */
if (NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device)->ppp_manager)
return;
return 0;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
g_assert (s_wired);
/* MTU override */
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
return nm_device_get_configured_mtu_for_wired (device, out_is_user_config);
}
static void
@ -1774,7 +1762,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->act_stage2_config = act_stage2_config;
parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->get_configured_mtu = get_configured_mtu;
parent_class->deactivate = deactivate;
parent_class->spec_match_list = spec_match_list;
parent_class->update_connection = update_connection;

View file

@ -118,22 +118,22 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
return NM_ACT_STAGE_RETURN_SUCCESS;
}
static void
ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
static guint32
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
{
NMConnection *connection;
NMSettingInfiniband *s_infiniband;
NMSettingInfiniband *setting;
guint32 mtu;
connection = nm_device_get_applied_connection (self);
g_assert (connection);
s_infiniband = nm_connection_get_setting_infiniband (connection);
g_assert (s_infiniband);
nm_assert (NM_IS_DEVICE (device));
nm_assert (out_is_user_config);
/* MTU override */
mtu = nm_setting_infiniband_get_mtu (s_infiniband);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
setting = NM_SETTING_INFINIBAND (nm_device_get_applied_setting (device, NM_TYPE_SETTING_INFINIBAND));
if (!setting)
g_return_val_if_reached (0);
mtu = nm_setting_infiniband_get_mtu (setting);
*out_is_user_config = (mtu != 0);
return mtu ?: NM_DEVICE_DEFAULT_MTU_INFINIBAND;
}
static gboolean
@ -381,7 +381,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
parent_class->update_connection = update_connection;
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->get_configured_mtu = get_configured_mtu;
obj_properties[PROP_IS_PARTITION] =
g_param_spec_boolean (NM_DEVICE_INFINIBAND_IS_PARTITION, "", "",

View file

@ -744,22 +744,22 @@ create_and_realize (NMDevice *device,
return TRUE;
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
static guint32
get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
{
NMConnection *connection;
NMSettingIPTunnel *s_ip_tunnel;
NMSettingIPTunnel *setting;
guint32 mtu;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
g_assert (s_ip_tunnel);
nm_assert (NM_IS_DEVICE (self));
nm_assert (out_is_user_config);
/* MTU override */
mtu = nm_setting_ip_tunnel_get_mtu (s_ip_tunnel);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
setting = NM_SETTING_IP_TUNNEL (nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP_TUNNEL));
if (!setting)
g_return_val_if_reached (0);
mtu = nm_setting_ip_tunnel_get_mtu (setting);
*out_is_user_config = (mtu != 0);
return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED;
}
static NMDeviceCapabilities
@ -873,7 +873,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
device_class->check_connection_compatible = check_connection_compatible;
device_class->create_and_realize = create_and_realize;
device_class->get_generic_capabilities = get_generic_capabilities;
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
device_class->get_configured_mtu = get_configured_mtu;
device_class->unrealize_notify = unrealize_notify;
NM_DEVICE_CLASS_DECLARE_TYPES (klass,

View file

@ -156,7 +156,7 @@ parent_changed_notify (NMDevice *device,
if (new_parent) {
priv->parent_state_id = g_signal_connect (new_parent,
"state-changed",
NM_DEVICE_STATE_CHANGED,
G_CALLBACK (parent_state_changed),
device);
@ -489,24 +489,6 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
return NM_ACT_STAGE_RETURN_SUCCESS;
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
}
}
/*****************************************************************************/
static void
@ -570,7 +552,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
device_class->connection_type = NM_SETTING_MACVLAN_SETTING_NAME;
device_class->create_and_realize = create_and_realize;
device_class->get_generic_capabilities = get_generic_capabilities;
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
device_class->is_available = is_available;
device_class->link_changed = link_changed;
device_class->parent_changed_notify = parent_changed_notify;

View file

@ -118,6 +118,16 @@ void nm_device_ip_method_failed (NMDevice *self, int family, NMDeviceStateReason
gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value);
/*****************************************************************************/
#define NM_DEVICE_DEFAULT_MTU_WIRED ((guint32) 1500)
#define NM_DEVICE_DEFAULT_MTU_WIRELESS ((guint32) 1500)
#define NM_DEVICE_DEFAULT_MTU_INFINIBAND ((guint32) 0)
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config);
/*****************************************************************************/
#define NM_DEVICE_CLASS_DECLARE_TYPES(klass, conn_type, ...) \
NM_DEVICE_CLASS (klass)->connection_type = conn_type; \
{ \

View file

@ -313,24 +313,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
return NM_ACT_STAGE_RETURN_SUCCESS;
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
}
}
static void
unrealize_notify (NMDevice *device)
{
@ -434,7 +416,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
device_class->unrealize_notify = unrealize_notify;
device_class->update_connection = update_connection;
device_class->act_stage1_prepare = act_stage1_prepare;
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
obj_properties[PROP_OWNER] =
g_param_spec_int64 (NM_DEVICE_TUN_OWNER, "", "",

View file

@ -572,24 +572,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
return ret;
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
}
}
/*****************************************************************************/
static void
@ -630,7 +612,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
parent_class->unrealize_notify = unrealize_notify;
parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
parent_class->is_available = is_available;
parent_class->parent_changed_notify = parent_changed_notify;

View file

@ -512,24 +512,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
return NM_ACT_STAGE_RETURN_SUCCESS;
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
}
}
/*****************************************************************************/
static void
@ -622,7 +604,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
device_class->get_generic_capabilities = get_generic_capabilities;
device_class->update_connection = update_connection;
device_class->act_stage1_prepare = act_stage1_prepare;
device_class->ip4_config_pre_commit = ip4_config_pre_commit;
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
obj_properties[PROP_ID] =
g_param_spec_uint (NM_DEVICE_VXLAN_ID, "", "",

View file

@ -306,8 +306,13 @@ typedef struct _NMDevicePrivate {
bool ignore_carrier;
gulong ignore_carrier_id;
guint32 mtu;
guint32 ip_mtu;
bool up; /* IFF_UP */
guint32 ip6_mtu;
guint32 mtu_initial;
guint32 ip6_mtu_initial;
bool mtu_initialized:1;
bool up:1; /* IFF_UP */
/* Generic DHCP stuff */
guint32 dhcp_timeout;
@ -383,7 +388,6 @@ typedef struct _NMDevicePrivate {
NMIP6Config * ext_ip6_config_captured; /* Configuration captured from platform. */
GSList * vpn6_configs; /* VPNs which use this device */
bool nm_ipv6ll; /* TRUE if NM handles the device's IPv6LL address */
guint32 ip6_mtu;
NMIP6Config * dad6_ip6_config;
NMNDisc * ndisc;
@ -492,7 +496,7 @@ static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, N
static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason);
static void nm_device_start_ip_check (NMDevice *self);
static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink);
static void nm_device_set_mtu (NMDevice *self, guint32 mtu);
static void _commit_mtu (NMDevice *self, const NMIP4Config *config);
static void dhcp_schedule_restart (NMDevice *self, int family, const char *reason);
static void _cancel_activation (NMDevice *self);
@ -643,9 +647,14 @@ nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *val
}
static guint32
nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback)
nm_device_ipv6_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback)
{
return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)), fallback);
return nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET,
NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property)),
10,
0,
G_MAXUINT32,
fallback);
}
gboolean
@ -910,9 +919,6 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
/* We don't care about any saved values from the old iface */
g_hash_table_remove_all (priv->ip6_saved_properties);
if (priv->ip_ifindex)
priv->ip_mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ip_ifindex);
_notify (self, PROP_IP_IFACE);
return TRUE;
}
@ -1631,38 +1637,6 @@ find_slave_info (NMDevice *self, NMDevice *slave)
return NULL;
}
static void
apply_mtu_from_config (NMDevice *self)
{
const char *method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
NMSettingIPConfig *s_ip4;
NMSettingWired *s_wired;
guint32 mtu;
/* Devices having an IPv4 configuration will set MTU during the commit
* stage, so it is an error to call this function if the IPv4 method is not
* 'disabled'.
*/
s_ip4 = (NMSettingIPConfig *)
nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
if (s_ip4)
method = nm_setting_ip_config_get_method (s_ip4);
g_return_if_fail (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED));
s_wired = (NMSettingWired *)
nm_device_get_applied_setting (self, NM_TYPE_SETTING_WIRED);
if (s_wired) {
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu) {
_LOGD (LOGD_DEVICE | LOGD_IP,
"setting MTU of device without IP4 config to %u",
mtu);
nm_device_set_mtu (self, mtu);
}
}
}
/**
* nm_device_master_enslave_slave:
* @self: the master device
@ -1723,7 +1697,7 @@ nm_device_master_enslave_slave (NMDevice *self, NMDevice *slave, NMConnection *c
/* Since slave devices don't have their own IP configuration,
* set the MTU here.
*/
apply_mtu_from_config (slave);
_commit_mtu (slave, NM_DEVICE_GET_PRIVATE (slave)->ip4_config);
return success;
}
@ -2171,7 +2145,6 @@ device_link_changed (NMDevice *self)
_notify (self, PROP_DRIVER);
}
/* Update MTU if it has changed. */
if (priv->mtu != info.mtu) {
priv->mtu = info.mtu;
_notify (self, PROP_MTU);
@ -2318,9 +2291,6 @@ device_ip_link_changed (NMDevice *self)
_stats_update_counters_from_pllink (self, pllink);
if (priv->ip_mtu != pllink->mtu)
priv->ip_mtu = pllink->mtu;
if (_ip_iface_update (self, pllink->name))
nm_device_update_dynamic_ip_setup (self);
@ -2584,6 +2554,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink)
NMDeviceCapabilities capabilities = 0;
NMConfig *config;
guint real_rate;
guint32 mtu;
g_return_if_fail (NM_IS_DEVICE (self));
@ -2604,6 +2575,15 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink)
/* Balanced by a thaw in nm_device_realize_finish() */
g_object_freeze_notify (G_OBJECT (self));
priv->mtu_initialized = FALSE;
priv->mtu_initial = 0;
priv->ip6_mtu_initial = 0;
priv->ip6_mtu = 0;
if (priv->mtu) {
priv->mtu = 0;
_notify (self, PROP_MTU);
}
if (plink) {
g_return_if_fail (link_type_compatible (self, plink->type, NULL, NULL));
update_device_from_platform_link (self, plink);
@ -2619,8 +2599,11 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink)
if (nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex))
capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex);
_notify (self, PROP_MTU);
mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex);
if (priv->mtu != mtu) {
priv->mtu = mtu;
_notify (self, PROP_MTU);
}
nm_platform_link_get_driver_info (NM_PLATFORM_GET,
priv->ifindex,
@ -2831,6 +2814,11 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
if (nm_clear_g_free (&priv->ip_iface))
_notify (self, PROP_IP_IFACE);
if (priv->mtu != 0) {
priv->mtu = 0;
_notify (self, PROP_MTU);
}
if (priv->driver_version) {
g_clear_pointer (&priv->driver_version, g_free);
_notify (self, PROP_DRIVER_VERSION);
@ -5175,7 +5163,6 @@ END_ADD_DEFAULT_ROUTE:
priv->default_route.v4_has = _device_get_default_route_from_platform (self, AF_INET, (NMPlatformIPRoute *) &priv->default_route.v4);
}
/* Allow setting MTU etc */
if (commit) {
if (NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit)
NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit (self, composite);
@ -5710,7 +5697,7 @@ act_stage3_ip4_config_start (NMDevice *self,
} else
g_return_val_if_reached (NM_ACT_STAGE_RETURN_FAILURE);
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) {
apply_mtu_from_config (self);
_commit_mtu (self, priv->ip4_config);
ret = NM_ACT_STAGE_RETURN_SUCCESS;
} else
_LOGW (LOGD_IP4, "unhandled IPv4 config method '%s'; will fail", method);
@ -5944,9 +5931,6 @@ END_ADD_DEFAULT_ROUTE:
nm_device_get_ip_ifindex (self),
iid);
}
if (NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit)
NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit (self, composite);
}
routes_full_sync = commit
@ -6587,82 +6571,172 @@ linklocal6_start (NMDevice *self)
/*****************************************************************************/
static void nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu);
static void
set_ip_mtu (NMDevice *self, guint32 mtu)
guint32
nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection;
NMSettingWired *setting;
guint32 mtu;
if (priv->ip_ifindex)
priv->ip_mtu = mtu;
else
priv->mtu = mtu;
nm_assert (NM_IS_DEVICE (self));
nm_assert (out_is_user_config);
connection = nm_device_get_applied_connection (self);
if (!connection)
g_return_val_if_reached (0);
setting = nm_connection_get_setting_wired (connection);
if (setting) {
mtu = nm_setting_wired_get_mtu (setting);
if (mtu) {
*out_is_user_config = TRUE;
return mtu;
}
}
*out_is_user_config = FALSE;
return NM_DEVICE_DEFAULT_MTU_WIRED;
}
static guint32
get_ip_mtu (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
if (priv->ip_ifindex)
return priv->ip_mtu;
else
return priv->mtu;
}
/*****************************************************************************/
static void
nm_device_set_mtu (NMDevice *self, guint32 mtu)
_commit_mtu (NMDevice *self, const NMIP4Config *config)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
int ifindex = nm_device_get_ip_ifindex (self);
guint32 ip_mtu;
guint32 ip6_mtu, ip6_mtu_orig;
guint32 mtu_desired, mtu_desired_orig;
guint32 mtu_plat;
struct {
gboolean initialized;
guint32 value;
} ip6_mtu_sysctl;
int ifindex;
char sbuf[64], sbuf1[64], sbuf2[64];
if (mtu)
set_ip_mtu (self, mtu);
ifindex = nm_device_get_ip_ifindex (self);
if (ifindex <= 0)
return;
/* Ensure the IPv6 MTU is still alright. */
if (priv->ip6_mtu)
nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
ip_mtu = get_ip_mtu (self);
if (ip_mtu && ip_mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex))
nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, ip_mtu);
}
static void
nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
guint32 ip_mtu = get_ip_mtu (self);
guint32 plat_mtu = nm_device_ipv6_sysctl_get_int32 (self, "mtu", ip_mtu);
priv->ip6_mtu = mtu ?: plat_mtu;
if (priv->ip6_mtu && ip_mtu && ip_mtu < priv->ip6_mtu) {
_LOGI (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)",
priv->ip6_mtu, ip_mtu);
priv->ip6_mtu = ip_mtu;
if (nm_device_uses_assumed_connection (self)) {
/* for assumed connections we don't tamper with the MTU. This is
* a bug and supposed to be fixed by the unmanaged/assumed rework. */
return;
}
if (priv->ip6_mtu && priv->ip6_mtu < 1280) {
_LOGI (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting",
priv->ip6_mtu);
priv->ip6_mtu = 1280;
{
gboolean mtu_is_user_config = FALSE;
guint32 mtu = 0;
/* preferably, get the MTU from explict user-configuration.
* Only if that fails, look at the current @config (which contains
* MTUs from DHCP/PPP) or maybe fallback to a device-specific MTU. */
if (NM_DEVICE_GET_CLASS (self)->get_configured_mtu)
mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &mtu_is_user_config);
if (mtu && mtu_is_user_config)
mtu_desired = mtu;
else {
if (config)
mtu_desired = nm_ip4_config_get_mtu (config);
else
mtu_desired = 0;
if (!mtu_desired && !priv->mtu_initialized) {
/* there is no MTU specified, and this is the first commit of the MTU.
* Reset a per-device MTU default, as returned from get_configured_mtu().
*
* The device might choose not to return a default MTU via get_configured_mtu()
* to suppress this behavior. */
mtu_desired = mtu;
}
}
}
if (priv->ip6_mtu && ip_mtu && ip_mtu < priv->ip6_mtu) {
_LOGI (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)",
ip_mtu, priv->ip6_mtu);
nm_device_set_mtu (self, priv->ip6_mtu);
if (mtu_desired && mtu_desired < 1280) {
NMSettingIPConfig *s_ip6;
s_ip6 = (NMSettingIPConfig *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
if (s_ip6 && nm_streq0 (nm_setting_ip_config_get_method (s_ip6),
NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
/* the interface has IPv6 enabled. The MTU with IPv6 cannot be smaller
* then 1280.
*
* For slave-devices (that don't have @s_ip6 we) don't do this fixup because
* it's anyway an unsolved problem when the slave configures a conflicting
* MTU. */
mtu_desired = 1280;
}
}
if (priv->ip6_mtu != plat_mtu) {
char val[64];
nm_device_ipv6_sysctl_set (self, "mtu",
nm_sprintf_buf (val, "%u", (unsigned) mtu));
ip6_mtu = priv->ip6_mtu;
if (!ip6_mtu && !priv->mtu_initialized) {
/* initially, if the IPv6 MTU is not specified, grow it as large as the
* link MTU @mtu_desired. Only exception is, if @mtu_desired is so small
* to disable IPv6. */
if (mtu_desired >= 1280)
ip6_mtu = mtu_desired;
}
priv->mtu_initialized = TRUE;
if (!ip6_mtu && !mtu_desired)
return;
mtu_desired_orig = mtu_desired;
ip6_mtu_orig = ip6_mtu;
mtu_plat = nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex);
if (ip6_mtu) {
ip6_mtu = NM_MAX (1280, ip6_mtu);
if (!mtu_desired)
mtu_desired = mtu_plat;
if (mtu_desired) {
mtu_desired = NM_MAX (1280, mtu_desired);
if (mtu_desired < ip6_mtu)
ip6_mtu = mtu_desired;
}
}
_LOGT (LOGD_DEVICE, "mtu: device-mtu: %u%s, ipv6-mtu: %u%s, ifindex: %d",
(guint) mtu_desired,
mtu_desired == mtu_desired_orig ? "" : nm_sprintf_buf (sbuf1, " (was %u)", (guint) mtu_desired_orig),
(guint) ip6_mtu,
ip6_mtu == ip6_mtu_orig ? "" : nm_sprintf_buf (sbuf2, " (was %u)", (guint) ip6_mtu_orig),
ifindex);
ip6_mtu_sysctl.initialized = FALSE;
#define _IP6_MTU_SYS() \
({ \
if (!ip6_mtu_sysctl.initialized) { \
ip6_mtu_sysctl.value = nm_device_ipv6_sysctl_get_uint32 (self, "mtu", 0); \
ip6_mtu_sysctl.initialized = TRUE; \
} \
ip6_mtu_sysctl.value; \
})
if ( (mtu_desired && mtu_desired != mtu_plat)
|| (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) {
if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
/* before touching any of the MTU paramters, record the
* original setting to restore on deactivation. */
priv->mtu_initial = mtu_plat;
priv->ip6_mtu_initial = _IP6_MTU_SYS ();
}
if (mtu_desired && mtu_desired != mtu_plat)
nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, mtu_desired);
if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
nm_device_ipv6_sysctl_set (self, "mtu",
nm_sprintf_buf (sbuf, "%u", (unsigned) ip6_mtu));
}
}
#undef _IP6_MTU_SYS
}
static void
@ -6788,8 +6862,12 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
if (changed & NM_NDISC_CONFIG_HOP_LIMIT)
nm_platform_sysctl_set_ip6_hop_limit_safe (NM_PLATFORM_GET, nm_device_get_ip_iface (self), rdata->hop_limit);
if (changed & NM_NDISC_CONFIG_MTU)
priv->ip6_mtu = rdata->mtu;
if (changed & NM_NDISC_CONFIG_MTU) {
if (priv->ip6_mtu != rdata->mtu) {
_LOGD (LOGD_DEVICE, "mtu: set IPv6 MTU to %u", (guint) rdata->mtu);
priv->ip6_mtu = rdata->mtu;
}
}
nm_device_activate_schedule_ip6_config_result (self);
}
@ -7204,8 +7282,7 @@ act_stage3_ip6_config_start (NMDevice *self,
* expose any ipv6 sysctls or allow presence of any addresses on the interface,
* including LL, which * would make it impossible to autoconfigure MTU to a
* correct value. */
if (!nm_device_uses_assumed_connection (self))
nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
_commit_mtu (self, priv->ip4_config);
/* Any method past this point requires an IPv6LL address. Use NM-controlled
* IPv6LL if this is not an assumed connection, since assumed connections
@ -9081,8 +9158,7 @@ nm_device_set_ip4_config (NMDevice *self,
if (commit && new_config) {
gboolean assumed = nm_device_uses_assumed_connection (self);
nm_device_set_mtu (self, nm_ip4_config_get_mtu (new_config));
_commit_mtu (self, new_config);
/* For assumed devices we must not touch the kernel-routes, such as the device-route.
* FIXME: this is wrong in case where "assumed" means "take-over-seamlessly". In this
* case, we should manage the device route, for example on new DHCP lease. */
@ -9250,7 +9326,7 @@ nm_device_set_ip6_config (NMDevice *self,
/* Always commit to nm-platform to update lifetimes */
if (commit && new_config) {
nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
_commit_mtu (self, priv->ip4_config);
success = nm_ip6_config_commit (new_config,
ip_ifindex,
routes_full_sync);
@ -11414,6 +11490,27 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean
NM_DEVICE_GET_CLASS (self)->deactivate_reset_hw_addr (self);
}
priv->mtu_initialized = FALSE;
if (priv->mtu_initial || priv->ip6_mtu_initial) {
ifindex = nm_device_get_ip_ifindex (self);
if ( ifindex > 0
&& cleanup_type == CLEANUP_TYPE_DECONFIGURE) {
_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
(guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
if (priv->mtu_initial)
nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu_initial);
if (priv->ip6_mtu_initial) {
char sbuf[64];
nm_device_ipv6_sysctl_set (self, "mtu",
nm_sprintf_buf (sbuf, "%u", (unsigned) priv->ip6_mtu_initial));
}
}
priv->mtu_initial = 0;
priv->ip6_mtu_initial = 0;
}
_cleanup_generic_post (self, cleanup_type);
}
@ -13082,9 +13179,6 @@ set_property (GObject *object, guint prop_id,
g_free (priv->firmware_version);
priv->firmware_version = g_value_dup_string (value);
break;
case PROP_MTU:
priv->mtu = g_value_get_uint (value);
break;
case PROP_IP4_ADDRESS:
priv->ip4_address = g_value_get_uint (value);
break;

View file

@ -232,6 +232,8 @@ typedef struct {
NMConnection *connection,
char **specific_object);
guint32 (*get_configured_mtu) (NMDevice *self, gboolean *out_is_user_config);
/* Checks whether the connection is compatible with the device using
* only the devices type and characteristics. Does not use any live
* network information like WiFi scan lists etc.
@ -275,9 +277,7 @@ typedef struct {
NMActStageReturn (* act_stage4_ip6_config_timeout) (NMDevice *self,
NMDeviceStateReason *reason);
/* Called right before IP config is set; use for setting MTU etc */
void (* ip4_config_pre_commit) (NMDevice *self, NMIP4Config *config);
void (* ip6_config_pre_commit) (NMDevice *self, NMIP6Config *config);
/* Async deactivating (in the DEACTIVATING phase) */
void (* deactivate_async) (NMDevice *self,

View file

@ -627,25 +627,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_FAILURE;
}
static void
ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
{
NMConnection *connection;
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_applied_connection (self);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
if (s_wired) {
/* MTU override */
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
}
}
static void
deactivate (NMDevice *device)
{
@ -876,7 +857,7 @@ nm_device_team_class_init (NMDeviceTeamClass *klass)
parent_class->master_update_slave_connection = master_update_slave_connection;
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
parent_class->deactivate = deactivate;
parent_class->enslave_slave = enslave_slave;
parent_class->release_slave = release_slave;

View file

@ -2741,22 +2741,22 @@ act_stage3_ip6_config_start (NMDevice *device,
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason);
}
static void
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
static guint32
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
{
NMConnection *connection;
NMSettingWireless *s_wifi;
NMSettingWireless *setting;
guint32 mtu;
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wifi = nm_connection_get_setting_wireless (connection);
g_assert (s_wifi);
nm_assert (NM_IS_DEVICE (device));
nm_assert (out_is_user_config);
/* MTU override */
mtu = nm_setting_wireless_get_mtu (s_wifi);
if (mtu)
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
setting = NM_SETTING_WIRELESS (nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS));
if (!setting)
g_return_val_if_reached (0);
mtu = nm_setting_wireless_get_mtu (setting);
*out_is_user_config = (mtu != 0);
return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRELESS;
}
static gboolean
@ -3215,7 +3215,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->act_stage2_config = act_stage2_config;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->get_configured_mtu = get_configured_mtu;
parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
parent_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start;
parent_class->act_stage4_ip4_config_timeout = act_stage4_ip4_config_timeout;

View file

@ -563,16 +563,16 @@ ppp_stage3_ip_config_start (NMModem *self,
if ( priv->ppp_manager
&& nm_ppp_manager_start (priv->ppp_manager, req, ppp_name,
ip_timeout, baud_override, &error)) {
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED,
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_CALLBACK (ppp_state_changed),
self);
g_signal_connect (priv->ppp_manager, "ip4-config",
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_CALLBACK (ppp_ip4_config),
self);
g_signal_connect (priv->ppp_manager, "ip6-config",
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_IP6_CONFIG,
G_CALLBACK (ppp_ip6_config),
self);
g_signal_connect (priv->ppp_manager, "stats",
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_SIGNAL_STATS,
G_CALLBACK (ppp_stats),
self);

View file

@ -851,7 +851,7 @@ set_property (GObject *object, guint prop_id,
g_warn_if_fail (priv->ifindex > 0);
break;
case PROP_HWADDR:
/* construct only */
/* construct-only */
priv->hwaddr = g_value_dup_boxed (value);
break;
case PROP_IPV6:

View file

@ -509,7 +509,7 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *p
switch (prop_id) {
case PROP_POLKIT_ENABLED:
/* construct only */
/* construct-only */
priv->polkit_enabled = !!g_value_get_boolean (value);
break;
default:

View file

@ -2232,7 +2232,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_CMD_LINE_OPTIONS:
/* construct only */
/* construct-only */
cli = g_value_get_pointer (value);
if (!cli)
_nm_config_cmd_line_options_clear (&priv->cli);
@ -2240,7 +2240,7 @@ set_property (GObject *object, guint prop_id,
_nm_config_cmd_line_options_copy (cli, &priv->cli);
break;
case PROP_ATOMIC_SECTION_PREFIXES:
/* construct only */
/* construct-only */
priv->atomic_section_prefixes = g_strdupv (g_value_get_boxed (value));
break;
default:

View file

@ -35,26 +35,49 @@
#include "introspection/org.freedesktop.NetworkManager.IP4Config.h"
/*****************************************************************************/
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
G_STATIC_ASSERT (sizeof (uint) >= sizeof (guint32));
G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF);
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config,
PROP_IFINDEX,
PROP_ADDRESS_DATA,
PROP_ADDRESSES,
PROP_ROUTE_DATA,
PROP_ROUTES,
PROP_GATEWAY,
PROP_NAMESERVERS,
PROP_DOMAINS,
PROP_SEARCHES,
PROP_DNS_OPTIONS,
PROP_WINS_SERVERS,
PROP_DNS_PRIORITY,
);
typedef struct {
gboolean never_default;
bool never_default:1;
bool metered:1;
bool has_gateway:1;
guint32 gateway;
gboolean has_gateway;
guint32 mss;
guint32 mtu;
int ifindex;
NMIPConfigSource mtu_source;
gint dns_priority;
gint64 route_metric;
GArray *addresses;
GArray *routes;
GArray *nameservers;
GPtrArray *domains;
GPtrArray *searches;
GPtrArray *dns_options;
guint32 mss;
GArray *nis;
char *nis_domain;
GArray *wins;
guint32 mtu;
NMIPConfigSource mtu_source;
int ifindex;
gint64 route_metric;
gboolean metered;
gint dns_priority;
GVariant *address_data_variant;
GVariant *addresses_variant;
} NMIP4ConfigPrivate;
@ -72,33 +95,7 @@ G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT)
#define NM_IP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP4Config, NM_IS_IP4_CONFIG)
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
G_STATIC_ASSERT (sizeof (uint) >= sizeof (guint32));
G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF);
NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config,
PROP_IFINDEX,
PROP_ADDRESS_DATA,
PROP_ADDRESSES,
PROP_ROUTE_DATA,
PROP_ROUTES,
PROP_GATEWAY,
PROP_NAMESERVERS,
PROP_DOMAINS,
PROP_SEARCHES,
PROP_DNS_OPTIONS,
PROP_WINS_SERVERS,
PROP_DNS_PRIORITY,
);
NMIP4Config *
nm_ip4_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
NM_IP4_CONFIG_IFINDEX, ifindex,
NULL);
}
/*****************************************************************************/
int
nm_ip4_config_get_ifindex (const NMIP4Config *config)
@ -705,9 +702,11 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl
nm_ip4_config_set_mss (dst, nm_ip4_config_get_mss (src));
/* MTU */
if (nm_ip4_config_get_mtu (src))
nm_ip4_config_set_mtu (dst, nm_ip4_config_get_mtu (src),
nm_ip4_config_get_mtu_source (src));
if ( src_priv->mtu_source > dst_priv->mtu_source
|| ( src_priv->mtu_source == dst_priv->mtu_source
&& ( (!dst_priv->mtu && src_priv->mtu)
|| (dst_priv->mtu && src_priv->mtu < dst_priv->mtu))))
nm_ip4_config_set_mtu (dst, src_priv->mtu, src_priv->mtu_source);
/* NIS */
if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) {
@ -935,7 +934,8 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src)
nm_ip4_config_set_mss (dst, 0);
/* MTU */
if (nm_ip4_config_get_mtu (src) == nm_ip4_config_get_mtu (dst))
if ( nm_ip4_config_get_mtu (src) == nm_ip4_config_get_mtu (dst)
&& nm_ip4_config_get_mtu_source (src) == nm_ip4_config_get_mtu_source (dst))
nm_ip4_config_set_mtu (dst, 0, NM_IP_CONFIG_SOURCE_UNKNOWN);
/* NIS */
@ -1255,7 +1255,8 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
}
/* mtu */
if (src_priv->mtu != dst_priv->mtu) {
if ( src_priv->mtu != dst_priv->mtu
|| src_priv->mtu_source != dst_priv->mtu_source) {
nm_ip4_config_set_mtu (dst, src_priv->mtu, src_priv->mtu_source);
has_minor_changes = TRUE;
}
@ -1332,7 +1333,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
g_message (" dnspri: %d", nm_ip4_config_get_dns_priority (config));
g_message (" mss: %"G_GUINT32_FORMAT, nm_ip4_config_get_mss (config));
g_message (" mtu: %"G_GUINT32_FORMAT, nm_ip4_config_get_mtu (config));
g_message (" mtu: %"G_GUINT32_FORMAT" (source: %d)", nm_ip4_config_get_mtu (config), (int) nm_ip4_config_get_mtu_source (config));
/* NIS */
for (i = 0; i < nm_ip4_config_get_num_nis_servers (config); i++) {
@ -1385,7 +1386,7 @@ nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->never_default = !!never_default;
priv->never_default = never_default;
}
gboolean
@ -2083,11 +2084,11 @@ nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu, NMIPConfigSource source
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
if (source > priv->mtu_source) {
priv->mtu = mtu;
priv->mtu_source = source;
} else if (source == priv->mtu_source && (!priv->mtu || priv->mtu > mtu))
priv->mtu = mtu;
if (!mtu)
source = NM_IP_CONFIG_SOURCE_UNKNOWN;
priv->mtu = mtu;
priv->mtu_source = source;
}
guint32
@ -2113,7 +2114,7 @@ nm_ip4_config_set_metered (NMIP4Config *config, gboolean metered)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->metered = !!metered;
priv->metered = metered;
}
gboolean
@ -2233,43 +2234,6 @@ nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b)
/*****************************************************************************/
static void
nm_ip4_config_init (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address));
priv->routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->route_metric = -1;
}
static void
finalize (GObject *object)
{
NMIP4Config *self = NM_IP4_CONFIG (object);
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
g_array_unref (priv->nis);
g_free (priv->nis_domain);
g_array_unref (priv->wins);
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
@ -2459,6 +2423,7 @@ set_property (GObject *object,
switch (prop_id) {
case PROP_IFINDEX:
/* construct-only */
priv->ifindex = g_value_get_int (value);
break;
default:
@ -2467,6 +2432,54 @@ set_property (GObject *object,
}
}
/*****************************************************************************/
static void
nm_ip4_config_init (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address));
priv->routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->route_metric = -1;
}
NMIP4Config *
nm_ip4_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
NM_IP4_CONFIG_IFINDEX, ifindex,
NULL);
}
static void
finalize (GObject *object)
{
NMIP4Config *self = NM_IP4_CONFIG (object);
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
g_array_unref (priv->nis);
g_free (priv->nis_domain);
g_array_unref (priv->wins);
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
}
static void
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
{

View file

@ -35,8 +35,15 @@
#include "introspection/org.freedesktop.NetworkManager.IP6Config.h"
/*****************************************************************************/
typedef struct {
gboolean never_default;
bool never_default:1;
guint32 mss;
int ifindex;
int dns_priority;
NMSettingIP6ConfigPrivacy privacy;
gint64 route_metric;
struct in6_addr gateway;
GArray *addresses;
GArray *routes;
@ -44,13 +51,8 @@ typedef struct {
GPtrArray *domains;
GPtrArray *searches;
GPtrArray *dns_options;
guint32 mss;
int ifindex;
gint64 route_metric;
gint dns_priority;
GVariant *address_data_variant;
GVariant *addresses_variant;
NMSettingIP6ConfigPrivacy privacy;
} NMIP6ConfigPrivate;
struct _NMIP6Config {
@ -80,26 +82,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMIP6Config,
PROP_DNS_PRIORITY,
);
NMIP6Config *
nm_ip6_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP6Config *) g_object_new (NM_TYPE_IP6_CONFIG,
NM_IP6_CONFIG_IFINDEX, ifindex,
NULL);
}
NMIP6Config *
nm_ip6_config_new_cloned (const NMIP6Config *src)
{
NMIP6Config *new;
g_return_val_if_fail (NM_IS_IP6_CONFIG (src), NULL);
new = nm_ip6_config_new (nm_ip6_config_get_ifindex (src));
nm_ip6_config_replace (new, src, NULL);
return new;
}
/*****************************************************************************/
int
nm_ip6_config_get_ifindex (const NMIP6Config *config)
@ -1256,7 +1239,7 @@ nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
priv->never_default = !!never_default;
priv->never_default = never_default;
}
gboolean
@ -1999,38 +1982,6 @@ nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b)
/*****************************************************************************/
static void
nm_ip6_config_init (NMIP6Config *config)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Address));
priv->routes = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Route));
priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->route_metric = -1;
}
static void
finalize (GObject *object)
{
NMIP6Config *self = NM_IP6_CONFIG (object);
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object);
}
static void
nameservers_to_gvalue (GArray *array, GValue *value)
{
@ -2223,6 +2174,7 @@ set_property (GObject *object,
switch (prop_id) {
case PROP_IFINDEX:
/* construct-only */
priv->ifindex = g_value_get_int (value);
break;
default:
@ -2231,6 +2183,61 @@ set_property (GObject *object,
}
}
/*****************************************************************************/
static void
nm_ip6_config_init (NMIP6Config *config)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Address));
priv->routes = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Route));
priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->route_metric = -1;
}
NMIP6Config *
nm_ip6_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP6Config *) g_object_new (NM_TYPE_IP6_CONFIG,
NM_IP6_CONFIG_IFINDEX, ifindex,
NULL);
}
NMIP6Config *
nm_ip6_config_new_cloned (const NMIP6Config *src)
{
NMIP6Config *new;
g_return_val_if_fail (NM_IS_IP6_CONFIG (src), NULL);
new = nm_ip6_config_new (nm_ip6_config_get_ifindex (src));
nm_ip6_config_replace (new, src, NULL);
return new;
}
static void
finalize (GObject *object)
{
NMIP6Config *self = NM_IP6_CONFIG (object);
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object);
}
static void
nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
{
@ -2239,12 +2246,10 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP6Config");
/* virtual methods */
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
/* properties */
obj_properties[PROP_IFINDEX] =
g_param_spec_int (NM_IP6_CONFIG_IFINDEX, "", "",
-1, G_MAXINT, -1,

View file

@ -676,12 +676,12 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_FD_NET:
/* construct only */
/* construct-only */
priv->fd_net = g_value_get_int (value);
g_return_if_fail (priv->fd_net > 0);
break;
case PROP_FD_MNT:
/* construct only */
/* construct-only */
priv->fd_mnt = g_value_get_int (value);
g_return_if_fail (priv->fd_mnt > 0);
break;

View file

@ -1243,7 +1243,7 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[STATE_CHANGED] =
g_signal_new (NM_PPP_MANAGER_STATE_CHANGED,
g_signal_new (NM_PPP_MANAGER_SIGNAL_STATE_CHANGED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
@ -1252,7 +1252,7 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_TYPE_UINT);
signals[IP4_CONFIG] =
g_signal_new ("ip4-config",
g_signal_new (NM_PPP_MANAGER_SIGNAL_IP4_CONFIG,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
@ -1262,7 +1262,7 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_TYPE_OBJECT);
signals[IP6_CONFIG] =
g_signal_new ("ip6-config",
g_signal_new (NM_PPP_MANAGER_SIGNAL_IP6_CONFIG,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
@ -1270,7 +1270,7 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_OBJECT);
signals[STATS] =
g_signal_new ("stats",
g_signal_new (NM_PPP_MANAGER_SIGNAL_STATS,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,

View file

@ -23,7 +23,11 @@
#define __NM_PPP_MANAGER_H__
#define NM_PPP_MANAGER_PARENT_IFACE "parent-iface"
#define NM_PPP_MANAGER_STATE_CHANGED "state-changed"
#define NM_PPP_MANAGER_SIGNAL_STATE_CHANGED "state-changed"
#define NM_PPP_MANAGER_SIGNAL_IP4_CONFIG "ip4-config"
#define NM_PPP_MANAGER_SIGNAL_IP6_CONFIG "ip6-config"
#define NM_PPP_MANAGER_SIGNAL_STATS "stats"
typedef struct _NMPPPManager NMPPPManager;