mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 10:08:05 +02:00
fake-platform: move route deletion above addition
No change in behavior.
We'll need it when we'll remove routes that clash upon addition.
(cherry picked from commit 1ee03eeb5a)
This commit is contained in:
parent
99c2980a65
commit
a3ff3fbbc0
1 changed files with 48 additions and 48 deletions
|
|
@ -1057,6 +1057,54 @@ ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mod
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen, guint32 metric)
|
||||||
|
{
|
||||||
|
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < priv->ip4_routes->len; i++) {
|
||||||
|
NMPlatformIP4Route *route = &g_array_index (priv->ip4_routes, NMPlatformIP4Route, i);
|
||||||
|
NMPlatformIP4Route deleted_route;
|
||||||
|
|
||||||
|
if ( route->ifindex != ifindex
|
||||||
|
|| route->network != network
|
||||||
|
|| route->plen != plen
|
||||||
|
|| route->metric != metric)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memcpy (&deleted_route, route, sizeof (deleted_route));
|
||||||
|
g_array_remove_index (priv->ip4_routes, i);
|
||||||
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, int plen, guint32 metric)
|
||||||
|
{
|
||||||
|
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < priv->ip6_routes->len; i++) {
|
||||||
|
NMPlatformIP6Route *route = &g_array_index (priv->ip6_routes, NMPlatformIP6Route, i);
|
||||||
|
NMPlatformIP6Route deleted_route;
|
||||||
|
|
||||||
|
if ( route->ifindex != ifindex
|
||||||
|
|| !IN6_ARE_ADDR_EQUAL (&route->network, &network)
|
||||||
|
|| route->plen != plen
|
||||||
|
|| route->metric != metric)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memcpy (&deleted_route, route, sizeof (deleted_route));
|
||||||
|
g_array_remove_index (priv->ip6_routes, i);
|
||||||
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
||||||
in_addr_t network, int plen, in_addr_t gateway,
|
in_addr_t network, int plen, in_addr_t gateway,
|
||||||
|
|
@ -1183,54 +1231,6 @@ ip6_route_get (NMPlatform *platform, int ifindex, struct in6_addr network, int p
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen, guint32 metric)
|
|
||||||
{
|
|
||||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->ip4_routes->len; i++) {
|
|
||||||
NMPlatformIP4Route *route = &g_array_index (priv->ip4_routes, NMPlatformIP4Route, i);
|
|
||||||
NMPlatformIP4Route deleted_route;
|
|
||||||
|
|
||||||
if ( route->ifindex != ifindex
|
|
||||||
|| route->network != network
|
|
||||||
|| route->plen != plen
|
|
||||||
|| route->metric != metric)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
memcpy (&deleted_route, route, sizeof (deleted_route));
|
|
||||||
g_array_remove_index (priv->ip4_routes, i);
|
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, int plen, guint32 metric)
|
|
||||||
{
|
|
||||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < priv->ip6_routes->len; i++) {
|
|
||||||
NMPlatformIP6Route *route = &g_array_index (priv->ip6_routes, NMPlatformIP6Route, i);
|
|
||||||
NMPlatformIP6Route deleted_route;
|
|
||||||
|
|
||||||
if ( route->ifindex != ifindex
|
|
||||||
|| !IN6_ARE_ADDR_EQUAL (&route->network, &network)
|
|
||||||
|| route->plen != plen
|
|
||||||
|| route->metric != metric)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
memcpy (&deleted_route, route, sizeof (deleted_route));
|
|
||||||
g_array_remove_index (priv->ip6_routes, i);
|
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
ip4_route_exists (NMPlatform *platform, int ifindex, in_addr_t network, int plen, guint32 metric)
|
ip4_route_exists (NMPlatform *platform, int ifindex, in_addr_t network, int plen, guint32 metric)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue