summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-08-07 19:48:01 +0200
committerPali Rohár <pali@kernel.org>2022-08-19 01:20:14 +0200
commit089687fbcc6524809ae9f4b2f8145fe3c2a91147 (patch)
tree920e026dc9af6933ece436eabda912640460bbee
parent87640b7b5ceb562146a1c4b820c7e151ff078eec (diff)
downloadppp-089687fbcc6524809ae9f4b2f8145fe3c2a91147.tar.gz
pppd: Retry registering interface when on rtnetlink -EBUSY error
Due to workaround in kernel module ppp_generic.ko in function ppp_nl_newlink(), kernel may return -EBUSY error to prevent possible mutex deadlock. In this case userspace needs to retry its request. Proper way would be to fix kernel module to order requests and mutex locking, so prevent deadlock in kernel and so never return this error to userspace. Until it happens we need retry code in userspace. Signed-off-by: Pali Rohár <pali@kernel.org>
-rw-r--r--pppd/sys-linux.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
index dc3b4d6..7beb977 100644
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -864,7 +864,14 @@ static int make_ppp_unit_rtnetlink(void)
nlreq.ifli.ifid.ifdata[0].rta.rta_type = IFLA_PPP_DEV_FD;
nlreq.ifli.ifid.ifdata[0].ppp.ppp_dev_fd = ppp_dev_fd;
- resp = rtnetlink_msg("RTM_NEWLINK/NLM_F_CREATE", NULL, &nlreq, sizeof(nlreq), NULL, NULL, 0);
+ /*
+ * See kernel function ppp_nl_newlink(), which may return -EBUSY to prevent
+ * possible deadlock in kernel and ask userspace to retry request again.
+ */
+ do {
+ resp = rtnetlink_msg("RTM_NEWLINK/NLM_F_CREATE", NULL, &nlreq, sizeof(nlreq), NULL, NULL, 0);
+ } while (resp == -EBUSY);
+
if (resp) {
/*
* Linux kernel versions prior to 4.7 do not support creating ppp