diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-01-02 12:52:18 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-01-02 12:52:18 +0000 |
commit | 003fff87d89089c03b0bfa7f53fd529b986247af (patch) | |
tree | 6e0191c88bef4c48940ebf2a9081164eff694433 /sys/net/if_var.h | |
parent | fee57507eb558f0270660f0cdbff0391138aaec9 (diff) |
Move the NET_LOCK() inside the switch and start documenting which field
is protected by which lock.
ok bluhm@, visa@
Diffstat (limited to 'sys/net/if_var.h')
-rw-r--r-- | sys/net/if_var.h | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 65ce87be4d3..b45c88b22c1 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.85 2017/12/15 01:37:30 dlg Exp $ */ +/* $OpenBSD: if_var.h,v 1.86 2018/01/02 12:52:17 mpi Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -91,7 +91,14 @@ struct if_clone { #define IF_CLONE_INITIALIZER(name, create, destroy) \ { { 0 }, name, sizeof(name) - 1, create, 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 + */ /* * Structure defining a queue for a network interface. * @@ -102,17 +109,17 @@ TAILQ_HEAD(ifnet_head, ifnet); /* the actual queue head */ struct ifnet { /* and the entries */ void *if_softc; /* lower-level data for this if */ struct refcnt if_refcnt; - TAILQ_ENTRY(ifnet) if_list; /* all struct ifnets are chained */ - TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */ - TAILQ_HEAD(, ifmaddr) if_maddrlist; /* list of multicast records */ - TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ - struct hook_desc_head *if_addrhooks; /* address change callbacks */ - struct hook_desc_head *if_linkstatehooks; /* link change callbacks */ - struct hook_desc_head *if_detachhooks; /* detach callbacks */ - /* check or clean routes (+ or -)'d */ + TAILQ_ENTRY(ifnet) if_list; /* [k] 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 */ + struct hook_desc_head *if_addrhooks; /* [I] address change callbacks */ + struct hook_desc_head *if_linkstatehooks; /* [I] link change callbacks*/ + struct hook_desc_head *if_detachhooks; /* [I] detach callbacks */ + /* [I] check or clean routes (+ or -)'d */ void (*if_rtrequest)(struct ifnet *, int, struct rtentry *); - char if_xname[IFNAMSIZ]; /* external name (name + unit) */ - int if_pcount; /* number of promiscuous listeners */ + char if_xname[IFNAMSIZ]; /* [I] external name (name + unit) */ + int if_pcount; /* [k] # of promiscuous listeners */ caddr_t if_bpf; /* packet filter structure */ caddr_t if_bridgeport; /* used by bridge ports */ caddr_t if_switchport; /* used by switch ports */ @@ -125,48 +132,43 @@ struct ifnet { /* and the entries */ } if_carp_ptr; #define if_carp if_carp_ptr.carp_s #define if_carpdev if_carp_ptr.carp_d - unsigned int if_index; /* numeric abbreviation for this if */ + unsigned int if_index; /* [I] unique index for this if */ short if_timer; /* time 'til if_watchdog called */ - unsigned short if_flags; /* up/down, broadcast, etc. */ - int if_xflags; /* extra softnet flags */ + unsigned short if_flags; /* [N] up/down, broadcast, etc. */ + int if_xflags; /* [N] extra softnet flags */ struct if_data if_data; /* stats and other data about if */ - u_int32_t if_hardmtu; /* maximum MTU device supports */ - char if_description[IFDESCRSIZE]; /* interface description */ - u_short if_rtlabelid; /* next route label */ - u_int8_t if_priority; - u_int8_t if_llprio; /* link layer priority */ - struct timeout *if_slowtimo; /* watchdog timeout */ - struct task *if_watchdogtask; /* watchdog task */ - struct task *if_linkstatetask; /* task to do route updates */ + uint32_t if_hardmtu; /* [d] maximum MTU device supports */ + char if_description[IFDESCRSIZE]; /* [c] interface description */ + u_short if_rtlabelid; /* [c] next route label */ + uint8_t if_priority; /* [c] route priority offset */ + uint8_t if_llprio; /* [N] link layer priority */ + struct timeout *if_slowtimo; /* [I] watchdog timeout */ + struct task *if_watchdogtask; /* [I] watchdog task */ + struct task *if_linkstatetask; /* [I] task to do route updates */ /* procedure handles */ SRPL_HEAD(, ifih) if_inputs; /* input routines (dequeue) */ - - /* output routine (enqueue) */ int (*if_output)(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); - + struct rtentry *); /* output routine (enqueue) */ /* link level output function */ int (*if_ll_output)(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); - /* initiate output routine */ - void (*if_start)(struct ifnet *); - /* ioctl routine */ - int (*if_ioctl)(struct ifnet *, u_long, caddr_t); - /* timer routine */ - void (*if_watchdog)(struct ifnet *); - int (*if_wol)(struct ifnet *, int); + void (*if_start)(struct ifnet *); /* initiate output */ + int (*if_ioctl)(struct ifnet *, u_long, caddr_t); /* ioctl hook */ + void (*if_watchdog)(struct ifnet *); /* timer routine */ + int (*if_wol)(struct ifnet *, int); /* WoL routine **/ + /* queues */ struct ifqueue if_snd; /* transmit queue */ - struct ifqueue **if_ifqs; /* pointer to an array of sndqs */ + struct ifqueue **if_ifqs; /* [I] pointer to an array of sndqs */ void (*if_qstart)(struct ifqueue *); - unsigned int if_nifqs; + unsigned int if_nifqs; /* [I] number of output queues */ struct ifiqueue if_rcv; /* rx/input queue */ - struct ifiqueue **if_iqs; /* pointer to the array of iqs */ - unsigned int if_niqs; + struct ifiqueue **if_iqs; /* [I] pointer to the array of iqs */ + unsigned int if_niqs; /* [I] number of input queues */ - struct sockaddr_dl *if_sadl; /* pointer to our sockaddr_dl */ + struct sockaddr_dl *if_sadl; /* [N] pointer to our sockaddr_dl */ void *if_afdata[AF_MAX]; }; @@ -189,7 +191,7 @@ struct ifnet { /* and the entries */ #define if_iqdrops if_data.ifi_iqdrops #define if_oqdrops if_data.ifi_oqdrops #define if_noproto if_data.ifi_noproto -#define if_lastchange if_data.ifi_lastchange +#define if_lastchange if_data.ifi_lastchange /* [c] last op. state change */ #define if_capabilities if_data.ifi_capabilities #define if_rdomain if_data.ifi_rdomain |