Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:fix-route-end-dhcp-lease into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Tony Espy
Approved revision: 06511d90695866218578feeff8740298b1034480
Merged at revision: 06511d90695866218578feeff8740298b1034480
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:fix-route-end-dhcp-lease
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2
Diff against target: 123 lines (+21/-20)
1 file modified
src/devices/nm-device.c (+21/-20)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Needs Fixing
Tony Espy Approve
Review via email: mp+361207@code.launchpad.net

Commit message

Make sure default routes survive across expiring of DHCP leases. Commits taken from upstream. Related to LP: #1800712.

Description of the change

Make sure default routes survive across expiring of DHCP leases. Commits taken from upstream. Related to LP: #1800712.

To post a comment you must log in.
Revision history for this message
Tony Espy (awe) wrote :

The bug you reference says:

FTR, this MP would also help here, although the initially proposed fix for the configuration snap should be enough.

It doesn't sound to me like this is *really* needed? Also the RH bug associated with the first commit isn't viewable w/out a login. ;(-

What version of NM did you cherry pick these fixes from?

Would also mind explaining the actual scenario in some more detail?

It sounds like NM is assuming an existing connection from networkd? And that when this happens, and DHCP leases associated with the connection expire, when a DHCP lease is re-acquired the default route wasn't being restored?

Finally, why is networkd involved here at all? Don't we ship a netplan file which makes NM the default renderer?

review: Needs Information
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Actually, both changes (the MP in the bug and this one) solve the issue, the first one by making sure the IP does not survive after networkd does not manage the interface anymore, this one by making sure NM handles well that situation. This MP is for more general cases, so it is good that we land it, it is a bug fix anyway.

The fixes come from branch 1.2 of NM upstream.

The scenario is basically as you describe. Bottom line is that NM finds an IP already existing in the interface, but when it uses DHCP (which it does always when starting) the lease gives a different IP. In that situation, some times the default route is not restored. This is a race which happens maybe 50% of the times. This is what this MP fixes.

We do ship a netplan file that sets NM as the rendered, but on *first boot* networkd takes eth0 until a systemd service that sets the new netplan file does the change of netplan files.

Revision history for this message
Tony Espy (awe) wrote :

Thanks for the explanation!

review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 8472ff8..e8da548 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4287,6 +4287,7 @@ ip4_config_merge_and_apply (NMDevice *self,
4287 gboolean routes_full_sync;4287 gboolean routes_full_sync;
4288 gboolean ignore_auto_routes = FALSE;4288 gboolean ignore_auto_routes = FALSE;
4289 gboolean ignore_auto_dns = FALSE;4289 gboolean ignore_auto_dns = FALSE;
4290 gboolean auto_method = FALSE;
42904291
4291 /* Merge all the configs into the composite config */4292 /* Merge all the configs into the composite config */
4292 if (config) {4293 if (config) {
@@ -4302,6 +4303,10 @@ ip4_config_merge_and_apply (NMDevice *self,
4302 if (s_ip4) {4303 if (s_ip4) {
4303 ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip4);4304 ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip4);
4304 ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip4);4305 ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip4);
4306
4307 if (nm_streq0 (nm_setting_ip_config_get_method (s_ip4),
4308 NM_SETTING_IP4_CONFIG_METHOD_AUTO))
4309 auto_method = TRUE;
4305 }4310 }
4306 }4311 }
43074312
@@ -4357,10 +4362,12 @@ ip4_config_merge_and_apply (NMDevice *self,
4357 goto END_ADD_DEFAULT_ROUTE;4362 goto END_ADD_DEFAULT_ROUTE;
4358 }4363 }
43594364
4360 if (nm_device_uses_generated_assumed_connection (self)) {4365 /* a generated-assumed connection detects the default route from the platform,
4361 /* a generate-assumed-connection always detects the default route from platform */4366 * but if the IP method is automatic we need to update the default route to
4367 * maintain connectivity.
4368 */
4369 if (nm_device_uses_generated_assumed_connection (self) && !auto_method)
4362 goto END_ADD_DEFAULT_ROUTE;4370 goto END_ADD_DEFAULT_ROUTE;
4363 }
43644371
4365 /* At this point, we treat assumed and non-assumed connections alike.4372 /* At this point, we treat assumed and non-assumed connections alike.
4366 * For assumed connections we do that because we still manage RA and DHCP4373 * For assumed connections we do that because we still manage RA and DHCP
@@ -5009,6 +5016,7 @@ ip6_config_merge_and_apply (NMDevice *self,
5009 gboolean routes_full_sync;5016 gboolean routes_full_sync;
5010 gboolean ignore_auto_routes = FALSE;5017 gboolean ignore_auto_routes = FALSE;
5011 gboolean ignore_auto_dns = FALSE;5018 gboolean ignore_auto_dns = FALSE;
5019 gboolean auto_method = FALSE;
50125020
5013 /* Apply ignore-auto-routes and ignore-auto-dns settings */5021 /* Apply ignore-auto-routes and ignore-auto-dns settings */
5014 connection = nm_device_get_applied_connection (self);5022 connection = nm_device_get_applied_connection (self);
@@ -5018,6 +5026,11 @@ ip6_config_merge_and_apply (NMDevice *self,
5018 if (s_ip6) {5026 if (s_ip6) {
5019 ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip6);5027 ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip6);
5020 ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip6);5028 ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip6);
5029
5030 if (NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
5031 NM_SETTING_IP6_CONFIG_METHOD_AUTO,
5032 NM_SETTING_IP6_CONFIG_METHOD_DHCP))
5033 auto_method = TRUE;
5021 }5034 }
5022 }5035 }
50235036
@@ -5081,10 +5094,12 @@ ip6_config_merge_and_apply (NMDevice *self,
5081 goto END_ADD_DEFAULT_ROUTE;5094 goto END_ADD_DEFAULT_ROUTE;
5082 }5095 }
50835096
5084 if (nm_device_uses_generated_assumed_connection (self)) {5097 /* a generated-assumed connection detects the default route from the platform,
5085 /* a generate-assumed-connection always detects the default route from platform */5098 * but if the IP method is automatic we need to update the default route to
5099 * maintain connectivity.
5100 */
5101 if (nm_device_uses_generated_assumed_connection (self) && !auto_method)
5086 goto END_ADD_DEFAULT_ROUTE;5102 goto END_ADD_DEFAULT_ROUTE;
5087 }
50885103
5089 /* At this point, we treat assumed and non-assumed connections alike.5104 /* At this point, we treat assumed and non-assumed connections alike.
5090 * For assumed connections we do that because we still manage RA and DHCP5105 * For assumed connections we do that because we still manage RA and DHCP
@@ -7963,23 +7978,16 @@ nm_device_set_ip4_config (NMDevice *self,
7963 nm_exported_object_clear_and_unexport (&old_config);7978 nm_exported_object_clear_and_unexport (&old_config);
79647979
7965 if (nm_device_uses_generated_assumed_connection (self)) {7980 if (nm_device_uses_generated_assumed_connection (self)) {
7966 NMConnection *connection = nm_device_get_applied_connection (self);
7967 NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self));7981 NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self));
7968 NMSetting *s_ip4;7982 NMSetting *s_ip4;
79697983
7970 g_object_freeze_notify (G_OBJECT (connection));
7971 g_object_freeze_notify (G_OBJECT (settings_connection));7984 g_object_freeze_notify (G_OBJECT (settings_connection));
79727985
7973 nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP4_CONFIG);7986 nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP4_CONFIG);
7974 s_ip4 = nm_ip4_config_create_setting (priv->ip4_config);7987 s_ip4 = nm_ip4_config_create_setting (priv->ip4_config);
7975 nm_connection_add_setting (settings_connection, s_ip4);7988 nm_connection_add_setting (settings_connection, s_ip4);
79767989
7977 nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
7978 s_ip4 = nm_ip4_config_create_setting (priv->ip4_config);
7979 nm_connection_add_setting (connection, s_ip4);
7980
7981 g_object_thaw_notify (G_OBJECT (settings_connection));7990 g_object_thaw_notify (G_OBJECT (settings_connection));
7982 g_object_thaw_notify (G_OBJECT (connection));
7983 }7991 }
79847992
7985 nm_device_queue_recheck_assume (self);7993 nm_device_queue_recheck_assume (self);
@@ -8128,23 +8136,16 @@ nm_device_set_ip6_config (NMDevice *self,
8128 nm_exported_object_clear_and_unexport (&old_config);8136 nm_exported_object_clear_and_unexport (&old_config);
81298137
8130 if (nm_device_uses_generated_assumed_connection (self)) {8138 if (nm_device_uses_generated_assumed_connection (self)) {
8131 NMConnection *connection = nm_device_get_applied_connection (self);
8132 NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self));8139 NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self));
8133 NMSetting *s_ip6;8140 NMSetting *s_ip6;
81348141
8135 g_object_freeze_notify (G_OBJECT (connection));
8136 g_object_freeze_notify (G_OBJECT (settings_connection));8142 g_object_freeze_notify (G_OBJECT (settings_connection));
81378143
8138 nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP6_CONFIG);8144 nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP6_CONFIG);
8139 s_ip6 = nm_ip6_config_create_setting (priv->ip6_config);8145 s_ip6 = nm_ip6_config_create_setting (priv->ip6_config);
8140 nm_connection_add_setting (settings_connection, s_ip6);8146 nm_connection_add_setting (settings_connection, s_ip6);
81418147
8142 nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
8143 s_ip6 = nm_ip6_config_create_setting (priv->ip6_config);
8144 nm_connection_add_setting (connection, s_ip6);
8145
8146 g_object_thaw_notify (G_OBJECT (settings_connection));8148 g_object_thaw_notify (G_OBJECT (settings_connection));
8147 g_object_thaw_notify (G_OBJECT (connection));
8148 }8149 }
81498150
8150 nm_device_queue_recheck_assume (self);8151 nm_device_queue_recheck_assume (self);

Subscribers

People subscribed via source and target branches