Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 2009 14:42:14 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r194626 - projects/mesh11s/sys/net80211
Message-ID:  <200906221442.n5MEgEsk043859@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Mon Jun 22 14:42:14 2009
New Revision: 194626
URL: http://svn.freebsd.org/changeset/base/194626

Log:
  Checkpoint HWMP work. We can now establish paths with mesh nodes in the
  middle.
  
  Sponsored by:	The FreeBSD Foundation

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

Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c	Mon Jun 22 14:32:47 2009	(r194625)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c	Mon Jun 22 14:42:14 2009	(r194626)
@@ -516,6 +516,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 	struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
 	struct ieee80211_hwmp_fi *fi = NULL;
 
+	/*
+	 * Ignore PREQs from us. Could happen because someone forward it
+	 * back to us.
+	 */
+	if (IEEE80211_ADDR_EQ(vap->iv_myaddr, preq->preq_origaddr))
+		return;
+
 	IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
 	    "received PREQ, source %s", ether_sprintf(preq->preq_origaddr));
 
@@ -532,11 +539,11 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 
 	HWMP_LOCK(hs);
 	TAILQ_FOREACH(fi, &hs->hs_head, fi_next) {
-		if (IEEE80211_ADDR_EQ(preq->preq_origaddr, fi->fi_dest))
+		if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), fi->fi_dest))
 			break;
 	}
 	HWMP_UNLOCK(hs);
-
+#if 0
 	/*
 	 * Record the PREQ ID and the originator MAC address.
 	 */
@@ -544,7 +551,7 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 		fi = malloc(sizeof(struct ieee80211_hwmp_fi), M_80211_HWMP,
 		    M_NOWAIT | M_ZERO);
 		memset(fi, 0, sizeof(*fi));
-		IEEE80211_ADDR_COPY(fi->fi_dest, preq->preq_origaddr);
+		IEEE80211_ADDR_COPY(fi->fi_dest, PREQ_TADDR(0));
 		fi->fi_seq = preq->preq_origseq;
 		fi->fi_metric = preq->preq_metric;
 		fi->fi_lifetime = preq->preq_lifetime;
@@ -553,6 +560,7 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 		HWMP_UNLOCK(hs);
 	}
 	fi->fi_preqid = preq->preq_id;
+#endif
 
 	/*
 	 * Check if the PREQ is addressed to us.
@@ -569,15 +577,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 		prep.prep_flags = 0;
 		prep.prep_hopcount = 0;
 		prep.prep_ttl = ieee80211_mesh_ttl;
-		IEEE80211_ADDR_COPY(prep.prep_targetaddr,
-		    preq->preq_targets[0].target_addr);
+		IEEE80211_ADDR_COPY(prep.prep_targetaddr, preq->preq_origaddr);
 		prep.prep_targetseq = preq->preq_origseq;
 		prep.prep_lifetime = preq->preq_lifetime;
 		prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
 		IEEE80211_ADDR_COPY(prep.prep_origaddr, vap->iv_myaddr);
 		prep.prep_origseq = hs->hs_seq++;
-		/* XXX addr1 = next hop */
-		hwmp_send_prep(ni, vap->iv_myaddr, preq->preq_origaddr, &prep);
+		hwmp_send_prep(ni, vap->iv_myaddr, wh->i_addr2, &prep);
 #if 0
 		/*
 		 * Build the reverse path, if we don't have it already.
@@ -596,19 +602,18 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 	/*
 	 * Intermediate reply for PREQs with 1 target.
 	 */
