Author: monthadar
Date: Thu Feb  7 21:31:37 2013
New Revision: 246519
URL: http://svnweb.freebsd.org/changeset/base/246519

Log:
  Mesh HWMP forwarding information: updating FI for transmitter.
  
  * Added hwmp_update_transmitter function that checks if the metric
    to the transmitter have improved. If old FI is invalid or metric
    is larger the FI to the transmitter is updated occurdingly.
    This is a recommendation from the 802.11 2012 standard, table 13-9;
  
  Approved by:  adrian (mentor)

Modified:
  head/sys/net80211/ieee80211_hwmp.c

Modified: head/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- head/sys/net80211/ieee80211_hwmp.c  Thu Feb  7 21:30:58 2013        
(r246518)
+++ head/sys/net80211/ieee80211_hwmp.c  Thu Feb  7 21:31:37 2013        
(r246519)
@@ -896,6 +896,45 @@ hwmp_rootmode_rann_cb(void *arg)
        hwmp_rootmode_setup(vap);
 }
 
+/*
+ * Update forwarding information to TA if metric improves.
+ */
+static void
+hwmp_update_transmitter(struct ieee80211vap *vap, struct ieee80211_node *ni,
+    const char *hwmp_frame)
+{
+       struct ieee80211_mesh_state *ms = vap->iv_mesh;
+       struct ieee80211_mesh_route *rttran = NULL;     /* Transmitter */
+       int metric = 0;
+
+       rttran = ieee80211_mesh_rt_find(vap, ni->ni_macaddr);
+       if (rttran == NULL) {
+               rttran = ieee80211_mesh_rt_add(vap, ni->ni_macaddr);
+               if (rttran == NULL) {
+                       IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
+                           "unable to add path to transmitter %6D of %s",
+                           ni->ni_macaddr, ":", hwmp_frame);
+                       vap->iv_stats.is_mesh_rtaddfailed++;
+                       return;
+               }
+       }
+       metric = ms->ms_pmetric->mpm_metric(ni);
+       if (!(rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) ||
+           rttran->rt_metric > metric)
+       {
+               IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
+                   "%s path to transmiter %6D of %s, metric %d:%d",
+                   rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ?
+                   "prefer" : "update", ni->ni_macaddr, ":", hwmp_frame,
+                   rttran->rt_metric, metric);
+               IEEE80211_ADDR_COPY(rttran->rt_nexthop, ni->ni_macaddr);
+               rttran->rt_metric = metric;
+               rttran->rt_nhops  = 1;
+               ieee80211_mesh_rt_update(rttran, ms->ms_ppath->mpp_inact);
+               rttran->rt_flags = IEEE80211_MESHRT_FLAGS_VALID;
+       }
+}
+
 #define        PREQ_TFLAGS(n)  preq->preq_targets[n].target_flags
 #define        PREQ_TADDR(n)   preq->preq_targets[n].target_addr
 #define        PREQ_TSEQ(n)    preq->preq_targets[n].target_seq
@@ -1010,10 +1049,8 @@ hwmp_recv_preq(struct ieee80211vap *vap,
                return;
        }
 
-       /*
-        * Forwarding information for transmitter mesh STA
-        * [OPTIONAL: if metric improved]
-        */
+       /* Update forwarding information to TA if metric improves. */
+       hwmp_update_transmitter(vap, ni, "PREQ");
 
        /*
         * Check if the PREQ is addressed to us.
@@ -1268,7 +1305,6 @@ hwmp_recv_prep(struct ieee80211vap *vap,
         * rules defined in 13.10.8.4). If the conditions for creating or
         * updating the forwarding information have not been met in those
         * rules, no further steps are applied to the PREP.
-        * [OPTIONAL]: update forwarding information to TA if metric improves.
         */
        rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr);
        if (rt == NULL) {
@@ -1323,6 +1359,9 @@ hwmp_recv_prep(struct ieee80211vap *vap,
        }
        rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */
 
+       /* Update forwarding information to TA if metric improves */
+       hwmp_update_transmitter(vap, ni, "PREP");
+
        /*
         * If it's NOT for us, propagate the PREP
         */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to