summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-16 14:17:27 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-16 14:17:27 -0700
commit62227966dc8deb2fb5a4480dce00e525c56eabd7 (patch)
treeaee682d16c46590ea2c7e7d841ebaa58c3b8c0cd /zebra
parent38701029fe978ca18645408771414a91588413d3 (diff)
downloadquagga-62227966dc8deb2fb5a4480dce00e525c56eabd7.tar.bz2
quagga-62227966dc8deb2fb5a4480dce00e525c56eabd7.tar.xz
Handle races with add/delete of routes
Adding a route that already exists, or deleting a route that is already gone, should not be an error.
Diffstat (limited to 'zebra')
-rw-r--r--zebra/rt_netlink.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index c6ec08c6..ba66ab90 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -327,6 +327,8 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *),
if (h->nlmsg_type == NLMSG_ERROR)
{
struct nlmsgerr *err = (struct nlmsgerr *) NLMSG_DATA (h);
+ int errnum = err->error;
+ int msg_type = err->msg.nlmsg_type;
/* If the error field is zero, then this is an ACK */
if (err->error == 0)
@@ -355,33 +357,24 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *),
return -1;
}
- /* Deal with Error Noise - MAG */
- {
- int loglvl = LOG_ERR;
- int errnum = err->error;
- int msg_type = err->msg.nlmsg_type;
-
- if (nl == &netlink_cmd
- && (-errnum == ENODEV || -errnum == ESRCH)
- && (msg_type == RTM_NEWROUTE || msg_type == RTM_DELROUTE))
- {
- /* These errors are normal during link transistion */
- if (IS_ZEBRA_DEBUG_KERNEL)
- loglvl = LOG_DEBUG;
- else
- return -1;
- }
-
- zlog (NULL, loglvl, "%s error: %s, type=%s(%u), "
- "seq=%u, pid=%u",
- nl->name, safe_strerror (-errnum),
- lookup (nlmsg_str, msg_type),
- msg_type, err->msg.nlmsg_seq, err->msg.nlmsg_pid);
- }
- /*
- ret = -1;
- continue;
- */
+ /* Deal with errors that occur because of races in link handling */
+ if (nl == &netlink_cmd
+ && ((msg_type == RTM_DELROUTE &&
+ (-errnum == ENODEV || -errnum == ESRCH))
+ || (msg_type == RTM_NEWROUTE && -errnum == EEXIST)))
+ {
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug ("%s: error: %s type=%s(%u), seq=%u, pid=%u",
+ nl->name, safe_strerror (-errnum),
+ lookup (nlmsg_str, msg_type),
+ msg_type, err->msg.nlmsg_seq, err->msg.nlmsg_pid);
+ return 0;
+ }
+
+ zlog_err ("%s error: %s, type=%s(%u), seq=%u, pid=%u",
+ nl->name, safe_strerror (-errnum),
+ lookup (nlmsg_str, msg_type),
+ msg_type, err->msg.nlmsg_seq, err->msg.nlmsg_pid);
return -1;
}