summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-07-28 10:01:19 +0200
committerThomas Haller <thaller@redhat.com>2020-07-31 08:53:06 +0200
commit1867746e6cb99cfa67c1bf76bc83a2999526003e (patch)
tree25bbbe99f655e67643919d63594b32818f0ad057
parent695ce608bafb8a05d704b6705150cce10e869fe9 (diff)
downloadNetworkManager-1867746e6cb99cfa67c1bf76bc83a2999526003e.tar.gz
l3cfg: track route-table sync mode in NML3ConfigData
Currently, we track the route table sync mode outside of the settings. But as it depends on configuration, we should track it in NML3ConfigData.
-rw-r--r--src/nm-l3-config-data.c46
-rw-r--r--src/nm-l3-config-data.h4
-rw-r--r--src/nm-types.h2
3 files changed, 45 insertions, 7 deletions
diff --git a/src/nm-l3-config-data.c b/src/nm-l3-config-data.c
index 7adcf15ed7..b46e1fe2ad 100644
--- a/src/nm-l3-config-data.c
+++ b/src/nm-l3-config-data.c
@@ -96,6 +96,14 @@ struct _NML3ConfigData {
int dns_priority_x[2];
};
+ union {
+ struct {
+ NMIPRouteTableSyncMode route_table_sync_6;
+ NMIPRouteTableSyncMode route_table_sync_4;
+ };
+ NMIPRouteTableSyncMode route_table_sync_x[2];
+ };
+
NMSettingConnectionMdns mdns;
NMSettingConnectionLlmnr llmnr;
@@ -359,13 +367,15 @@ nm_l3_config_data_new (NMDedupMultiIndex *multi_idx,
self = g_slice_new (NML3ConfigData);
*self = (NML3ConfigData) {
- .ref_count = 1,
- .ifindex = ifindex,
- .multi_idx = nm_dedup_multi_index_ref (multi_idx),
- .mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT,
- .llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT,
- .flags = NM_L3_CONFIG_DAT_FLAGS_NONE,
- .metered = NM_TERNARY_DEFAULT,
+ .ref_count = 1,
+ .ifindex = ifindex,
+ .multi_idx = nm_dedup_multi_index_ref (multi_idx),
+ .mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT,
+ .llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT,
+ .flags = NM_L3_CONFIG_DAT_FLAGS_NONE,
+ .metered = NM_TERNARY_DEFAULT,
+ .route_table_sync_4 = NM_IP_ROUTE_TABLE_SYNC_MODE_NONE,
+ .route_table_sync_6 = NM_IP_ROUTE_TABLE_SYNC_MODE_NONE,
};
_idx_type_init (&self->idx_addresses_4, NMP_OBJECT_TYPE_IP4_ADDRESS);
@@ -1026,6 +1036,23 @@ nm_l3_config_data_set_llmnr (NML3ConfigData *self,
}
gboolean
+nm_l3_config_data_set_route_table_sync (NML3ConfigData *self,
+ int addr_family,
+ NMIPRouteTableSyncMode route_table_sync)
+{
+ const gboolean IS_IPv4 = NM_IS_IPv4 (addr_family);
+
+ nm_assert (_NM_IS_L3_CONFIG_DATA (self, FALSE));
+ nm_assert_addr_family (addr_family);
+
+ if (self->route_table_sync_x[IS_IPv4] == route_table_sync)
+ return FALSE;
+
+ self->route_table_sync_x [IS_IPv4] = route_table_sync;
+ return TRUE;
+}
+
+gboolean
nm_l3_config_data_set_metered (NML3ConfigData *self,
NMTernary metered)
{
@@ -1123,6 +1150,8 @@ nm_l3_config_data_cmp (const NML3ConfigData *a, const NML3ConfigData *b)
if (NM_FLAGS_ANY (a->flags, NM_L3_CONFIG_DAT_FLAGS_HAS_DNS_PRIORITY (IS_IPv4)))
NM_CMP_DIRECT (a->dns_priority_x[IS_IPv4], b->dns_priority_x[IS_IPv4]);
+
+ NM_CMP_DIRECT (a->route_table_sync_x[IS_IPv4], b->route_table_sync_x[IS_IPv4]);
}
NM_CMP_RETURN (_garray_inaddr_cmp (a->wins, b->wins, AF_INET));
@@ -1823,6 +1852,9 @@ _init_merge (NML3ConfigData *self,
self->dns_priority_x[IS_IPv4] = src->dns_priority_x[IS_IPv4];
self->flags |= has_dns_priority_flag;
}
+
+ if (self->route_table_sync_x[IS_IPv4] == NM_IP_ROUTE_TABLE_SYNC_MODE_NONE)
+ self->route_table_sync_x[IS_IPv4] = src->route_table_sync_x[IS_IPv4];
}
if (!NM_FLAGS_HAS (merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_DNS)) {
diff --git a/src/nm-l3-config-data.h b/src/nm-l3-config-data.h
index 84c33db163..127f73e0d5 100644
--- a/src/nm-l3-config-data.h
+++ b/src/nm-l3-config-data.h
@@ -301,6 +301,10 @@ gboolean nm_l3_config_data_set_mdns (NML3ConfigData *self,
gboolean nm_l3_config_data_set_llmnr (NML3ConfigData *self,
NMSettingConnectionLlmnr llmnr);
+gboolean nm_l3_config_data_set_route_table_sync (NML3ConfigData *self,
+ int addr_family,
+ NMIPRouteTableSyncMode route_table_sync);
+
gboolean nm_l3_config_data_set_metered (NML3ConfigData *self,
NMTernary metered);
diff --git a/src/nm-types.h b/src/nm-types.h
index 9624bfa877..5d9eb67dc4 100644
--- a/src/nm-types.h
+++ b/src/nm-types.h
@@ -272,6 +272,7 @@ typedef enum {
/**
* NMIPRouteTableSyncMode:
+ * @NM_IP_ROUTE_TABLE_SYNC_MODE_NONE: indicate an invalid setting.
* @NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN: only the main table is synced. For all
* other tables, NM won't delete any extra routes.
* @NM_IP_ROUTE_TABLE_SYNC_MODE_FULL: NM will sync all tables, except the
@@ -280,6 +281,7 @@ typedef enum {
* local table (255).
*/
typedef enum {
+ NM_IP_ROUTE_TABLE_SYNC_MODE_NONE = 0,
NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN = 1,
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL = 2,
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL = 3,