Skip to content

Commit 538665f

Browse files
committed
cps: correct returned error code for RTM_DELROUTE
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
1 parent 1ee27cb commit 538665f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

cps/rd.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,31 @@ static int
289289
del_route(struct route_update *update, const struct cps_config *cps_conf)
290290
{
291291
struct gk_fib *prefix_fib;
292-
int ret;
293292

294-
ret = get_prefix_fib(update, &cps_conf->gk->lpm_tbl, &prefix_fib);
293+
int ret = get_prefix_fib(update, &cps_conf->gk->lpm_tbl, &prefix_fib);
295294
if (ret < 0)
296-
return ret;
295+
goto error;
297296

298-
if (prefix_fib == NULL)
299-
return -ENOENT;
297+
if (prefix_fib == NULL) {
298+
ret = -ENOENT;
299+
goto error;
300+
}
300301

301302
ret = can_rd_del_route(update, prefix_fib);
302303
if (ret < 0)
303-
return ret;
304+
goto error;
304305

305-
return del_fib_entry_numerical(&update->prefix_info, cps_conf->gk);
306+
ret = del_fib_entry_numerical(&update->prefix_info, cps_conf->gk);
307+
308+
error:
309+
/*
310+
* Although the Linux kernel uses ENOENT for similar situations (e.g.
311+
* when RTM_NEWROUTE tries to replace an entry that does not exist),
312+
* it uses ESRCH for RTM_DELROUTE.
313+
*/
314+
if (ret == -ENOENT)
315+
return -ESRCH;
316+
return ret;
306317
}
307318

308319
/*

0 commit comments

Comments
 (0)