Add support for bridging to if_tx.c

PR:		10534
Submitted by:	nsayer
This commit is contained in:
Nick Sayer 1999-03-31 13:50:52 +00:00
parent 32c75b7dab
commit 4db9b34751
2 changed files with 86 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* $OpenBSD: if_tx.c,v 1.3 1998/10/10 04:30:09 jason Exp $ */ /* $OpenBSD: if_tx.c,v 1.3 1998/10/10 04:30:09 jason Exp $ */
/* $Id: if_tx.c,v 1.20 1998/12/14 06:32:56 dillon Exp $ */ /* $Id: if_tx.c,v 1.22 1999/03/14 08:30:23 semenu Exp $ */
/*- /*-
* Copyright (c) 1997 Semen Ustimenko (semen@iclub.nsu.ru) * Copyright (c) 1997 Semen Ustimenko (semen@iclub.nsu.ru)
@ -69,6 +69,7 @@
#include "bpfilter.h" #include "bpfilter.h"
#include "pci.h" #include "pci.h"
#include "opt_bdg.h"
#if NPCI > 0 #if NPCI > 0
#include <sys/param.h> #include <sys/param.h>
@ -135,6 +136,11 @@
#include <pci/pcivar.h> #include <pci/pcivar.h>
#include <pci/if_txvar.h> #include <pci/if_txvar.h>
#ifdef BRIDGE
#include <net/bridge.h>
#endif
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
@ -921,7 +927,43 @@ epic_rx_done __P((
#else /* __OpenBSD__ */ #else /* __OpenBSD__ */
bpf_mtap( sc->sc_if.if_bpf, m ); bpf_mtap( sc->sc_if.if_bpf, m );
#endif /* __FreeBSD__ */ #endif /* __FreeBSD__ */
#endif /* NBPFILTER */
#ifdef BRIDGE
if (do_bridge) {
struct ifnet *bdg_ifp ;
bdg_ifp = bridge_in(m);
if (bdg_ifp == BDG_DROP) {
if (m)
m_free(m);
continue; /* and drop */
}
if (bdg_ifp != BDG_LOCAL)
bdg_forward(&m, bdg_ifp);
if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_BCAST &&
bdg_ifp != BDG_MCAST) {
if (m)
m_free(m);
continue; /* and drop */
}
/* all others accepted locally */
}
#endif
#if NBPFILTER > 0
#ifdef BRIDGE
/*
* This deserves explanation
* If the bridge is _on_, then the following check
* must not be done because occasionally the bridge
* gets packets that are local but have the ethernet
* address of one of the other interfaces.
*
* But if the bridge is off, then we have to drop
* stuff that came in just via bpfilter.
*/
if (!do_bridge)
#endif
/* Accept only our packets, broadcasts and multicasts */ /* Accept only our packets, broadcasts and multicasts */
if( (eh->ether_dhost[0] & 1) == 0 && if( (eh->ether_dhost[0] & 1) == 0 &&
bcmp(eh->ether_dhost,sc->sc_macaddr,ETHER_ADDR_LEN)){ bcmp(eh->ether_dhost,sc->sc_macaddr,ETHER_ADDR_LEN)){

View File

@ -1,5 +1,5 @@
/* $OpenBSD: if_tx.c,v 1.3 1998/10/10 04:30:09 jason Exp $ */ /* $OpenBSD: if_tx.c,v 1.3 1998/10/10 04:30:09 jason Exp $ */
/* $Id: if_tx.c,v 1.20 1998/12/14 06:32:56 dillon Exp $ */ /* $Id: if_tx.c,v 1.22 1999/03/14 08:30:23 semenu Exp $ */
/*- /*-
* Copyright (c) 1997 Semen Ustimenko (semen@iclub.nsu.ru) * Copyright (c) 1997 Semen Ustimenko (semen@iclub.nsu.ru)
@ -69,6 +69,7 @@
#include "bpfilter.h" #include "bpfilter.h"
#include "pci.h" #include "pci.h"
#include "opt_bdg.h"
#if NPCI > 0 #if NPCI > 0
#include <sys/param.h> #include <sys/param.h>
@ -135,6 +136,11 @@
#include <pci/pcivar.h> #include <pci/pcivar.h>
#include <pci/if_txvar.h> #include <pci/if_txvar.h>
#ifdef BRIDGE
#include <net/bridge.h>
#endif
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
@ -921,7 +927,43 @@ epic_rx_done __P((
#else /* __OpenBSD__ */ #else /* __OpenBSD__ */
bpf_mtap( sc->sc_if.if_bpf, m ); bpf_mtap( sc->sc_if.if_bpf, m );
#endif /* __FreeBSD__ */ #endif /* __FreeBSD__ */
#endif /* NBPFILTER */
#ifdef BRIDGE
if (do_bridge) {
struct ifnet *bdg_ifp ;
bdg_ifp = bridge_in(m);
if (bdg_ifp == BDG_DROP) {
if (m)
m_free(m);
continue; /* and drop */
}
if (bdg_ifp != BDG_LOCAL)
bdg_forward(&m, bdg_ifp);
if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_BCAST &&
bdg_ifp != BDG_MCAST) {
if (m)
m_free(m);
continue; /* and drop */
}
/* all others accepted locally */
}
#endif
#if NBPFILTER > 0
#ifdef BRIDGE
/*
* This deserves explanation
* If the bridge is _on_, then the following check
* must not be done because occasionally the bridge
* gets packets that are local but have the ethernet
* address of one of the other interfaces.
*
* But if the bridge is off, then we have to drop
* stuff that came in just via bpfilter.
*/
if (!do_bridge)
#endif
/* Accept only our packets, broadcasts and multicasts */ /* Accept only our packets, broadcasts and multicasts */
if( (eh->ether_dhost[0] & 1) == 0 && if( (eh->ether_dhost[0] & 1) == 0 &&
bcmp(eh->ether_dhost,sc->sc_macaddr,ETHER_ADDR_LEN)){ bcmp(eh->ether_dhost,sc->sc_macaddr,ETHER_ADDR_LEN)){