* Mechanism for marking a tunnel device as busy so that we can safely do some * orthogonal operations (such as operations on devices) without racing against * tun_destroy. tun_destroy will wait on the condvar if we're at all busy or * open, to be woken up when the condition is alleviated. */
| 344 | * open, to be woken up when the condition is alleviated. |
| 345 | */ |
| 346 | static int |
| 347 | tun_busy_locked(struct tuntap_softc *tp) |
| 348 | { |
| 349 | |
| 350 | TUN_LOCK_ASSERT(tp); |
| 351 | if ((tp->tun_flags & TUN_DYING) != 0) { |
| 352 | /* |
| 353 | * Perhaps unintuitive, but the device is busy going away. |
| 354 | * Other interpretations of EBUSY from tun_busy make little |
| 355 | * sense, since making a busy device even more busy doesn't |
| 356 | * sound like a problem. |
| 357 | */ |
| 358 | return (EBUSY); |
| 359 | } |
| 360 | |
| 361 | ++tp->tun_busy; |
| 362 | return (0); |
| 363 | } |
| 364 | |
| 365 | static void |
| 366 | tun_unbusy_locked(struct tuntap_softc *tp) |