diff options
author | Pavel Šimerda <psimerda@redhat.com> | 2013-08-01 00:13:10 +0200 |
---|---|---|
committer | Pavel Šimerda <psimerda@redhat.com> | 2013-08-01 18:09:03 +0200 |
commit | 5dd15bd4595dcc5ff838e10efbebbe1beff60edb (patch) | |
tree | dd89feb233a08d2df468f278cd971dc3d48e6a20 /src/platform/nm-fake-platform.c | |
parent | 42b4323902f21b15f7c9878524ddde4588d1dbc4 (diff) | |
download | NetworkManager-5dd15bd4595dcc5ff838e10efbebbe1beff60edb.tar.gz |
platform: don't check for route existence
This is the same we already did for nm-platform addresses in commit
68c3e1153c415111e9254c1086c82360c069bc92. It will help to avoid various
issues and is also a step towards support for route lifetimes.
Diffstat (limited to 'src/platform/nm-fake-platform.c')
-rw-r--r-- | src/platform/nm-fake-platform.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 8604f64aea..2027faa0d2 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -941,6 +941,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, in_addr_t network, int plen, { NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMPlatformIP4Route route; + guint i; memset (&route, 0, sizeof (route)); route.ifindex = ifindex; @@ -950,8 +951,22 @@ ip4_route_add (NMPlatform *platform, int ifindex, in_addr_t network, int plen, route.metric = metric; route.mss = mss; - g_array_append_val (priv->ip4_routes, route); + for (i = 0; i < priv->ip4_routes->len; i++) { + NMPlatformIP4Route *item = &g_array_index (priv->ip4_routes, NMPlatformIP4Route, i); + + if (item->ifindex != route.ifindex) + continue; + if (item->network != route.network) + continue; + if (item->plen != route.plen) + continue; + memcpy (item, &route, sizeof (route)); + g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_CHANGED, ifindex, &route); + return TRUE; + } + + g_array_append_val (priv->ip4_routes, route); g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_ADDED, ifindex, &route); return TRUE; @@ -963,6 +978,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, struct in6_addr network, int p { NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMPlatformIP6Route route; + guint i; memset (&route, 0, sizeof (route)); route.ifindex = ifindex; @@ -972,8 +988,22 @@ ip6_route_add (NMPlatform *platform, int ifindex, struct in6_addr network, int p route.metric = metric; route.mss = mss; - g_array_append_val (priv->ip6_routes, route); + for (i = 0; i < priv->ip6_routes->len; i++) { + NMPlatformIP6Route *item = &g_array_index (priv->ip6_routes, NMPlatformIP6Route, i); + + if (item->ifindex != route.ifindex) + continue; + if (!IN6_ARE_ADDR_EQUAL (&item->network, &route.network)) + continue; + if (item->plen != route.plen) + continue; + memcpy (item, &route, sizeof (route)); + g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_CHANGED, ifindex, &route); + return TRUE; + } + + g_array_append_val (priv->ip6_routes, route); g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_ADDED, ifindex, &route); return TRUE; |