From a24b9b5299ff8ed9a89df0a6c894377507594a19 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 16 Jan 2012 10:27:21 -0600 Subject: [PATCH] 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. --- src/nm-system.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nm-system.c b/src/nm-system.c index 75d2c9fc9c..08f5084da7 100644 --- a/src/nm-system.c +++ b/src/nm-system.c @@ -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;