Date: Tue, 27 Aug 2002 21:49:58 -0700 From: Brooks Davis <brooks@one-eyed-alien.net> To: mark@inetu.net Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: bridge(4) Message-ID: <20020827214958.A3713@Odin.AC.HMC.Edu> In-Reply-To: <Pine.BSF.4.10.10208272352030.7606-100000@norad.inetu.net>; from mark@inetu.net on Tue, Aug 27, 2002 at 11:54:30PM -0400 References: <20020827201705.A29826@Odin.AC.HMC.Edu> <Pine.BSF.4.10.10208272352030.7606-100000@norad.inetu.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 27, 2002 at 11:54:30PM -0400, mark@inetu.net wrote: >=20 > I'm actually going to throw up a 5.0-current box <groan :)> and start > playing. By the time done what I need, there'll probably be a release of > it. :) >=20 > It looks like a more than trivial backport, at least for my ability and > general sleepless state. Here you go. It's untested other then compiling, but the diff applied almost directly so I'd guess it works. -- Brooks Index: ng_one2many.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/netgraph/ng_one2many.c,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 ng_one2many.c --- ng_one2many.c 2 Jul 2002 23:44:02 -0000 1.1.2.2 +++ ng_one2many.c 28 Aug 2002 04:47:32 -0000 @@ -43,7 +43,7 @@ * ng_one2many(4) netgraph node type * * Packets received on the "one" hook are sent out each of the - * "many" hooks in round-robin fashion. Packets received on any + * "many" hooks accoring to an algorithm. Packets received on any * "many" hook are always delivered to the "one" hook. */ =20 @@ -284,6 +284,7 @@ ng_one2many_rcvmsg(node_p node, struct n conf =3D (struct ng_one2many_config *)msg->data; switch (conf->xmitAlg) { case NG_ONE2MANY_XMIT_ROUNDROBIN: + case NG_ONE2MANY_XMIT_ALL: break; default: error =3D EINVAL; @@ -390,6 +391,7 @@ ng_one2many_rcvdata(hook_p hook, struct=20 struct ng_one2many_link *dst; int error =3D 0; int linkNum; + int i; =20 /* Get link number */ linkNum =3D LINK_NUM(hook); @@ -412,8 +414,48 @@ ng_one2many_rcvdata(hook_p hook, struct=20 NG_FREE_DATA(m, meta); return (ENOTCONN); } - dst =3D &priv->many[priv->activeMany[priv->nextMany]]; - priv->nextMany =3D (priv->nextMany + 1) % priv->numActiveMany; + switch(priv->conf.xmitAlg) { + case NG_ONE2MANY_XMIT_ROUNDROBIN: + dst =3D &priv->many[priv->activeMany[priv->nextMany]]; + priv->nextMany =3D (priv->nextMany + 1) % priv->numActiveMany; + break; + case NG_ONE2MANY_XMIT_ALL: + /* no need to copy data for the 1st one */ + dst =3D &priv->many[priv->activeMany[0]]; + + /* make copies of data and send for all links + * except the first one, which we'll do last=20 + */ + for (i =3D 1; i < priv->numActiveMany; i++) { + meta_p meta2 =3D NULL; + struct mbuf *m2; + struct ng_one2many_link *mdst; + + mdst =3D &priv->many[priv->activeMany[i]]; + m2 =3D m_dup(m, M_NOWAIT); /* XXX m_copypacket() */ + if (m2 =3D=3D NULL) { + mdst->stats.memoryFailures++; + NG_FREE_DATA(m, meta); + return (ENOBUFS); + } + if (meta !=3D NULL + && (meta2 =3D ng_copy_meta(meta)) =3D=3D NULL) { + mdst->stats.memoryFailures++; + m_freem(m2); + NG_FREE_DATA(m, meta); + return (ENOMEM); + } + /* Update transmit stats */ + mdst->stats.xmitPackets++; + mdst->stats.xmitOctets +=3D m->m_pkthdr.len; + NG_SEND_DATA(error, mdst->hook, m2, meta2); + } + break; +#ifdef INVARIANTS + default: + panic("%s: invalid xmitAlg", __FUNCTION__); +#endif + } } else dst =3D &priv->one; =20 @@ -509,6 +551,8 @@ ng_one2many_update_many(priv_p priv) case NG_ONE2MANY_XMIT_ROUNDROBIN: if (priv->numActiveMany > 0) priv->nextMany %=3D priv->numActiveMany; + break; + case NG_ONE2MANY_XMIT_ALL: break; #ifdef INVARIANTS default: Index: ng_one2many.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/netgraph/ng_one2many.h,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 ng_one2many.h --- ng_one2many.h 2 Jul 2002 23:44:02 -0000 1.1.2.3 +++ ng_one2many.h 28 Aug 2002 04:47:33 -0000 @@ -59,6 +59,7 @@ =20 /* Algorithms for outgoing packet distribution (XXX only one so far) */ #define NG_ONE2MANY_XMIT_ROUNDROBIN 1 /* round-robin delivery */ +#define NG_ONE2MANY_XMIT_ALL 2 /* send packets to all many hooks */ =20 /* Algorithms for detecting link failure (XXX only one so far) */ #define NG_ONE2MANY_FAIL_MANUAL 1 /* use enabledLinks[] array */ @@ -84,6 +85,7 @@ struct ng_one2many_link_stats { u_int64_t recvPackets; /* total pkts rec'd on link */ u_int64_t xmitOctets; /* total octets xmit'd on link */ u_int64_t xmitPackets; /* total pkts xmit'd on link */ + u_int64_t memoryFailures; /* times couldn't get mem or mbuf */ }; =20 /* Keep this in sync with the above structure definition */ @@ -92,6 +94,7 @@ struct ng_one2many_link_stats { { "recvPackets", &ng_parse_uint64_type }, \ { "xmitOctets", &ng_parse_uint64_type }, \ { "xmitPackets", &ng_parse_uint64_type }, \ + { "memoryFailures", &ng_parse_uint64_type }, \ { NULL } \ } --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --3V7upXqbjpZ4EhLz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9bFZ2XY6L6fI4GtQRAnmPAKCn82xz3C9GYss7L8/e29SwhYKNDgCgxFbJ FOTlQrGBx/0yU9pbc05ur/8= =4vTm -----END PGP SIGNATURE----- --3V7upXqbjpZ4EhLz-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020827214958.A3713>