From owner-freebsd-questions Mon Apr 5 6:37:42 1999 Delivered-To: freebsd-questions@freebsd.org Received: from mailhub.scl.ameslab.gov (mailhub.scl.ameslab.gov [147.155.137.127]) by hub.freebsd.org (Postfix) with ESMTP id D320814CE1 for ; Mon, 5 Apr 1999 06:37:39 -0700 (PDT) (envelope-from ghelmer@scl.ameslab.gov) Received: from demios.ether.scl.ameslab.gov ([147.155.137.54]) by mailhub.scl.ameslab.gov with esmtp (Exim 1.90 #1) id 10U9Xx-00068O-00; Mon, 5 Apr 1999 08:36:13 -0500 Date: Mon, 5 Apr 1999 08:35:30 -0500 From: Guy Helmer To: Andres Cc: Vallo Kallaste , questions@freebsd.org Subject: Re: bridging In-Reply-To: <3708AF1A.8B18EB01@via.ecp.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 5 Apr 1999, Andres wrote: > Guy Helmer wrote: > > > /sys/i386/isa/if_ep.c does not have bridging support in it. If nobody > > else has sent you patches to enable bridging in if_ep.c, please let me > > know. I have written bridging support in a related driver and it should > > not be difficult to write the patch for if_ep.c. > > thanks for your quick answers. i'm using 3.1-R, and i'd seen from the > "man 4 bridge": > > Not all interface support bridging -- at the moment it works for > ``ed'', > ``de'', ``ep'', ``fxp'', ``lnc'' interfaces. > > so i assumed that both my nics were able to do bridging. that was > probably wrong, and nobody has sent me patches for if_ep.c yet. if it's > not difficult for you to do one, a patch would be greatly appreciated. > how can i tell from the source whether an interface is or not able to > bridge ? i've tried to look at if_ed (assuming that ed could do > bridging) , but couldn't spot the pieces of code that made it suited for > bridging. I should have checked the source tree for if_ep before responding. if_ep.c in 2.2.8-RELEASE had support for bridging, but support wasn't merged into the current or the 3.x branch. I've appended the patch for the if_ep.c in 3.1-RELEASE below. You can tell whether a driver has support for bridging by doing a "grep BRIDGE" on the source. Guy --- if_ep.c-3.1.ORIG Mon Apr 5 08:29:25 1999 +++ if_ep.c-3.1 Mon Apr 5 08:32:38 1999 @@ -97,6 +97,10 @@ #include #endif +#ifdef BRIDGE +#include +#endif + #if defined(__FreeBSD__) #include #endif @@ -1132,36 +1136,51 @@ top->m_pkthdr.len = sc->cur_len; #if NBPFILTER > 0 - if (ifp->if_bpf) { + if (ifp->if_bpf) bpf_mtap(ifp, top); - - /* - * Note that the interface cannot be in promiscuous mode if there are - * no BPF listeners. And if we are in promiscuous mode, we have to - * check if this packet is really ours. - */ - eh = mtod(top, struct ether_header *); - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - if (sc->top) { - m_freem(sc->top); - sc->top = 0; - } - ep_fset(F_RX_FIRST); -#ifdef EP_LOCAL_STATS - sc->rx_bpf_disc++; #endif - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); - return; - } +#ifdef BRIDGE + if (do_bridge) { + struct ifnet * bdg_ifp ; + + bdg_ifp = bridge_in(top); + if (bdg_ifp == BDG_DROP) + goto dropit ; + if (bdg_ifp != BDG_LOCAL) + bdg_forward(&(sc->top), bdg_ifp); + if (bdg_ifp !=BDG_LOCAL && bdg_ifp !=BDG_BCAST && bdg_ifp !=BDG_MCAST) + goto dropit ; + /* all others accepted locally */ + goto getit ; + } #endif + /* + * If we are in promiscuous mode, we have to + * check if this packet is really ours. + */ + eh = mtod(top, struct ether_header *); + if ((ifp->if_flags & IFF_PROMISC) && + (eh->ether_dhost[0] & 1) == 0 && + bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, + sizeof(eh->ether_dhost)) != 0 && + bcmp(eh->ether_dhost, etherbroadcastaddr, + sizeof(eh->ether_dhost)) != 0) { +dropit: + if (sc->top) { + m_freem(sc->top); + sc->top = 0; + } + ep_fset(F_RX_FIRST); +#ifdef EP_LOCAL_STATS + sc->rx_bpf_disc++; +#endif + while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); + outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); + return; + } +getit: eh = mtod(top, struct ether_header *); m_adj(top, sizeof(struct ether_header)); ether_input(ifp, eh, top); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message