2016-02-15 04:11:41 +03:00
|
|
|
/* $NetBSD: if_bridgevar.h,v 1.26 2016/02/15 01:11:41 ozaki-r Exp $ */
|
2001-08-18 01:37:27 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2001 Wasabi Systems, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the NetBSD Project by
|
|
|
|
* Wasabi Systems, Inc.
|
|
|
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2005-02-27 01:45:09 +03:00
|
|
|
/*
|
2001-08-18 01:37:27 +04:00
|
|
|
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
|
2005-02-27 01:45:09 +03:00
|
|
|
* All rights reserved.
|
2001-08-18 01:37:27 +04:00
|
|
|
*
|
2005-02-27 01:45:09 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
2001-08-18 01:37:27 +04:00
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Jason L. Wright
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Data structure and control definitions for bridge interfaces.
|
|
|
|
*/
|
|
|
|
|
2005-12-11 02:21:38 +03:00
|
|
|
#ifndef _NET_IF_BRIDGEVAR_H_
|
|
|
|
#define _NET_IF_BRIDGEVAR_H_
|
|
|
|
|
2001-08-18 01:37:27 +04:00
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/queue.h>
|
2014-07-14 06:34:36 +04:00
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/condvar.h>
|
2001-08-18 01:37:27 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the
|
|
|
|
* bridge interface itself is keyed off the ifdrv structure.
|
|
|
|
*/
|
|
|
|
#define BRDGADD 0 /* add bridge member (ifbreq) */
|
|
|
|
#define BRDGDEL 1 /* delete bridge member (ifbreq) */
|
|
|
|
#define BRDGGIFFLGS 2 /* get member if flags (ifbreq) */
|
|
|
|
#define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */
|
|
|
|
#define BRDGSCACHE 4 /* set cache size (ifbrparam) */
|
|
|
|
#define BRDGGCACHE 5 /* get cache size (ifbrparam) */
|
2015-06-01 09:14:43 +03:00
|
|
|
#define OBRDGGIFS 6 /* get member list (ifbifconf) */
|
|
|
|
#define OBRDGRTS 7 /* get address list (ifbaconf) */
|
2001-08-18 01:37:27 +04:00
|
|
|
#define BRDGSADDR 8 /* set static address (ifbareq) */
|
|
|
|
#define BRDGSTO 9 /* set cache timeout (ifbrparam) */
|
|
|
|
#define BRDGGTO 10 /* get cache timeout (ifbrparam) */
|
|
|
|
#define BRDGDADDR 11 /* delete address (ifbareq) */
|
|
|
|
#define BRDGFLUSH 12 /* flush address cache (ifbreq) */
|
|
|
|
|
|
|
|
#define BRDGGPRI 13 /* get priority (ifbrparam) */
|
|
|
|
#define BRDGSPRI 14 /* set priority (ifbrparam) */
|
|
|
|
#define BRDGGHT 15 /* get hello time (ifbrparam) */
|
|
|
|
#define BRDGSHT 16 /* set hello time (ifbrparam) */
|
|
|
|
#define BRDGGFD 17 /* get forward delay (ifbrparam) */
|
|
|
|
#define BRDGSFD 18 /* set forward delay (ifbrparam) */
|
|
|
|
#define BRDGGMA 19 /* get max age (ifbrparam) */
|
|
|
|
#define BRDGSMA 20 /* set max age (ifbrparam) */
|
|
|
|
#define BRDGSIFPRIO 21 /* set if priority (ifbreq) */
|
2003-03-19 13:34:33 +03:00
|
|
|
#define BRDGSIFCOST 22 /* set if path cost (ifbreq) */
|
|
|
|
#define BRDGGFILT 23 /* get filter flags (ifbrparam) */
|
|
|
|
#define BRDGSFILT 24 /* set filter flags (ifbrparam) */
|
2001-08-18 01:37:27 +04:00
|
|
|
|
2015-06-01 09:14:43 +03:00
|
|
|
#define BRDGGIFS 25 /* get member list */
|
|
|
|
#define BRDGRTS 26 /* get address list */
|
|
|
|
|
2001-08-18 01:37:27 +04:00
|
|
|
/*
|
|
|
|
* Generic bridge control request.
|
|
|
|
*/
|
|
|
|
struct ifbreq {
|
|
|
|
char ifbr_ifsname[IFNAMSIZ]; /* member if name */
|
|
|
|
uint32_t ifbr_ifsflags; /* member if flags */
|
|
|
|
uint8_t ifbr_state; /* member if STP state */
|
|
|
|
uint8_t ifbr_priority; /* member if STP priority */
|
2003-03-19 13:34:33 +03:00
|
|
|
uint8_t ifbr_path_cost; /* member if STP cost */
|
2001-08-18 01:37:27 +04:00
|
|
|
uint8_t ifbr_portno; /* member if port number */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* BRDGGIFFLAGS, BRDGSIFFLAGS */
|
|
|
|
#define IFBIF_LEARNING 0x01 /* if can learn */
|
|
|
|
#define IFBIF_DISCOVER 0x02 /* if sends packets w/ unknown dest. */
|
|
|
|
#define IFBIF_STP 0x04 /* if participates in spanning tree */
|
|
|
|
|
|
|
|
#define IFBIFBITS "\020\1LEARNING\2DISCOVER\3STP"
|
|
|
|
|
|
|
|
/* BRDGFLUSH */
|
|
|
|
#define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */
|
|
|
|
#define IFBF_FLUSHALL 0x01 /* flush all addresses */
|
|
|
|
|
2003-02-15 03:46:30 +03:00
|
|
|
/* BRDGSFILT */
|
|
|
|
#define IFBF_FILT_USEIPF 0x00000001 /* enable ipf on bridge */
|
|
|
|
#define IFBF_FILT_MASK 0x00000001 /* mask of valid values */
|
|
|
|
|
2001-08-18 01:37:27 +04:00
|
|
|
/* STP port states */
|
|
|
|
#define BSTP_IFSTATE_DISABLED 0
|
|
|
|
#define BSTP_IFSTATE_LISTENING 1
|
|
|
|
#define BSTP_IFSTATE_LEARNING 2
|
|
|
|
#define BSTP_IFSTATE_FORWARDING 3
|
|
|
|
#define BSTP_IFSTATE_BLOCKING 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface list structure.
|
|
|
|
*/
|
|
|
|
struct ifbifconf {
|
|
|
|
uint32_t ifbic_len; /* buffer size */
|
|
|
|
union {
|
2007-03-04 08:59:00 +03:00
|
|
|
void * ifbicu_buf;
|
2001-08-18 01:37:27 +04:00
|
|
|
struct ifbreq *ifbicu_req;
|
|
|
|
} ifbic_ifbicu;
|
|
|
|
#define ifbic_buf ifbic_ifbicu.ifbicu_buf
|
|
|
|
#define ifbic_req ifbic_ifbicu.ifbicu_req
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bridge address request.
|
|
|
|
*/
|
|
|
|
struct ifbareq {
|
|
|
|
char ifba_ifsname[IFNAMSIZ]; /* member if name */
|
2015-06-01 09:14:43 +03:00
|
|
|
time_t ifba_expire; /* address expire time */
|
2001-08-18 01:37:27 +04:00
|
|
|
uint8_t ifba_flags; /* address flags */
|
|
|
|
uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IFBAF_TYPEMASK 0x03 /* address type mask */
|
|
|
|
#define IFBAF_DYNAMIC 0x00 /* dynamically learned address */
|
|
|
|
#define IFBAF_STATIC 0x01 /* static address */
|
|
|
|
|
|
|
|
#define IFBAFBITS "\020\1STATIC"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Address list structure.
|
|
|
|
*/
|
|
|
|
struct ifbaconf {
|
|
|
|
uint32_t ifbac_len; /* buffer size */
|
|
|
|
union {
|
2007-03-04 08:59:00 +03:00
|
|
|
void *ifbacu_buf;
|
2001-08-18 01:37:27 +04:00
|
|
|
struct ifbareq *ifbacu_req;
|
|
|
|
} ifbac_ifbacu;
|
|
|
|
#define ifbac_buf ifbac_ifbacu.ifbacu_buf
|
|
|
|
#define ifbac_req ifbac_ifbacu.ifbacu_req
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bridge parameter structure.
|
|
|
|
*/
|
|
|
|
struct ifbrparam {
|
|
|
|
union {
|
|
|
|
uint32_t ifbrpu_int32;
|
|
|
|
uint16_t ifbrpu_int16;
|
|
|
|
uint8_t ifbrpu_int8;
|
|
|
|
} ifbrp_ifbrpu;
|
|
|
|
};
|
|
|
|
#define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */
|
|
|
|
#define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */
|
|
|
|
#define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */
|
|
|
|
#define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */
|
|
|
|
#define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */
|
|
|
|
#define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */
|
2003-02-15 03:46:30 +03:00
|
|
|
#define ifbrp_filter ifbrp_ifbrpu.ifbrpu_int32 /* filtering flags */
|
2001-08-18 01:37:27 +04:00
|
|
|
|
|
|
|
#ifdef _KERNEL
|
2015-01-16 13:36:14 +03:00
|
|
|
#ifdef _KERNEL_OPT
|
|
|
|
#include "opt_net_mpsafe.h"
|
|
|
|
#endif /* _KERNEL_OPT */
|
|
|
|
|
2014-12-31 20:36:24 +03:00
|
|
|
#include <sys/pserialize.h>
|
2015-01-08 13:47:44 +03:00
|
|
|
#include <sys/workqueue.h>
|
2014-12-31 20:36:24 +03:00
|
|
|
|
2014-06-16 07:43:10 +04:00
|
|
|
#include <net/pktqueue.h>
|
|
|
|
|
2001-08-18 01:37:27 +04:00
|
|
|
/*
|
|
|
|
* Timekeeping structure used in spanning tree code.
|
|
|
|
*/
|
|
|
|
struct bridge_timer {
|
|
|
|
uint16_t active;
|
|
|
|
uint16_t value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bstp_config_unit {
|
|
|
|
uint64_t cu_rootid;
|
|
|
|
uint64_t cu_bridge_id;
|
|
|
|
uint32_t cu_root_path_cost;
|
|
|
|
uint16_t cu_message_age;
|
|
|
|
uint16_t cu_max_age;
|
|
|
|
uint16_t cu_hello_time;
|
|
|
|
uint16_t cu_forward_delay;
|
|
|
|
uint16_t cu_port_id;
|
|
|
|
uint8_t cu_message_type;
|
|
|
|
uint8_t cu_topology_change_acknowledgment;
|
|
|
|
uint8_t cu_topology_change;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bstp_tcn_unit {
|
|
|
|
uint8_t tu_message_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bridge interface list entry.
|
|
|
|
*/
|
|
|
|
struct bridge_iflist {
|
|
|
|
LIST_ENTRY(bridge_iflist) bif_next;
|
|
|
|
uint64_t bif_designated_root;
|
|
|
|
uint64_t bif_designated_bridge;
|
|
|
|
uint32_t bif_path_cost;
|
|
|
|
uint32_t bif_designated_cost;
|
|
|
|
struct bridge_timer bif_hold_timer;
|
|
|
|
struct bridge_timer bif_message_age_timer;
|
|
|
|
struct bridge_timer bif_forward_delay_timer;
|
|
|
|
uint16_t bif_port_id;
|
|
|
|
uint16_t bif_designated_port;
|
2005-06-29 00:09:44 +04:00
|
|
|
struct bstp_config_unit bif_config_bpdu;
|
2001-08-18 01:37:27 +04:00
|
|
|
uint8_t bif_state;
|
|
|
|
uint8_t bif_topology_change_acknowledge;
|
|
|
|
uint8_t bif_config_pending;
|
|
|
|
uint8_t bif_change_detection_enabled;
|
|
|
|
uint8_t bif_priority;
|
|
|
|
struct ifnet *bif_ifp; /* member if */
|
|
|
|
uint32_t bif_flags; /* member if flags */
|
2014-07-14 06:34:36 +04:00
|
|
|
uint32_t bif_refs; /* reference count */
|
|
|
|
bool bif_waiting; /* waiting for released */
|
2001-08-18 01:37:27 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bridge route node.
|
|
|
|
*/
|
|
|
|
struct bridge_rtnode {
|
|
|
|
LIST_ENTRY(bridge_rtnode) brt_hash; /* hash table linkage */
|
|
|
|
LIST_ENTRY(bridge_rtnode) brt_list; /* list linkage */
|
|
|
|
struct ifnet *brt_ifp; /* destination if */
|
2009-01-11 05:45:45 +03:00
|
|
|
time_t brt_expire; /* expiration time */
|
2001-08-18 01:37:27 +04:00
|
|
|
uint8_t brt_flags; /* address flags */
|
|
|
|
uint8_t brt_addr[ETHER_ADDR_LEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Software state for each bridge.
|
|
|
|
*/
|
|
|
|
struct bridge_softc {
|
|
|
|
struct ifnet sc_if;
|
|
|
|
LIST_ENTRY(bridge_softc) sc_list;
|
|
|
|
uint64_t sc_designated_root;
|
|
|
|
uint64_t sc_bridge_id;
|
|
|
|
struct bridge_iflist *sc_root_port;
|
|
|
|
uint32_t sc_root_path_cost;
|
|
|
|
uint16_t sc_max_age;
|
|
|
|
uint16_t sc_hello_time;
|
|
|
|
uint16_t sc_forward_delay;
|
|
|
|
uint16_t sc_bridge_max_age;
|
|
|
|
uint16_t sc_bridge_hello_time;
|
|
|
|
uint16_t sc_bridge_forward_delay;
|
|
|
|
uint16_t sc_topology_change_time;
|
|
|
|
uint16_t sc_hold_time;
|
|
|
|
uint16_t sc_bridge_priority;
|
|
|
|
uint8_t sc_topology_change_detected;
|
|
|
|
uint8_t sc_topology_change;
|
|
|
|
struct bridge_timer sc_hello_timer;
|
|
|
|
struct bridge_timer sc_topology_change_timer;
|
|
|
|
struct bridge_timer sc_tcn_timer;
|
|
|
|
uint32_t sc_brtmax; /* max # of addresses */
|
|
|
|
uint32_t sc_brtcnt; /* cur. # of addresses */
|
|
|
|
uint32_t sc_brttimeout; /* rt timeout in seconds */
|
2007-07-10 00:51:58 +04:00
|
|
|
callout_t sc_brcallout; /* bridge callout */
|
|
|
|
callout_t sc_bstpcallout; /* STP callout */
|
2001-08-18 01:37:27 +04:00
|
|
|
LIST_HEAD(, bridge_iflist) sc_iflist; /* member interface list */
|
2014-07-14 06:34:36 +04:00
|
|
|
kcondvar_t sc_iflist_cv;
|
2014-12-31 20:36:24 +03:00
|
|
|
pserialize_t sc_iflist_psz;
|
|
|
|
kmutex_t *sc_iflist_lock;
|
2001-08-18 01:37:27 +04:00
|
|
|
LIST_HEAD(, bridge_rtnode) *sc_rthash; /* our forwarding table */
|
|
|
|
LIST_HEAD(, bridge_rtnode) sc_rtlist; /* list version of above */
|
2014-07-14 06:34:36 +04:00
|
|
|
kmutex_t *sc_rtlist_lock;
|
2015-01-08 13:47:44 +03:00
|
|
|
pserialize_t sc_rtlist_psz;
|
|
|
|
struct workqueue *sc_rtage_wq;
|
2016-02-10 09:30:23 +03:00
|
|
|
struct work sc_rtage_wk;
|
2001-08-18 01:37:27 +04:00
|
|
|
uint32_t sc_rthash_key; /* key for hash */
|
2003-02-15 03:46:30 +03:00
|
|
|
uint32_t sc_filter_flags; /* ipf and flags */
|
2001-08-18 01:37:27 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const uint8_t bstp_etheraddr[];
|
|
|
|
|
2003-07-08 11:13:50 +04:00
|
|
|
void bridge_ifdetach(struct ifnet *);
|
2001-08-18 01:37:27 +04:00
|
|
|
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
int bridge_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
|
2001-08-18 01:37:27 +04:00
|
|
|
struct rtentry *);
|
|
|
|
|
|
|
|
void bstp_initialization(struct bridge_softc *);
|
|
|
|
void bstp_stop(struct bridge_softc *);
|
2014-06-17 14:39:46 +04:00
|
|
|
void bstp_input(struct bridge_softc *, struct bridge_iflist *, struct mbuf *);
|
2001-08-18 01:37:27 +04:00
|
|
|
|
2003-09-16 21:38:24 +04:00
|
|
|
void bridge_enqueue(struct bridge_softc *, struct ifnet *, struct mbuf *,
|
|
|
|
int);
|
2001-08-18 01:37:27 +04:00
|
|
|
|
2014-07-14 06:34:36 +04:00
|
|
|
#ifdef NET_MPSAFE
|
|
|
|
#define BRIDGE_MPSAFE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BRIDGE_LOCK(_sc) if ((_sc)->sc_iflist_lock) \
|
|
|
|
mutex_enter((_sc)->sc_iflist_lock)
|
|
|
|
#define BRIDGE_UNLOCK(_sc) if ((_sc)->sc_iflist_lock) \
|
|
|
|
mutex_exit((_sc)->sc_iflist_lock)
|
|
|
|
#define BRIDGE_LOCKED(_sc) (!(_sc)->sc_iflist_lock || \
|
|
|
|
mutex_owned((_sc)->sc_iflist_lock))
|
|
|
|
|
2014-12-31 20:36:24 +03:00
|
|
|
#ifdef BRIDGE_MPSAFE
|
|
|
|
/*
|
|
|
|
* These macros can be used in both HW interrupt and softint contexts.
|
|
|
|
*/
|
2016-02-15 04:11:41 +03:00
|
|
|
#define BRIDGE_PSZ_RENTER(__s) do { __s = pserialize_read_enter(); } while (0)
|
|
|
|
#define BRIDGE_PSZ_REXIT(__s) do { pserialize_read_exit(__s); } while (0)
|
2014-12-31 20:36:24 +03:00
|
|
|
#else /* BRIDGE_MPSAFE */
|
|
|
|
#define BRIDGE_PSZ_RENTER(__s) do { __s = 0; } while (0)
|
|
|
|
#define BRIDGE_PSZ_REXIT(__s) do { (void)__s; } while (0)
|
|
|
|
#endif /* BRIDGE_MPSAFE */
|
|
|
|
|
|
|
|
#define BRIDGE_PSZ_PERFORM(_sc) if ((_sc)->sc_iflist_psz) \
|
|
|
|
pserialize_perform((_sc)->sc_iflist_psz);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locking notes:
|
|
|
|
* - Updates of sc_iflist are serialized by sc_iflist_lock (an adaptive mutex)
|
2016-02-15 04:11:41 +03:00
|
|
|
* - The mutex is also used for STP
|
2014-12-31 20:36:24 +03:00
|
|
|
* - Items of sc_iflist (bridge_iflist) is protected by both pserialize
|
|
|
|
* (sc_iflist_psz) and reference counting (bridge_iflist#bif_refs)
|
|
|
|
* - Before destroying an item of sc_iflist, we have to do pserialize_perform
|
|
|
|
* and synchronize with the reference counting via a conditional variable
|
|
|
|
* (sc_iflist_cz)
|
2016-02-15 04:11:41 +03:00
|
|
|
* - Updates of sc_rtlist are serialized by sc_rtlist_lock (an adaptive mutex)
|
|
|
|
* - The mutex is also used for pserialize
|
2015-01-08 13:47:44 +03:00
|
|
|
* - A workqueue is used to run bridge_rtage in LWP context via bridge_timer callout
|
|
|
|
* - bridge_rtage uses pserialize that requires non-interrupt context
|
2014-12-31 20:36:24 +03:00
|
|
|
*/
|
2001-08-18 01:37:27 +04:00
|
|
|
#endif /* _KERNEL */
|
2005-12-11 02:21:38 +03:00
|
|
|
#endif /* !_NET_IF_BRIDGEVAR_H_ */
|