mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 14:20:17 +01:00
core: don't track route MSS in ip-config
The MSS is only set for VPN connections (by merging it in the respective NMIP4Config/NMIP6Config). It is also only used when setting the MSS of the default route. Don't track that property in NMIP4Config/NMIP6Config, instead, set the mss of the route directly in nm_vpn_connection_ip4_config_get() and nm_vpn_connection_ip6_config_get(). There is a potential change in behavior here: NMDevice also consisdered the MSS for the default route, but that would only be set if the MSS gets merged from an vpn-ip-config. Which at most is the case for iterface-less VPN types (libreswan). But even in that case, it doesn't seem right to me to use the VPN's MSS for the device's default-route.
This commit is contained in:
parent
2e14614870
commit
9003dae6cd
7 changed files with 8 additions and 92 deletions
|
|
@ -5868,7 +5868,6 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||
default_route.gateway = gateway;
|
||||
default_route.table_coerced = nm_platform_route_table_coerce (nm_device_get_route_table (self, AF_INET, TRUE));
|
||||
default_route.metric = route_metric_with_penalty (self, default_route_metric);
|
||||
default_route.mss = nm_ip4_config_get_mss (composite);
|
||||
nm_clear_nmp_object (&priv->default_route4);
|
||||
nm_ip4_config_add_route (composite, &default_route, &priv->default_route4);
|
||||
|
||||
|
|
@ -6609,7 +6608,6 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
default_route.gateway = *gateway;
|
||||
default_route.table_coerced = nm_platform_route_table_coerce (nm_device_get_route_table (self, AF_INET6, TRUE));
|
||||
default_route.metric = route_metric_with_penalty (self, default_route_metric);
|
||||
default_route.mss = nm_ip6_config_get_mss (composite);
|
||||
nm_clear_nmp_object (&priv->default_route6);
|
||||
nm_ip6_config_add_route (composite, &default_route, &priv->default_route6);
|
||||
|
||||
|
|
|
|||
|
|
@ -291,7 +291,6 @@ typedef struct {
|
|||
bool metered:1;
|
||||
bool has_gateway:1;
|
||||
guint32 gateway;
|
||||
guint32 mss;
|
||||
guint32 mtu;
|
||||
int ifindex;
|
||||
NMIPConfigSource mtu_source;
|
||||
|
|
@ -1141,10 +1140,6 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl
|
|||
nm_ip4_config_add_dns_option (dst, nm_ip4_config_get_dns_option (src, i));
|
||||
}
|
||||
|
||||
/* MSS */
|
||||
if (nm_ip4_config_get_mss (src))
|
||||
nm_ip4_config_set_mss (dst, nm_ip4_config_get_mss (src));
|
||||
|
||||
/* MTU */
|
||||
if ( src_priv->mtu_source > dst_priv->mtu_source
|
||||
|| ( src_priv->mtu_source == dst_priv->mtu_source
|
||||
|
|
@ -1372,10 +1367,6 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src)
|
|||
nm_ip4_config_del_dns_option (dst, idx);
|
||||
}
|
||||
|
||||
/* MSS */
|
||||
if (nm_ip4_config_get_mss (src) == nm_ip4_config_get_mss (dst))
|
||||
nm_ip4_config_set_mss (dst, 0);
|
||||
|
||||
/* MTU */
|
||||
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))
|
||||
|
|
@ -1733,12 +1724,6 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||
has_minor_changes = TRUE;
|
||||
}
|
||||
|
||||
/* mss */
|
||||
if (src_priv->mss != dst_priv->mss) {
|
||||
nm_ip4_config_set_mss (dst, src_priv->mss);
|
||||
has_minor_changes = TRUE;
|
||||
}
|
||||
|
||||
/* nis */
|
||||
num = nm_ip4_config_get_num_nis_servers (src);
|
||||
are_equal = num == nm_ip4_config_get_num_nis_servers (dst);
|
||||
|
|
@ -1863,7 +1848,6 @@ nm_ip4_config_dump (const NMIP4Config *self, const char *detail)
|
|||
|
||||
g_message (" dnspri: %d", nm_ip4_config_get_dns_priority (self));
|
||||
|
||||
g_message (" mss: %"G_GUINT32_FORMAT, nm_ip4_config_get_mss (self));
|
||||
g_message (" mtu: %"G_GUINT32_FORMAT" (source: %d)", nm_ip4_config_get_mtu (self), (int) nm_ip4_config_get_mtu_source (self));
|
||||
|
||||
/* NIS */
|
||||
|
|
@ -2517,24 +2501,6 @@ nm_ip4_config_get_dns_priority (const NMIP4Config *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_ip4_config_set_mss (NMIP4Config *self, guint32 mss)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
priv->mss = mss;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_ip4_config_get_mss (const NMIP4Config *self)
|
||||
{
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
return priv->mss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_ip4_config_reset_nis_servers (NMIP4Config *self)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -233,9 +233,6 @@ const char * nm_ip4_config_get_dns_option (const NMIP4Config *self, guint i);
|
|||
void nm_ip4_config_set_dns_priority (NMIP4Config *self, gint priority);
|
||||
gint nm_ip4_config_get_dns_priority (const NMIP4Config *self);
|
||||
|
||||
void nm_ip4_config_set_mss (NMIP4Config *self, guint32 mss);
|
||||
guint32 nm_ip4_config_get_mss (const NMIP4Config *self);
|
||||
|
||||
void nm_ip4_config_reset_nis_servers (NMIP4Config *self);
|
||||
void nm_ip4_config_add_nis_server (NMIP4Config *self, guint32 nis);
|
||||
void nm_ip4_config_del_nis_server (NMIP4Config *self, guint i);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ _route_valid (const NMPlatformIP6Route *r)
|
|||
|
||||
typedef struct {
|
||||
bool never_default:1;
|
||||
guint32 mss;
|
||||
int ifindex;
|
||||
int dns_priority;
|
||||
NMSettingIP6ConfigPrivacy privacy;
|
||||
|
|
@ -940,9 +939,6 @@ nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFl
|
|||
nm_ip6_config_add_dns_option (dst, nm_ip6_config_get_dns_option (src, i));
|
||||
}
|
||||
|
||||
if (nm_ip6_config_get_mss (src))
|
||||
nm_ip6_config_set_mss (dst, nm_ip6_config_get_mss (src));
|
||||
|
||||
/* DNS priority */
|
||||
if (nm_ip6_config_get_dns_priority (src))
|
||||
nm_ip6_config_set_dns_priority (dst, nm_ip6_config_get_dns_priority (src));
|
||||
|
|
@ -1135,9 +1131,6 @@ nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src)
|
|||
nm_ip6_config_del_dns_option (dst, idx);
|
||||
}
|
||||
|
||||
if (nm_ip6_config_get_mss (src) == nm_ip6_config_get_mss (dst))
|
||||
nm_ip6_config_set_mss (dst, 0);
|
||||
|
||||
/* DNS priority */
|
||||
if (nm_ip6_config_get_dns_priority (src) == nm_ip6_config_get_dns_priority (dst))
|
||||
nm_ip6_config_set_dns_priority (dst, 0);
|
||||
|
|
@ -1468,12 +1461,6 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
|
|||
has_relevant_changes = TRUE;
|
||||
}
|
||||
|
||||
/* mss */
|
||||
if (src_priv->mss != dst_priv->mss) {
|
||||
nm_ip6_config_set_mss (dst, src_priv->mss);
|
||||
has_minor_changes = TRUE;
|
||||
}
|
||||
|
||||
/* DNS priority */
|
||||
if (src_priv->dns_priority != dst_priv->dns_priority) {
|
||||
nm_ip6_config_set_dns_priority (dst, src_priv->dns_priority);
|
||||
|
|
@ -1550,7 +1537,6 @@ nm_ip6_config_dump (const NMIP6Config *self, const char *detail)
|
|||
|
||||
g_message (" dnspri: %d", nm_ip6_config_get_dns_priority (self));
|
||||
|
||||
g_message (" mss: %"G_GUINT32_FORMAT, nm_ip6_config_get_mss (self));
|
||||
g_message (" n-dflt: %d", nm_ip6_config_get_never_default (self));
|
||||
}
|
||||
|
||||
|
|
@ -2338,24 +2324,6 @@ nm_ip6_config_get_dns_priority (const NMIP6Config *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_ip6_config_set_mss (NMIP6Config *self, guint32 mss)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
priv->mss = mss;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_ip6_config_get_mss (const NMIP6Config *self)
|
||||
{
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
return priv->mss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const NMPObject *
|
||||
nm_ip6_config_nmpobj_lookup (const NMIP6Config *self, const NMPObject *needle)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -194,9 +194,6 @@ const char * nm_ip6_config_get_dns_option (const NMIP6Config *self, guint i);
|
|||
void nm_ip6_config_set_dns_priority (NMIP6Config *self, gint priority);
|
||||
gint nm_ip6_config_get_dns_priority (const NMIP6Config *self);
|
||||
|
||||
void nm_ip6_config_set_mss (NMIP6Config *self, guint32 mss);
|
||||
guint32 nm_ip6_config_get_mss (const NMIP6Config *self);
|
||||
|
||||
const NMPObject *nm_ip6_config_nmpobj_lookup (const NMIP6Config *self,
|
||||
const NMPObject *needle);
|
||||
gboolean nm_ip6_config_nmpobj_remove (NMIP6Config *self,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ test_subtract (void)
|
|||
const char *expected_search = "somewhere.com";
|
||||
guint32 expected_nis = nmtst_inet4_from_string ("1.2.3.13");
|
||||
guint32 expected_wins = nmtst_inet4_from_string ("2.3.4.5");
|
||||
guint32 expected_mss = 1400;
|
||||
guint32 expected_mtu = 1492;
|
||||
|
||||
src = build_test_config ();
|
||||
|
|
@ -105,7 +104,6 @@ test_subtract (void)
|
|||
nm_ip4_config_add_nis_server (dst, expected_nis);
|
||||
nm_ip4_config_add_wins (dst, expected_wins);
|
||||
|
||||
nm_ip4_config_set_mss (dst, expected_mss);
|
||||
nm_ip4_config_set_mtu (dst, expected_mtu, NM_IP_CONFIG_SOURCE_UNKNOWN);
|
||||
|
||||
nm_ip4_config_subtract (dst, src);
|
||||
|
|
@ -142,7 +140,6 @@ test_subtract (void)
|
|||
g_assert_cmpuint (nm_ip4_config_get_num_wins (dst), ==, 1);
|
||||
g_assert_cmpuint (nm_ip4_config_get_wins (dst, 0), ==, expected_wins);
|
||||
|
||||
g_assert_cmpuint (nm_ip4_config_get_mss (dst), ==, expected_mss);
|
||||
g_assert_cmpuint (nm_ip4_config_get_mtu (dst), ==, expected_mtu);
|
||||
|
||||
g_object_unref (src);
|
||||
|
|
@ -267,12 +264,10 @@ test_add_route_with_source (void)
|
|||
}
|
||||
|
||||
static void
|
||||
test_merge_subtract_mss_mtu (void)
|
||||
test_merge_subtract_mtu (void)
|
||||
{
|
||||
NMIP4Config *cfg1, *cfg2, *cfg3;
|
||||
guint32 expected_mss2 = 1400;
|
||||
guint32 expected_mtu2 = 1492;
|
||||
guint32 expected_mss3 = 555;
|
||||
guint32 expected_mtu3 = 666;
|
||||
|
||||
cfg1 = build_test_config ();
|
||||
|
|
@ -280,24 +275,19 @@ test_merge_subtract_mss_mtu (void)
|
|||
cfg3 = build_test_config ();
|
||||
|
||||
/* add MSS, MTU to configs to test them */
|
||||
nm_ip4_config_set_mss (cfg2, expected_mss2);
|
||||
nm_ip4_config_set_mtu (cfg2, expected_mtu2, NM_IP_CONFIG_SOURCE_UNKNOWN);
|
||||
nm_ip4_config_set_mss (cfg3, expected_mss3);
|
||||
nm_ip4_config_set_mtu (cfg3, expected_mtu3, NM_IP_CONFIG_SOURCE_UNKNOWN);
|
||||
|
||||
nm_ip4_config_merge (cfg1, cfg2, NM_IP_CONFIG_MERGE_DEFAULT);
|
||||
/* ensure MSS and MTU are in cfg1 */
|
||||
g_assert_cmpuint (nm_ip4_config_get_mss (cfg1), ==, expected_mss2);
|
||||
g_assert_cmpuint (nm_ip4_config_get_mtu (cfg1), ==, expected_mtu2);
|
||||
|
||||
nm_ip4_config_merge (cfg1, cfg3, NM_IP_CONFIG_MERGE_DEFAULT);
|
||||
/* ensure again the MSS and MTU in cfg1 got overridden */
|
||||
g_assert_cmpuint (nm_ip4_config_get_mss (cfg1), ==, expected_mss3);
|
||||
g_assert_cmpuint (nm_ip4_config_get_mtu (cfg1), ==, expected_mtu3);
|
||||
|
||||
nm_ip4_config_subtract (cfg1, cfg3);
|
||||
/* ensure MSS and MTU are zero in cfg1 */
|
||||
g_assert_cmpuint (nm_ip4_config_get_mss (cfg1), ==, 0);
|
||||
g_assert_cmpuint (nm_ip4_config_get_mtu (cfg1), ==, 0);
|
||||
|
||||
g_object_unref (cfg1);
|
||||
|
|
@ -339,7 +329,7 @@ main (int argc, char **argv)
|
|||
g_test_add_func ("/ip4-config/compare-with-source", test_compare_with_source);
|
||||
g_test_add_func ("/ip4-config/add-address-with-source", test_add_address_with_source);
|
||||
g_test_add_func ("/ip4-config/add-route-with-source", test_add_route_with_source);
|
||||
g_test_add_func ("/ip4-config/merge-subtract-mss-mtu", test_merge_subtract_mss_mtu);
|
||||
g_test_add_func ("/ip4-config/merge-subtract-mtu", test_merge_subtract_mtu);
|
||||
g_test_add_func ("/ip4-config/strip-search-trailing-dot", test_strip_search_trailing_dot);
|
||||
|
||||
return g_test_run ();
|
||||
|
|
|
|||
|
|
@ -1010,7 +1010,6 @@ print_vpn_config (NMVpnConnection *self)
|
|||
_LOGI ("Data: Internal Address: %s", nm_utils_inet4_ntop (address4->address, NULL));
|
||||
_LOGI ("Data: Internal Prefix: %d", address4->plen);
|
||||
_LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet4_ntop (address4->peer_address, NULL));
|
||||
_LOGI ("Data: Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (priv->ip4_config));
|
||||
|
||||
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->ip4_config, &route) {
|
||||
_LOGI ("Data: Static Route: %s/%d Next Hop: %s",
|
||||
|
|
@ -1048,7 +1047,6 @@ print_vpn_config (NMVpnConnection *self)
|
|||
_LOGI ("Data: Internal Address: %s", nm_utils_inet6_ntop (&address6->address, NULL));
|
||||
_LOGI ("Data: Internal Prefix: %d", address6->plen);
|
||||
_LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet6_ntop (&address6->peer_address, NULL));
|
||||
_LOGI ("Data: Maximum Segment Size (MSS): %d", nm_ip6_config_get_mss (priv->ip6_config));
|
||||
|
||||
nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->ip6_config, &route) {
|
||||
_LOGI ("Data: Static Route: %s/%d Next Hop: %s",
|
||||
|
|
@ -1480,6 +1478,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
GVariant *v;
|
||||
gboolean b;
|
||||
int ip_ifindex;
|
||||
guint32 mss = 0;
|
||||
|
||||
g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT));
|
||||
|
||||
|
|
@ -1563,7 +1562,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
}
|
||||
|
||||
if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_MSS, "u", &u32))
|
||||
nm_ip4_config_set_mss (config, u32);
|
||||
mss = u32;
|
||||
|
||||
if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_DOMAIN, "&s", &str))
|
||||
nm_ip4_config_add_domain (config, str);
|
||||
|
|
@ -1641,7 +1640,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
.gateway = nm_ip4_config_get_gateway (config),
|
||||
.table_coerced = nm_platform_route_table_coerce (route_table),
|
||||
.metric = route_metric,
|
||||
.mss = nm_ip4_config_get_mss (config),
|
||||
.mss = mss,
|
||||
};
|
||||
|
||||
nm_ip4_config_add_route (config, &r, NULL);
|
||||
|
|
@ -1679,6 +1678,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
GVariant *v;
|
||||
gboolean b;
|
||||
int ip_ifindex;
|
||||
guint32 mss = 0;
|
||||
|
||||
g_return_if_fail (dict && g_variant_is_of_type (dict, G_VARIANT_TYPE_VARDICT));
|
||||
|
||||
|
|
@ -1752,7 +1752,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
}
|
||||
|
||||
if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_MSS, "u", &u32))
|
||||
nm_ip6_config_set_mss (config, u32);
|
||||
mss = u32;
|
||||
|
||||
if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_DOMAIN, "&s", &str))
|
||||
nm_ip6_config_add_domain (config, str);
|
||||
|
|
@ -1827,7 +1827,7 @@ next:
|
|||
.gateway = *(nm_ip6_config_get_gateway (config) ?: &in6addr_any),
|
||||
.table_coerced = nm_platform_route_table_coerce (route_table),
|
||||
.metric = route_metric,
|
||||
.mss = nm_ip6_config_get_mss (config),
|
||||
.mss = mss,
|
||||
};
|
||||
|
||||
nm_ip6_config_add_route (config, &r, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue