summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-30 15:49:07 +0200
committerThomas Haller <thaller@redhat.com>2019-07-29 18:39:49 +0200
commit9d88f0d73f8a0239f3023851b80a3c5db5800883 (patch)
tree317bffaaec86c325b6da9b1950f1fa66fc3172c3
parent40ae1c8d7d2cea480ef26f32513937ec43d3f70a (diff)
downloadNetworkManager-9d88f0d73f8a0239f3023851b80a3c5db5800883.tar.gz
device: allow device classes to overwrite the route-table
-rw-r--r--src/devices/nm-device.c28
-rw-r--r--src/devices/nm-device.h7
2 files changed, 27 insertions, 8 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index d4bee8780a..01e00a7107 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -2265,9 +2265,11 @@ _get_route_table (NMDevice *self,
int addr_family)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ NMDeviceClass *klass;
NMConnection *connection;
NMSettingIPConfig *s_ip;
guint32 route_table = 0;
+ gboolean is_user_config = TRUE;
nm_assert_addr_family (addr_family);
@@ -2288,16 +2290,26 @@ _get_route_table (NMDevice *self,
route_table = nm_setting_ip_config_get_route_table (s_ip);
}
if (route_table == 0u) {
- route_table = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
- addr_family == AF_INET
- ? NM_CON_DEFAULT ("ipv4.route-table")
- : NM_CON_DEFAULT ("ipv6.route-table"),
- self,
- 0,
- G_MAXUINT32,
- 0);
+ gint64 v;
+
+ v = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ addr_family == AF_INET
+ ? NM_CON_DEFAULT ("ipv4.route-table")
+ : NM_CON_DEFAULT ("ipv6.route-table"),
+ self,
+ 0,
+ G_MAXUINT32,
+ -1);
+ if (v != -1) {
+ route_table = v;
+ is_user_config = FALSE;
+ }
}
+ klass = NM_DEVICE_GET_CLASS (self);
+ if (klass->coerce_route_table)
+ route_table = klass->coerce_route_table (self, addr_family, route_table, is_user_config);
+
if (addr_family == AF_INET) {
priv->v4_route_table_initialized = TRUE;
priv->v4_route_table = route_table;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 40639987e4..ae6aab392a 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -337,6 +337,13 @@ typedef struct _NMDeviceClass {
guint32 (*get_configured_mtu) (NMDevice *self, NMDeviceMtuSource *out_source);
+ /* allow the subclass to overwrite the routing table. This is mainly useful
+ * to change from partial mode (route-table=0) to full-sync mode (route-table=254). */
+ guint32 (*coerce_route_table) (NMDevice *self,
+ int addr_family,
+ guint32 route_table,
+ gboolean is_user_config);
+
const char *(*get_auto_ip_config_method) (NMDevice *self, int addr_family);
/* Checks whether the connection is compatible with the device using