Module Name: src
Committed By: riastradh
Date: Thu Mar 3 05:55:10 UTC 2022
Modified Files:
src/sys/dev/usb: usbnet.c
Log Message:
usbnet: Do nothing on if_init/stop if already in the target state.
The network stack _shouldn't_ ever call us if so, but I'm not yet
sure it _won't_.
To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/usb/usbnet.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.84 src/sys/dev/usb/usbnet.c:1.85
--- src/sys/dev/usb/usbnet.c:1.84 Thu Mar 3 05:54:52 2022
+++ src/sys/dev/usb/usbnet.c Thu Mar 3 05:55:10 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: usbnet.c,v 1.84 2022/03/03 05:54:52 riastradh Exp $ */
+/* $NetBSD: usbnet.c,v 1.85 2022/03/03 05:55:10 riastradh Exp $ */
/*
* Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.84 2022/03/03 05:54:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.85 2022/03/03 05:55:10 riastradh Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -1162,6 +1162,16 @@ usbnet_if_stop(struct ifnet *ifp, int di
KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
+ /*
+ * If we're already stopped, nothing to do.
+ *
+ * XXX This should be an assertion, but it may require some
+ * analysis -- and possibly some tweaking -- of sys/net to
+ * ensure.
+ */
+ if ((ifp->if_flags & IFF_RUNNING) == 0)
+ return;
+
mutex_enter(&unp->unp_core_lock);
usbnet_stop(un, ifp, disable);
mutex_exit(&unp->unp_core_lock);
@@ -1263,6 +1273,16 @@ usbnet_if_init(struct ifnet *ifp)
if (usbnet_isdying(un))
return EIO;
+ /*
+ * If we're already running, nothing to do.
+ *
+ * XXX This should be an assertion, but it may require some
+ * analysis -- and possibly some tweaking -- of sys/net to
+ * ensure.
+ */
+ if (ifp->if_flags & IFF_RUNNING)
+ return 0;
+
mutex_enter(&un->un_pri->unp_core_lock);
error = uno_init(un, ifp);
mutex_exit(&un->un_pri->unp_core_lock);