From: Pali Rohár Date: Sat, 7 Aug 2021 17:48:01 +0000 (+0200) Subject: pppd: Retry registering interface when on rtnetlink -EBUSY error X-Git-Tag: ppp-2.5.0~24^2 X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;h=089687fbcc6524809ae9f4b2f8145fe3c2a91147;p=ppp.git 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 --- 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