Deleted Added
full compact
ng_bridge.c (130931) ng_bridge.c (131155)
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 *
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 130931 2004-06-22 18:56:47Z green $
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;
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 meta_p meta;
524 struct ng_bridge_link *firstLink;
525
526 NGI_GET_M(item, m);
527 /* Get link number */
528 linkNum = (intptr_t)NG_HOOK_PRIVATE(hook);
529 KASSERT(linkNum >= 0 && linkNum < NG_BRIDGE_MAX_LINKS,
530 ("%s: linkNum=%u", __func__, linkNum));
531 link = priv->links[linkNum];

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

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

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

700 * If we never find another we save a copy.
701 */
702 firstLink = destLink;
703 continue;
704 }
705
706 /*
707 * It's usable link but not the reserved (first) one.
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.
708 * Copy mbuf and meta info for sending.
705 * Copy mbuf info for sending.
709 */
710 m2 = m_dup(m, M_DONTWAIT); /* XXX m_copypacket() */
711 if (m2 == NULL) {
712 link->stats.memoryFailures++;
713 NG_FREE_ITEM(item);
714 NG_FREE_M(m);
715 return (ENOBUFS);
716 }
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 }
717 if (meta != NULL
718 && (meta2 = ng_copy_meta(meta)) == NULL) {
719 link->stats.memoryFailures++;
720 m_freem(m2);
721 NG_FREE_ITEM(item);
722 NG_FREE_M(m);
723 return (ENOMEM);
724 }
725 }
726
727 /* Update stats */
728 destLink->stats.xmitPackets++;
729 destLink->stats.xmitOctets += m->m_pkthdr.len;
730 switch (manycast) {
731 case 0: /* unicast */
732 break;

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

742 if (destLink == firstLink) {
743 /*
744 * If we've sent all the others, send the original
745 * on the first link we found.
746 */
747 NG_FWD_NEW_DATA(error, item, destLink->hook, m);
748 break; /* always done last - not really needed. */
749 } else {
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 {
750 NG_SEND_DATA(error, destLink->hook, m2, meta2);
739 NG_SEND_DATA_ONLY(error, destLink->hook, m2);
751 }
752 }
753 return (error);
754}
755
756/*
757 * Shutdown node
758 */

--- 304 unchanged lines hidden ---
740 }
741 }
742 return (error);
743}
744
745/*
746 * Shutdown node
747 */

--- 304 unchanged lines hidden ---