On Mon, Apr 17, 2023 at 02:58:59PM +0200, Alexander Bluhm wrote:
> On Mon, Apr 17, 2023 at 01:20:28AM +0300, Vitaliy Makkoveev wrote:
> > It performs read-only access to netlock protected data.
>
> OK bluhm@
>
> Could you somewhere document that ifnetlist is protected by netlock?
>
We use both kernel and net lock for protect `ifnetlist'. This is the
exception, so I propose to document this like below.
Index: sys/net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.688
diff -u -p -r1.688 if.c
--- sys/net/if.c 8 Apr 2023 13:49:38 -0000 1.688
+++ sys/net/if.c 17 Apr 2023 14:42:10 -0000
@@ -272,6 +272,10 @@ ifinit(void)
static struct if_idxmap if_idxmap;
+/*
+ * XXXSMP: For `ifnetlist' modification both kernel and net locks
+ * should be taken. For read-only access only one lock of them required.
+ */
struct ifnet_head ifnetlist = TAILQ_HEAD_INITIALIZER(ifnetlist);
static inline unsigned int
Index: sys/net/if_var.h
===================================================================
RCS file: /cvs/src/sys/net/if_var.h,v
retrieving revision 1.123
diff -u -p -r1.123 if_var.h
--- sys/net/if_var.h 5 Apr 2023 19:35:23 -0000 1.123
+++ sys/net/if_var.h 17 Apr 2023 14:42:10 -0000
@@ -121,7 +121,7 @@ TAILQ_HEAD(ifnet_head, ifnet); /* the a
struct ifnet { /* and the entries */
void *if_softc; /* [I] lower-level data for this if */
struct refcnt if_refcnt;
- TAILQ_ENTRY(ifnet) if_list; /* [K] all struct ifnets are chained */
+ TAILQ_ENTRY(ifnet) if_list; /* [NK] all struct ifnets are chained */
TAILQ_HEAD(, ifaddr) if_addrlist; /* [N] list of addresses per if */
TAILQ_HEAD(, ifmaddr) if_maddrlist; /* [N] list of multicast records */
TAILQ_HEAD(, ifg_list) if_groups; /* [N] list of groups per if */