From e35b502a1ddc0d8f6362397e031a49ebf562440d Mon Sep 17 00:00:00 2001 From: kn Date: Tue, 8 Nov 2022 18:43:22 +0000 Subject: [PATCH] Document ifc_list immutability Move up to comment explaining different locks to account for all structs. OK millert mvs --- sys/net/if.c | 7 ++++--- sys/net/if_var.h | 27 ++++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 99c19721a74..75f57394641 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.669 2022/11/08 17:57:47 kn Exp $ */ +/* $OpenBSD: if.c,v 1.670 2022/11/08 18:43:22 kn Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -228,8 +228,9 @@ void if_idxmap_remove(struct ifnet *); TAILQ_HEAD(, ifg_group) ifg_head = TAILQ_HEAD_INITIALIZER(ifg_head); -LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners); -int if_cloners_count; +LIST_HEAD(, if_clone) if_cloners = + LIST_HEAD_INITIALIZER(if_cloners); /* [I] list of clonable interfaces */ +int if_cloners_count; /* [I] number of clonable interfaces */ struct rwlock if_cloners_lock = RWLOCK_INITIALIZER("clonelk"); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 28514a0bfcd..bf4adfbc744 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.117 2022/09/08 10:22:06 kn Exp $ */ +/* $OpenBSD: if_var.h,v 1.118 2022/11/08 18:43:22 kn Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -73,6 +73,18 @@ * interfaces. These routines live in the files if.c and route.c */ +/* + * Locks used to protect struct members in this file: + * I immutable after creation + * d protection left do the driver + * c only used in ioctl or routing socket contexts (kernel lock) + * K kernel lock + * N net lock + * + * For SRP related structures that allow lock-free reads, the write lock + * is indicated below. + */ + struct rtentry; struct ifnet; struct task; @@ -82,7 +94,7 @@ struct cpumem; * Structure describing a `cloning' interface. */ struct if_clone { - LIST_ENTRY(if_clone) ifc_list; /* on list of cloners */ + LIST_ENTRY(if_clone) ifc_list; /* [I] on list of cloners */ const char *ifc_name; /* name of device, e.g. `gif' */ size_t ifc_namelen; /* length of name */ @@ -99,17 +111,6 @@ struct if_clone { .ifc_destroy = destroy, \ } -/* - * Locks used to protect struct members in this file: - * I immutable after creation - * d protection left do the driver - * c only used in ioctl or routing socket contexts (kernel lock) - * K kernel lock - * N net lock - * - * For SRP related structures that allow lock-free reads, the write lock - * is indicated below. - */ /* * Structure defining a queue for a network interface. * -- 2.20.1