All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mac80211: Check SN for deactivated mpaths
@ 2015-06-12 22:38 Alexis Green
  2015-06-17  9:00 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Alexis Green @ 2015-06-12 22:38 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Jesse Jones

From: Jesse Jones <jjones@cococorp.com>

When processing a PREQ or PREP it's critical to use the incoming SN. If
that is improperly done routing loops and other types of badness can
happen. But the code was always processing path messages for deactivated
paths. This path fixes that so that if we have a valid SN then we use it
to verify that it is a message we can accept. For reference the relevant
section of the standard is 13.10.8.4 which doesn't address the deactivated
path case at all.

I also included a special case for when our peer reboots or restarts
networking. This is an important case because without it there can be a
very long delay before we accept path messages from that peer. It's also a
simple case and intimately associated with processing messages for
deactivated paths so I used one patch instead of two.

Signed-off-by: Alexis Green <agreen@cococorp.com>

---

diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 45485f3..3c5f76a 100755
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -79,6 +79,12 @@ static inline u16 u16_field_get(const u8 *preq_elem, int offset, bool ae)
 #define MSEC_TO_TU(x) (x*1000/1024)
 #define SN_GT(x, y) ((s32)(y - x) < 0)
 #define SN_LT(x, y) ((s32)(x - y) < 0)
+#define MAX_SANE_SN_DELTA 32
+
+static inline u32 SN_DELTA(u32 x, u32 y)
+{
+	return x >= y ? x - y : y - x;
+}
 
 #define net_traversal_jiffies(s) \
 	msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime)
@@ -441,6 +447,26 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
 					process = false;
 					fresh_info = false;
 				}
+			} else if (!(mpath->flags & MESH_PATH_ACTIVE)) {
+				bool have_sn, newer_sn, bounced;
+
+				have_sn = mpath->flags & MESH_PATH_SN_VALID;
+				newer_sn = have_sn && SN_GT(orig_sn, mpath->sn);
+				bounced = have_sn &&
+					(SN_DELTA(orig_sn, mpath->sn) >
+					MAX_SANE_SN_DELTA);
+
+				if (!have_sn || newer_sn) {
+					/* if SN is newer than what we had
+					 * then we can take it */;
+				} else if (bounced) {
+					/* if SN is way different than what
+					 * we had then assume the other side
+					 * rebooted or restarted */;
+				} else {
+					process = false;
+					fresh_info = false;
+				}
 			}
 		} else {
 			mpath = mesh_path_add(sdata, orig_addr);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mac80211: Check SN for deactivated mpaths
  2015-06-12 22:38 [PATCH] mac80211: Check SN for deactivated mpaths Alexis Green
@ 2015-06-17  9:00 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2015-06-17  9:00 UTC (permalink / raw)
  To: agreen; +Cc: linux-wireless, Jesse Jones

On Fri, 2015-06-12 at 15:38 -0700, Alexis Green wrote:
> From: Jesse Jones <jjones@cococorp.com>
> 
> When processing a PREQ or PREP it's critical to use the incoming SN. If
> that is improperly done routing loops and other types of badness can
> happen. But the code was always processing path messages for deactivated
> paths. This path fixes that so that if we have a valid SN then we use it
> to verify that it is a message we can accept. For reference the relevant
> section of the standard is 13.10.8.4 which doesn't address the deactivated
> path case at all.
> 
> I also included a special case for when our peer reboots or restarts
> networking. This is an important case because without it there can be a
> very long delay before we accept path messages from that peer. It's also a
> simple case and intimately associated with processing messages for
> deactivated paths so I used one patch instead of two.

Applied.

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-17  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 22:38 [PATCH] mac80211: Check SN for deactivated mpaths Alexis Green
2015-06-17  9:00 ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.