mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 00:38:07 +02:00
core: fix MTU handling while merging/subtracting IP configs (bgo #721420)
https://bugzilla.gnome.org/show_bug.cgi?id=721420 https://bugzilla.redhat.com/show_bug.cgi?id=1047083
This commit is contained in:
parent
30a98f3149
commit
0757e33e74
2 changed files with 60 additions and 2 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2013 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2014 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -502,9 +502,14 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src)
|
|||
for (i = 0; i < nm_ip4_config_get_num_searches (src); i++)
|
||||
nm_ip4_config_add_search (dst, nm_ip4_config_get_search (src, i));
|
||||
|
||||
/* MSS */
|
||||
if (!nm_ip4_config_get_mss (dst))
|
||||
nm_ip4_config_set_mss (dst, nm_ip4_config_get_mss (src));
|
||||
|
||||
/* MTU */
|
||||
if (!nm_ip4_config_get_mtu (dst))
|
||||
nm_ip4_config_set_mtu (dst, nm_ip4_config_get_mtu (src));
|
||||
|
||||
/* NIS */
|
||||
for (i = 0; i < nm_ip4_config_get_num_nis_servers (src); i++)
|
||||
nm_ip4_config_add_nis_server (dst, nm_ip4_config_get_nis_server (src, i));
|
||||
|
|
@ -611,9 +616,14 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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_set_mtu (dst, 0);
|
||||
|
||||
/* NIS */
|
||||
for (i = 0; i < nm_ip4_config_get_num_nis_servers (src); i++) {
|
||||
guint32 src_nis = nm_ip4_config_get_nis_server (src, i);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2013 Red Hat, Inc.
|
||||
* Copyright (C) 2013 - 2014 Red Hat, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -116,6 +116,8 @@ test_subtract (void)
|
|||
const char *expected_search = "somewhere.com";
|
||||
guint32 expected_nis = addr_to_num ("1.2.3.13");
|
||||
guint32 expected_wins = addr_to_num ("2.3.4.5");
|
||||
guint32 expected_mss = 1400;
|
||||
guint32 expected_mtu = 1492;
|
||||
|
||||
src = build_test_config ();
|
||||
|
||||
|
|
@ -135,6 +137,9 @@ 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_ip4_config_subtract (dst, src);
|
||||
|
||||
/* ensure what's left is what we expect */
|
||||
|
|
@ -169,6 +174,9 @@ 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);
|
||||
g_object_unref (dst);
|
||||
}
|
||||
|
|
@ -286,6 +294,45 @@ test_add_route_with_source (void)
|
|||
g_object_unref (a);
|
||||
}
|
||||
|
||||
static void
|
||||
test_merge_subtract_mss_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 ();
|
||||
cfg2 = build_test_config ();
|
||||
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_ip4_config_set_mss (cfg3, expected_mss3);
|
||||
nm_ip4_config_set_mtu (cfg3, expected_mtu3);
|
||||
|
||||
nm_ip4_config_merge (cfg1, cfg2);
|
||||
/* 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);
|
||||
/* ensure again the same 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_subtract (cfg1, cfg2);
|
||||
/* 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);
|
||||
g_object_unref (cfg2);
|
||||
g_object_unref (cfg3);
|
||||
}
|
||||
|
||||
/*******************************************/
|
||||
|
||||
int
|
||||
|
|
@ -299,6 +346,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);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue