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

Rui Paulo rpaulo at FreeBSD.org
Thu Jun 11 21:41:52 UTC 2009


Author: rpaulo
Date: Thu Jun 11 21:41:51 2009
New Revision: 194041
URL: http://svn.freebsd.org/changeset/base/194041

Log:
  Enforce PREQ/PREP/PERR time intervals between packets.
  
  Sponsored by:	The FreeBSD Foundation

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

Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c	Thu Jun 11 21:37:23 2009	(r194040)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c	Thu Jun 11 21:41:51 2009	(r194041)
@@ -76,17 +76,17 @@ static uint8_t *hwmp_add_meshrann(uint8_
     const struct ieee80211_meshrann_ie *);
 static void	hwmp_recv_preq(struct ieee80211vap *, struct ieee80211_node *,
     const struct ieee80211_frame *, const struct ieee80211_meshpreq_ie *);
-static inline int hwmp_send_preq(struct ieee80211_node *,
+static 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_frame *, const struct ieee80211_meshprep_ie *);
-static inline int hwmp_send_prep(struct ieee80211_node *,
+static 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_frame *, const struct ieee80211_meshperr_ie *);
-static inline int hwmp_send_perr(struct ieee80211_node *,
+static 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 *,
@@ -96,26 +96,23 @@ static inline int hwmp_send_rann(struct 
     struct ieee80211_meshrann_ie *);
 
 static int	ieee80211_hwmp_maxhops = 31;	
-#ifdef notyet
-static int	ieee80211_hwmp_maxhopstime = 500;
-static int	ieee80211_hwmp_maxprepretries = 3;
-static int	ieee80211_hwmp_prepminint = 100;
-static int	ieee80211_hwmp_perrminint = 100;
-#endif
-static int	ieee80211_hwmp_roottimeout = 5000;
-static int	ieee80211_hwmp_pathtimeout = 5000;
-#ifdef notyet
 static int	ieee80211_hwmp_rootmode = 0;	/* XXX move to vap */
-static int	ieee80211_hwmp_pathtoroottimeout = 5000;
-static int	ieee80211_hmwp_rootint = 2000;
-static int	ieee80211_hwmp_rannint = 1000;
-#endif
 static int	ieee80211_hwmp_targetonly = 0;
 static int	ieee80211_hwmp_replyforward = 1;
-#ifdef notyet
-static int	ieee80211_hwmp_pathmaintenance = 2000;
-static int	ieee80211_hwmp_confirmint = 2000;
-#endif
+static const int ieee80211_hwmp_maxprepretries = 3;
+static const struct timeval ieee80211_hwmp_maxhopstime = { 0, 500000 };
+static const struct timeval ieee80211_hwmp_preqminint = { 0, 100000 };
+static const struct timeval ieee80211_hwmp_prepminint = { 0, 100000 };
+static const struct timeval ieee80211_hwmp_perrminint = { 0, 100000 };
+static const struct timeval ieee80211_hwmp_roottimeout = { 5, 0 };
+static const struct timeval ieee80211_hwmp_pathtimeout = { 5, 0 };
+static const struct timeval ieee80211_hwmp_pathtoroottimeout = { 5, 0 };
+static const struct timeval ieee80211_hmwp_rootint = { 2, 0 };
+static const struct timeval ieee80211_hwmp_rannint = { 1, 0 };
+static const struct timeval ieee80211_hwmp_pathmaintenanceint = { 2, 0 };
+static const struct timeval ieee80211_hwmp_confirmint = { 2, 0 };
+
+#define	timeval2msecs(tv)	(tv.tv_sec * 1000 + tv.tv_usec / 1000)
 
 /*
  * Target Address set in a Proactive PREQ.
@@ -136,12 +133,10 @@ SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, tar
     &ieee80211_hwmp_targetonly, 0, "Set TO bit on generated PREQs");
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, replyforward, CTLTYPE_INT | CTLFLAG_RW,
     &ieee80211_hwmp_replyforward, 0, "Set RF bit on generated PREQs");
-#ifdef notyet
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rootmode, CTLTYPE_INT | CTLFLAG_RW,
     &ieee80211_hwmp_rootmode, 0, "0 = Not a Root, "
     "2 = Root with normal PREPs, 3 = Root with proactive PREPs, "
     "3 = Root with RANNs");
-#endif
 
 MALLOC_DEFINE(M_80211_HWMP, "80211hwmp", "802.11 HWMP routing table");
 
@@ -647,12 +642,21 @@ hwmp_recv_preq(struct ieee80211vap *vap,
 #undef	PREQ_TADDR
 #undef	PREQ_TSEQ
 
-static inline int
+static int
 hwmp_send_preq(struct ieee80211_node *ni,
     const uint8_t sa[IEEE80211_ADDR_LEN],
     const uint8_t da[IEEE80211_ADDR_LEN],
     struct ieee80211_meshpreq_ie *preq)
 {
+	struct ieee80211_hwmp_state *hs = ni->ni_vap->iv_hwmp;
+
+	/*
+	 * Enforce PREQ interval.
+	 */
+	if (ratecheck(&hs->hs_lastpreq, &ieee80211_hwmp_preqminint) == 0)
+		return EALREADY;
+	getmicrouptime(&hs->hs_lastpreq);
+
 	/*
 	 * mesh preq action frame format
 	 *     [6] da
@@ -745,6 +749,15 @@ hwmp_send_prep(struct ieee80211_node *ni
     const uint8_t da[IEEE80211_ADDR_LEN],
     struct ieee80211_meshprep_ie *prep)
 {
+	struct ieee80211_hwmp_state *hs = ni->ni_vap->iv_hwmp;
+
+	/*
+	 * Enforce PREP interval.
+	 */
+	if (ratecheck(&hs->hs_lastprep, &ieee80211_hwmp_prepminint) == 0)
+		return EALREADY;
+	getmicrouptime(&hs->hs_lastprep);
+
 	/*
 	 * mesh prep action frame format
 	 *     [6] da
@@ -801,6 +814,15 @@ hwmp_send_perr(struct ieee80211_node *ni
     const uint8_t da[IEEE80211_ADDR_LEN],
     struct ieee80211_meshperr_ie *perr)
 {
+	struct ieee80211_hwmp_state *hs = ni->ni_vap->iv_hwmp;
+
+	/*
+	 * Enforce PERR interval.
+	 */
+	if (ratecheck(&hs->hs_lastperr, &ieee80211_hwmp_perrminint) == 0)
+		return EALREADY;
+	getmicrouptime(&hs->hs_lastperr);
+
 	/*
 	 * mesh perr action frame format
 	 *     [6] da
@@ -849,7 +871,7 @@ hwmp_recv_rann(struct ieee80211vap *vap,
 		IEEE80211_ADDR_COPY(preq.preq_targets[0].target_addr,
 		    rann->rann_addr);
 		preq.preq_targets[0].target_seq = rann->rann_seq;
-		preq.preq_lifetime = ieee80211_hwmp_roottimeout;
+		preq.preq_lifetime = timeval2msecs(ieee80211_hwmp_roottimeout);
 		preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; 
 		hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, &preq);
 	/*
@@ -905,6 +927,7 @@ ieee80211_hwmp_discover(struct ieee80211
 	if (IEEE80211_IS_MULTICAST(dest))
 		return ieee80211_find_txnode(vap, dest);
 
+
 	mtx_lock(&hs->hs_lock);
 	TAILQ_FOREACH(fi, &hs->hs_head, fi_next) {
 		if (IEEE80211_ADDR_EQ(fi->fi_dest, dest)) {
@@ -925,7 +948,7 @@ ieee80211_hwmp_discover(struct ieee80211
 		fi->fi_seq = ++hs->hs_seq;
 		fi->fi_preqid = ++hs->hs_preqid;
 		fi->fi_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
-		fi->fi_lifetime = ieee80211_hwmp_pathtimeout;
+		fi->fi_lifetime = timeval2msecs(ieee80211_hwmp_pathtimeout);
 		mtx_lock(&hs->hs_lock);
 		TAILQ_INSERT_TAIL(&hs->hs_head, fi, fi_next);
 		mtx_unlock(&hs->hs_lock);
@@ -933,6 +956,7 @@ ieee80211_hwmp_discover(struct ieee80211
 		unknowndst = 1;
 	}
 
+
 	if (sendpreq) {
 		IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest,
 		    "%s", "initiating path discovery");

Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.h	Thu Jun 11 21:37:23 2009	(r194040)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h	Thu Jun 11 21:41:51 2009	(r194041)
@@ -47,6 +47,7 @@ struct ieee80211_hwmp_fi {
 	uint32_t		fi_nhops;	/* Number of Hops */
 	uint8_t			fi_prevhop[IEEE80211_ADDR_LEN];
 	uint32_t		fi_lifetime;
+	int			fi_preqretries;
 };
 
 #ifdef _KERNEL
@@ -55,9 +56,12 @@ MALLOC_DECLARE(M_80211_HWMP);
 
 struct ieee80211_hwmp_state {
 	TAILQ_HEAD(, ieee80211_hwmp_fi)	hs_head;
-	ieee80211_hwmp_seq		hs_seq;	   /* next seq to be used */
-	ieee80211_hwmp_seq		hs_preqid; /* next PREQ ID to be used */
-	struct mtx			hs_lock;   /* lock for the fi table */
+	ieee80211_hwmp_seq	hs_seq;		/* next seq to be used */
+	ieee80211_hwmp_seq	hs_preqid;	/* next PREQ ID to be used */
+	struct timeval		hs_lastpreq;	/* last time we sent a PREQ */
+	struct timeval		hs_lastprep;	/* last time we sent a PREP */
+	struct timeval		hs_lastperr;	/* last time we sent a PERR */
+	struct mtx		hs_lock;	/* lock for the fi table */
 };
 
 void		ieee80211_hwmp_vattach(struct ieee80211vap *);


More information about the svn-src-projects mailing list