diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-07-21 10:42:04 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-08-08 09:50:35 +0200 |
commit | b9e6433a024c13631c984797c964f1863de83113 (patch) | |
tree | 21e00fcc9ab6364b5de112e4496852329a2e5445 /src/nm-ip4-config.c | |
parent | 9ca56089ebdb09e4f30e277164cfa03746892e6b (diff) |
core: handle route metric when reapplying dynamic IP methods
For dynamic IP methods (DHCP, IPv4LL, WWAN) the route metric is set at
activation/renewal time using the value from static configuration. To
support runtime change we need to update the dynamic configuration in
place and tell the DHCP client the new value to use for future
renewals.
https://bugzilla.redhat.com/show_bug.cgi?id=1528071
Diffstat (limited to 'src/nm-ip4-config.c')
-rw-r--r-- | src/nm-ip4-config.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index caae660464..1edd3257af 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -648,6 +648,37 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i } void +nm_ip4_config_update_routes_metric (NMIP4Config *self, gint64 metric) +{ + gs_free NMPlatformIP4Route *routes = NULL; + gboolean need_update = FALSE; + const NMPlatformIP4Route *r; + NMDedupMultiIter iter; + guint num = 0, i = 0; + + nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) { + if (r->metric != metric) + need_update = TRUE; + num++; + } + if (!need_update) + return; + + routes = g_new (NMPlatformIP4Route, num); + nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) { + routes[i] = *r; + routes[i].metric = metric; + i++; + } + + g_object_freeze_notify (G_OBJECT (self)); + nm_ip4_config_reset_routes (self); + for (i = 0; i < num; i++) + nm_ip4_config_add_route (self, &routes[i], NULL); + g_object_thaw_notify (G_OBJECT (self)); +} + +void nm_ip4_config_add_dependent_routes (NMIP4Config *self, guint32 route_table, guint32 route_metric, |