Deleted Added
sdiff udiff text old ( 130931 ) new ( 131155 )
full compact
1
2/*
3 * ng_bridge.c
4 *
5 * Copyright (c) 2000 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 22 unchanged lines hidden (view full) ---

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
39 * $FreeBSD: head/sys/netgraph/ng_bridge.c 131155 2004-06-26 22:24:16Z julian $
40 */
41
42/*
43 * ng_bridge(4) netgraph node type
44 *
45 * The node performs standard intelligent Ethernet bridging over
46 * each of its connected hooks, or links. A simple loop detection
47 * algorithm is included which disables a link for priv->conf.loopTimeout

--- 467 unchanged lines hidden (view full) ---

515 const node_p node = NG_HOOK_NODE(hook);
516 const priv_p priv = NG_NODE_PRIVATE(node);
517 struct ng_bridge_host *host;
518 struct ng_bridge_link *link;
519 struct ether_header *eh;
520 int error = 0, linkNum, linksSeen;
521 int manycast;
522 struct mbuf *m;
523 struct ng_bridge_link *firstLink;
524
525 NGI_GET_M(item, m);
526 /* Get link number */
527 linkNum = (intptr_t)NG_HOOK_PRIVATE(hook);
528 KASSERT(linkNum >= 0 && linkNum < NG_BRIDGE_MAX_LINKS,
529 ("%s: linkNum=%u", __func__, linkNum));
530 link = priv->links[linkNum];

--- 129 unchanged lines hidden (view full) ---

660 return (error);
661 }
662
663 /* Destination host is not known */
664 link->stats.recvUnknown++;
665 }
666
667 /* Distribute unknown, multicast, broadcast pkts to all other links */
668 firstLink = NULL;
669 for (linkNum = linksSeen = 0; linksSeen <= priv->numLinks; linkNum++) {
670 struct ng_bridge_link *destLink;
671 struct mbuf *m2 = NULL;
672
673 /*
674 * If we have checked all the links then now
675 * send the original on its reserved link
676 */
677 if (linksSeen == priv->numLinks) {
678 /* If we never saw a good link, leave. */

--- 18 unchanged lines hidden (view full) ---

697 * If we never find another we save a copy.
698 */
699 firstLink = destLink;
700 continue;
701 }
702
703 /*
704 * It's usable link but not the reserved (first) one.
705 * Copy mbuf info for sending.
706 */
707 m2 = m_dup(m, M_DONTWAIT); /* XXX m_copypacket() */
708 if (m2 == NULL) {
709 link->stats.memoryFailures++;
710 NG_FREE_ITEM(item);
711 NG_FREE_M(m);
712 return (ENOBUFS);
713 }
714 }
715
716 /* Update stats */
717 destLink->stats.xmitPackets++;
718 destLink->stats.xmitOctets += m->m_pkthdr.len;
719 switch (manycast) {
720 case 0: /* unicast */
721 break;

--- 9 unchanged lines hidden (view full) ---

731 if (destLink == firstLink) {
732 /*
733 * If we've sent all the others, send the original
734 * on the first link we found.
735 */
736 NG_FWD_NEW_DATA(error, item, destLink->hook, m);
737 break; /* always done last - not really needed. */
738 } else {
739 NG_SEND_DATA_ONLY(error, destLink->hook, m2);
740 }
741 }
742 return (error);
743}
744
745/*
746 * Shutdown node
747 */

--- 304 unchanged lines hidden ---