mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 15:20:08 +01:00
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.
This commit is contained in:
parent
695ce608ba
commit
1867746e6c
3 changed files with 45 additions and 7 deletions
|
|
@ -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);
|
||||
|
|
@ -1025,6 +1035,23 @@ nm_l3_config_data_set_llmnr (NML3ConfigData *self,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue