Skip to content

Commit

Permalink
cps: correct returned error code for RTM_DELROUTE
Browse files Browse the repository at this point in the history
Although the Linux kernel uses ENOENT for similar situations (e.g.
when RTM_NEWROUTE tries to replace an entry that does not exist),
it uses ESRCH for RTM_DELROUTE.  Thus, this patch replaces ENOENT
with ESRCH when returning a not-found error for RTM_DELROUTE.

This patch was motivated by many enigmatic log entries from Bird
like this one:
<DATE> <SERVER> bird[<PID>]: Netlink: No such file or directory
  • Loading branch information
AltraMayor committed Sep 15, 2021
1 parent 1ee27cb commit 538665f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions cps/rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,31 @@ static int
del_route(struct route_update *update, const struct cps_config *cps_conf)
{
struct gk_fib *prefix_fib;
int ret;

ret = get_prefix_fib(update, &cps_conf->gk->lpm_tbl, &prefix_fib);
int ret = get_prefix_fib(update, &cps_conf->gk->lpm_tbl, &prefix_fib);
if (ret < 0)
return ret;
goto error;

if (prefix_fib == NULL)
return -ENOENT;
if (prefix_fib == NULL) {
ret = -ENOENT;
goto error;
}

ret = can_rd_del_route(update, prefix_fib);
if (ret < 0)
return ret;
goto error;

return del_fib_entry_numerical(&update->prefix_info, cps_conf->gk);
ret = del_fib_entry_numerical(&update->prefix_info, cps_conf->gk);

error:
/*
* Although the Linux kernel uses ENOENT for similar situations (e.g.
* when RTM_NEWROUTE tries to replace an entry that does not exist),
* it uses ESRCH for RTM_DELROUTE.
*/
if (ret == -ENOENT)
return -ESRCH;
return ret;
}

/*
Expand Down

0 comments on commit 538665f

Please sign in to comment.