Date: Mon, 5 Apr 1999 08:35:30 -0500 From: Guy Helmer <ghelmer@scl.ameslab.gov> To: Andres <dae@via.ecp.fr> Cc: Vallo Kallaste <vallo@matti.ee>, questions@freebsd.org Subject: Re: bridging Message-ID: <Pine.SGI.4.05.9904050815310.8009-100000@demios.scl.ameslab.gov> In-Reply-To: <3708AF1A.8B18EB01@via.ecp.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <net/bpf.h>
#endif
+#ifdef BRIDGE
+#include <net/bridge.h>
+#endif
+
#if defined(__FreeBSD__)
#include <machine/clock.h>
#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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SGI.4.05.9904050815310.8009-100000>
