diff options
author | mlaier <mlaier@FreeBSD.org> | 2005-09-27 18:10:43 +0000 |
---|---|---|
committer | mlaier <mlaier@FreeBSD.org> | 2005-09-27 18:10:43 +0000 |
commit | a42af632d87879621ea936244e0eb8a934e9054c (patch) | |
tree | 06d50385e76f077f148ab914f1e6e424fbea50a1 | |
parent | ef35b51d9d50287690c02c0c566d37a0a97161db (diff) | |
download | FreeBSD-src-a42af632d87879621ea936244e0eb8a934e9054c.zip FreeBSD-src-a42af632d87879621ea936244e0eb8a934e9054c.tar.gz |
Remove bridge(4) from the tree. if_bridge(4) is a full functional
replacement and has additional features which make it superior.
Discussed on: -arch
Reviewed by: thompsa
X-MFC-after: never (RELENG_6 as transition period)
81 files changed, 71 insertions, 1922 deletions
@@ -21,6 +21,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 7.x IS SLOW: developers choose to disable these features on build machines to maximize performance. +20050927: + The old bridge(4) implementation was retired. The new + if_bridge(4) serves as a full functional replacement. + 20050722: The ai_addrlen of a struct addrinfo was changed to a socklen_t to conform to POSIX-2001. This change broke an ABI diff --git a/release/picobsd/bridge/PICOBSD b/release/picobsd/bridge/PICOBSD index 5a2de48..1b6c50e 100644 --- a/release/picobsd/bridge/PICOBSD +++ b/release/picobsd/bridge/PICOBSD @@ -39,7 +39,7 @@ options IPDIVERT # divert (for natd) # Support for bridging and bandwidth limiting options DUMMYNET -options BRIDGE +device if_bridge options HZ=1000 #options NMBCLUSTERS=4096 diff --git a/release/picobsd/tinyware/ns/ns.c b/release/picobsd/tinyware/ns/ns.c index 777a7be..c6e58e2 100644 --- a/release/picobsd/tinyware/ns/ns.c +++ b/release/picobsd/tinyware/ns/ns.c @@ -52,12 +52,6 @@ #include <netinet/udp.h> #include <netinet/udp_var.h> -#ifdef BRIDGING -#include <net/if_types.h> /* IFT_ETHER */ -#include <net/ethernet.h> -#include <net/bridge.h> -#endif - #include <err.h> #include <errno.h> #include <osreldate.h> @@ -80,11 +74,7 @@ void usage() { fprintf(stderr, "\n%s [-nrsil] [-p proto] [-w wait]\n", progname); -#ifdef BRIDGING - fprintf(stderr, " proto: {ip|tcp|udp|icmp|bdg}\n\n"); -#else fprintf(stderr, " proto: {ip|tcp|udp|icmp}\n\n"); -#endif } @@ -720,19 +710,12 @@ stats(char *proto) print_udp_stats(); if (strcmp(proto, "tcp") == 0) print_tcp_stats(); -#ifdef BRIDGING - if (strcmp(proto, "bdg") == 0) - print_bdg_stats(); -#endif return (0); } print_ip_stats(); print_icmp_stats(); print_udp_stats(); print_tcp_stats(); -#ifdef BRIDGING - print_bdg_stats(); -#endif return (0); } @@ -844,42 +827,3 @@ print_load_stats(void) X(0), X(1), X(2), X(3), X(4) ); bcopy(new_cp_time, cp_time, sizeof(cp_time)); } - -#ifdef BRIDGING -/* print bridge statistics */ -int -print_bdg_stats() -{ - int i; - int mib[4]; - int slen; - struct bdg_stats s; - - slen = sizeof(s); - - mib[0] = CTL_NET; - mib[1] = PF_LINK; - mib[2] = IFT_ETHER; - mib[3] = PF_BDG; - if (sysctl(mib, 4, &s, &slen, NULL, 0) == -1) { - return 0; /* no bridging */ - } - printf("-- Bridging statistics --\n"); - printf( - "Name In Out Forward Drop Bcast" - "Mcast Local Unknown\n"); - for (i = 0; i < 16; i++) { - if (s.s[i].name[0]) - printf("%-6s %9d%9d%9d%9d%9d%9d%9d%9d\n", - s.s[i].name, - s.s[i].p_in[(int)BDG_IN], - s.s[i].p_in[(int)BDG_OUT], - s.s[i].p_in[(int)BDG_FORWARD], - s.s[i].p_in[(int)BDG_DROP], - s.s[i].p_in[(int)BDG_BCAST], - s.s[i].p_in[(int)BDG_MCAST], - s.s[i].p_in[(int)BDG_LOCAL], - s.s[i].p_in[(int)BDG_UNKNOWN]); - } -} -#endif diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 7199483..1f2d758 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -34,7 +34,6 @@ MAN= aac.4 \ bktr.4 \ blackhole.4 \ bpf.4 \ - bridge.4 \ bt.4 \ cardbus.4 \ carp.4 \ diff --git a/share/man/man4/bridge.4 b/share/man/man4/bridge.4 deleted file mode 100644 index 98b882d..0000000 --- a/share/man/man4/bridge.4 +++ /dev/null @@ -1,252 +0,0 @@ -.\" -.\" $FreeBSD$ -.\" -.Dd September 20, 2003 -.Dt BRIDGE 4 -.Os -.Sh NAME -.Nm bridge -.Nd bridging support -.Sh SYNOPSIS -.Cd "options BRIDGE" -.Sh DESCRIPTION -.Fx -supports bridging on Ethernet-type interfaces, including VLANs. -Bridging support can be either compiled into the kernel, or loaded -at runtime as a kernel module. -.Pp -A single -.Fx -host can do bridging on independent sets of interfaces, -which are called -.Dq clusters . -Each cluster connects a set of interfaces, and is -identified by a -.Dq cluster-ID -which is a number in the range 1..65535. -A cluster in fact is very similar to what commercial switches call -a -.Dq VLAN . -Note however that there is no relation whatsoever -between the cluster-ID and the IEEE 802.1q VLAN-ID which appears -in the header of packets transmitted on the wire. -In fact, in most cases there is no relation between the -so-called -.Dq "VLAN identifier" -used in most commercial switches, and -the IEEE 802.1q VLAN-ID. -.Pp -By putting both physical and logical -.Pq Xr vlan 4 -interfaces in the same cluster, a -.Fx -box can also implement what in commercial terms is called a -.Dq trunk -interface. -This means that packets -coming from one of the interfaces in a cluster -will appear on the wire of the -.Dq parent -interface of any VLAN interface in a cluster, -with the proper VLAN tag. -Similarly, packets -coming from a parent interface of any VLAN interface in a cluster -will have the VLAN tag stripped, -and will be forwarded to other interfaces in a cluster. -See the -.Sx EXAMPLES -section for more details. -.Pp -Runtime operation of the -.Nm -is controlled by several -.Xr sysctl 8 -variables, as follows. -.Bl -tag -width indent -.It Va net.link.ether.bridge.enable -Set to -.Li 1 -to enable bridging, set to -.Li 0 -to disable it. -.It Va net.link.ether.bridge.ipfw -Set to -.Li 1 -to enable -.Xr ipfw 8 -processing of bridged packets. -Note that -.Xr ipfw 8 -rules only apply -to IP packets. -Non-IP packets are accepted by default. -See the -.Sx BUGS -section and the -.Xr ipfw 8 -manpage for more details on the interaction of bridging -and the firewall. -.It Va net.link.ether.bridge.ipf -Set to -.Li 1 -to enable -.Xr ipf 8 -processing of bridged packets. -Note that -.Xr ipf 8 -rules only apply -to IP packets. -Non-IP packets are accepted by default. -.It Va net.link.ether.bridge.config -Set to the list of interfaces to bridge. -Interfaces are separated by spaces, commas or tabs. -Each interface -can be optionally followed by a colon and an integer indicating the -cluster it belongs to (defaults to 1 if the cluster-ID is missing), e.g.\& -.Dq Li "dc0:1,dc1,vlan0:3 dc2:3" -will put -.Li dc0 -and -.Li dc1 -in cluster number 1, and -.Li vlan0 -and -.Li dc2 -in cluster -number 3. -See the -.Sx EXAMPLES -section for more examples. -.Pp -The list of interfaces is rescanned every time the list is -modified, bridging is enabled, or new interfaces are created or -destroyed. -An explicit request to refresh the -.Nm -configuration can also -be done by writing any value to -.Va net.link.ether.bridge.refresh . -Interfaces that are in the list but cannot be used -for bridging (because they are non-existing, or not Ethernet or VLAN) -are not used and a warning message is generated. -.El -.Pp -Bridging requires interfaces to be put in promiscuous mode, -and transmit packets with Ethernet source addresses different -than their own. -Some interfaces (e.g.\& -.Xr wi 4 ) -do not support this functionality. -Also, bridging is not compatible with interfaces which -use hardware loopback, because there is no way to tell locally -generated packets from externally generated ones. -.Sh FILES -.Bl -tag -width ".Pa /boot/kernel/bridge.ko" -compact -.It Pa /boot/kernel/bridge.ko -.Nm -loadable module. -.El -.Sh EXAMPLES -A simple -.Nm -configuration with three interfaces in the same -cluster can be set as follows. -No cluster-ID is specified here, which -will cause the interfaces to appear as part of cluster #1. -.Pp -.Dl "sysctl net.link.ether.bridge.config=dc0,dc1,fxp1" -.Pp -If you do not know what actual interfaces will be present on -your system, you can just put all existing interfaces in the -configuration, as follows: -.Pp -.Dl sysctl net.link.ether.bridge.config="`ifconfig -l`" -.Pp -This will result in a space-separated list of interfaces. -Out of the list, only Ethernet and VLAN interfaces will be -used for bridging, whereas for others the kernel will produce -a warning message. -.Pp -More complex configurations can be used to create multiple -clusters, e.g.\& -.Pp -.Dl "sysctl net.link.ether.bridge.config=dc0:3,dc1:3,fxp0:4,fxp1:4" -.Pp -will create two completely independent clusters. -.Pp -Finally, interesting configurations involve VLANs and parent interfaces. -As an example, the following configuration will use interface -.Li dc0 -as a -.Dq trunk -interface, and pass packets -for 802.1q VLANs 10 and 20 to physical interfaces -.Li dc1 -and -.Li dc2 , -respectively: -.Bd -literal -offset indent -sysctl net.link.ether.bridge.config=vlan0:34,dc1:34,vlan1:56,dc2:56 -ifconfig vlan0 vlan 10 vlandev dc0 -ifconfig vlan1 vlan 20 vlandev dc0 -.Ed -.Pp -Note how there is no relation between the 802.1q VLAN identifiers -(10 and 20) and the cluster-ID's (34 and 56) used in -the -.Va bridge.config -variable. -.Pp -Note also that the trunk interface -does not even appear in the -.Va bridge.config , -as VLAN tag insertion/removal -is performed by the -.Xr vlan 4 -devices. -When using VLAN devices, care must be taken by not creating loops -between these devices and their parent interfaces. -.Sh SEE ALSO -.Xr ip 4 , -.Xr ng_bridge 4 , -.Xr vlan 4 , -.Xr ipf 8 , -.Xr ipfw 8 , -.Xr sysctl 8 -.Sh HISTORY -Bridging was introduced in -.Fx 2.2.8 -by -.An Luigi Rizzo Aq luigi@iet.unipi.it . -.Sh BUGS -Care must be taken not to construct loops in the -.Nm -topology. -The kernel supports only a primitive form of loop detection, by disabling -some interfaces when a loop is detected. -No support for a daemon running the -spanning tree algorithm is currently provided. -.Pp -With bridging active, interfaces are in promiscuous mode, -thus causing some load on the system to receive and filter -out undesired traffic. -.Pp -When passing bridged packets to -.Xr ipfw 8 , -remember that only IP packets are passed to the firewall, while -other packets are silently accepted. -Also remember that bridged packets are accepted after the -first pass through the firewall irrespective of the setting -of the sysctl variable -.Va net.inet.ip.fw.one_pass , -and that some -.Xr ipfw 8 -actions such as -.Cm divert -do not apply to bridged packets. -It might be useful to have a rule of the form -.Pp -.Dl "skipto 20000 ip from any to any bridged" -.Pp -near the beginning of your ruleset to implement specific rulesets -for bridged packets. diff --git a/share/man/man4/dummynet.4 b/share/man/man4/dummynet.4 index 50811f8..4ab2106 100644 --- a/share/man/man4/dummynet.4 +++ b/share/man/man4/dummynet.4 @@ -60,7 +60,6 @@ sum of the bandwidth-delay products and queue sizes of all configured pipes. .Sh SEE ALSO .Xr setsockopt 2 , -.Xr bridge 4 , .Xr if_bridge 4 , .Xr ip 4 , .Xr ipfw 8 , diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index b9a04db..3b1dd71 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -192,7 +192,7 @@ control message, or when all hooks have been disconnected. Example script showing how to set up a bridging network .El .Sh SEE ALSO -.Xr bridge 4 , +.Xr if_bridge 4 , .Xr netgraph 4 , .Xr ng_ether 4 , .Xr ng_hub 4 , diff --git a/share/man/man4/txp.4 b/share/man/man4/txp.4 index 366a81e..beecc67 100644 --- a/share/man/man4/txp.4 +++ b/share/man/man4/txp.4 @@ -78,10 +78,6 @@ checksum offloading, segmentation, nor .Xr ipsec 4 acceleration. -Note that hardware checksumming is only used when the interface is not -in -.Xr bridge 4 -mode. .Pp Each of the host's network addresses is specified at boot time with an diff --git a/share/man/man9/pfil.9 b/share/man/man9/pfil.9 index b54449e..11ce046 100644 --- a/share/man/man9/pfil.9 +++ b/share/man/man9/pfil.9 @@ -145,7 +145,7 @@ function might sleep! .Sh SEE ALSO .Xr bpf 4 , -.Xr bridge 4 +.Xr if_bridge 4 .Sh HISTORY The .Nm @@ -196,10 +196,12 @@ Packets diverted through these hooks have data in host byte order contrary to the above statements. .Pp The -.Xr bridge 4 -diverts inbound +.Xr if_bridge 4 +diverts .Dv AF_INET -traffic, but contrary to the above +and +.DV AF_INET6 +traffic according to it's sysctl settings, but contrary to the above statements, the data is provided in host byte order. .Pp When a diff --git a/sys/conf/NOTES b/sys/conf/NOTES index ba0225b..157f61c 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -765,12 +765,7 @@ options TCP_DROP_SYNFIN #drop TCP packets with SYN+FIN # as well. See dummynet(4) and ipfw(8) for more info. When you run # DUMMYNET it is advisable to also have "options HZ=1000" to achieve a # smoother scheduling of the traffic. -# -# BRIDGE enables bridging between ethernet cards -- see bridge(4). -# You can use IPFIREWALL and DUMMYNET together with bridging. -# options DUMMYNET -options BRIDGE # Zero copy sockets support. This enables "zero copy" for sending and # receiving data via a socket. The send side works for any type of NIC, diff --git a/sys/conf/files b/sys/conf/files index 6e057cb..eae581a 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1418,7 +1418,6 @@ libkern/strvalid.c standard net/bpf.c standard net/bpf_filter.c optional bpf net/bpf_filter.c optional netgraph_bpf -net/bridge.c optional bridge net/bridgestp.c optional if_bridge net/bsd_comp.c optional ppp_bsdcomp net/if.c standard diff --git a/sys/conf/options b/sys/conf/options index fdee8b5..b11aa09 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -327,7 +327,6 @@ BOOTP_COMPAT opt_bootp.h BOOTP_NFSROOT opt_bootp.h BOOTP_NFSV3 opt_bootp.h BOOTP_WIRED_TO opt_bootp.h -BRIDGE opt_bdg.h DEV_PF opt_pf.h DEV_PFLOG opt_pf.h DEV_PFSYNC opt_pf.h diff --git a/sys/dev/em/if_em.h b/sys/dev/em/if_em.h index 8d46455..097ab0e 100644 --- a/sys/dev/em/if_em.h +++ b/sys/dev/em/if_em.h @@ -75,7 +75,6 @@ POSSIBILITY OF SUCH DAMAGE. #include <dev/pci/pcireg.h> #include <sys/endian.h> #include <sys/proc.h> -#include "opt_bdg.h" #include <dev/em/if_em_hw.h> diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c index f22068e..02a3dd6 100644 --- a/sys/dev/if_ndis/if_ndis.c +++ b/sys/dev/if_ndis/if_ndis.c @@ -35,8 +35,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "opt_bdg.h" - #include <sys/param.h> #include <sys/systm.h> #include <sys/sockio.h> diff --git a/sys/dev/ixgb/if_ixgb.h b/sys/dev/ixgb/if_ixgb.h index 5d7b4d9..f92989c 100644 --- a/sys/dev/ixgb/if_ixgb.h +++ b/sys/dev/ixgb/if_ixgb.h @@ -78,7 +78,6 @@ POSSIBILITY OF SUCH DAMAGE. #include <sys/proc.h> #include <sys/sysctl.h> #include <sys/endian.h> -#include "opt_bdg.h" #include <dev/ixgb/ixgb_hw.h> #include <dev/ixgb/ixgb_ee.h> diff --git a/sys/modules/Makefile b/sys/modules/Makefile index e330ee2..e570a89 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -38,7 +38,6 @@ SUBDIR= ${_3dfx} \ bge \ ${_bios} \ ${_bktr} \ - bridge \ cam \ ${_canbepm} \ ${_canbus} \ diff --git a/sys/modules/agp/Makefile b/sys/modules/agp/Makefile index 2fc3b73..8e2ae03 100644 --- a/sys/modules/agp/Makefile +++ b/sys/modules/agp/Makefile @@ -18,7 +18,7 @@ SRCS+= agp_amd.c SRCS+= agp_amd64.c .endif SRCS+= device_if.h bus_if.h agp_if.h pci_if.h -SRCS+= opt_bdg.h opt_bus.h +SRCS+= opt_bus.h MFILES= kern/device_if.m kern/bus_if.m pci/agp_if.m dev/pci/pci_if.m WERROR= diff --git a/sys/modules/ath/Makefile b/sys/modules/ath/Makefile index 15e760c..f844b23 100644 --- a/sys/modules/ath/Makefile +++ b/sys/modules/ath/Makefile @@ -40,7 +40,7 @@ KMOD= if_ath SRCS= if_ath.c if_ath_pci.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h opt_inet.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h HAL= ${.CURDIR}/../../contrib/dev/ath CFLAGS+= -I. -I${HAL}/freebsd -I${HAL} diff --git a/sys/modules/ath_rate_amrr/Makefile b/sys/modules/ath_rate_amrr/Makefile index 22f16d2..fea186e 100644 --- a/sys/modules/ath_rate_amrr/Makefile +++ b/sys/modules/ath_rate_amrr/Makefile @@ -40,7 +40,7 @@ KMOD= ath_rate SRCS= amrr.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h opt_inet.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h HAL= ${.CURDIR}/../../contrib/dev/ath CFLAGS+= -I. -I${HAL}/freebsd -I${HAL} diff --git a/sys/modules/ath_rate_onoe/Makefile b/sys/modules/ath_rate_onoe/Makefile index e404e4b..b7a6732 100644 --- a/sys/modules/ath_rate_onoe/Makefile +++ b/sys/modules/ath_rate_onoe/Makefile @@ -40,7 +40,7 @@ KMOD= ath_rate SRCS= onoe.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h opt_inet.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h HAL= ${.CURDIR}/../../contrib/dev/ath CFLAGS+= -I. -I${HAL}/freebsd -I${HAL} diff --git a/sys/modules/ath_rate_sample/Makefile b/sys/modules/ath_rate_sample/Makefile index 1ce6ea3..51c3130 100644 --- a/sys/modules/ath_rate_sample/Makefile +++ b/sys/modules/ath_rate_sample/Makefile @@ -40,7 +40,7 @@ KMOD= ath_rate SRCS= sample.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h opt_inet.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h HAL= ${.CURDIR}/../../contrib/dev/ath CFLAGS+= -I. -I${HAL}/freebsd -I${HAL} diff --git a/sys/modules/aue/Makefile b/sys/modules/aue/Makefile index c7bb645..c8b3890 100644 --- a/sys/modules/aue/Makefile +++ b/sys/modules/aue/Makefile @@ -4,7 +4,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_aue -SRCS= if_aue.c opt_bdg.h opt_usb.h device_if.h bus_if.h +SRCS= if_aue.c opt_usb.h device_if.h bus_if.h SRCS+= miibus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/axe/Makefile b/sys/modules/axe/Makefile index fa00d09..4d82d5a 100644 --- a/sys/modules/axe/Makefile +++ b/sys/modules/axe/Makefile @@ -4,7 +4,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_axe -SRCS= if_axe.c opt_bdg.h opt_usb.h device_if.h bus_if.h +SRCS= if_axe.c opt_usb.h device_if.h bus_if.h SRCS+= miibus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/bfe/Makefile b/sys/modules/bfe/Makefile index 6fbe93a..19413f7 100644 --- a/sys/modules/bfe/Makefile +++ b/sys/modules/bfe/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/bfe KMOD= if_bfe -SRCS= if_bfe.c miibus_if.h miidevs.h opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_bfe.c miibus_if.h miidevs.h device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/bge/Makefile b/sys/modules/bge/Makefile index 53d8e54..3f66451 100644 --- a/sys/modules/bge/Makefile +++ b/sys/modules/bge/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/bge KMOD= if_bge -SRCS= opt_bge.h if_bge.c miibus_if.h miidevs.h opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= opt_bge.h if_bge.c miibus_if.h miidevs.h device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/bridge/Makefile b/sys/modules/bridge/Makefile deleted file mode 100644 index d2c1e32..0000000 --- a/sys/modules/bridge/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../net -KMOD= bridge -SRCS= bridge.c - -.include <bsd.kmod.mk> diff --git a/sys/modules/cdce/Makefile b/sys/modules/cdce/Makefile index c82754d..9942ded 100644 --- a/sys/modules/cdce/Makefile +++ b/sys/modules/cdce/Makefile @@ -4,7 +4,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_cdce -SRCS= if_cdce.c opt_bdg.h opt_usb.h device_if.h bus_if.h +SRCS= if_cdce.c opt_usb.h device_if.h bus_if.h SRCS+= usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/cue/Makefile b/sys/modules/cue/Makefile index 939e714..ae31329 100644 --- a/sys/modules/cue/Makefile +++ b/sys/modules/cue/Makefile @@ -4,7 +4,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_cue -SRCS= if_cue.c opt_bdg.h opt_usb.h device_if.h bus_if.h +SRCS= if_cue.c opt_usb.h device_if.h bus_if.h SRCS+= miibus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/dc/Makefile b/sys/modules/dc/Makefile index ac56533..915d444 100644 --- a/sys/modules/dc/Makefile +++ b/sys/modules/dc/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_dc -SRCS= if_dc.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_dc.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/de/Makefile b/sys/modules/de/Makefile index cf07c46..12f3caf 100644 --- a/sys/modules/de/Makefile +++ b/sys/modules/de/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_de -SRCS= if_de.c opt_bdg.h opt_ddb.h device_if.h bus_if.h pci_if.h +SRCS= if_de.c opt_ddb.h device_if.h bus_if.h pci_if.h # Compile-time options. diff --git a/sys/modules/dummynet/Makefile b/sys/modules/dummynet/Makefile index 18f6eed..84ccffe 100644 --- a/sys/modules/dummynet/Makefile +++ b/sys/modules/dummynet/Makefile @@ -2,6 +2,6 @@ .PATH: ${.CURDIR}/../../netinet KMOD= dummynet -SRCS= ip_dummynet.c opt_bdg.h +SRCS= ip_dummynet.c .include <bsd.kmod.mk> diff --git a/sys/modules/em/Makefile b/sys/modules/em/Makefile index 9518d68..21c6e16 100644 --- a/sys/modules/em/Makefile +++ b/sys/modules/em/Makefile @@ -4,6 +4,6 @@ KMOD= if_em SRCS= if_em.c if_em_hw.c -SRCS+= device_if.h bus_if.h pci_if.h opt_bdg.h +SRCS+= device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/fxp/Makefile b/sys/modules/fxp/Makefile index 0904e1a..b80c3ec 100644 --- a/sys/modules/fxp/Makefile +++ b/sys/modules/fxp/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/fxp KMOD= if_fxp -SRCS= if_fxp.c opt_bdg.h device_if.h bus_if.h pci_if.h miibus_if.h +SRCS= if_fxp.c device_if.h bus_if.h pci_if.h miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/hifn/Makefile b/sys/modules/hifn/Makefile index 33e6a77..a3f4f85 100644 --- a/sys/modules/hifn/Makefile +++ b/sys/modules/hifn/Makefile @@ -4,7 +4,7 @@ KMOD = hifn SRCS = hifn7751.c opt_hifn.h SRCS += device_if.h bus_if.h pci_if.h -SRCS += opt_bdg.h opt_bus.h crypto_if.h +SRCS += opt_bus.h crypto_if.h opt_hifn.h: echo "#define HIFN_DEBUG 1" > opt_hifn.h diff --git a/sys/modules/if_ndis/Makefile b/sys/modules/if_ndis/Makefile index cbc2ed0..0830aec 100644 --- a/sys/modules/if_ndis/Makefile +++ b/sys/modules/if_ndis/Makefile @@ -4,7 +4,7 @@ KMOD= if_ndis SRCS= if_ndis.c if_ndis_pci.c if_ndis_pccard.c if_ndis_usb.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h card_if.h pccarddevs.h +SRCS+= device_if.h bus_if.h pci_if.h card_if.h pccarddevs.h SRCS+= opt_usb.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/ipw/Makefile b/sys/modules/ipw/Makefile index 8ef8135..741d852 100644 --- a/sys/modules/ipw/Makefile +++ b/sys/modules/ipw/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/ipw KMOD = if_ipw -SRCS = if_ipw.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS = if_ipw.c device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/iwi/Makefile b/sys/modules/iwi/Makefile index a5a9605..60c6051 100644 --- a/sys/modules/iwi/Makefile +++ b/sys/modules/iwi/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/iwi KMOD = if_iwi -SRCS = if_iwi.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS = if_iwi.c device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/ixgb/Makefile b/sys/modules/ixgb/Makefile index 4396c2d..16e5975 100644 --- a/sys/modules/ixgb/Makefile +++ b/sys/modules/ixgb/Makefile @@ -4,6 +4,6 @@ KMOD= if_ixgb SRCS= if_ixgb.c ixgb_hw.c ixgb_ee.c -SRCS+= device_if.h bus_if.h pci_if.h opt_bdg.h +SRCS+= device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/kue/Makefile b/sys/modules/kue/Makefile index 8569f16..d5271d1 100644 --- a/sys/modules/kue/Makefile +++ b/sys/modules/kue/Makefile @@ -4,7 +4,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_kue -SRCS= if_kue.c opt_bdg.h opt_usb.h device_if.h bus_if.h +SRCS= if_kue.c opt_usb.h device_if.h bus_if.h SRCS+= miibus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/lge/Makefile b/sys/modules/lge/Makefile index 0728e6e..810e220 100644 --- a/sys/modules/lge/Makefile +++ b/sys/modules/lge/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/lge KMOD= if_lge -SRCS= if_lge.c miibus_if.h opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_lge.c miibus_if.h device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/ncv/Makefile b/sys/modules/ncv/Makefile index b1a273a..0181db8 100644 --- a/sys/modules/ncv/Makefile +++ b/sys/modules/ncv/Makefile @@ -4,7 +4,7 @@ KMOD= ncv SRCS= ncr53c500_pccard.c ncr53c500.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h isa_if.h card_if.h pccarddevs.h +SRCS+= device_if.h bus_if.h pci_if.h isa_if.h card_if.h pccarddevs.h SRCS+= opt_cam.h opt_scsi.h opt_ddb.h .include <bsd.kmod.mk> diff --git a/sys/modules/ndis/Makefile b/sys/modules/ndis/Makefile index 688cf97..2d14b18 100644 --- a/sys/modules/ndis/Makefile +++ b/sys/modules/ndis/Makefile @@ -5,7 +5,7 @@ KMOD= ndis SRCS= subr_pe.c subr_ndis.c subr_hal.c subr_ntoskrnl.c kern_ndis.c SRCS+= kern_windrv.c subr_usbd.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h vnode_if.h +SRCS+= device_if.h bus_if.h pci_if.h vnode_if.h .if ${MACHINE_ARCH} == "amd64" SRCS+= winx64_wrap.S diff --git a/sys/modules/nge/Makefile b/sys/modules/nge/Makefile index 15dc955..4bb68cd 100644 --- a/sys/modules/nge/Makefile +++ b/sys/modules/nge/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/nge KMOD= if_nge -SRCS= if_nge.c miibus_if.h opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_nge.c miibus_if.h device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/nsp/Makefile b/sys/modules/nsp/Makefile index 3cdc705..1773286 100644 --- a/sys/modules/nsp/Makefile +++ b/sys/modules/nsp/Makefile @@ -4,7 +4,7 @@ KMOD= nsp SRCS= nsp.c nsp_pccard.c -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h isa_if.h card_if.h pccarddevs.h +SRCS+= device_if.h bus_if.h pci_if.h isa_if.h card_if.h pccarddevs.h SRCS+= opt_cam.h opt_scsi.h opt_ddb.h .include <bsd.kmod.mk> diff --git a/sys/modules/pcn/Makefile b/sys/modules/pcn/Makefile index 637692e..c09af2d 100644 --- a/sys/modules/pcn/Makefile +++ b/sys/modules/pcn/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_pcn -SRCS= if_pcn.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_pcn.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/ral/Makefile b/sys/modules/ral/Makefile index 002d1e8..b3dcc69 100644 --- a/sys/modules/ral/Makefile +++ b/sys/modules/ral/Makefile @@ -4,6 +4,6 @@ KMOD = if_ral SRCS = if_ral.c if_ralrate.c if_ral_pccard.c if_ral_pci.c \ - opt_bdg.h device_if.h bus_if.h pci_if.h card_if.h pccarddevs.h + device_if.h bus_if.h pci_if.h card_if.h pccarddevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/re/Makefile b/sys/modules/re/Makefile index c28eb84..abc9e49 100644 --- a/sys/modules/re/Makefile +++ b/sys/modules/re/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../dev/re KMOD= if_re -SRCS= if_re.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_re.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/rl/Makefile b/sys/modules/rl/Makefile index 23a06a1..e846579 100644 --- a/sys/modules/rl/Makefile +++ b/sys/modules/rl/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_rl -SRCS= if_rl.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_rl.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/rue/Makefile b/sys/modules/rue/Makefile index 7e61752..1837eff 100644 --- a/sys/modules/rue/Makefile +++ b/sys/modules/rue/Makefile @@ -4,7 +4,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_rue -SRCS= if_rue.c opt_bdg.h opt_usb.h device_if.h bus_if.h +SRCS= if_rue.c opt_usb.h device_if.h bus_if.h SRCS+= miibus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/safe/Makefile b/sys/modules/safe/Makefile index b47a594..6886897 100644 --- a/sys/modules/safe/Makefile +++ b/sys/modules/safe/Makefile @@ -30,7 +30,7 @@ KMOD = safe SRCS = safe.c opt_safe.h SRCS += device_if.h bus_if.h pci_if.h -SRCS += opt_bdg.h opt_bus.h crypto_if.h +SRCS += opt_bus.h crypto_if.h opt_safe.h: echo "#define SAFE_DEBUG 1" > opt_safe.h diff --git a/sys/modules/sf/Makefile b/sys/modules/sf/Makefile index 1725f09..156a3b2 100644 --- a/sys/modules/sf/Makefile +++ b/sys/modules/sf/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_sf -SRCS= if_sf.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_sf.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/sis/Makefile b/sys/modules/sis/Makefile index 8fa9ec4..d16611b8 100644 --- a/sys/modules/sis/Makefile +++ b/sys/modules/sis/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_sis -SRCS= if_sis.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_sis.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/sk/Makefile b/sys/modules/sk/Makefile index 28ad56b..dae187c 100644 --- a/sys/modules/sk/Makefile +++ b/sys/modules/sk/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_sk -SRCS= if_sk.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_sk.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/snc/Makefile b/sys/modules/snc/Makefile index 4b158fb..b862372 100644 --- a/sys/modules/snc/Makefile +++ b/sys/modules/snc/Makefile @@ -4,7 +4,7 @@ KMOD= if_snc SRCS= if_snc.c if_snc_cbus.c if_snc_pccard.c dp83932.c dp83932subr.c -SRCS+= opt_inet.h opt_bdg.h device_if.h bus_if.h isa_if.h +SRCS+= opt_inet.h device_if.h bus_if.h isa_if.h opt_inet.h: echo "#define INET 1" > ${.TARGET} diff --git a/sys/modules/ste/Makefile b/sys/modules/ste/Makefile index 6ad69a8..7f6e405 100644 --- a/sys/modules/ste/Makefile +++ b/sys/modules/ste/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_ste -SRCS= if_ste.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_ste.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/stg/Makefile b/sys/modules/stg/Makefile index 83362d3..b8c0ae8 100644 --- a/sys/modules/stg/Makefile +++ b/sys/modules/stg/Makefile @@ -7,7 +7,7 @@ SRCS= tmc18c30.c tmc18c30_subr.c \ tmc18c30_isa.c isa_if.h \ tmc18c30_pccard.c card_if.h pccarddevs.h \ tmc18c30_pci.c pci_if.h -SRCS+= opt_bdg.h device_if.h bus_if.h +SRCS+= device_if.h bus_if.h SRCS+= opt_cam.h opt_scsi.h opt_ddb.h .include <bsd.kmod.mk> diff --git a/sys/modules/ti/Makefile b/sys/modules/ti/Makefile index fdafb8a..c74b6ab 100644 --- a/sys/modules/ti/Makefile +++ b/sys/modules/ti/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_ti -SRCS= if_ti.c opt_bdg.h device_if.h bus_if.h pci_if.h opt_ti.h opt_zero.h +SRCS= if_ti.c device_if.h bus_if.h pci_if.h opt_ti.h opt_zero.h .include <bsd.kmod.mk> diff --git a/sys/modules/tl/Makefile b/sys/modules/tl/Makefile index bbd30a1..ea5c808 100644 --- a/sys/modules/tl/Makefile +++ b/sys/modules/tl/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_tl -SRCS= if_tl.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_tl.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/tx/Makefile b/sys/modules/tx/Makefile index 8d4ded9..1fe6ba1 100644 --- a/sys/modules/tx/Makefile +++ b/sys/modules/tx/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../dev/tx KMOD= if_tx -SRCS= if_tx.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_tx.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h miidevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/txp/Makefile b/sys/modules/txp/Makefile index 7e1f500..379f3e3 100644 --- a/sys/modules/txp/Makefile +++ b/sys/modules/txp/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/txp KMOD= if_txp -SRCS= if_txp.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_txp.c device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/ubsec/Makefile b/sys/modules/ubsec/Makefile index 4c9f58c..8b6799af 100644 --- a/sys/modules/ubsec/Makefile +++ b/sys/modules/ubsec/Makefile @@ -4,7 +4,7 @@ KMOD = ubsec SRCS = ubsec.c opt_ubsec.h SRCS += device_if.h bus_if.h pci_if.h -SRCS += opt_bdg.h opt_bus.h crypto_if.h +SRCS += opt_bus.h crypto_if.h opt_ubsec.h: echo "#define UBSEC_DEBUG 1" > opt_ubsec.h diff --git a/sys/modules/udav/Makefile b/sys/modules/udav/Makefile index 02a9d72..fd7acf9 100644 --- a/sys/modules/udav/Makefile +++ b/sys/modules/udav/Makefile @@ -3,7 +3,7 @@ S= ${.CURDIR}/../.. .PATH: $S/dev/usb KMOD= if_udav -SRCS= if_udav.c opt_bdg.h opt_usb.h device_if.h bus_if.h opt_inet.h +SRCS= if_udav.c opt_usb.h device_if.h bus_if.h opt_inet.h SRCS+= miibus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/ural/Makefile b/sys/modules/ural/Makefile index e347e05..7076e811 100644 --- a/sys/modules/ural/Makefile +++ b/sys/modules/ural/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/usb KMOD = if_ural -SRCS = if_ural.c opt_bdg.h opt_usb.h device_if.h bus_if.h usbdevs.h +SRCS = if_ural.c opt_usb.h device_if.h bus_if.h usbdevs.h .include <bsd.kmod.mk> diff --git a/sys/modules/vge/Makefile b/sys/modules/vge/Makefile index 8569f68..a06ee56 100644 --- a/sys/modules/vge/Makefile +++ b/sys/modules/vge/Makefile @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../dev/vge KMOD= if_vge -SRCS= if_vge.c miibus_if.h opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_vge.c miibus_if.h device_if.h bus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/vr/Makefile b/sys/modules/vr/Makefile index fd58ab0..9d0e8db 100644 --- a/sys/modules/vr/Makefile +++ b/sys/modules/vr/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_vr -SRCS= if_vr.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_vr.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/vx/Makefile b/sys/modules/vx/Makefile index 37d036f..6293b1a 100644 --- a/sys/modules/vx/Makefile +++ b/sys/modules/vx/Makefile @@ -7,6 +7,6 @@ SRCS= if_vx.c if_vx_pci.c .if ${MACHINE_ARCH} == "i386" SRCS+= if_vx_eisa.c .endif -SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h eisa_if.h +SRCS+= device_if.h bus_if.h pci_if.h eisa_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/wb/Makefile b/sys/modules/wb/Makefile index e53d986..2f32cd3 100644 --- a/sys/modules/wb/Makefile +++ b/sys/modules/wb/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_wb -SRCS= if_wb.c opt_bdg.h device_if.h +SRCS= if_wb.c device_if.h SRCS+= bus_if.h miibus_if.h pci_if.h .include <bsd.kmod.mk> diff --git a/sys/modules/xl/Makefile b/sys/modules/xl/Makefile index 3c2c162..637da41 100644 --- a/sys/modules/xl/Makefile +++ b/sys/modules/xl/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../pci KMOD= if_xl -SRCS= if_xl.c opt_bdg.h device_if.h bus_if.h pci_if.h +SRCS= if_xl.c device_if.h bus_if.h pci_if.h SRCS+= miibus_if.h .include <bsd.kmod.mk> diff --git a/sys/net/bridge.c b/sys/net/bridge.c deleted file mode 100644 index b95fa57..0000000 --- a/sys/net/bridge.c +++ /dev/null @@ -1,1302 +0,0 @@ -/*- - * Copyright (c) 1998-2002 Luigi Rizzo - * - * Work partly supported by: Cisco Systems, Inc. - NSITE lab, RTP, NC - * - * 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. - * - * 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 REGENTS OR CONTRIBUTORS 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. - * - * $FreeBSD$ - */ - -/* - * This code implements bridging in FreeBSD. It only acts on ethernet - * interfaces, including VLANs (others are still usable for routing). - * A FreeBSD host can implement multiple logical bridges, called - * "clusters". Each cluster is made of a set of interfaces, and - * identified by a "cluster-id" which is a number in the range 1..2^16-1. - * - * Bridging is enabled by the sysctl variable - * net.link.ether.bridge.enable - * the grouping of interfaces into clusters is done with - * net.link.ether.bridge.config - * containing a list of interfaces each optionally followed by - * a colon and the cluster it belongs to (1 is the default). - * Separators can be spaces, commas or tabs, e.g. - * net.link.ether.bridge.config="fxp0:2 fxp1:2 dc0 dc1:1" - * Optionally bridged packets can be passed through the firewall, - * this is controlled by the variable - * net.link.ether.bridge.ipfw - * - * For each cluster there is a descriptor (cluster_softc) storing - * the following data structures: - * - a hash table with the MAC address and destination interface for each - * known node. The table is indexed using a hash of the source address. - * - an array with the MAC addresses of the interfaces used in the cluster. - * - * Input packets are tapped near the beginning of ether_input(), and - * analysed by bridge_in(). Depending on the result, the packet - * can be forwarded to one or more output interfaces using bdg_forward(), - * and/or sent to the upper layer (e.g. in case of multicast). - * - * Output packets are intercepted near the end of ether_output(). - * The correct destination is selected by bridge_dst_lookup(), - * and then forwarding is done by bdg_forward(). - * - * The arp code is also modified to let a machine answer to requests - * irrespective of the port the request came from. - * - * In case of loops in the bridging topology, the bridge detects this - * event and temporarily mutes output bridging on one of the ports. - * Periodically, interfaces are unmuted by bdg_timeout(). - * Muting is only implemented as a safety measure, and also as - * a mechanism to support a user-space implementation of the spanning - * tree algorithm. - * - * To build a bridging kernel, use the following option - * option BRIDGE - * and then at runtime set the sysctl variable to enable bridging. - * - * Only one interface per cluster is supposed to have addresses set (but - * there are no substantial problems if you set addresses for none or - * for more than one interface). - * Bridging will act before routing, but nothing prevents a machine - * from doing both (modulo bugs in the implementation...). - * - * THINGS TO REMEMBER - * - bridging is incompatible with multicast routing on the same - * machine. There is not an easy fix to this. - * - be very careful when bridging VLANs - * - loop detection is still not very robust. - */ - -#include <sys/param.h> -#include <sys/mbuf.h> -#include <sys/malloc.h> -#include <sys/protosw.h> -#include <sys/systm.h> -#include <sys/socket.h> /* for net/if.h */ -#include <sys/ctype.h> /* string functions */ -#include <sys/kernel.h> -#include <sys/module.h> -#include <sys/sysctl.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_arp.h> /* for struct arpcom */ -#include <net/if_types.h> -#include <net/if_var.h> -#include <net/pfil.h> - -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#include <netinet/ip_var.h> - -#include <net/route.h> -#include <netinet/ip_fw.h> -#include <netinet/ip_dummynet.h> -#include <net/bridge.h> - -/*--------------------*/ - -#define ETHER_ADDR_COPY(_dst,_src) bcopy(_src, _dst, ETHER_ADDR_LEN) -#define ETHER_ADDR_EQ(_a1,_a2) (bcmp(_a1, _a2, ETHER_ADDR_LEN) == 0) - -/* - * For each cluster, source MAC addresses are stored into a hash - * table which locates the port they reside on. - */ -#define HASH_SIZE 8192 /* Table size, must be a power of 2 */ - -typedef struct hash_table { /* each entry. */ - struct ifnet * name; - u_char etheraddr[ETHER_ADDR_LEN]; - u_int16_t used; /* also, padding */ -} bdg_hash_table ; - -/* - * The hash function applied to MAC addresses. Out of the 6 bytes, - * the last ones tend to vary more. Since we are on a little endian machine, - * we have to do some gimmick... - */ -#define HASH_FN(addr) ( \ - ntohs( ((u_int16_t *)addr)[1] ^ ((u_int16_t *)addr)[2] ) & (HASH_SIZE -1)) - -/* - * This is the data structure where local addresses are stored. - */ -struct bdg_addr { - u_char etheraddr[ETHER_ADDR_LEN]; - u_int16_t _padding; -}; - -/* - * The configuration of each cluster includes the cluster id, a pointer to - * the hash table, and an array of local MAC addresses (of size "ports"). - */ -struct cluster_softc { - u_int16_t cluster_id; - u_int16_t ports; - bdg_hash_table *ht; - struct bdg_addr *my_macs; /* local MAC addresses */ -}; - - -extern struct protosw inetsw[]; /* from netinet/ip_input.c */ - -static int n_clusters; /* number of clusters */ -static struct cluster_softc *clusters; - -static struct mtx bdg_mtx; -#define BDG_LOCK_INIT() mtx_init(&bdg_mtx, "bridge", NULL, MTX_DEF) -#define BDG_LOCK_DESTROY() mtx_destroy(&bdg_mtx) -#define BDG_LOCK() mtx_lock(&bdg_mtx) -#define BDG_UNLOCK() mtx_unlock(&bdg_mtx) -#define BDG_LOCK_ASSERT() mtx_assert(&bdg_mtx, MA_OWNED) - -#define BDG_MUTED(ifp) (ifp2sc[ifp->if_index].flags & IFF_MUTE) -#define BDG_MUTE(ifp) ifp2sc[ifp->if_index].flags |= IFF_MUTE -#define BDG_CLUSTER(ifp) (ifp2sc[ifp->if_index].cluster) - -#define BDG_SAMECLUSTER(ifp,src) \ - (src == NULL || BDG_CLUSTER(ifp) == BDG_CLUSTER(src) ) - -#ifdef __i386__ -#define BDG_MATCH(a,b) ( \ - ((u_int16_t *)(a))[2] == ((u_int16_t *)(b))[2] && \ - *((u_int32_t *)(a)) == *((u_int32_t *)(b)) ) -#define IS_ETHER_BROADCAST(a) ( \ - *((u_int32_t *)(a)) == 0xffffffff && \ - ((u_int16_t *)(a))[2] == 0xffff ) -#else -/* for machines that do not support unaligned access */ -#define BDG_MATCH(a,b) ETHER_ADDR_EQ(a,b) -#define IS_ETHER_BROADCAST(a) ETHER_ADDR_EQ(a,"\377\377\377\377\377\377") -#endif - -SYSCTL_DECL(_net_link_ether); -SYSCTL_NODE(_net_link_ether, OID_AUTO, bridge, CTLFLAG_RD, 0, - "Bridge parameters"); -static char bridge_version[] = "031224"; -SYSCTL_STRING(_net_link_ether_bridge, OID_AUTO, version, CTLFLAG_RD, - bridge_version, 0, "software version"); - -#define BRIDGE_DEBUG -#ifdef BRIDGE_DEBUG -int bridge_debug = 0; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, debug, CTLFLAG_RW, &bridge_debug, - 0, "control debugging printfs"); -#define DPRINTF(X) if (bridge_debug) printf X -#else -#define DPRINTF(X) -#endif - -#ifdef BRIDGE_TIMING -/* - * For timing-related debugging, you can use the following macros. - * remember, rdtsc() only works on Pentium-class machines - - quad_t ticks; - DDB(ticks = rdtsc();) - ... interesting code ... - DDB(bdg_fw_ticks += (u_long)(rdtsc() - ticks) ; bdg_fw_count++ ;) - - * - */ -#define DDB(x) x - -static int bdg_fw_avg; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, fw_avg, CTLFLAG_RW, - &bdg_fw_avg, 0,"Cycle counter avg"); -static int bdg_fw_ticks; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, fw_ticks, CTLFLAG_RW, - &bdg_fw_ticks, 0,"Cycle counter item"); -static int bdg_fw_count; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, fw_count, CTLFLAG_RW, - &bdg_fw_count, 0,"Cycle counter count"); -#else -#define DDB(x) -#endif - -static int bdginit(void); -static void parse_bdg_cfg(void); -static struct mbuf *bdg_forward(struct mbuf *, struct ifnet *); - -static int bdg_ipf; /* IPFilter enabled in bridge */ -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, ipf, CTLFLAG_RW, - &bdg_ipf, 0,"Pass bridged pkts through IPFilter"); -static int bdg_ipfw; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, ipfw, CTLFLAG_RW, - &bdg_ipfw,0,"Pass bridged pkts through firewall"); - -static int bdg_copy; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, copy, CTLFLAG_RW, - &bdg_copy, 0, "Force packet copy in bdg_forward"); - -int bdg_ipfw_drops; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, ipfw_drop, - CTLFLAG_RW, &bdg_ipfw_drops,0,""); -int bdg_ipfw_colls; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, ipfw_collisions, - CTLFLAG_RW, &bdg_ipfw_colls,0,""); - -static int bdg_thru; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, packets, CTLFLAG_RW, - &bdg_thru, 0, "Packets through bridge"); -static int bdg_dropped; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, dropped, CTLFLAG_RW, - &bdg_dropped, 0, "Packets dropped in bdg_forward"); -static int bdg_predict; -SYSCTL_INT(_net_link_ether_bridge, OID_AUTO, predict, CTLFLAG_RW, - &bdg_predict, 0, "Correctly predicted header location"); - -#ifdef BRIDGE_DEBUG -static char *bdg_dst_names[] = { - "BDG_NULL ", - "BDG_BCAST ", - "BDG_MCAST ", - "BDG_LOCAL ", - "BDG_DROP ", - "BDG_UNKNOWN ", - "BDG_IN ", - "BDG_OUT ", - "BDG_FORWARD " }; -#endif /* BRIDGE_DEBUG */ - -/* - * System initialization - */ -static struct bdg_stats bdg_stats ; -SYSCTL_STRUCT(_net_link_ether_bridge, OID_AUTO, stats, CTLFLAG_RD, - &bdg_stats, bdg_stats, "bridge statistics"); - -static struct callout bdg_callout; - -/* - * Add an interface to a cluster, possibly creating a new entry in - * the cluster table. This requires reallocation of the table and - * updating pointers in ifp2sc. - */ -static struct cluster_softc * -add_cluster(u_int16_t cluster_id, struct ifnet *ifp) -{ - struct cluster_softc *c = NULL; - int i; - - BDG_LOCK_ASSERT(); - - for (i = 0; i < n_clusters ; i++) - if (clusters[i].cluster_id == cluster_id) - goto found; - - /* Not found, need to reallocate */ - c = malloc((1+n_clusters) * sizeof (*c), M_IFADDR, M_NOWAIT | M_ZERO); - if (c == NULL) {/* malloc failure */ - printf("-- bridge: cannot add new cluster\n"); - goto bad; - } - c[n_clusters].ht = (struct hash_table *) - malloc(HASH_SIZE * sizeof(struct hash_table), - M_IFADDR, M_NOWAIT | M_ZERO); - if (c[n_clusters].ht == NULL) { - printf("-- bridge: cannot allocate hash table for new cluster\n"); - goto bad; - } - c[n_clusters].my_macs = (struct bdg_addr *) - malloc(BDG_MAX_PORTS * sizeof(struct bdg_addr), - M_IFADDR, M_NOWAIT | M_ZERO); - if (c[n_clusters].my_macs == NULL) { - printf("-- bridge: cannot allocate mac addr table for new cluster\n"); - free(c[n_clusters].ht, M_IFADDR); - goto bad; - } - - c[n_clusters].cluster_id = cluster_id; - c[n_clusters].ports = 0; - /* - * now copy old descriptors here - */ - if (n_clusters > 0) { - for (i=0; i < n_clusters; i++) - c[i] = clusters[i]; - /* - * and finally update pointers in ifp2sc - */ - for (i = 0 ; i < if_index && i < BDG_MAX_PORTS; i++) - if (ifp2sc[i].cluster != NULL) - ifp2sc[i].cluster = c + (ifp2sc[i].cluster - clusters); - free(clusters, M_IFADDR); - } - clusters = c; - i = n_clusters; /* index of cluster entry */ - n_clusters++; -found: - c = clusters + i; /* the right cluster ... */ - ETHER_ADDR_COPY(c->my_macs[c->ports].etheraddr, IFP2ENADDR(ifp)); - c->ports++; - return c; -bad: - if (c) - free(c, M_IFADDR); - return NULL; -} - - -/* - * Turn off bridging, by clearing promisc mode on the interface, - * marking the interface as unused, and clearing the name in the - * stats entry. - * Also dispose the hash tables associated with the clusters. - */ -static void -bridge_off(void) -{ - struct ifnet *ifp ; - int i; - - BDG_LOCK_ASSERT(); - - DPRINTF(("%s: n_clusters %d\n", __func__, n_clusters)); - - IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) { - struct bdg_softc *b; - - if (ifp->if_index >= BDG_MAX_PORTS) - continue; /* make sure we do not go beyond the end */ - b = &ifp2sc[ifp->if_index]; - - if ( b->flags & IFF_BDG_PROMISC ) { - ifpromisc(ifp, 0); - b->flags &= ~(IFF_BDG_PROMISC|IFF_MUTE) ; - DPRINTF(("%s: %s promisc OFF if_flags 0x%x " - "bdg_flags 0x%x\n", __func__, ifp->if_xname, - ifp->if_flags, b->flags)); - } - b->flags &= ~(IFF_USED) ; - b->cluster = NULL; - bdg_stats.s[ifp->if_index].name[0] = '\0'; - } - IFNET_RUNLOCK(); - /* flush_tables */ - - for (i=0; i < n_clusters; i++) { - free(clusters[i].ht, M_IFADDR); - free(clusters[i].my_macs, M_IFADDR); - } - if (clusters != NULL) - free(clusters, M_IFADDR); - clusters = NULL; - n_clusters =0; -} - -/* - * set promisc mode on the interfaces we use. - */ -static void -bridge_on(void) -{ - struct ifnet *ifp ; - - BDG_LOCK_ASSERT(); - - IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) { - struct bdg_softc *b = &ifp2sc[ifp->if_index]; - - if ( !(b->flags & IFF_USED) ) - continue ; - if ( !( ifp->if_flags & IFF_UP) ) { - if_up(ifp); - } - if ( !(b->flags & IFF_BDG_PROMISC) ) { - (void) ifpromisc(ifp, 1); - b->flags |= IFF_BDG_PROMISC ; - DPRINTF(("%s: %s promisc ON if_flags 0x%x bdg_flags 0x%x\n", - __func__, ifp->if_xname, ifp->if_flags, b->flags)); - } - if (b->flags & IFF_MUTE) { - DPRINTF(("%s: unmuting %s\n", __func__, ifp->if_xname)); - b->flags &= ~IFF_MUTE; - } - } - IFNET_RUNLOCK(); -} - -static char bridge_cfg[1024]; /* NB: in BSS so initialized to zero */ - -/** - * reconfigure bridge. - * This is also done every time we attach or detach an interface. - * Main use is to make sure that we do not bridge on some old - * (ejected) device. So, it would be really useful to have a - * pointer to the modified device as an argument. Without it, we - * have to scan all interfaces. - */ -static void -reconfigure_bridge_locked(void) -{ - BDG_LOCK_ASSERT(); - - bridge_off(); - if (do_bridge) { - if (if_index >= BDG_MAX_PORTS) { - printf("-- sorry too many interfaces (%d, max is %d)," - " disabling bridging\n", if_index, BDG_MAX_PORTS); - do_bridge = 0; - return; - } - parse_bdg_cfg(); - bridge_on(); - } -} - -static void -reconfigure_bridge(void) -{ - BDG_LOCK(); - reconfigure_bridge_locked(); - BDG_UNLOCK(); -} - -/* - * parse the config string, set IFF_USED, name and cluster_id - * for all interfaces found. - * The config string is a list of "if[:cluster]" with - * a number of possible separators (see "sep"). In particular the - * use of the space lets you set bridge_cfg with the output from - * "ifconfig -l" - */ -static void -parse_bdg_cfg(void) -{ - char *p, *beg; - int l, cluster; - static const char *sep = ", \t"; - - BDG_LOCK_ASSERT(); - - for (p = bridge_cfg; *p ; p++) { - struct ifnet *ifp; - int found = 0; - char c; - - if (index(sep, *p)) /* skip separators */ - continue ; - /* names are lowercase and digits */ - for ( beg = p ; islower(*p) || isdigit(*p) ; p++ ) - ; - l = p - beg ; /* length of name string */ - if (l == 0) /* invalid name */ - break ; - if ( *p != ':' ) /* no ':', assume default cluster 1 */ - cluster = 1 ; - else /* fetch cluster */ - cluster = strtoul( p+1, &p, 10); - c = *p; - *p = '\0'; - /* - * now search in interface list for a matching name - */ - IFNET_RLOCK(); /* could sleep XXX */ - TAILQ_FOREACH(ifp, &ifnet, if_link) { - - if (!strncmp(beg, ifp->if_xname, max(l, strlen(ifp->if_xname)))) { - struct bdg_softc *b = &ifp2sc[ifp->if_index]; - if (ifp->if_type != IFT_ETHER && ifp->if_type != IFT_L2VLAN) { - printf("%s is not an ethernet, continue\n", ifp->if_xname); - continue; - } - if (b->flags & IFF_USED) { - printf("%s already used, skipping\n", ifp->if_xname); - break; - } - b->cluster = add_cluster(htons(cluster), ifp); - b->flags |= IFF_USED ; - snprintf(bdg_stats.s[ifp->if_index].name, - sizeof(bdg_stats.s[ifp->if_index].name), - "%s:%d", ifp->if_xname, cluster); - - DPRINTF(("%s: found %s next c %d\n", __func__, - bdg_stats.s[ifp->if_index].name, c)); - found = 1; - break ; - } - } - IFNET_RUNLOCK(); - if (!found) - printf("interface %s Not found in bridge\n", beg); - *p = c; - if (c == '\0') - break; /* no more */ - } -} - -/* - * handler for net.link.ether.bridge - */ -static int -sysctl_bdg(SYSCTL_HANDLER_ARGS) -{ - int enable = do_bridge; - int error; - - error = sysctl_handle_int(oidp, &enable, 0, req); - enable = (enable) ? 1 : 0; - BDG_LOCK(); - if (enable != do_bridge) { - do_bridge = enable; - reconfigure_bridge_locked(); - } - BDG_UNLOCK(); - return error ; -} -SYSCTL_PROC(_net_link_ether_bridge, OID_AUTO, enable, CTLTYPE_INT|CTLFLAG_RW, - &do_bridge, 0, &sysctl_bdg, "I", "Bridging"); - -/* - * handler for net.link.ether.bridge_cfg - */ -static int -sysctl_bdg_cfg(SYSCTL_HANDLER_ARGS) -{ - int error; - char *new_cfg; - - new_cfg = malloc(sizeof(bridge_cfg), M_TEMP, M_WAITOK); - bcopy(bridge_cfg, new_cfg, sizeof(bridge_cfg)); - - error = sysctl_handle_string(oidp, new_cfg, oidp->oid_arg2, req); - if (error == 0) { - BDG_LOCK(); - if (strcmp(new_cfg, bridge_cfg)) { - bcopy(new_cfg, bridge_cfg, sizeof(bridge_cfg)); - reconfigure_bridge_locked(); - } - BDG_UNLOCK(); - } - - free(new_cfg, M_TEMP); - - return error; -} -SYSCTL_PROC(_net_link_ether_bridge, OID_AUTO, config, CTLTYPE_STRING|CTLFLAG_RW, - &bridge_cfg, sizeof(bridge_cfg), &sysctl_bdg_cfg, "A", - "Bridge configuration"); - -static int -sysctl_refresh(SYSCTL_HANDLER_ARGS) -{ - if (req->newptr) - reconfigure_bridge(); - - return 0; -} -SYSCTL_PROC(_net_link_ether_bridge, OID_AUTO, refresh, CTLTYPE_INT|CTLFLAG_WR, - NULL, 0, &sysctl_refresh, "I", "iface refresh"); - -#ifndef BURN_BRIDGES -#define SYSCTL_OID_COMPAT(parent, nbr, name, kind, a1, a2, handler, fmt, descr)\ - static struct sysctl_oid sysctl__##parent##_##name##_compat = { \ - &sysctl_##parent##_children, { 0 }, \ - nbr, kind, a1, a2, #name, handler, fmt, 0, descr }; \ - DATA_SET(sysctl_set, sysctl__##parent##_##name##_compat) -#define SYSCTL_INT_COMPAT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID_COMPAT(parent, nbr, name, CTLTYPE_INT|(access), \ - ptr, val, sysctl_handle_int, "I", descr) -#define SYSCTL_STRUCT_COMPAT(parent, nbr, name, access, ptr, type, descr)\ - SYSCTL_OID_COMPAT(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ - ptr, sizeof(struct type), sysctl_handle_opaque, \ - "S," #type, descr) -#define SYSCTL_PROC_COMPAT(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ - SYSCTL_OID_COMPAT(parent, nbr, name, (access), \ - ptr, arg, handler, fmt, descr) - -SYSCTL_INT_COMPAT(_net_link_ether, OID_AUTO, bridge_ipf, CTLFLAG_RW, - &bdg_ipf, 0,"Pass bridged pkts through IPFilter"); -SYSCTL_INT_COMPAT(_net_link_ether, OID_AUTO, bridge_ipfw, CTLFLAG_RW, - &bdg_ipfw,0,"Pass bridged pkts through firewall"); -SYSCTL_STRUCT_COMPAT(_net_link_ether, PF_BDG, bdgstats, CTLFLAG_RD, - &bdg_stats, bdg_stats, "bridge statistics"); -SYSCTL_PROC_COMPAT(_net_link_ether, OID_AUTO, bridge_cfg, - CTLTYPE_STRING|CTLFLAG_RW, - &bridge_cfg, sizeof(bridge_cfg), &sysctl_bdg_cfg, "A", - "Bridge configuration"); -SYSCTL_PROC_COMPAT(_net_link_ether, OID_AUTO, bridge_refresh, - CTLTYPE_INT|CTLFLAG_WR, - NULL, 0, &sysctl_refresh, "I", "iface refresh"); -#endif - -static int bdg_loops; -static int bdg_slowtimer = 0; -static int bdg_age_index = 0; /* index of table position to age */ - -/* - * called periodically to flush entries etc. - */ -static void -bdg_timeout(void *dummy) -{ - if (do_bridge) { - int l, i; - - BDG_LOCK(); - /* - * age entries in the forwarding table. - */ - l = bdg_age_index + HASH_SIZE/4 ; - if (l > HASH_SIZE) - l = HASH_SIZE; - - for (i = 0; i < n_clusters; i++) { - bdg_hash_table *bdg_table = clusters[i].ht; - for (; bdg_age_index < l; bdg_age_index++) - if (bdg_table[bdg_age_index].used) - bdg_table[bdg_age_index].used = 0; - else if (bdg_table[bdg_age_index].name) { - DPRINTF(("%s: flushing stale entry %d\n", - __func__, bdg_age_index)); - bdg_table[bdg_age_index].name = NULL; - } - } - if (bdg_age_index >= HASH_SIZE) - bdg_age_index = 0; - - if (--bdg_slowtimer <= 0 ) { - bdg_slowtimer = 5; - - bridge_on(); /* we just need unmute, really */ - bdg_loops = 0; - } - BDG_UNLOCK(); - } - callout_reset(&bdg_callout, 2*hz, bdg_timeout, NULL); -} - -/* - * Find the right pkt destination: - * BDG_BCAST is a broadcast - * BDG_MCAST is a multicast - * BDG_LOCAL is for a local address - * BDG_DROP must be dropped - * other ifp of the dest. interface (incl.self) - * - * We assume this is only called for interfaces for which bridging - * is enabled, i.e. BDG_USED(ifp) is true. - */ -static __inline struct ifnet * -bridge_dst_lookup(struct ether_header *eh, struct cluster_softc *c) -{ - bdg_hash_table *bt; /* pointer to entry in hash table */ - - BDG_LOCK_ASSERT(); - - if (ETHER_IS_MULTICAST(eh->ether_dhost)) - return IS_ETHER_BROADCAST(eh->ether_dhost) ? BDG_BCAST : BDG_MCAST; - /* - * Lookup local addresses in case one matches. We optimize - * for the common case of two interfaces. - */ - KASSERT(c->ports != 0, ("lookup with no ports!")); - switch (c->ports) { - int i; - default: - for (i = c->ports-1; i > 1; i--) { - if (ETHER_ADDR_EQ(c->my_macs[i].etheraddr, eh->ether_dhost)) - return BDG_LOCAL; - } - /* fall thru... */ - case 2: - if (ETHER_ADDR_EQ(c->my_macs[1].etheraddr, eh->ether_dhost)) - return BDG_LOCAL; - case 1: - if (ETHER_ADDR_EQ(c->my_macs[0].etheraddr, eh->ether_dhost)) - return BDG_LOCAL; - } - /* - * Look for a possible destination in table - */ - bt = &c->ht[HASH_FN(eh->ether_dhost)]; - if (bt->name && ETHER_ADDR_EQ(bt->etheraddr, eh->ether_dhost)) - return bt->name; - else - return BDG_UNKNOWN; -} - -/** - * bridge_in() is invoked to perform bridging decision on input packets. - * - * On Input: - * eh Ethernet header of the incoming packet. - * ifp interface the packet is coming from. - * - * On Return: destination of packet, one of - * BDG_BCAST broadcast - * BDG_MCAST multicast - * BDG_LOCAL is only for a local address (do not forward) - * BDG_DROP drop the packet - * ifp ifp of the destination interface. - * - * Forwarding is not done directly to give a chance to some drivers - * to fetch more of the packet, or simply drop it completely. - */ - -static struct mbuf * -bridge_in(struct ifnet *ifp, struct mbuf *m) -{ - struct ether_header *eh; - struct ifnet *dst, *old; - bdg_hash_table *bt; /* location in hash table */ - int dropit = BDG_MUTED(ifp); - int index; - - eh = mtod(m, struct ether_header *); - - /* - * hash the source address - */ - BDG_LOCK(); - index = HASH_FN(eh->ether_shost); - bt = &BDG_CLUSTER(ifp)->ht[index]; - bt->used = 1; - old = bt->name; - if (old) { /* the entry is valid */ - if (!ETHER_ADDR_EQ(eh->ether_shost, bt->etheraddr)) { - bdg_ipfw_colls++; - bt->name = NULL; /* NB: will overwrite below */ - } else if (old != ifp) { - /* - * Found a loop. Either a machine has moved, or there - * is a misconfiguration/reconfiguration of the network. - * First, do not forward this packet! - * Record the relocation anyways; then, if loops persist, - * suspect a reconfiguration and disable forwarding - * from the old interface. - */ - bt->name = ifp; /* relocate address */ - printf("-- loop (%d) %6D to %s from %s (%s)\n", - bdg_loops, eh->ether_shost, ".", - ifp->if_xname, old->if_xname, - BDG_MUTED(old) ? "muted":"active"); - dropit = 1; - if (!BDG_MUTED(old)) { - if (bdg_loops++ > 10) - BDG_MUTE(old); - } - } - } - - /* - * now write the source address into the table - */ - if (bt->name == NULL) { - DPRINTF(("%s: new addr %6D at %d for %s\n", - __func__, eh->ether_shost, ".", index, ifp->if_xname)); - ETHER_ADDR_COPY(bt->etheraddr, eh->ether_shost); - bt->name = ifp; - } - dst = bridge_dst_lookup(eh, BDG_CLUSTER(ifp)); - BDG_UNLOCK(); - - /* - * bridge_dst_lookup can return the following values: - * BDG_BCAST, BDG_MCAST, BDG_LOCAL, BDG_UNKNOWN, BDG_DROP, ifp. - * For muted interfaces, or when we detect a loop, the first 3 are - * changed in BDG_LOCAL (we still listen to incoming traffic), - * and others to BDG_DROP (no use for the local host). - * Also, for incoming packets, ifp is changed to BDG_DROP if ifp == src. - * These changes are not necessary for outgoing packets from ether_output(). - */ - BDG_STAT(ifp, BDG_IN); - switch ((uintptr_t)dst) { - case (uintptr_t)BDG_BCAST: - case (uintptr_t)BDG_MCAST: - case (uintptr_t)BDG_LOCAL: - case (uintptr_t)BDG_UNKNOWN: - case (uintptr_t)BDG_DROP: - BDG_STAT(ifp, dst); - break; - default: - if (dst == ifp || dropit) - BDG_STAT(ifp, BDG_DROP); - else - BDG_STAT(ifp, BDG_FORWARD); - break; - } - - if (dropit) { - if (dst == BDG_BCAST || dst == BDG_MCAST || dst == BDG_LOCAL) - dst = BDG_LOCAL; - else - dst = BDG_DROP; - } else { - if (dst == ifp) - dst = BDG_DROP; - } - DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s\n", __func__, - eh->ether_shost, ".", - eh->ether_dhost, ".", - ntohs(eh->ether_type), - (dst <= BDG_FORWARD) ? bdg_dst_names[(uintptr_t)dst] : - dst->if_xname)); - - switch ((uintptr_t)dst) { - case (uintptr_t)BDG_DROP: - m_freem(m); - return (NULL); - - case (uintptr_t)BDG_LOCAL: - return (m); - - case (uintptr_t)BDG_BCAST: - case (uintptr_t)BDG_MCAST: - m = bdg_forward(m, dst); -#ifdef DIAGNOSTIC - if (m == NULL) - if_printf(ifp, "bridge dropped %s packet\n", - dst == BDG_BCAST ? "broadcast" : "multicast"); -#endif - return (m); - - default: - m = bdg_forward(m, dst); - /* - * But in some cases the bridge may return the - * packet for us to free; sigh. - */ - if (m != NULL) - m_freem(m); - - } - - return (NULL); -} - -/* - * Return 1 if it's ok to send a packet out the specified interface. - * The interface must be: - * used for bridging, - * not muted, - * not full, - * up and running, - * not the source interface, and - * belong to the same cluster as the 'real_dst'. - */ -static __inline int -bridge_ifok(struct ifnet *ifp, struct ifnet *src, struct ifnet *dst) -{ - return (BDG_USED(ifp) - && !BDG_MUTED(ifp) - && !_IF_QFULL(&ifp->if_snd) - && (ifp->if_flags & IFF_UP) - && (ifp->if_drv_flags & IFF_DRV_RUNNING) - && ifp != src - && BDG_SAMECLUSTER(ifp, dst)); -} - -/* - * Forward a packet to dst -- which can be a single interface or - * an entire cluster. The src port and muted interfaces are excluded. - * - * If src == NULL, the pkt comes from ether_output, and dst is the real - * interface the packet is originally sent to. In this case, we must forward - * it to the whole cluster. - * We never call bdg_forward from ether_output on interfaces which are - * not part of a cluster. - * - * If possible (i.e. we can determine that the caller does not need - * a copy), the packet is consumed here, and bdg_forward returns NULL. - * Otherwise, a pointer to a copy of the packet is returned. - */ -static struct mbuf * -bdg_forward(struct mbuf *m0, struct ifnet *dst) -{ -#define EH_RESTORE(_m) do { \ - M_PREPEND((_m), ETHER_HDR_LEN, M_DONTWAIT); \ - if ((_m) == NULL) { \ - bdg_dropped++; \ - return NULL; \ - } \ - if (eh != mtod((_m), struct ether_header *)) \ - bcopy(&save_eh, mtod((_m), struct ether_header *), ETHER_HDR_LEN); \ - else \ - bdg_predict++; \ -} while (0); - struct ether_header *eh; - struct ifnet *src; - struct ifnet *ifp, *last; - int shared = bdg_copy; /* someone else is using the mbuf */ - int error; - struct ifnet *real_dst = dst; /* real dst from ether_output */ - struct ip_fw_args args; - struct ether_header save_eh; - struct mbuf *m; - - DDB(quad_t ticks; ticks = rdtsc();) - - args.rule = ip_dn_claim_rule(m0); - if (args.rule) - shared = 0; /* For sure this is our own mbuf. */ - else - bdg_thru++; /* count 1st time through bdg_forward */ - - /* - * The packet arrives with the Ethernet header at the front. - */ - eh = mtod(m0, struct ether_header *); - - src = m0->m_pkthdr.rcvif; - if (src == NULL) { /* packet from ether_output */ - BDG_LOCK(); - dst = bridge_dst_lookup(eh, BDG_CLUSTER(real_dst)); - BDG_UNLOCK(); - } - - if (dst == BDG_DROP) { /* this should not happen */ - printf("xx bdg_forward for BDG_DROP\n"); - m_freem(m0); - bdg_dropped++; - return NULL; - } - if (dst == BDG_LOCAL) { /* this should not happen as well */ - printf("xx ouch, bdg_forward for local pkt\n"); - return m0; - } - if (dst == BDG_BCAST || dst == BDG_MCAST) { - /* need a copy for the local stack */ - shared = 1; - } - - /* - * Do filtering in a very similar way to what is done in ip_output. - * Only if firewall is loaded, enabled, and the packet is not - * from ether_output() (src==NULL, or we would filter it twice). - * Additional restrictions may apply e.g. non-IP, short packets, - * and pkts already gone through a pipe. - */ - if (src != NULL && ( - (inet_pfil_hook.ph_busy_count >= 0 && bdg_ipf != 0) || - (IPFW_LOADED && bdg_ipfw != 0))) { - - int i; - - if (args.rule != NULL && fw_one_pass) - goto forward; /* packet already partially processed */ - /* - * i need some amt of data to be contiguous, and in case others need - * the packet (shared==1) also better be in the first mbuf. - */ - i = min(m0->m_pkthdr.len, max_protohdr) ; - if (shared || m0->m_len < i) { - m0 = m_pullup(m0, i); - if (m0 == NULL) { - printf("%s: m_pullup failed\n", __func__); /* XXXDPRINTF*/ - bdg_dropped++; - return NULL; - } - eh = mtod(m0, struct ether_header *); - } - - /* - * Processing below expects the Ethernet header is stripped. - * Furthermore, the mbuf chain might be replaced at various - * places. To deal with this we copy the header to a temporary - * location, strip the header, and restore it as needed. - */ - bcopy(eh, &save_eh, ETHER_HDR_LEN); /* local copy for restore */ - m_adj(m0, ETHER_HDR_LEN); /* temporarily strip header */ - - /* - * Check that the IP header is aligned before passing up to the packet - * filter. - */ - if (ntohs(save_eh.ether_type) == ETHERTYPE_IP && - IP_HDR_ALIGNED_P(mtod(m0, caddr_t)) == 0) { - if ((m0 = m_copyup(m0, sizeof(struct ip), - (max_linkhdr + 3) & ~3)) == NULL) { - bdg_dropped++; - return NULL; - } - } - - /* - * NetBSD-style generic packet filter, pfil(9), hooks. - * Enables ipf(8) in bridging. - */ - if (!IPFW_LOADED) { /* XXX: Prevent ipfw from being run twice. */ - if (inet_pfil_hook.ph_busy_count >= 0 && - m0->m_pkthdr.len >= sizeof(struct ip) && - ntohs(save_eh.ether_type) == ETHERTYPE_IP) { - /* - * before calling the firewall, swap fields the same as IP does. - * here we assume the pkt is an IP one and the header is contiguous - */ - struct ip *ip = mtod(m0, struct ip *); - - ip->ip_len = ntohs(ip->ip_len); - ip->ip_off = ntohs(ip->ip_off); - - if (pfil_run_hooks(&inet_pfil_hook, &m0, src, PFIL_IN, NULL) != 0) { - /* NB: hook should consume packet */ - return NULL; - } - if (m0 == NULL) /* consumed by filter */ - return m0; - /* - * If we get here, the firewall has passed the pkt, but the mbuf - * pointer might have changed. Restore ip and the fields ntohs()'d. - */ - ip = mtod(m0, struct ip *); - ip->ip_len = htons(ip->ip_len); - ip->ip_off = htons(ip->ip_off); - } - } /* XXX: Prevent ipfw from being run twice. */ - - /* - * Prepare arguments and call the firewall. - */ - if (!IPFW_LOADED || bdg_ipfw == 0) { - EH_RESTORE(m0); /* restore Ethernet header */ - goto forward; /* not using ipfw, accept the packet */ - } - - /* - * XXX The following code is very similar to the one in - * if_ethersubr.c:ether_ipfw_chk() - */ - - args.m = m0; /* the packet we are looking at */ - args.oif = NULL; /* this is an input packet */ - args.next_hop = NULL; /* we do not support forward yet */ - args.eh = &save_eh; /* MAC header for bridged/MAC packets */ - i = ip_fw_chk_ptr(&args); - m0 = args.m; /* in case the firewall used the mbuf */ - - if (m0 != NULL) - EH_RESTORE(m0); /* restore Ethernet header */ - - if (i == IP_FW_DENY) /* drop */ - return m0; - - KASSERT(m0 != NULL, ("bdg_forward: m0 is NULL")); - - if (i == 0) /* a PASS rule. */ - goto forward; - if (DUMMYNET_LOADED && (i == IP_FW_DUMMYNET)) { - /* - * Pass the pkt to dummynet, which consumes it. - * If shared, make a copy and keep the original. - */ - if (shared) { - m = m_copypacket(m0, M_DONTWAIT); - if (m == NULL) { /* copy failed, give up */ - bdg_dropped++; - return NULL; - } - } else { - m = m0 ; /* pass the original to dummynet */ - m0 = NULL ; /* and nothing back to the caller */ - } - - args.oif = real_dst; - ip_dn_io_ptr(m, DN_TO_BDG_FWD, &args); - return m0; - } - /* - * XXX at some point, add support for divert/forward actions. - * If none of the above matches, we have to drop the packet. - */ - bdg_ipfw_drops++; - return m0; - } -forward: - /* - * Again, bring up the headers in case of shared bufs to avoid - * corruptions in the future. - */ - if (shared) { - int i = min(m0->m_pkthdr.len, max_protohdr); - - m0 = m_pullup(m0, i); - if (m0 == NULL) { - bdg_dropped++; - return NULL; - } - /* NB: eh is not used below; no need to recalculate it */ - } - - /* - * now real_dst is used to determine the cluster where to forward. - * For packets coming from ether_input, this is the one of the 'src' - * interface, whereas for locally generated packets (src==NULL) it - * is the cluster of the original destination interface, which - * was already saved into real_dst. - */ - if (src != NULL) - real_dst = src; - - last = NULL; - if (dst == BDG_BCAST || dst == BDG_MCAST || dst == BDG_UNKNOWN) { - /* - * Scan all ports and send copies to all but the last. - */ - IFNET_RLOCK(); /* XXX replace with generation # */ - TAILQ_FOREACH(ifp, &ifnet, if_link) { - if (bridge_ifok(ifp, src, real_dst)) { - if (last) { - /* - * At this point we know two interfaces need a copy - * of the packet (last + ifp) so we must create a - * copy to handoff to last. - */ - m = m_copypacket(m0, M_DONTWAIT); - if (m == NULL) { - IFNET_RUNLOCK(); - printf("%s: , m_copypacket failed!\n", __func__); - bdg_dropped++; - return m0; /* the original is still there... */ - } - IFQ_HANDOFF(last, m, error); - if (!error) - BDG_STAT(last, BDG_OUT); - else - bdg_dropped++; - } - last = ifp; - } - } - IFNET_RUNLOCK(); - } else { - if (bridge_ifok(dst, src, real_dst)) - last = dst; - } - if (last) { - if (shared) { /* need to copy */ - m = m_copypacket(m0, M_DONTWAIT); - if (m == NULL) { - printf("%s: sorry, m_copypacket failed!\n", __func__); - bdg_dropped++ ; - return m0; /* the original is still there... */ - } - } else { /* consume original */ - m = m0, m0 = NULL; - } - IFQ_HANDOFF(last, m, error); - if (!error) - BDG_STAT(last, BDG_OUT); - else - bdg_dropped++; - } - - DDB(bdg_fw_ticks += (u_long)(rdtsc() - ticks) ; bdg_fw_count++ ; - if (bdg_fw_count != 0) bdg_fw_avg = bdg_fw_ticks/bdg_fw_count; ) - return m0; -#undef EH_RESTORE -} - -/* - * initialization of bridge code. - */ -static int -bdginit(void) -{ - if (bootverbose) - printf("BRIDGE %s loaded\n", bridge_version); - - ifp2sc = malloc(BDG_MAX_PORTS * sizeof(struct bdg_softc), - M_IFADDR, M_WAITOK | M_ZERO ); - if (ifp2sc == NULL) - return ENOMEM; - - BDG_LOCK_INIT(); - - n_clusters = 0; - clusters = NULL; - do_bridge = 0; - - bzero(&bdg_stats, sizeof(bdg_stats)); - - bridge_in_ptr = bridge_in; - bdg_forward_ptr = bdg_forward; - bdgtakeifaces_ptr = reconfigure_bridge; - - bdgtakeifaces_ptr(); /* XXX does this do anything? */ - - callout_init(&bdg_callout, NET_CALLOUT_MPSAFE); - bdg_timeout(0); - return 0 ; -} - -static void -bdgdestroy(void) -{ - bridge_in_ptr = NULL; - bdg_forward_ptr = NULL; - bdgtakeifaces_ptr = NULL; - - callout_stop(&bdg_callout); - BDG_LOCK(); - bridge_off(); - - if (ifp2sc) { - free(ifp2sc, M_IFADDR); - ifp2sc = NULL; - } - BDG_LOCK_DESTROY(); -} - -/* - * initialization code, both for static and dynamic loading. - */ -static int -bridge_modevent(module_t mod, int type, void *unused) -{ - int err; - - switch (type) { - case MOD_LOAD: - if (BDG_LOADED) - err = EEXIST; - else - err = bdginit(); - break; - case MOD_UNLOAD: - do_bridge = 0; - bdgdestroy(); - err = 0; - break; - default: - err = EINVAL; - break; - } - return err; -} - -static moduledata_t bridge_mod = { - "bridge", - bridge_modevent, - 0 -}; - -DECLARE_MODULE(bridge, bridge_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); -MODULE_VERSION(bridge, 1); diff --git a/sys/net/bridge.h b/sys/net/bridge.h deleted file mode 100644 index 76594f5..0000000 --- a/sys/net/bridge.h +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright (c) 1998-2002 Luigi Rizzo - * - * Work partly supported by: Cisco Systems, Inc. - NSITE lab, RTP, NC - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * $FreeBSD$ - */ - -extern int do_bridge; - -/* - * We need additional per-interface info for the bridge, which is - * stored in a struct bdg_softc. The ifp2sc[] array provides a pointer - * to this struct using the if_index as a mapping key. - * bdg_softc has a backpointer to the struct ifnet, the bridge - * flags, and a cluster (bridging occurs only between port of the - * same cluster). - */ - -struct cluster_softc; /* opaque here, defined in bridge.c */ - -struct bdg_softc { - struct ifnet *ifp ; - int flags ; -#define IFF_BDG_PROMISC 0x0001 /* set promisc mode on this if. */ -#define IFF_MUTE 0x0002 /* mute this if for bridging. */ -#define IFF_USED 0x0004 /* use this if for bridging. */ - struct cluster_softc *cluster; -} ; - -extern struct bdg_softc *ifp2sc; - -#define BDG_USED(ifp) (ifp2sc[ifp->if_index].flags & IFF_USED) -/* - * BDG_ACTIVE(ifp) does all checks to see if bridging is enabled, loaded, - * and used on a given interface. - */ -#define BDG_ACTIVE(ifp) (do_bridge && BDG_LOADED && BDG_USED(ifp)) - -/* - * The following constants are not legal ifnet pointers, and are used - * as return values from the classifier, bridge_dst_lookup(). - * The same values are used as index in the statistics arrays, - * with BDG_FORWARD replacing specifically forwarded packets. - * - * These constants are here because they are used in 'netstat' - * to show bridge statistics. - */ -#define BDG_BCAST ( (struct ifnet *)1 ) -#define BDG_MCAST ( (struct ifnet *)2 ) -#define BDG_LOCAL ( (struct ifnet *)3 ) -#define BDG_DROP ( (struct ifnet *)4 ) -#define BDG_UNKNOWN ( (struct ifnet *)5 ) -#define BDG_IN ( (struct ifnet *)7 ) -#define BDG_OUT ( (struct ifnet *)8 ) -#define BDG_FORWARD ( (struct ifnet *)9 ) - -/* - * Statistics are passed up with the sysctl interface, "netstat -p bdg" - * reads them. PF_BDG defines the 'bridge' protocol family. - */ - -#define PF_BDG 3 /* XXX superhack */ - -#define STAT_MAX (int)BDG_FORWARD -struct bdg_port_stat { - char name[16]; - u_long collisions; - u_long p_in[STAT_MAX+1]; -} ; - -/* XXX this should be made dynamic */ -#define BDG_MAX_PORTS 128 -struct bdg_stats { - struct bdg_port_stat s[BDG_MAX_PORTS]; -} ; - - -#define BDG_STAT(ifp, type) bdg_stats.s[ifp->if_index].p_in[(uintptr_t)type]++ - -#ifdef _KERNEL -typedef struct mbuf *bridge_in_t(struct ifnet *, struct mbuf *); -/* bdg_forward frees the mbuf if necessary, returning null */ -typedef struct mbuf *bdg_forward_t(struct mbuf *, struct ifnet *); -typedef void bdgtakeifaces_t(void); -extern bridge_in_t *bridge_in_ptr; -extern bdg_forward_t *bdg_forward_ptr; -extern bdgtakeifaces_t *bdgtakeifaces_ptr; - -#define BDG_LOADED (bdgtakeifaces_ptr != NULL) -#endif /* KERNEL */ diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 3582c91..1d2cd9c 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -34,7 +34,6 @@ #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipx.h" -#include "opt_bdg.h" #include "opt_mac.h" #include "opt_netgraph.h" #include "opt_carp.h" @@ -60,7 +59,6 @@ #include <net/if_types.h> #include <net/bpf.h> #include <net/ethernet.h> -#include <net/bridge.h> #include <net/if_vlan_var.h> #if defined(INET) || defined(INET6) @@ -108,12 +106,6 @@ void (*ng_ether_detach_p)(struct ifnet *ifp); void (*vlan_input_p)(struct ifnet *, struct mbuf *); /* bridge support */ -int do_bridge; -bridge_in_t *bridge_in_ptr; -bdg_forward_t *bdg_forward_ptr; -bdgtakeifaces_t *bdgtakeifaces_ptr; -struct bdg_softc *ifp2sc; - struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *); int (*bridge_output_p)(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); @@ -378,18 +370,6 @@ ether_output_frame(struct ifnet *ifp, struct mbuf *m) #endif int error; - if (rule == NULL && BDG_ACTIVE(ifp)) { - /* - * Beware, the bridge code notices the null rcvif and - * uses that identify that it's being called from - * ether_output as opposd to ether_input. Yech. - */ - m->m_pkthdr.rcvif = NULL; - m = bdg_forward_ptr(m, ifp); - if (m != NULL) - m_freem(m); - return (0); - } #if defined(INET) || defined(INET6) if (IPFW_LOADED && ether_ipfw != 0) { if (ether_ipfw_chk(&m, ifp, &rule, 0) == 0) { @@ -414,9 +394,7 @@ ether_output_frame(struct ifnet *ifp, struct mbuf *m) /* * ipfw processing for ethernet packets (in and out). * The second parameter is NULL from ether_demux, and ifp from - * ether_output_frame. This section of code could be used from - * bridge.c as well as long as we use some extra info - * to distinguish that case from ether_output_frame(); + * ether_output_frame. */ int ether_ipfw_chk(struct mbuf **m0, struct ifnet *dst, @@ -635,11 +613,6 @@ ether_input(struct ifnet *ifp, struct mbuf *m) ifp = m->m_pkthdr.rcvif; } - /* Check for bridging mode */ - if (BDG_ACTIVE(ifp) ) - if ((m = bridge_in_ptr(ifp, m)) == NULL) - return; - /* First chunk of an mbuf contains good entropy */ if (harvest.ethernet) random_harvest(m, 16, 3, 0, RANDOM_NET); @@ -672,7 +645,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m) goto post_stats; #endif - if (!(BDG_ACTIVE(ifp)) && !(ifp->if_bridge) && + if (!(ifp->if_bridge) && !((ether_type == ETHERTYPE_VLAN || m->m_flags & M_VLANTAG) && ifp->if_nvlans > 0)) { #ifdef DEV_CARP @@ -929,8 +902,6 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *llc) bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN); if (ng_ether_attach_p != NULL) (*ng_ether_attach_p)(ifp); - if (BDG_LOADED) - bdgtakeifaces_ptr(); /* Announce Ethernet MAC address if non-zero. */ for (i = 0; i < ifp->if_addrlen; i++) @@ -955,8 +926,6 @@ ether_ifdetach(struct ifnet *ifp) } bpfdetach(ifp); if_detach(ifp); - if (BDG_LOADED) - bdgtakeifaces_ptr(); } SYSCTL_DECL(_net_link); diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c index be6c76f..ae1cb58 100644 --- a/sys/netgraph/ng_ether.c +++ b/sys/netgraph/ng_ether.c @@ -55,7 +55,6 @@ #include <sys/syslog.h> #include <sys/socket.h> -#include <net/bridge.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_types.h> @@ -644,9 +643,7 @@ ng_ether_rcv_upper(node_p node, struct mbuf *m) m->m_pkthdr.rcvif = priv->ifp; - if (BDG_ACTIVE(priv->ifp) ) - if ((m = bridge_in_ptr(priv->ifp, m)) == NULL) - return (0); + /* XXX: if_bridge hook here? */ /* Route packet back in */ ether_demux(priv->ifp, m); diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index e5d1073..ec5a7a7 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -37,7 +37,6 @@ */ #include "opt_inet.h" -#include "opt_bdg.h" #include "opt_mac.h" #include "opt_carp.h" @@ -59,7 +58,6 @@ #include <net/netisr.h> #include <net/if_llc.h> #include <net/ethernet.h> -#include <net/bridge.h> #include <netinet/in.h> #include <netinet/in_var.h> @@ -607,7 +605,7 @@ in_arpinput(m) int carp_match = 0; #endif - if (do_bridge || ifp->if_bridge) + if (ifp->if_bridge) bridged = 1; req_len = arphdr_len2(ifp->if_addrlen, sizeof(struct in_addr)); diff --git a/sys/netinet/ip_dummynet.c b/sys/netinet/ip_dummynet.c index 0f57afe..51a3ad6 100644 --- a/sys/netinet/ip_dummynet.c +++ b/sys/netinet/ip_dummynet.c @@ -79,7 +79,6 @@ #include <netinet/ip_var.h> #include <netinet/if_ether.h> /* for struct arpcom */ -#include <net/bridge.h> #include <netinet/ip6.h> /* for ip6_input, ip6_output prototypes */ #include <netinet6/ip6_var.h> @@ -488,27 +487,6 @@ transmit_event(struct dn_pipe *pipe) break; - case DN_TO_BDG_FWD : - /* - * The bridge requires/assumes the Ethernet header is - * contiguous in the first mbuf header. Insure this is true. - */ - if (BDG_LOADED) { - if (m->m_len < ETHER_HDR_LEN && - (m = m_pullup(m, ETHER_HDR_LEN)) == NULL) { - printf("dummynet/bridge: pullup fail, dropping pkt\n"); - break; - } - m = bdg_forward_ptr(m, pkt->ifp); - } else { - /* somebody unloaded the bridge module. Drop pkt */ - /* XXX rate limit */ - printf("dummynet: dropping bridged packet trapped in pipe\n"); - } - if (m) - m_freem(m); - break; - case DN_TO_ETH_DEMUX: /* * The Ethernet code assumes the Ethernet header is @@ -1175,7 +1153,6 @@ locate_flowset(int pipe_nr, struct ip_fw *rule) * m the mbuf with the packet * ifp the 'ifp' parameter from the caller. * NULL in ip_input, destination interface in ip_output, - * real_dst in bdg_forward * rule matching rule, in case of multiple passes * flags flags from the caller, only used in ip_output * diff --git a/sys/netinet/ip_dummynet.h b/sys/netinet/ip_dummynet.h index 72a8863..b98ee4c 100644 --- a/sys/netinet/ip_dummynet.h +++ b/sys/netinet/ip_dummynet.h @@ -121,7 +121,7 @@ struct dn_pkt_tag { int dn_dir; /* action when packet comes out. */ #define DN_TO_IP_OUT 1 #define DN_TO_IP_IN 2 -#define DN_TO_BDG_FWD 3 +/* Obsolete: #define DN_TO_BDG_FWD 3 */ #define DN_TO_ETH_DEMUX 4 #define DN_TO_ETH_OUT 5 #define DN_TO_IP6_IN 6 diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c index dd6d70d..4061596 100644 --- a/sys/netinet/ip_fw2.c +++ b/sys/netinet/ip_fw2.c @@ -2076,7 +2076,7 @@ ipfw_chk(struct ip_fw_args *args) /* * oif | args->oif If NULL, ipfw_chk has been called on the - * inbound path (ether_input, bdg_forward, ip_input). + * inbound path (ether_input, ip_input). * If non-NULL, ipfw_chk has been called on the outbound path * (ether_output, ip_output). */ diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c index 205e007..a4a6ef2 100644 --- a/sys/pci/if_wb.c +++ b/sys/pci/if_wb.c @@ -83,8 +83,6 @@ __FBSDID("$FreeBSD$"); * three of my test boards seems fine. */ -#include "opt_bdg.h" - #include <sys/param.h> #include <sys/systm.h> #include <sys/sockio.h> diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index fcedce7..87bd6e7 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include <net/if_var.h> #include <net/if_dl.h> #include <net/if_types.h> -#include <net/bridge.h> #include <net/ethernet.h> #include <net/pfvar.h> #include <net/if_pfsync.h> @@ -79,50 +78,8 @@ static void catchalarm (int); #ifdef INET6 static char ntop_buf[INET6_ADDRSTRLEN]; /* for inet_ntop() */ -static int bdg_done; #endif -/* print bridge statistics */ -void -bdg_stats(u_long dummy __unused, const char *name, int af1 __unused) -{ - int i; - size_t slen ; - struct bdg_stats s ; - int mib[4] ; - - slen = sizeof(s); - - mib[0] = CTL_NET ; - mib[1] = PF_LINK ; - mib[2] = IFT_ETHER ; - mib[3] = PF_BDG ; - if (sysctl(mib,4, &s,&slen,NULL,0)==-1) - return ; /* no bridging */ -#ifdef INET6 - if (bdg_done != 0) - return; - else - bdg_done = 1; -#endif - printf("-- Bridging statistics (%s) --\n", name) ; - printf( -"Name In Out Forward Drop Bcast Mcast Local Unknown\n"); - for (i = 0 ; i < 16 ; i++) { - if (s.s[i].name[0]) - printf("%-6s %9ld%9ld%9ld%9ld%9ld%9ld%9ld%9ld\n", - s.s[i].name, - s.s[i].p_in[(int)BDG_IN], - s.s[i].p_in[(int)BDG_OUT], - s.s[i].p_in[(int)BDG_FORWARD], - s.s[i].p_in[(int)BDG_DROP], - s.s[i].p_in[(int)BDG_BCAST], - s.s[i].p_in[(int)BDG_MCAST], - s.s[i].p_in[(int)BDG_LOCAL], - s.s[i].p_in[(int)BDG_UNKNOWN] ); - } -} - /* * Dump pfsync statistics structure. */ diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index cf7082f..ef8a7b9 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -171,8 +171,6 @@ struct protox { { -1, N_IPSECSTAT, 1, NULL, ipsec_stats, NULL, "ipsec", 0}, #endif - { -1, -1, 1, NULL, - bdg_stats, NULL, "bdg", 1 /* bridging... */ }, { -1, -1, 1, protopr, pim_stats, NULL, "pim", IPPROTO_PIM }, { -1, N_CARPSTAT, 1, 0, @@ -203,8 +201,6 @@ struct protox ip6protox[] = { #endif { -1, -1, 1, NULL, rip6_stats, NULL, "rip6", 0 }, - { -1, -1, 1, NULL, - bdg_stats, NULL, "bdg", 1 /* bridging... */ }, { -1, -1, 0, NULL, NULL, NULL, NULL, 0 } }; diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index ef2a4b3..0dac06f 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -294,9 +294,9 @@ The following address families and protocols are recognized: .It Em Family .Em Protocols .It Cm inet Pq Dv AF_INET -.Cm bdg , divert , icmp , igmp , ip , ipsec , pim, tcp , udp +.Cm divert , icmp , igmp , ip , ipsec , pim, tcp , udp .It Cm inet6 Pq Dv AF_INET6 -.Cm bdg , icmp6 , ip6 , ipsec6 , rip6 , tcp , udp +.Cm icmp6 , ip6 , ipsec6 , rip6 , tcp , udp .It Cm pfkey Pq Dv PF_KEY .Cm pfkey .It Cm atalk Pq Dv AF_APPLETALK diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index a2c3687..c69d5f7 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -99,8 +99,6 @@ void inet6print(struct in6_addr *, int, const char *, int); void pfkey_stats(u_long, const char *, int); #endif -void bdg_stats(u_long, const char *, int); - void mbpr(u_long, u_long, u_long, u_long, u_long, u_long, u_long, u_long, u_long, u_long, u_long); |