wtap(4): Fix bug in wtap_node_write() and wtap_vap_create()
authorEn-Wei Wu <enweiwu@FreeBSD.org>
Mon, 1 Aug 2022 19:40:13 +0000 (19:40 +0000)
committerBjoern A. Zeeb <bz@FreeBSD.org>
Mon, 1 Aug 2022 19:40:13 +0000 (19:40 +0000)
commitfb1526ca278301a495ea547ba18e22c4509e36e5
tree02dab9bae0f613a2e51c756203337ae9fbd2eb55
parent2c4276aaa2d03217b9c1797196864bbbe4f2d8ea
wtap(4): Fix bug in wtap_node_write() and wtap_vap_create()

Originally, wtap_node_write() gets the wrong softc by iterating V_inet and
gets the ifp by string comparison, then gets softc by ifp->if_softc.
However, ifp->if_softc will not point to the correct softc owned by
ieee80211com, and thus causes a kernel panic.
Fix it by assigning softc to cdev's si_drv1 in wtap_vap_create()
and get the softc directly via dev->si_drv1 in wtap_node_write().

The cdev created by wtap_vap_create() use the name of ieee80211com
rather than the vap's name. It will cause the second vap based on
the same ieee80211com as first vap fail to create a device node
because the device node is already exists. Fix it by assigning
vap->iv_ifp->if_xname to cdev's name.

Sponsored by: Google, Inc. (GSoC 2022)
Reviewed by: adrian, cy, bz
Differential Revision: https://reviews.freebsd.org/D35752
sys/dev/wtap/if_wtap.c