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

Sam Leffler sam at FreeBSD.org
Wed Jun 24 18:02:35 UTC 2009


Author: sam
Date: Wed Jun 24 18:02:34 2009
New Revision: 194867
URL: http://svn.freebsd.org/changeset/base/194867

Log:
  Forwarding fixups/cleanups:
  o pull code into new mesh_forward function
  o correct multiple mcast/ucast issues
  o take tx parms from the dest node in case they are operating w/
    different channel characteristics (may need to revisi mcast case)
  o on raw xmit error free the correct node ref
  
  Reviewed by:	rpaulo

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

Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c	Wed Jun 24 18:00:34 2009	(r194866)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c	Wed Jun 24 18:02:34 2009	(r194867)
@@ -281,6 +281,91 @@ restart:
 	return r;
 }
 
+/*
+ * Forward the specified frame.
+ * Decrement the TTL and set TA to our MAC address.
+ */
+static void
+mesh_forward(struct ieee80211vap *vap, struct mbuf *m)
+{
+	struct ieee80211com *ic = vap->iv_ic;
+	struct ifnet *ifp = vap->iv_ifp;
+	const struct ieee80211_frame *wh =
+	    mtod(m, const struct ieee80211_frame *);
+	struct mbuf *mcopy;
+	struct ieee80211_meshcntl *mccopy;
+	struct ieee80211_frame *whcopy;
+	const struct ieee80211_txparam *tp;
+	struct ieee80211_bpf_params params;
+	struct ieee80211_node *nidest;
+	int err;
+
+	mcopy = m_dup(m, M_DONTWAIT);
+	if (mcopy == NULL) {
+		/* XXX stat+msg? */
+		ifp->if_oerrors++;
+		return;
+	}
+	mcopy = m_pullup(mcopy, ieee80211_hdrspace(ic, wh) +
+	    sizeof(struct ieee80211_meshcntl));
+	if (mcopy == NULL) {
+		/* XXX stat+msg? */
+		ifp->if_oerrors++;
+		m_freem(mcopy);
+		return;
+	}
+	whcopy = mtod(mcopy, struct ieee80211_frame *);
+	mccopy = (struct ieee80211_meshcntl *)
+	    (mtod(mcopy, uint8_t *) + ieee80211_hdrspace(ic, wh));
+	memset(&params, 0, sizeof(params));
+	/* XXX clear other bits? */
+	whcopy->i_fc[1] &= ~IEEE80211_FC1_RETRY;
+	IEEE80211_ADDR_COPY(whcopy->i_addr2, vap->iv_myaddr);
+	if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+		nidest = vap->iv_bss;
+		tp = nidest->ni_txparms;
+		params.ibp_rate0 = tp->mcastrate;
+		params.ibp_flags |= IEEE80211_BPF_NOACK;
+		params.ibp_try0 = 1;
+		mcopy->m_flags |= M_MCAST;
+	} else {
+		nidest = ieee80211_hwmp_find_txnode(vap, whcopy->i_addr3);
+		if (nidest == NULL) {
+			/* XXX stat+msg? */
+			m_freem(mcopy);
+			return;
+		}
+		tp = nidest->ni_txparms;
+		params.ibp_rate0 = tp->ucastrate;
+		params.ibp_try0 = tp->maxretry;
+		IEEE80211_ADDR_COPY(whcopy->i_addr1, nidest->ni_macaddr);
+	}
+	IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, nidest,
+	    "fwd %s frame from %s ttl %d",
+	    IEEE80211_IS_MULTICAST(wh->i_addr1) ?  "mcast" : "ucast",
+	    ether_sprintf(wh->i_addr3), mccopy->mc_ttl);
+	mccopy->mc_ttl--;
+	/* XXX calculate priority so drivers can find the tx queue */
+	M_WME_SETAC(mcopy, WME_AC_BE);
+	params.ibp_pri = M_WME_GETAC(mcopy);
+	params.ibp_power = nidest->ni_txpower;
+#ifdef IEEE80211_DEBUG_REFCNT
+	IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
+	    "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n",
+	    __func__, __LINE__,
+	    ni, ether_sprintf(nidest->ni_macaddr),
+	    ieee80211_node_refcnt(nidest)+1);
+#endif
+	ieee80211_ref_node(nidest);
+	err = ic->ic_raw_xmit(nidest, mcopy, &params);
+	if (err) {
+		/* NB: IFQ_HANDOFF reclaims mbuf */
+		ifp->if_oerrors++;
+		ieee80211_free_node(nidest);
+	} else
+		ifp->if_opackets++;
+}
+
 static int
 mesh_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int noise)
 {
@@ -341,8 +426,10 @@ mesh_input(struct ieee80211_node *ni, st
 	case IEEE80211_FC0_TYPE_DATA:
 		if (ni == vap->iv_bss)
 			goto out;
+#if 0
 		IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
 		    "received data frame, dir 0x%x", dir);
+#endif
 		if (ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) {
 			IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH,
 			    ni->ni_macaddr, NULL,
@@ -389,84 +476,14 @@ mesh_input(struct ieee80211_node *ni, st
 		/*
 		 * 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
 		 */
 		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 &&
-		    (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) {
-			struct mbuf *mcopy;
-			struct ieee80211_meshcntl *mccopy;
-			struct ieee80211_frame *whcopy;
-			const struct ieee80211_txparam *tp;
-			struct ieee80211_bpf_params params;
-			struct ieee80211_node *nidest;
-			int err;
-
-			mcopy = m_dup(m, M_DONTWAIT);
-			if (mcopy == NULL) {
-				ifp->if_oerrors++;
-				goto deliver;
-			}
-			mcopy = m_pullup(mcopy, ieee80211_hdrspace(ic, wh) +
-			    sizeof(struct ieee80211_meshcntl));
-			if (mcopy == NULL) {
-				ifp->if_oerrors++;
-				m_freem(mcopy);
-				goto deliver;
-			}
-			whcopy = mtod(mcopy, struct ieee80211_frame *);
-			mccopy = (struct ieee80211_meshcntl *)
-			    (mtod(mcopy, uint8_t *) +
-				ieee80211_hdrspace(ic, wh));
-			memset(&params, 0, sizeof(params));
-			tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
-			/* XXX clear other bits? */
-			whcopy->i_fc[1] &= ~IEEE80211_FC1_RETRY;
-			IEEE80211_ADDR_COPY(whcopy->i_addr2, vap->iv_myaddr);
-			if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
-				IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
-				    "forwarding multicast frame from %s ttl %d",
-				    ether_sprintf(wh->i_addr3), mc->mc_ttl);
-				nidest = vap->iv_bss;
-				params.ibp_rate0 = tp->mcastrate;
-			} else {
-				IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
-				    "forwarding unicast frame from %s ttl %d",
-				    ether_sprintf(wh->i_addr3), mc->mc_ttl);
-				params.ibp_rate0 = tp->ucastrate;
-				nidest = ieee80211_hwmp_find_txnode(vap,
-				    whcopy->i_addr3);
-				if (nidest == NULL) {
-					m_freem(mcopy);
-					goto deliver;
-				}
-				IEEE80211_ADDR_COPY(whcopy->i_addr1,
-				    nidest->ni_macaddr);
-			}
-			mccopy->mc_ttl--;
-			/* XXX calculate priority so drivers can find the tx queue */
-			mcopy->m_flags |= M_MCAST;
-			M_WME_SETAC(mcopy, WME_AC_BE);
-			params.ibp_pri = M_WME_GETAC(mcopy);
-			params.ibp_power = nidest->ni_txpower;
-			params.ibp_flags |= IEEE80211_BPF_NOACK;
-			params.ibp_try0 = 1;
-			IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
-			    "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n",
-			    __func__, __LINE__,
-			    ni, ether_sprintf(nidest->ni_macaddr),
-			    ieee80211_node_refcnt(nidest)+1);
-			ieee80211_ref_node(nidest);
-			err = ic->ic_raw_xmit(nidest, mcopy, &params);
-			if (err) {
-				/* NB: IFQ_HANDOFF reclaims mbuf */
-				ifp->if_oerrors++;
-				ieee80211_free_node(vap->iv_bss);
-			} else
-				ifp->if_opackets++;
-		}
-deliver:
+		    (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD))
+			mesh_forward(vap, m);
 		/*
 		 * Next up, any fragmentation.
 		 */


More information about the svn-src-projects mailing list