-	if (preq->preq_ttl > 1 && preq->preq_tcount == 1 &&
-	    !(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) {
+	if (preq->preq_ttl > 1 && preq->preq_tcount == 1) {
 		struct ieee80211_meshpreq_ie ppreq; /* propagated PREQ */
 
 		memcpy(&ppreq, preq, sizeof(ppreq));
 		/*
-		 * Can we do an intermediate path reply?
+		 * We have a valid route to this node.
 		 */
-		if (fi != NULL) {
-			struct ieee80211_meshprep_ie prep;
+		if (fi != NULL &&
+		    !IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) {
 
 			IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
-			    "replying and forwarding PREQ from %s",
+			    "forwarding PREQ from %s",
 			    ether_sprintf(preq->preq_origaddr));
 			/*
 			 * Propagate the original PREQ.
@@ -626,23 +631,29 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 			    ~IEEE80211_MESHPREQ_TFLAGS_RF;
 			hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr,
 			    &ppreq);
-
 			/*
-			 * Build and send an intermediate PREP.
+			 * Check if we can send an intermediate Path Reply.
 			 */
-			prep.prep_flags = 0;
-			prep.prep_hopcount = 0;
-			prep.prep_ttl = ieee80211_mesh_ttl;
-			IEEE80211_ADDR_COPY(&prep.prep_targetaddr,
-			    preq->preq_origaddr);
-			prep.prep_targetseq = fi->fi_seq;
-			prep.prep_lifetime = preq->preq_lifetime;
-			prep.prep_metric = fi->fi_metric;
-			IEEE80211_ADDR_COPY(&prep.prep_origaddr,
-			    vap->iv_myaddr);
-			prep.prep_origseq = hs->hs_seq++;
-			hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr,
-			    &prep);
+	    		if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) {
+				struct ieee80211_meshprep_ie prep;
+
+				IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+				    "intermediate reply for PREQ from %s",
+				    ether_sprintf(preq->preq_origaddr));
+				prep.prep_flags = 0;
+				prep.prep_hopcount = 0;
+				prep.prep_ttl = ieee80211_mesh_ttl;
+				IEEE80211_ADDR_COPY(&prep.prep_targetaddr,
+				    preq->preq_origaddr);
+				prep.prep_targetseq = fi->fi_seq;
+				prep.prep_lifetime = preq->preq_lifetime;
+				prep.prep_metric = fi->fi_metric;
+				IEEE80211_ADDR_COPY(&prep.prep_origaddr,
+				    PREQ_TADDR(0));
+				prep.prep_origseq = hs->hs_seq++;
+				hwmp_send_prep(ni, vap->iv_myaddr,
+				    broadcastaddr, &prep);
+			}
 		} else {
 			IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
 			    "forwarding PREQ from %s",
@@ -732,26 +743,13 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 	IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
 	    "received PREP from %s", ether_sprintf(prep->prep_origaddr));
 
-	/*
-	 * Find out if this path reply is useful to us.
-	 */
 	HWMP_LOCK(hs);
 	TAILQ_FOREACH(fi, &hs->hs_head, fi_next) {
-		if (IEEE80211_ADDR_EQ(prep->prep_targetaddr, fi->fi_dest))
+		if (IEEE80211_ADDR_EQ(prep->prep_origaddr, fi->fi_dest))
 			break;
 	}
 	HWMP_UNLOCK(hs);
 
-	/* XXX */
-	if (fi == NULL)
-		return;
-
-	/*
-	 * Record the next hop.
-	 * XXX check for SEQ and PREQ ID.
-	 */
-	IEEE80211_ADDR_COPY(fi->fi_nexthop, wh->i_addr2);
-
 	/*
 	 * If it's NOT for us, propagate the PREP if TTL is
 	 * greater than 1.
@@ -760,6 +758,10 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 	    prep->prep_ttl > 1) {
 		struct ieee80211_meshprep_ie pprep; /* propagated PREP */
 
+		IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+		    "propagating PREP from %s",
+		    ether_sprintf(prep->prep_origaddr));
+
 		memcpy(&pprep, prep, sizeof(pprep));
 		pprep.prep_hopcount += 1;
 		pprep.prep_ttl -= 1;
@@ -772,6 +774,14 @@ hwmp_recv_prep(struct ieee80211vap *vap,
 		return;
 	}
 
+	if (fi != NULL) {
+		/*
+		 * Record the next hop.
+		 * XXX check for SEQ and PREQ ID.
+		 */
+		IEEE80211_ADDR_COPY(fi->fi_nexthop, wh->i_addr2);
+	}
+
 	/*
 	 * XXX: If it's for us and the AE bit is set, update the
 	 * proxy information table.
@@ -1015,6 +1025,7 @@ ieee80211_hwmp_discover(struct ieee80211
 		preq.preq_metric = fi->fi_metric;
 		preq.preq_tcount = 1;
 		IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest);
+		PREQ_TFLAGS(0) = 0;
 		if (ieee80211_hwmp_targetonly)
 			PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_TO;
 		if (ieee80211_hwmp_replyforward)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906221442.n5MEgEsk043859>