diff options
author | luigi <luigi@FreeBSD.org> | 1998-12-14 17:58:05 +0000 |
---|---|---|
committer | luigi <luigi@FreeBSD.org> | 1998-12-14 17:58:05 +0000 |
commit | 78f32fa7e071a1e01b906f438ffe7454438b1730 (patch) | |
tree | c3586f268e4d14b08735ae8410f8c9fc1e83f7df /sys/net | |
parent | 9c55aebaa438b30ec51f87c8753651909f0b2800 (diff) | |
download | FreeBSD-src-78f32fa7e071a1e01b906f438ffe7454438b1730.zip FreeBSD-src-78f32fa7e071a1e01b906f438ffe7454438b1730.tar.gz |
Bridging support. Wait for LINT to be updated before trying it.
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bridge.c | 20 | ||||
-rw-r--r-- | sys/net/bridge.h | 2 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 21 |
3 files changed, 32 insertions, 11 deletions
diff --git a/sys/net/bridge.c b/sys/net/bridge.c index 7c2e0f2..d07d1a3 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -77,6 +77,7 @@ #include <sys/param.h> #include <sys/mbuf.h> +#include <sys/malloc.h> #include <sys/systm.h> #include <sys/socket.h> /* for net/if.h */ #include <sys/kernel.h> @@ -89,9 +90,11 @@ #include <netinet/if_ether.h> /* for struct arpcom */ #include "opt_ipfw.h" +#include "opt_ipdn.h" #if defined(IPFIREWALL) && defined(DUMMYNET) #include <net/route.h> +#include <netinet/ip_fw.h> #include <netinet/ip_dummynet.h> #endif @@ -236,7 +239,7 @@ bdg_timeout(void *dummy) if (--slowtimer <= 0 ) { slowtimer = 5 ; - for (ifp = ifnet; ifp; ifp = ifp->if_next) { + for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next) { if (ifp->if_type != IFT_ETHER) continue ; if ( 0 == ( ifp->if_flags & IFF_UP) ) { @@ -299,8 +302,9 @@ bdginit(dummy) bdg_ports = 0 ; eth_addr = bdg_addresses ; - printf("BRIDGE 980911, have %d interfaces\n", if_index); - for (i = 0 , ifp = ifnet ; i < if_index ; i++, ifp = ifp->if_next) + printf("BRIDGE 981214, have %d interfaces\n", if_index); + for (i = 0 , ifp = ifnet.tqh_first ; i < if_index ; + i++, ifp = ifp->if_link.tqe_next) if (ifp->if_type == IFT_ETHER) { /* ethernet ? */ ac = (struct arpcom *)ifp; sprintf(bdg_stats.s[ifp->if_index].name, @@ -322,7 +326,7 @@ bdginit(dummy) bdg_ports ++ ; } bdg_timeout(0); - do_bridge=1; + do_bridge=0; } /* @@ -464,7 +468,7 @@ bdg_forward (struct mbuf **m0, struct ifnet *dst) return 0; } if (dst == BDG_BCAST || dst == BDG_MCAST || dst == BDG_UNKNOWN) { - ifp = ifnet ; + ifp = ifnet.tqh_first ; once = 0 ; if (dst != BDG_UNKNOWN) canfree = 0 ; @@ -515,7 +519,7 @@ bdg_forward (struct mbuf **m0, struct ifnet *dst) } dummy = 0 ; - off=(*ip_fw_chk_ptr)(NULL, 0, src, &dummy, &m, &rule) ; + off= (*ip_fw_chk_ptr)(NULL, 0, src, &dummy, &m, &rule, NULL /*next hop */ ) ; if (m == NULL) { /* pkt discarded by firewall */ printf("-- bdg: firewall discarded pkt\n"); if (canfree) @@ -556,12 +560,12 @@ forward: else m = NULL ; - for ( ; ifp ; ifp = ifp->if_next ) { + for ( ; ifp ; ifp = ifp->if_link.tqe_next ) { if (ifp != src && ifp->if_type == IFT_ETHER && (ifp->if_flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING) && SAMEGROUP(ifp, src) && !MUTED(ifp) ) { if (m == NULL) { /* do i need to make a copy ? */ - if (canfree && ifp->if_next == NULL) /* last one! */ + if (canfree && ifp->if_link.tqe_next == NULL) /* last one! */ m = *m0 ; else /* on a P5-90, m_packetcopy takes 540 ticks */ m = m_copypacket(*m0, M_DONTWAIT); diff --git a/sys/net/bridge.h b/sys/net/bridge.h index 8dcee07..e151e4e 100644 --- a/sys/net/bridge.h +++ b/sys/net/bridge.h @@ -108,7 +108,7 @@ struct bdg_stats { * BDG_DROP must be dropped * other ifp of the dest. interface (incl.self) */ -static inline +static __inline struct ifnet * bridge_dst_lookup(struct mbuf *m) { diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index ca66eb0..eab4795 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -31,12 +31,13 @@ * SUCH DAMAGE. * * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 - * $Id: if_ethersubr.c,v 1.51 1998/06/14 20:58:14 julian Exp $ + * $Id: if_ethersubr.c,v 1.52 1998/08/04 23:17:05 julian Exp $ */ #include "opt_atalk.h" #include "opt_inet.h" #include "opt_ipx.h" +#include "opt_bdg.h" #include <sys/param.h> #include <sys/systm.h> @@ -101,6 +102,10 @@ extern u_char at_org_code[3]; extern u_char aarp_org_code[3]; #endif /* NETATALK */ +#ifdef BRIDGE +#include <net/bridge.h> +#endif + #include "vlan.h" #if NVLAN > 0 #include <net/if_vlan_var.h> @@ -372,7 +377,19 @@ ether_output(ifp, m0, dst, rt0) return(0); /* XXX */ } } - +#ifdef BRIDGE + if (do_bridge) { + struct ifnet *old_ifp = ifp ; + struct mbuf *m0 = m ; + if (m->m_pkthdr.rcvif ) + m->m_pkthdr.rcvif = NULL ; + ifp = bridge_dst_lookup(m); + bdg_forward(&m0, ifp); + if (m0) + m_freem(m0); + return 0 ; + } +#endif s = splimp(); /* * Queue message on interface, and start output if interface |