diff options
author | Thomas Haller <thaller@redhat.com> | 2019-04-05 16:29:10 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-04-05 16:29:11 +0200 |
commit | 69765c11fd8e175e203a2a13265f7984f943c493 (patch) | |
tree | 3219b98a7d6da7b88eb5c0d75553833b23234514 | |
parent | 78d9bd62ff152523489226b0bc7fd4f2b8ddc80d (diff) | |
parent | c422fc06b086b75ef9d1d0098e6a805133f87e49 (diff) | |
download | NetworkManager-69765c11fd8e175e203a2a13265f7984f943c493.tar.gz |
libnm,infiniband: merge branch 'th/infiniband-max-mtu'
https://bugzilla.redhat.com/show_bug.cgi?id=1534869
https://bugzilla.redhat.com/show_bug.cgi?id=1653494
https://github.com/NetworkManager/NetworkManager/pull/334
-rw-r--r-- | libnm-core/nm-connection.c | 25 | ||||
-rw-r--r-- | libnm-core/nm-setting-infiniband.c | 25 | ||||
-rw-r--r-- | libnm-core/nm-setting-ip-tunnel.c | 4 | ||||
-rw-r--r-- | libnm-core/tests/test-general.c | 13 | ||||
-rw-r--r-- | shared/nm-libnm-core-utils.h | 16 | ||||
-rw-r--r-- | src/devices/nm-device-private.h | 3 | ||||
-rw-r--r-- | src/devices/nm-device.c | 10 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem.c | 2 |
8 files changed, 56 insertions, 42 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index e91052a35b..3182e3460f 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1059,23 +1059,14 @@ _normalize_infiniband_mtu (NMConnection *self, GHashTable *parameters) { NMSettingInfiniband *s_infini = nm_connection_get_setting_infiniband (self); - if (s_infini) { - const char *transport_mode = nm_setting_infiniband_get_transport_mode (s_infini); - guint32 max_mtu = 0; - - if (transport_mode) { - if (!strcmp (transport_mode, "datagram")) - max_mtu = 2044; - else if (!strcmp (transport_mode, "connected")) - max_mtu = 65520; - - if (max_mtu && nm_setting_infiniband_get_mtu (s_infini) > max_mtu) { - g_object_set (s_infini, NM_SETTING_INFINIBAND_MTU, (guint) max_mtu, NULL); - return TRUE; - } - } - } - return FALSE; + if ( !s_infini + || nm_setting_infiniband_get_mtu (s_infini) <= NM_INFINIBAND_MAX_MTU + || !NM_IN_STRSET (nm_setting_infiniband_get_transport_mode (s_infini), "datagram", + "connected")) + return FALSE; + + g_object_set (s_infini, NM_SETTING_INFINIBAND_MTU, (guint) NM_INFINIBAND_MAX_MTU, NULL); + return TRUE; } static gboolean diff --git a/libnm-core/nm-setting-infiniband.c b/libnm-core/nm-setting-infiniband.c index 9348fa2be0..bde7eda986 100644 --- a/libnm-core/nm-setting-infiniband.c +++ b/libnm-core/nm-setting-infiniband.c @@ -170,7 +170,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingConnection *s_con = NULL; NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting); - guint32 normerr_max_mtu = 0; if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, INFINIBAND_ALEN)) { g_set_error_literal (error, @@ -181,13 +180,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (!g_strcmp0 (priv->transport_mode, "datagram")) { - if (priv->mtu > 2044) - normerr_max_mtu = 2044; - } else if (!g_strcmp0 (priv->transport_mode, "connected")) { - if (priv->mtu > 65520) - normerr_max_mtu = 65520; - } else { + if (!NM_IN_STRSET (priv->transport_mode, "datagram", + "connected")) { g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -271,12 +265,21 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */ - if (normerr_max_mtu > 0) { + if (priv->mtu > NM_INFINIBAND_MAX_MTU) { + /* Traditionally, MTU for "datagram" mode was limited to 2044 + * and for "connected" mode it was 65520. + * + * This is no longer the case, and both transport modes use the same + * maximum of 65520 (NM_INFINIBAND_MAX_MTU). + * + * Note that this is the MTU in the connection profile. Whether + * we will be able to configure large MTUs later (during activation) + * is unknown at this point. */ g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("mtu for transport mode '%s' can be at most %d but it is %d"), - priv->transport_mode, normerr_max_mtu, priv->mtu); + _("mtu can be at most %u but it is %u"), + NM_INFINIBAND_MAX_MTU, priv->mtu); g_prefix_error (error, "%s.%s: ", NM_SETTING_INFINIBAND_SETTING_NAME, NM_SETTING_INFINIBAND_MTU); return NM_SETTING_VERIFY_NORMALIZABLE_ERROR; } diff --git a/libnm-core/nm-setting-ip-tunnel.c b/libnm-core/nm-setting-ip-tunnel.c index 9fdb5481a9..42c44c1cd1 100644 --- a/libnm-core/nm-setting-ip-tunnel.c +++ b/libnm-core/nm-setting-ip-tunnel.c @@ -60,7 +60,7 @@ typedef struct { char *output_key; guint encapsulation_limit; guint flow_label; - guint mtu; + guint32 mtu; guint32 flags; } NMSettingIPTunnelPrivate; @@ -819,7 +819,7 @@ nm_setting_ip_tunnel_class_init (NMSettingIPTunnelClass *klass) **/ obj_properties[PROP_MTU] = g_param_spec_uint (NM_SETTING_IP_TUNNEL_MTU, "", "", - 0, G_MAXUINT, 0, + 0, G_MAXUINT32, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE | diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 98e5837176..765957135a 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -4737,6 +4737,7 @@ test_connection_normalize_infiniband_mtu (void) { gs_unref_object NMConnection *con = NULL; NMSettingInfiniband *s_infini; + guint mtu_regular = nmtst_rand_select (2044, 2045, 65520); con = nmtst_create_minimal_connection ("test_connection_normalize_infiniband_mtu", NULL, NM_SETTING_INFINIBAND_SETTING_NAME, NULL); @@ -4749,26 +4750,26 @@ test_connection_normalize_infiniband_mtu (void) g_object_set (s_infini, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", - NM_SETTING_INFINIBAND_MTU, (guint) 2044, + NM_SETTING_INFINIBAND_MTU, (guint) mtu_regular, NULL); nmtst_assert_connection_verifies_and_normalizable (con); nmtst_connection_normalize (con); - g_assert_cmpint (2044, ==, nm_setting_infiniband_get_mtu (s_infini)); + g_assert_cmpint (mtu_regular, ==, nm_setting_infiniband_get_mtu (s_infini)); g_object_set (s_infini, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", - NM_SETTING_INFINIBAND_MTU, (guint) 2045, + NM_SETTING_INFINIBAND_MTU, (guint) 65521, NULL); nmtst_assert_connection_verifies_after_normalization (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); nmtst_connection_normalize (con); - g_assert_cmpint (2044, ==, nm_setting_infiniband_get_mtu (s_infini)); + g_assert_cmpint (65520, ==, nm_setting_infiniband_get_mtu (s_infini)); g_object_set (s_infini, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", - NM_SETTING_INFINIBAND_MTU, (guint) 65520, + NM_SETTING_INFINIBAND_MTU, (guint) mtu_regular, NULL); nmtst_assert_connection_verifies_without_normalization (con); - g_assert_cmpint (65520, ==, nm_setting_infiniband_get_mtu (s_infini)); + g_assert_cmpint (mtu_regular, ==, nm_setting_infiniband_get_mtu (s_infini)); g_object_set (s_infini, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", diff --git a/shared/nm-libnm-core-utils.h b/shared/nm-libnm-core-utils.h index f55d6b3cc0..35d6c5ad5b 100644 --- a/shared/nm-libnm-core-utils.h +++ b/shared/nm-libnm-core-utils.h @@ -94,4 +94,20 @@ nm_setting_ip_config_get_addr_family (NMSettingIPConfig *s_ip) g_return_val_if_reached (AF_UNSPEC); } +/*****************************************************************************/ + +/* The maximum MTU for infiniband. + * + * This is both in transport-mode "datagram" and "connected" + * and they both have the same maximum define. + * + * Note that in the past, MTU in "datagram" mode was restricted + * to 2044 bytes. That is no longer the case and we accept large + * MTUs. + * + * This define is the maxiumum for the MTU in a connection profile (the + * setting). Whether large MTUs can be configured later (at activation time) + * depends on other factors. */ +#define NM_INFINIBAND_MAX_MTU ((guint) 65520) + #endif /* __NM_LIBNM_SHARED_UTILS_H__ */ diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index 6e2372abf9..dd98e92f73 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -168,7 +168,8 @@ NMIPConfig *nm_device_ip_config_new (NMDevice *self, int addr_family); /*****************************************************************************/ gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self, - const char *property_name); + const char *property_name, + guint32 max_mtu); guint32 nm_device_get_configured_mtu_from_connection (NMDevice *device, GType setting_type, diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 925c1b5252..1b594ce000 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -8926,12 +8926,13 @@ linklocal6_start (NMDevice *self) gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self, - const char *property_name) + const char *property_name, + guint32 max_mtu) { return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA, property_name, self, - 0, G_MAXUINT32, -1); + 0, max_mtu, -1); } guint32 @@ -8944,6 +8945,7 @@ nm_device_get_configured_mtu_from_connection (NMDevice *self, NMSetting *setting; gint64 mtu_default; guint32 mtu = 0; + guint32 max_mtu = G_MAXUINT32; nm_assert (NM_IS_DEVICE (self)); nm_assert (out_source); @@ -8966,6 +8968,7 @@ nm_device_get_configured_mtu_from_connection (NMDevice *self, if (setting) mtu = nm_setting_infiniband_get_mtu (NM_SETTING_INFINIBAND (setting)); global_property_name = NM_CON_DEFAULT ("infiniband.mtu"); + max_mtu = NM_INFINIBAND_MAX_MTU; } else if (setting_type == NM_TYPE_SETTING_IP_TUNNEL) { if (setting) mtu = nm_setting_ip_tunnel_get_mtu (NM_SETTING_IP_TUNNEL (setting)); @@ -8977,13 +8980,12 @@ nm_device_get_configured_mtu_from_connection (NMDevice *self, } else g_return_val_if_reached (0); - if (mtu) { *out_source = NM_DEVICE_MTU_SOURCE_CONNECTION; return mtu; } - mtu_default = nm_device_get_configured_mtu_from_connection_default (self, global_property_name); + mtu_default = nm_device_get_configured_mtu_from_connection_default (self, global_property_name, max_mtu); if (mtu_default >= 0) { *out_source = NM_DEVICE_MTU_SOURCE_CONNECTION; return (guint32) mtu_default; diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 2217f2a2df..1779422956 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -885,7 +885,7 @@ nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source) } property_name = NM_IS_SETTING_GSM (setting) ? "gsm.mtu" : "cdma.mtu"; - mtu_default = nm_device_get_configured_mtu_from_connection_default (self, property_name); + mtu_default = nm_device_get_configured_mtu_from_connection_default (self, property_name, G_MAXUINT32); if (mtu_default >= 0) { *out_source = NM_DEVICE_MTU_SOURCE_CONNECTION; return (guint32) mtu_default; |