aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenlei Huang <zlei@FreeBSD.org>2024-10-22 04:32:24 +0000
committerZhenlei Huang <zlei@FreeBSD.org>2024-11-07 16:32:16 +0000
commit5b8e4b1c123ec3cb779a5563d672b62be1c94065 (patch)
tree7082f7668f1e4f0b9eea4484f470f223212eddc8
parent56d38dda6b909031995bac73d166efa1b6cccb26 (diff)
ifnet: Assert that we are assigning network stack correctly
It makes no sense to assign NULL vnet to an interface when the kernel option VIMAGE is enabled. Add an assertion to catch that. This will also help diagnosing problem report [1] and [2]. 1. https://bugs.freebsd.org/275381 2. https://bugs.freebsd.org/282168 Reviewed by: kp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46982 (cherry picked from commit d1d839d0b593541174ca48c675c9eff4ddb4715e) (cherry picked from commit 2f3c87296cc727fc21fbb4d549deaed7dfa2fef1)
-rw-r--r--sys/net/if.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 8a870bb4e1bc..107ff67d547a 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -864,6 +864,7 @@ if_attach_internal(struct ifnet *ifp, bool vmove)
ifp->if_xname);
#ifdef VIMAGE
+ CURVNET_ASSERT_SET();
ifp->if_vnet = curvnet;
if (ifp->if_home_vnet == NULL)
ifp->if_home_vnet = curvnet;