1/*-
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 13 unchanged lines hidden (view full) ---
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)if.c 8.5 (Berkeley) 1/9/95
30 * $FreeBSD: head/sys/net/if.c 206637 2010-04-14 22:02:19Z delphij $
31 */
32
33#include "opt_compat.h"
34#include "opt_inet6.h"
35#include "opt_inet.h"
36#include "opt_carp.h"
37#include "opt_ddb.h"
38
--- 119 unchanged lines hidden (view full) ---
158#ifdef INET6
159/*
160 * XXX: declare here to avoid to include many inet6 related files..
161 * should be more generalized?
162 */
163extern void nd6_setmtu(struct ifnet *);
164#endif
165
166VNET_DEFINE(struct ifnethead, ifnet); /* depend on static init XXX */
167VNET_DEFINE(struct ifgrouphead, ifg_head);
168VNET_DEFINE(int, if_index);
169static VNET_DEFINE(int, if_indexlim) = 8;
170
171/* Table of ifnet by index. */
172static VNET_DEFINE(struct ifindex_entry *, ifindex_table);
173
174#define V_if_indexlim VNET(if_indexlim)
175#define V_ifindex_table VNET(ifindex_table)
176
177int ifqmaxlen = IFQ_MAXLEN;
178
179/*
180 * The global network interface list (V_ifnet) and related state (such as
181 * if_index, if_indexlim, and ifindex_table) are protected by an sxlock and
182 * an rwlock. Either may be acquired shared to stablize the list, but both
183 * must be acquired writable to modify the list. This model allows us to
184 * both stablize the interface list during interrupt thread processing, but
185 * also to stablize it over long-running ioctls, without introducing priority
186 * inversions and deadlocks.
--- 3233 unchanged lines hidden ---
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 13 unchanged lines hidden (view full) ---
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)if.c 8.5 (Berkeley) 1/9/95
30 * $FreeBSD: head/sys/net/if.c 206637 2010-04-14 22:02:19Z delphij $
31 */
32
33#include "opt_compat.h"
34#include "opt_inet6.h"
35#include "opt_inet.h"
36#include "opt_carp.h"
37#include "opt_ddb.h"
38
--- 119 unchanged lines hidden (view full) ---
158#ifdef INET6
159/*
160 * XXX: declare here to avoid to include many inet6 related files..
161 * should be more generalized?
162 */
163extern void nd6_setmtu(struct ifnet *);
164#endif
165
166VNET_DEFINE(struct ifnethead, ifnet); /* depend on static init XXX */
167VNET_DEFINE(struct ifgrouphead, ifg_head);
168VNET_DEFINE(int, if_index);
169static VNET_DEFINE(int, if_indexlim) = 8;
170
171/* Table of ifnet by index. */
172static VNET_DEFINE(struct ifindex_entry *, ifindex_table);
173
174#define V_if_indexlim VNET(if_indexlim)
175#define V_ifindex_table VNET(ifindex_table)
176
177int ifqmaxlen = IFQ_MAXLEN;
178
179/*
180 * The global network interface list (V_ifnet) and related state (such as
181 * if_index, if_indexlim, and ifindex_table) are protected by an sxlock and
182 * an rwlock. Either may be acquired shared to stablize the list, but both
183 * must be acquired writable to modify the list. This model allows us to
184 * both stablize the interface list during interrupt thread processing, but
185 * also to stablize it over long-running ioctls, without introducing priority
186 * inversions and deadlocks.
--- 3233 unchanged lines hidden ---