Clean up the if_bridge hooks a bit in if_ethersubr.c and ng_ether.c, move

the broadcast/multicast test to bridge_input().

Requested by:	glebius
This commit is contained in:
Andrew Thompson 2005-10-13 09:43:30 +00:00
parent ca107a4b1e
commit 9cff52f7f6
3 changed files with 10 additions and 33 deletions

View File

@ -333,6 +333,9 @@ const struct bridge_control bridge_control_table[] = {
const int bridge_control_table_size =
sizeof(bridge_control_table) / sizeof(bridge_control_table[0]);
static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
LIST_HEAD(, bridge_softc) bridge_list;
IFC_SIMPLE_DECLARE(bridge, 0);
@ -1698,7 +1701,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
return (m);
}
if (m->m_flags & (M_BCAST|M_MCAST)) {
if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
/* Tap off 802.1D packets; they do not get forwarded. */
if (memcmp(eh->ether_dhost, bstp_etheraddr,
ETHER_ADDR_LEN) == 0) {
@ -1719,6 +1722,12 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
}
}
if (bcmp(etherbroadcastaddr, eh->ether_dhost,
sizeof(etherbroadcastaddr)) == 0)
m->m_flags |= M_BCAST;
else
m->m_flags |= M_MCAST;
/*
* Make a deep copy of the packet and enqueue the copy
* for bridge processing; return the original packet for

View File

@ -592,19 +592,6 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
KASSERT(bridge_input_p != NULL,
("%s: if_bridge not loaded!", __func__));
/* Mark the packet as broadcast or multicast. This is also set
* further down the code in ether_demux() but since the bridge
* input routine rarely returns a mbuf for further processing,
* it is an acceptable duplication.
*/
if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
if (bcmp(etherbroadcastaddr, eh->ether_dhost,
sizeof(etherbroadcastaddr)) == 0)
m->m_flags |= M_BCAST;
else
m->m_flags |= M_MCAST;
}
m = (*bridge_input_p)(ifp, m);
if (m == NULL)
return;

View File

@ -105,8 +105,6 @@ static int ng_ether_rcv_upper(node_p node, struct mbuf *m);
/* if_bridge(4) support. XXX: should go into some include. */
extern struct mbuf *(*bridge_input_p)(struct ifnet *, struct mbuf *);
static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/* Netgraph node methods */
static ng_constructor_t ng_ether_constructor;
@ -653,26 +651,9 @@ ng_ether_rcv_upper(node_p node, struct mbuf *m)
* XXX: This is a copy'and'paste from if_ethersubr.c:ether_input()
*/
if (ifp->if_bridge) {
struct ether_header *eh;
KASSERT(bridge_input_p != NULL,
("%s: if_bridge not loaded!", __func__));
eh = mtod(m, struct ether_header *);
/* Mark the packet as broadcast or multicast. This is also set
* further down the code in ether_demux() but since the bridge
* input routine rarely returns a mbuf for further processing,
* it is an acceptable duplication.
*/
if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
if (bcmp(etherbroadcastaddr, eh->ether_dhost,
sizeof(etherbroadcastaddr)) == 0)
m->m_flags |= M_BCAST;
else
m->m_flags |= M_MCAST;
}
m = (*bridge_input_p)(ifp, m);
if (m == NULL)
return (0);