summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-13 13:11:11 +0200
committerThomas Haller <thaller@redhat.com>2017-10-23 17:53:22 +0200
commit05c4497bddffbd1ab024d2f249b3e2400373d325 (patch)
tree9e587bdcd34810a7c3149c48373192ec6117137d
parent8daa61dae354ea3c5138222e2de2ab15e23f6d3a (diff)
downloadNetworkManager-05c4497bddffbd1ab024d2f249b3e2400373d325.tar.gz
device: set MTU property of device in new _set_mtu() function
-rw-r--r--src/devices/nm-device.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e7e076ec23..f3ae934e22 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -550,6 +550,7 @@ static void realize_start_setup (NMDevice *self,
const char *assume_state_connection_uuid,
gboolean set_nm_owned,
NMUnmanFlagOp unmanaged_user_explicit);
+static void _set_mtu (NMDevice *self, guint32 mtu);
static void _commit_mtu (NMDevice *self, const NMIP4Config *config);
static void dhcp_schedule_restart (NMDevice *self, int addr_family, const char *reason);
static void _cancel_activation (NMDevice *self);
@@ -2672,10 +2673,7 @@ device_link_changed (NMDevice *self)
_notify (self, PROP_DRIVER);
}
- if (priv->mtu != info.mtu) {
- priv->mtu = info.mtu;
- _notify (self, PROP_MTU);
- }
+ _set_mtu (self, info.mtu);
if (ifindex == nm_device_get_ip_ifindex (self))
_stats_update_counters_from_pllink (self, &info);
@@ -3242,7 +3240,6 @@ realize_start_setup (NMDevice *self,
NMDeviceCapabilities capabilities = 0;
NMConfig *config;
guint real_rate;
- guint32 mtu;
/* plink is a NMPlatformLink type, however, we require it to come from the platform
* cache (where else would it come from?). */
@@ -3271,10 +3268,7 @@ realize_start_setup (NMDevice *self,
priv->mtu_initial = 0;
priv->ip6_mtu_initial = 0;
priv->ip6_mtu = 0;
- if (priv->mtu) {
- priv->mtu = 0;
- _notify (self, PROP_MTU);
- }
+ _set_mtu (self, 0);
_assume_state_set (self, assume_state_guess_assume, assume_state_connection_uuid);
@@ -3295,11 +3289,9 @@ realize_start_setup (NMDevice *self,
if (nm_platform_link_is_software (nm_device_get_platform (self), priv->ifindex))
capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
- mtu = nm_platform_link_get_mtu (nm_device_get_platform (self), priv->ifindex);
- if (priv->mtu != mtu) {
- priv->mtu = mtu;
- _notify (self, PROP_MTU);
- }
+ _set_mtu (self,
+ nm_platform_link_get_mtu (nm_device_get_platform (self),
+ priv->ifindex));
nm_platform_link_get_driver_info (nm_device_get_platform (self),
priv->ifindex,
@@ -3524,10 +3516,7 @@ 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);
- }
+ _set_mtu (self, 0);
if (priv->driver_version) {
g_clear_pointer (&priv->driver_version, g_free);
@@ -7212,6 +7201,18 @@ nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_co
/*****************************************************************************/
static void
+_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+
+ if (priv->mtu == mtu)
+ return;
+
+ priv->mtu = mtu;
+ _notify (self, PROP_MTU);
+}
+
+static void
_commit_mtu (NMDevice *self, const NMIP4Config *config)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);