From owner-svn-src-projects@FreeBSD.ORG Thu Jun 11 11:59:53 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5ADCA106564A; Thu, 11 Jun 2009 11:59:53 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4817C8FC0C; Thu, 11 Jun 2009 11:59:53 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5BBxr0j046391; Thu, 11 Jun 2009 11:59:53 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5BBxrCQ046390; Thu, 11 Jun 2009 11:59:53 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200906111159.n5BBxrCQ046390@svn.freebsd.org> From: Rui Paulo Date: Thu, 11 Jun 2009 11:59:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193989 - projects/mesh11s/sys/net80211 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2009 11:59:53 -0000 Author: rpaulo Date: Thu Jun 11 11:59:53 2009 New Revision: 193989 URL: http://svn.freebsd.org/changeset/base/193989 Log: Fix some code that was introduced in previous revisions. Add a bit more of PREP processing, still unfinished. This makes HWMP usable for local neighbors. 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 Thu Jun 11 11:17:16 2009 (r193988) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Thu Jun 11 11:59:53 2009 (r193989) @@ -75,22 +75,22 @@ static uint8_t *hwmp_add_meshperr(uint8_ static uint8_t *hwmp_add_meshrann(uint8_t *, const struct ieee80211_meshrann_ie *); static void hwmp_recv_preq(struct ieee80211vap *, struct ieee80211_node *, - const struct ieee80211_meshpreq_ie *); + const struct ieee80211_frame *, const struct ieee80211_meshpreq_ie *); static inline int hwmp_send_preq(struct ieee80211_node *, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], struct ieee80211_meshpreq_ie *); static void hwmp_recv_prep(struct ieee80211vap *, struct ieee80211_node *, - const struct ieee80211_meshprep_ie *); + const struct ieee80211_frame *, const struct ieee80211_meshprep_ie *); static inline int hwmp_send_prep(struct ieee80211_node *, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], struct ieee80211_meshprep_ie *); static void hwmp_recv_perr(struct ieee80211vap *, struct ieee80211_node *, - const struct ieee80211_meshperr_ie *); + const struct ieee80211_frame *, const struct ieee80211_meshperr_ie *); static inline int hwmp_send_perr(struct ieee80211_node *, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], struct ieee80211_meshperr_ie *); static void hwmp_recv_rann(struct ieee80211vap *, struct ieee80211_node *, - const struct ieee80211_meshrann_ie *); + const struct ieee80211_frame *, const struct ieee80211_meshrann_ie *); static inline int hwmp_send_rann(struct ieee80211_node *, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], struct ieee80211_meshrann_ie *); @@ -240,7 +240,7 @@ ieee80211_hwmp_recv_action(struct ieee80 vap->iv_stats.is_rx_mgtdiscard++; return; } - hwmp_recv_preq(vap, ni, meshpreq); + hwmp_recv_preq(vap, ni, wh, meshpreq); break; case IEEE80211_ACTION_MESHPATH_REP: if (meshprep == NULL) { @@ -250,7 +250,7 @@ ieee80211_hwmp_recv_action(struct ieee80 vap->iv_stats.is_rx_mgtdiscard++; return; } - hwmp_recv_prep(vap, ni, meshprep); + hwmp_recv_prep(vap, ni, wh, meshprep); break; case IEEE80211_ACTION_MESHPATH_ERR: if (meshperr == NULL) { @@ -260,7 +260,7 @@ ieee80211_hwmp_recv_action(struct ieee80 vap->iv_stats.is_rx_mgtdiscard++; return; } - hwmp_recv_perr(vap, ni, meshperr); + hwmp_recv_perr(vap, ni, wh, meshperr); break; case IEEE80211_ACTION_MESHPATH_RANN: if (meshrann == NULL) { @@ -270,7 +270,7 @@ ieee80211_hwmp_recv_action(struct ieee80 vap->iv_stats.is_rx_mgtdiscard++; return; } - hwmp_recv_rann(vap, ni, meshrann); + hwmp_recv_rann(vap, ni, wh, meshrann); break; default: IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH, @@ -472,7 +472,7 @@ hwmp_add_meshrann(uint8_t *frm, const st #define PREQ_TSEQ(n) preq->preq_targets[n].target_seq static void hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_node *ni, - const struct ieee80211_meshpreq_ie *preq) + const struct ieee80211_frame *wh, const struct ieee80211_meshpreq_ie *preq) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi = NULL; @@ -493,7 +493,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, mtx_lock(&hs->hs_lock); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { - if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), fi->fi_dest)) + if (IEEE80211_ADDR_EQ(preq->preq_origaddr, fi->fi_dest)) break; } mtx_unlock(&hs->hs_lock); @@ -539,13 +539,15 @@ hwmp_recv_preq(struct ieee80211vap *vap, prep.prep_origseq = hs->hs_seq++; /* XXX addr1 = next hop */ hwmp_send_prep(ni, vap->iv_myaddr, preq->preq_origaddr, &prep); +#if 0 /* * Build the reverse path, if we don't have it already. */ if (fi == NULL || - memcmp(fi->fi_nexthop, invalidaddr, IEEE80211_ADDR_LEN)) { + IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) { ieee80211_hwmp_discover(vap, fi->fi_dest); } +#endif return; } @@ -666,8 +668,10 @@ hwmp_send_preq(struct ieee80211_node *ni static void hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_node *ni, - const struct ieee80211_meshprep_ie *prep) + const struct ieee80211_frame *wh, const struct ieee80211_meshprep_ie *prep) { + struct ieee80211_hwmp_state *hs = vap->iv_hwmp; + struct ieee80211_hwmp_fi *fi = NULL; /* * Acceptance criteria: if the PREP was not generated by us and @@ -677,10 +681,28 @@ hwmp_recv_prep(struct ieee80211vap *vap, !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) return; + IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni, + "received PREP from %s", ether_sprintf(prep->prep_origaddr)); + /* - * Update the Forwarding Information. + * Find out if this path reply is useful to us. */ + mtx_lock(&hs->hs_lock); + TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { + if (IEEE80211_ADDR_EQ(prep->prep_targetaddr, fi->fi_dest)) + break; + } + mtx_unlock(&hs->hs_lock); + /* 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 @@ -740,7 +762,7 @@ hwmp_send_prep(struct ieee80211_node *ni #define PREQ_DSEQ(n) perr->perr_dests[n].dest_seq static void hwmp_recv_perr(struct ieee80211vap *vap, struct ieee80211_node *ni, - const struct ieee80211_meshperr_ie *perr) + const struct ieee80211_frame *wh, const struct ieee80211_meshperr_ie *perr) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi = NULL; @@ -792,7 +814,7 @@ hwmp_send_perr(struct ieee80211_node *ni static void hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_node *ni, - const struct ieee80211_meshrann_ie *rann) + const struct ieee80211_frame *wh, const struct ieee80211_meshrann_ie *rann) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi = NULL; @@ -881,16 +903,14 @@ ieee80211_hwmp_discover(struct ieee80211 if (IEEE80211_IS_MULTICAST(dest)) return ieee80211_find_txnode(vap, dest); - IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest, - "%s", "initiating path discovery"); - mtx_lock(&hs->hs_lock); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { - if (IEEE80211_ADDR_EQ(fi->fi_dest, dest) && - IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) { - /* XXX check preq retries */ - sendpreq = 1; - unknowndst = 1; + if (IEEE80211_ADDR_EQ(fi->fi_dest, dest)) { + if (IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) { + /* XXX check preq retries */ + sendpreq = 1; + unknowndst = 1; + } break; } } @@ -901,6 +921,7 @@ ieee80211_hwmp_discover(struct ieee80211 M_NOWAIT | M_ZERO); IEEE80211_ADDR_COPY(fi->fi_dest, dest); fi->fi_seq = ++hs->hs_seq; + fi->fi_preqid = ++hs->hs_preqid; fi->fi_metric = IEEE80211_MESHLMETRIC_INITIALVAL; fi->fi_lifetime = ieee80211_hwmp_pathtimeout; mtx_lock(&hs->hs_lock); @@ -911,13 +932,15 @@ ieee80211_hwmp_discover(struct ieee80211 } if (sendpreq) { + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest, + "%s", "initiating path discovery"); /* * Try to discover the path for this node. */ preq.preq_flags = 0; preq.preq_hopcount = 0; preq.preq_ttl = ieee80211_mesh_ttl; - preq.preq_id = ++hs->hs_preqid; + preq.preq_id = fi->fi_preqid; IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); preq.preq_origseq = fi->fi_seq; preq.preq_lifetime = fi->fi_lifetime;