mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 01:40:16 +01:00
device: introduce mtu source
Instead of returning a boolean @is_user_config value from
get_configured_mtu(), return an mtu-source enum with possible values
NONE,CONNECTION. This enum will be expanded later; for now there is no
change in behavior.
(cherry picked from commit 9f8b0697de)
This commit is contained in:
parent
ef0b76a0ec
commit
ccecc6db59
11 changed files with 38 additions and 32 deletions
|
|
@ -1317,13 +1317,13 @@ act_stage3_ip4_config_start (NMDevice *device,
|
|||
}
|
||||
|
||||
static guint32
|
||||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
/* MTU only set for plain ethernet */
|
||||
if (NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device)->ppp_manager)
|
||||
return 0;
|
||||
|
||||
return nm_device_get_configured_mtu_for_wired (device, out_is_user_config);
|
||||
return nm_device_get_configured_mtu_for_wired (device, out_source);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -115,11 +115,11 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
}
|
||||
|
||||
static guint32
|
||||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
return nm_device_get_configured_mtu_from_connection (device,
|
||||
NM_TYPE_SETTING_INFINIBAND,
|
||||
out_is_user_config);
|
||||
out_source);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -741,11 +741,11 @@ create_and_realize (NMDevice *device,
|
|||
}
|
||||
|
||||
static guint32
|
||||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
return nm_device_get_configured_mtu_from_connection (device,
|
||||
NM_TYPE_SETTING_IP_TUNNEL,
|
||||
out_is_user_config);
|
||||
out_source);
|
||||
}
|
||||
|
||||
static NMDeviceCapabilities
|
||||
|
|
|
|||
|
|
@ -122,9 +122,9 @@ gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self,
|
|||
|
||||
guint32 nm_device_get_configured_mtu_from_connection (NMDevice *device,
|
||||
GType setting_type,
|
||||
gboolean *out_is_user_config);
|
||||
NMDeviceMtuSource *out_source);
|
||||
|
||||
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config);
|
||||
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, NMDeviceMtuSource *out_source);
|
||||
|
||||
void nm_device_commit_mtu (NMDevice *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -534,13 +534,13 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
}
|
||||
|
||||
static guint32
|
||||
get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
|
||||
get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
guint32 mtu = 0;
|
||||
int ifindex;
|
||||
|
||||
mtu = nm_device_get_configured_mtu_for_wired (self, out_is_user_config);
|
||||
if (*out_is_user_config)
|
||||
mtu = nm_device_get_configured_mtu_for_wired (self, out_source);
|
||||
if (*out_source != NM_DEVICE_MTU_SOURCE_NONE)
|
||||
return mtu;
|
||||
|
||||
/* Inherit the MTU from parent device, if any */
|
||||
|
|
|
|||
|
|
@ -8373,7 +8373,7 @@ nm_device_get_configured_mtu_from_connection_default (NMDevice *self,
|
|||
guint32
|
||||
nm_device_get_configured_mtu_from_connection (NMDevice *self,
|
||||
GType setting_type,
|
||||
gboolean *out_is_user_config)
|
||||
NMDeviceMtuSource *out_source)
|
||||
{
|
||||
const char *global_property_name;
|
||||
NMConnection *connection;
|
||||
|
|
@ -8382,7 +8382,7 @@ nm_device_get_configured_mtu_from_connection (NMDevice *self,
|
|||
guint32 mtu = 0;
|
||||
|
||||
nm_assert (NM_IS_DEVICE (self));
|
||||
nm_assert (out_is_user_config);
|
||||
nm_assert (out_source);
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
if (!connection)
|
||||
|
|
@ -8409,27 +8409,28 @@ nm_device_get_configured_mtu_from_connection (NMDevice *self,
|
|||
} else
|
||||
g_return_val_if_reached (0);
|
||||
|
||||
|
||||
if (mtu) {
|
||||
*out_is_user_config = TRUE;
|
||||
*out_source = NM_DEVICE_MTU_SOURCE_CONNECTION;
|
||||
return mtu;
|
||||
}
|
||||
|
||||
mtu_default = nm_device_get_configured_mtu_from_connection_default (self, global_property_name);
|
||||
if (mtu_default >= 0) {
|
||||
*out_is_user_config = TRUE;
|
||||
*out_source = NM_DEVICE_MTU_SOURCE_CONNECTION;
|
||||
return (guint32) mtu_default;
|
||||
}
|
||||
|
||||
*out_is_user_config = FALSE;
|
||||
*out_source = NM_DEVICE_MTU_SOURCE_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config)
|
||||
nm_device_get_configured_mtu_for_wired (NMDevice *self, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
return nm_device_get_configured_mtu_from_connection (self,
|
||||
NM_TYPE_SETTING_WIRED,
|
||||
out_is_user_config);
|
||||
out_source);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -8480,7 +8481,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
|||
}
|
||||
|
||||
{
|
||||
gboolean mtu_is_user_config = FALSE;
|
||||
NMDeviceMtuSource mtu_source = NM_DEVICE_MTU_SOURCE_NONE;
|
||||
guint32 mtu = 0;
|
||||
|
||||
/* preferably, get the MTU from explict user-configuration.
|
||||
|
|
@ -8488,9 +8489,9 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
|||
* 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);
|
||||
mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &mtu_source);
|
||||
|
||||
if (mtu_is_user_config)
|
||||
if (mtu_source == NM_DEVICE_MTU_SOURCE_CONNECTION)
|
||||
mtu_desired = mtu;
|
||||
else {
|
||||
if (config)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ typedef enum {
|
|||
NM_DEVICE_SYS_IFACE_STATE_REMOVED,
|
||||
} NMDeviceSysIfaceState;
|
||||
|
||||
typedef enum {
|
||||
NM_DEVICE_MTU_SOURCE_NONE,
|
||||
NM_DEVICE_MTU_SOURCE_CONNECTION,
|
||||
} NMDeviceMtuSource;
|
||||
|
||||
static inline NMDeviceStateReason
|
||||
nm_device_state_reason_check (NMDeviceStateReason reason)
|
||||
{
|
||||
|
|
@ -287,7 +292,7 @@ typedef struct _NMDeviceClass {
|
|||
NMConnection *connection,
|
||||
char **specific_object);
|
||||
|
||||
guint32 (*get_configured_mtu) (NMDevice *self, gboolean *out_is_user_config);
|
||||
guint32 (*get_configured_mtu) (NMDevice *self, NMDeviceMtuSource *out_source);
|
||||
|
||||
/* Checks whether the connection is compatible with the device using
|
||||
* only the devices type and characteristics. Does not use any live
|
||||
|
|
|
|||
|
|
@ -1434,11 +1434,11 @@ out:
|
|||
}
|
||||
|
||||
static guint32
|
||||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
return nm_device_get_configured_mtu_from_connection (device,
|
||||
NM_TYPE_SETTING_WIRELESS,
|
||||
out_is_user_config);
|
||||
out_source);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -2786,11 +2786,11 @@ act_stage3_ip6_config_start (NMDevice *device,
|
|||
}
|
||||
|
||||
static guint32
|
||||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
return nm_device_get_configured_mtu_from_connection (device,
|
||||
NM_TYPE_SETTING_WIRELESS,
|
||||
out_is_user_config);
|
||||
out_source);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -859,7 +859,7 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
|
|||
}
|
||||
|
||||
guint32
|
||||
nm_modem_get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
|
||||
nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMSetting *setting;
|
||||
|
|
@ -868,7 +868,7 @@ nm_modem_get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
|
|||
const char *property_name;
|
||||
|
||||
nm_assert (NM_IS_DEVICE (self));
|
||||
nm_assert (out_is_user_config);
|
||||
nm_assert (out_source);
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
if (!connection)
|
||||
|
|
@ -881,19 +881,19 @@ nm_modem_get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
|
|||
if (setting) {
|
||||
g_object_get (setting, "mtu", &mtu, NULL);
|
||||
if (mtu) {
|
||||
*out_is_user_config = TRUE;
|
||||
*out_source = NM_DEVICE_MTU_SOURCE_CONNECTION;
|
||||
return mtu;
|
||||
}
|
||||
|
||||
property_name = NM_IS_SETTING_GSM (setting) ? "gsm.mtu" : "cdma.mtu";
|
||||
mtu_default = nm_device_get_configured_mtu_from_connection_default (self, property_name);
|
||||
if (mtu_default >= 0) {
|
||||
*out_is_user_config = TRUE;
|
||||
*out_source = NM_DEVICE_MTU_SOURCE_CONNECTION;
|
||||
return (guint32) mtu_default;
|
||||
}
|
||||
}
|
||||
|
||||
*out_is_user_config = FALSE;
|
||||
*out_source = NM_DEVICE_MTU_SOURCE_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -275,6 +275,6 @@ void nm_modem_emit_ip6_config_result (NMModem *self,
|
|||
|
||||
const gchar *nm_modem_ip_type_to_string (NMModemIPType ip_type);
|
||||
|
||||
guint32 nm_modem_get_configured_mtu (NMDevice *self, gboolean *out_is_user_config);
|
||||
guint32 nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source);
|
||||
|
||||
#endif /* __NETWORKMANAGER_MODEM_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue