Skip to content

Commit b17da86

Browse files
authored
pppd: Suppress spurious ESRCH on route removal (#550)
Signed-off-by: Jaco Kroon <[email protected]>
1 parent b514c2c commit b17da86

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pppd/sys-linux.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2176,12 +2176,15 @@ int _route_netlink(const char* op_fam, int operation, int family, unsigned metri
21762176
nlreq.metric.val = metric;
21772177

21782178
resp = rtnetlink_msg(op_fam, NULL, &nlreq, sizeof(nlreq), NULL, NULL, 0);
2179-
if (resp == 0)
2179+
/* In some cases the interface could be down already from kernel perspective,
2180+
* and routes already removed resulting in errno=ESRCH, treat as success */
2181+
if (resp == 0 || operation == RTM_DELROUTE && -resp == ESRCH)
21802182
return 1; /* success */
21812183

21822184
error("Unable to %s %s default route: %s", operation == RTM_NEWROUTE ? "add" : "remove",
21832185
family == AF_INET ? "IPv4" : "IPv6",
21842186
resp < 0 ? strerror(-resp) : "Netlink error");
2187+
21852188
return 0;
21862189
}
21872190
#define route_netlink(operation, family, metric) _route_netlink(#operation "/" #family, operation, family, metric)

0 commit comments

Comments
 (0)