core: add NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE mode
When we deactivate a device, we flush all IP addresses and routes. Thus, have yet another sync mode for that. It will sync more than "ALL".
This commit is contained in:
@@ -4318,7 +4318,8 @@ nm_platform_ip_route_get_prune_list(NMPlatform * self,
|
|||||||
nm_assert(NM_IN_SET(route_table_sync,
|
nm_assert(NM_IN_SET(route_table_sync,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN,
|
NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL,
|
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL));
|
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL,
|
||||||
|
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE));
|
||||||
|
|
||||||
nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family)), ifindex);
|
nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family)), ifindex);
|
||||||
head_entry = nm_platform_lookup(self, &lookup);
|
head_entry = nm_platform_lookup(self, &lookup);
|
||||||
@@ -4330,16 +4331,24 @@ nm_platform_ip_route_get_prune_list(NMPlatform * self,
|
|||||||
c_list_for_each (iter, &head_entry->lst_entries_head) {
|
c_list_for_each (iter, &head_entry->lst_entries_head) {
|
||||||
const NMPObject *obj = c_list_entry(iter, NMDedupMultiEntry, lst_entries)->obj;
|
const NMPObject *obj = c_list_entry(iter, NMDedupMultiEntry, lst_entries)->obj;
|
||||||
|
|
||||||
if (route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_FULL) {
|
switch (route_table_sync) {
|
||||||
if (nm_platform_ip_route_get_effective_table(NMP_OBJECT_CAST_IP_ROUTE(obj))
|
case NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN:
|
||||||
== RT_TABLE_LOCAL)
|
|
||||||
continue;
|
|
||||||
} else if (route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN) {
|
|
||||||
if (!nm_platform_route_table_is_main(
|
if (!nm_platform_route_table_is_main(
|
||||||
nm_platform_ip_route_get_effective_table(NMP_OBJECT_CAST_IP_ROUTE(obj))))
|
nm_platform_ip_route_get_effective_table(NMP_OBJECT_CAST_IP_ROUTE(obj))))
|
||||||
continue;
|
continue;
|
||||||
} else
|
break;
|
||||||
nm_assert(route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_ALL);
|
case NM_IP_ROUTE_TABLE_SYNC_MODE_FULL:
|
||||||
|
if (nm_platform_ip_route_get_effective_table(NMP_OBJECT_CAST_IP_ROUTE(obj))
|
||||||
|
== RT_TABLE_LOCAL)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
case NM_IP_ROUTE_TABLE_SYNC_MODE_ALL:
|
||||||
|
case NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nm_assert_not_reached();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
g_ptr_array_add(routes_prune, (gpointer) nmp_object_ref(obj));
|
g_ptr_array_add(routes_prune, (gpointer) nmp_object_ref(obj));
|
||||||
}
|
}
|
||||||
@@ -4634,7 +4643,7 @@ nm_platform_ip_route_flush(NMPlatform *self, int addr_family, int ifindex)
|
|||||||
routes_prune = nm_platform_ip_route_get_prune_list(self,
|
routes_prune = nm_platform_ip_route_get_prune_list(self,
|
||||||
AF_INET,
|
AF_INET,
|
||||||
ifindex,
|
ifindex,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL);
|
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE);
|
||||||
success &= nm_platform_ip_route_sync(self, AF_INET, ifindex, NULL, routes_prune, NULL);
|
success &= nm_platform_ip_route_sync(self, AF_INET, ifindex, NULL, routes_prune, NULL);
|
||||||
}
|
}
|
||||||
if (NM_IN_SET(addr_family, AF_UNSPEC, AF_INET6)) {
|
if (NM_IN_SET(addr_family, AF_UNSPEC, AF_INET6)) {
|
||||||
@@ -4643,7 +4652,7 @@ nm_platform_ip_route_flush(NMPlatform *self, int addr_family, int ifindex)
|
|||||||
routes_prune = nm_platform_ip_route_get_prune_list(self,
|
routes_prune = nm_platform_ip_route_get_prune_list(self,
|
||||||
AF_INET6,
|
AF_INET6,
|
||||||
ifindex,
|
ifindex,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL);
|
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE);
|
||||||
success &= nm_platform_ip_route_sync(self, AF_INET6, ifindex, NULL, routes_prune, NULL);
|
success &= nm_platform_ip_route_sync(self, AF_INET6, ifindex, NULL, routes_prune, NULL);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
@@ -168,12 +168,16 @@ nmp_object_type_to_flags(NMPObjectType obj_type)
|
|||||||
* local table (255).
|
* local table (255).
|
||||||
* @NM_IP_ROUTE_TABLE_SYNC_MODE_ALL: NM will sync all tables, including the
|
* @NM_IP_ROUTE_TABLE_SYNC_MODE_ALL: NM will sync all tables, including the
|
||||||
* local table (255).
|
* local table (255).
|
||||||
|
* @NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE: NM will sync all tables (including
|
||||||
|
* the local table). It will thereby remove all addresses, that is during
|
||||||
|
* deactivation.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_NONE = 0,
|
NM_IP_ROUTE_TABLE_SYNC_MODE_NONE,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN = 1,
|
NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL = 2,
|
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL,
|
||||||
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL = 3,
|
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL,
|
||||||
|
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE,
|
||||||
} NMIPRouteTableSyncMode;
|
} NMIPRouteTableSyncMode;
|
||||||
|
|
||||||
#endif /* __NMP_FWD_H__ */
|
#endif /* __NMP_FWD_H__ */
|
||||||
|
Reference in New Issue
Block a user