git: 2f3c87296cc7 - stable/14 - ifnet: Assert that we are assigning network stack correctly
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 31 Oct 2024 04:43:52 UTC
The branch stable/14 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=2f3c87296cc727fc21fbb4d549deaed7dfa2fef1
commit 2f3c87296cc727fc21fbb4d549deaed7dfa2fef1
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-10-22 04:32:24 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-10-31 04:40:16 +0000
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)
---
sys/net/if.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sys/net/if.c b/sys/net/if.c
index fe51ba5a0b60..edc7d8376bbf 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -834,6 +834,7 @@ if_attach_internal(struct ifnet *ifp, bool vmove)
MPASS(ifindex_table[ifp->if_index].ife_ifnet == ifp);
#ifdef VIMAGE
+ CURVNET_ASSERT_SET();
ifp->if_vnet = curvnet;
if (ifp->if_home_vnet == NULL)
ifp->if_home_vnet = curvnet;