diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-07-19 00:55:36 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-19 00:55:36 +0300 |
| commit | 214be6067128e5c1982c0b4ab1a950c287b05e3e (patch) | |
| tree | 61240d3466fc4f39ef2375cec0e7b1d1a288dda3 | |
| parent | 9e01deafb63f81dc67102602faa5ce6f3734773f (diff) | |
| parent | 1d67a133e31cfe0c6cff01a3417c1e7eb4eb6e38 (diff) | |
| download | accel-ppp-214be6067128e5c1982c0b4ab1a950c287b05e3e.tar.gz accel-ppp-214be6067128e5c1982c0b4ab1a950c287b05e3e.zip | |
Merge pull request #334 from nuclearcat/ppp-unit-fd-close-race
ppp: close unit fd only after session cleanup finishes
| -rw-r--r-- | accel-pppd/ppp/ppp.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c index 55d08bb7..cd726e17 100644 --- a/accel-pppd/ppp/ppp.c +++ b/accel-pppd/ppp/ppp.c @@ -273,7 +273,7 @@ static void destablish_ppp(struct ppp_t *ppp) if (ppp->ses.net != def_net) { if (net->move_link(def_net, ppp->ses.ifindex)) { log_ppp_warn("failed to attach to default namespace\n"); - triton_md_unregister_handler(&ppp->unit_hnd, 1); + triton_md_unregister_handler(&ppp->unit_hnd, 0); goto skip; } ppp->ses.net = def_net; @@ -286,7 +286,7 @@ static void destablish_ppp(struct ppp_t *ppp) strncpy(ifr.ifr_name, ppp->ses.ifname, IFNAMSIZ); if (net->sock_ioctl(SIOCSIFNAME, &ifr)) { log_ppp_warn("failed to rename ppp to default name\n"); - triton_md_unregister_handler(&ppp->unit_hnd, 1); + triton_md_unregister_handler(&ppp->unit_hnd, 0); goto skip; } } @@ -299,11 +299,18 @@ static void destablish_ppp(struct ppp_t *ppp) uc->fd = ppp->unit_fd; uc->unit_idx = ppp->ses.unit_idx; } else - triton_md_unregister_handler(&ppp->unit_hnd, 1); + triton_md_unregister_handler(&ppp->unit_hnd, 0); skip: ap_session_finished(&ppp->ses); + /* The unit fd is closed only after session cleanup (ip-down scripts, + * radattr removal) has finished, so the kernel cannot give the same + * unit index (and thus ifname) to a new session while cleanup still + * references the ifname. */ + if (!uc) + close(ppp->unit_fd); + ppp->unit_fd = -1; destroy_ppp_channel(ppp); |
