svn commit: r195176 - projects/mesh11s/sys/net80211

Rui Paulo rpaulo at FreeBSD.org
Mon Jun 29 20:12:54 UTC 2009


Author: rpaulo
Date: Mon Jun 29 20:12:54 2009
New Revision: 195176
URL: http://svn.freebsd.org/changeset/base/195176

Log:
  Rework the forwarding check a bit. Still a bit expensive.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/mesh11s/sys/net80211/ieee80211_mesh.c

Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c	Mon Jun 29 19:46:29 2009	(r195175)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c	Mon Jun 29 20:12:54 2009	(r195176)
@@ -379,6 +379,7 @@ mesh_forward(struct ieee80211vap *vap, s
 	    "fwd %s frame from %s ttl %d",
 	    IEEE80211_IS_MULTICAST(wh->i_addr1) ?  "mcast" : "ucast",
 	    ether_sprintf(wh->i_addr3), mccopy->mc_ttl);
+	KASSERT(mccopy->mc_ttl > 0, ("%s called with wrong ttl", __func__));
 	mccopy->mc_ttl--;
 	/* XXX calculate priority so drivers can find the tx queue */
 	M_WME_SETAC(mcopy, WME_AC_BE);
@@ -388,7 +389,7 @@ mesh_forward(struct ieee80211vap *vap, s
 	IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
 	    "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n",
 	    __func__, __LINE__,
-	    ni, ether_sprintf(nidest->ni_macaddr),
+	    nidest, ether_sprintf(nidest->ni_macaddr),
 	    ieee80211_node_refcnt(nidest)+1);
 #endif
 	ieee80211_ref_node(nidest);
@@ -514,16 +515,28 @@ mesh_input(struct ieee80211_node *ni, st
 		} else
 			qos = 0;
 		/*
-		 * Forward packets if they are not destined to us.
-		 * We just decrement the TTL and set TA to our MAC address.
-		 * XXX make this check cheaper
+		 * Check if we can forward the packet.
 		 */
-		if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr2) &&
-		    !IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr3) &&
-		    !IEEE80211_ADDR_EQ(wh->i_addr1, wh->i_addr3) &&
-		    mc->mc_ttl > 0 &&
-		    (ms->ms_flags & IEEE80211_MESHFLAGS_FWD))
+		if (mc->mc_ttl <= 0 ||
+		    !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD))
+			goto deliver;
+		/*
+		 * Forward and deliver multicast packets
+		 */
+		if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+			mesh_forward(vap, m);
+			goto deliver;
+		}
+		/*
+		 * Forward packets if their final destination is not us.
+		 */
+		if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr3) &&
+		    IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr1)) {
 			mesh_forward(vap, m);
+			/* NB: don't deliver */
+			goto out;
+		}
+deliver:
 		/*
 		 * Next up, any fragmentation.
 		 */


More information about the svn-src-projects mailing list