Index | Thread | Search

From:
Yuichiro NAITO <naito.yuichiro@gmail.com>
Subject:
iavf(4): NETLOCK is not necessary for getting media status.
To:
tech@openbsd.org
Date:
Thu, 04 Jul 2024 14:54:03 +0900

Download raw body.

Thread
  • Yuichiro NAITO:

    iavf(4): NETLOCK is not necessary for getting media status.

Hi. I see the following messages on my console, when I use iavf(4) on
my OpenBSD current.

```
# ifconfig iavf0
iavf0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0c:29:a2:be:06
        index 1 priority 0 llprio 3
splassert: iavf_media_status: want 2 have 0
splassert: iavf_media_status: want 2 have 0
        media: Ethernet autoselect (autoselect)
```

These messages are printed by NET_ASSERT_LOCKED macro in the
'sys/dev/pci/if_iavf.c'.


 952 static void
 953 iavf_media_status(struct ifnet *ifp, struct ifmediareq *ifm)
 954 {
 955         struct iavf_softc *sc = ifp->if_softc;
 956 
 957         NET_ASSERT_LOCKED();

iavf(4) is a virtual function driver of ixl(4). So, I checked changes of ixl(4)
related to media status change and found the following commit.

https://github.com/OpenBSD/src/commit/91afdc872fc385dceac799d2693b4a5e40e4abcc

The commit message says

`The netlock for SIOCSIFMEDIA and SIOCGIFMEDIA ioctl is not necessary.`.

It should be replaced with KERNEL_LOCK_ASSERT.
OK?

diff --git a/sys/dev/pci/if_iavf.c b/sys/dev/pci/if_iavf.c
index dc3ef72aecd..1a1902109bf 100644
--- a/sys/dev/pci/if_iavf.c
+++ b/sys/dev/pci/if_iavf.c
@@ -954,7 +954,7 @@ iavf_media_status(struct ifnet *ifp, struct ifmediareq *ifm)
 {
 	struct iavf_softc *sc = ifp->if_softc;
 
-	NET_ASSERT_LOCKED();
+	KERNEL_ASSERT_LOCKED();
 
 	ifm->ifm_status = sc->sc_media_status;
 	ifm->ifm_active = sc->sc_media_active;


-- 
Yuichiro NAITO (naito.yuichiro@gmail.com)