Prevent wg(4) stuck on peer destruction.
authormvs <mvs@openbsd.org>
Mon, 23 Oct 2023 10:22:05 +0000 (10:22 +0000)
committermvs <mvs@openbsd.org>
Mon, 23 Oct 2023 10:22:05 +0000 (10:22 +0000)
commit8c2c9fccf09e41746c89a6d9626accd14d0bde1a
treea6e9781b63dfad44fe72717cc341450a99d77c7b
parent3ca40aab63590c51ed84101105e72153dfe25327
Prevent wg(4) stuck on peer destruction.

While interface going down and output stopped, packets could rest in
`if_snd' queue. So the (!ifq_empty(&sc->sc_if.if_snd)) condition will
always be true and wg_peer_destroy() will sleep until interface became
up and stuck packets transmitted.

Check IFF_RUNNING flag within (!ifq_empty(&sc->sc_if.if_snd)) loop in
wg_peer_destroy(). If the flag is not set that means interface is down,
so drain the `if_snd' queue manually to prevent wg_peer_destroy() stuck.

Problem reported and fix tested by Kirill Miazine.

ok bluhm@
sys/net/if_wg.c