Commit a24b9b52 authored by Dan Williams's avatar Dan Williams

core: ignore errors when replacing a default route that already exists

If  the route already exists and the kernel tells us that, we
don't need to do anything.  We certainly don't need to warn
about it in the logs.

There was a typo in the IPv6 default route replace function that
ignored a returned error, and thus we didn't suppress the NLE_EXIST
error like we wanted to.  Do the same for the IPv4 default route
while we're at it.
parent c4758ef3
......@@ -849,7 +849,7 @@ replace_default_ip4_route (int ifindex, guint32 gw, guint32 mss)
struct rtnl_route *route = NULL;
struct nl_sock *nlh;
int err = -1;
int dst=0;
int dst = 0;
g_return_val_if_fail (ifindex > 0, -ENODEV);
......@@ -864,6 +864,8 @@ replace_default_ip4_route (int ifindex, guint32 gw, guint32 mss)
/* Add the new default route */
err = nm_netlink_route_add (route, AF_INET, &dst, 0, &gw, NLM_F_REPLACE);
if (err == -NLE_EXIST)
err = 0;
rtnl_route_put (route);
return err;
......@@ -1033,7 +1035,7 @@ replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
g_return_val_if_fail (route != NULL, -ENOMEM);
/* Add the new default route */
nm_netlink_route_add(route, AF_INET6, NULL, 0, gw, NLM_F_REPLACE);
err = nm_netlink_route_add (route, AF_INET6, NULL, 0, gw, NLM_F_REPLACE);
if (err == -NLE_EXIST) {
/* FIXME: even though we use NLM_F_REPLACE the kernel won't replace
* the route if it's the same. Should try to remove it first, then
......@@ -1064,6 +1066,9 @@ nm_system_replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
if (err == 0)
return TRUE;
if (err == -NLE_EXIST)
return TRUE;
iface = nm_netlink_index_to_iface (ifindex);
if (!iface)
goto out;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment