Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include <net/ethernet.h> | #include <net/ethernet.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_arp.h> | #include <net/if_arp.h> | ||||
#include <net/if_clone.h> | #include <net/if_clone.h> | ||||
#include <net/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/if_types.h> | #include <net/if_types.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_media.h> | #include <net/if_media.h> | ||||
#include <net/if_mib.h> | |||||
#include <net/if_vlan_var.h> | #include <net/if_vlan_var.h> | ||||
#include <net/radix.h> | #include <net/radix.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/route/route_ctl.h> | #include <net/route/route_ctl.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
#if defined(INET) || defined(INET6) | #if defined(INET) || defined(INET6) | ||||
#include <net/ethernet.h> | #include <net/ethernet.h> | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
extern void nd6_setmtu(struct ifnet *); | extern void nd6_setmtu(struct ifnet *); | ||||
#endif | #endif | ||||
/* ipsec helper hooks */ | /* ipsec helper hooks */ | ||||
VNET_DEFINE(struct hhook_head *, ipsec_hhh_in[HHOOK_IPSEC_COUNT]); | VNET_DEFINE(struct hhook_head *, ipsec_hhh_in[HHOOK_IPSEC_COUNT]); | ||||
VNET_DEFINE(struct hhook_head *, ipsec_hhh_out[HHOOK_IPSEC_COUNT]); | VNET_DEFINE(struct hhook_head *, ipsec_hhh_out[HHOOK_IPSEC_COUNT]); | ||||
VNET_DEFINE(int, if_index); | |||||
int ifqmaxlen = IFQ_MAXLEN; | int ifqmaxlen = IFQ_MAXLEN; | ||||
VNET_DEFINE(struct ifnethead, ifnet); /* depend on static init XXX */ | VNET_DEFINE(struct ifnethead, ifnet); /* depend on static init XXX */ | ||||
VNET_DEFINE(struct ifgrouphead, ifg_head); | VNET_DEFINE(struct ifgrouphead, ifg_head); | ||||
VNET_DEFINE_STATIC(int, if_indexlim) = 8; | |||||
/* Table of ifnet by index. */ | /* Table of ifnet by index. */ | ||||
VNET_DEFINE_STATIC(struct ifnet **, ifindex_table); | VNET_DEFINE_STATIC(int, if_index); | ||||
#define V_if_index VNET(if_index) | |||||
VNET_DEFINE_STATIC(int, if_indexlim) = 8; | |||||
#define V_if_indexlim VNET(if_indexlim) | #define V_if_indexlim VNET(if_indexlim) | ||||
VNET_DEFINE_STATIC(struct ifnet **, ifindex_table); | |||||
#define V_ifindex_table VNET(ifindex_table) | #define V_ifindex_table VNET(ifindex_table) | ||||
SYSCTL_NODE(_net_link_generic, IFMIB_SYSTEM, system, | |||||
melifaro: I'd rather try keep the separation between it and if_mib. (Also, if.c Is huge and worth… | |||||
CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | |||||
"Variables global to all interfaces"); | |||||
SYSCTL_INT(_net_link_generic_system, IFMIB_IFCOUNT, ifcount, | |||||
CTLFLAG_VNET | CTLFLAG_RD, &VNET_NAME(if_index), 0, | |||||
"Number of configured interfaces"); | |||||
/* | /* | ||||
* The global network interface list (V_ifnet) and related state (such as | * The global network interface list (V_ifnet) and related state (such as | ||||
* if_index, if_indexlim, and ifindex_table) are protected by an sxlock. | * if_index, if_indexlim, and ifindex_table) are protected by an sxlock. | ||||
* This may be acquired to stabilise the list, or we may rely on NET_EPOCH. | * This may be acquired to stabilise the list, or we may rely on NET_EPOCH. | ||||
*/ | */ | ||||
struct sx ifnet_sxlock; | struct sx ifnet_sxlock; | ||||
SX_SYSINIT_FLAGS(ifnet_sx, &ifnet_sxlock, "ifnet_sx", SX_RECURSE); | SX_SYSINIT_FLAGS(ifnet_sx, &ifnet_sxlock, "ifnet_sx", SX_RECURSE); | ||||
▲ Show 20 Lines • Show All 4,286 Lines • Show Last 20 Lines |
I'd rather try keep the separation between it and if_mib. (Also, if.c Is huge and worth splitting by itself).
Speaking of static -
Maybe having a SYSCTL_PROC with an V_ifindex accessor function will do?