git: 6766a47c0211 - stable/13 - vnet: add CURVNET_ASSERT_SET

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 11 Mar 2024 21:05:29 UTC
The branch stable/13 has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=6766a47c02117a4935c097dc8996c9faf7b42d4f

commit 6766a47c02117a4935c097dc8996c9faf7b42d4f
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-02-17 16:48:45 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-03-11 20:58:00 +0000

    vnet: add CURVNET_ASSERT_SET
    
    Reviewed by:    kp
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D34312
    
    (cherry picked from commit 75cde1f872a4dc2187e6d172e5a5e69a2b3a59cf)
---
 sys/net/vnet.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/net/vnet.h b/sys/net/vnet.h
index 12bf0d83c119..fb26077e694c 100644
--- a/sys/net/vnet.h
+++ b/sys/net/vnet.h
@@ -236,6 +236,10 @@ void vnet_log_recursion(struct vnet *, const char *, int);
 	curvnet = saved_vnet;
 #endif /* VNET_DEBUG */
 
+#define	CURVNET_ASSERT_SET()						\
+	VNET_ASSERT(curvnet != NULL, ("vnet is not set at %s:%d %s()",  \
+	    __FILE__, __LINE__, __func__))
+
 extern struct vnet *vnet0;
 #define	IS_DEFAULT_VNET(arg)	((arg) == vnet0)