From patchwork Fri Jun 12 22:38:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexis Green X-Patchwork-Id: 6601171 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F47F9F1C1 for ; Fri, 12 Jun 2015 22:38:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A83B020662 for ; Fri, 12 Jun 2015 22:38:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76E6C203F3 for ; Fri, 12 Jun 2015 22:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751362AbbFLWiW (ORCPT ); Fri, 12 Jun 2015 18:38:22 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:34812 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbbFLWiV (ORCPT ); Fri, 12 Jun 2015 18:38:21 -0400 Received: by igbhj9 with SMTP id hj9so20909033igb.1 for ; Fri, 12 Jun 2015 15:38:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:reply-to:user-agent :mime-version:to:cc:subject:content-type:content-transfer-encoding; bh=nPKMWNUfrlcj/SKBWdHkMsL9UDLhtD0D8RjWwrigi/k=; b=bo38IwC5YCqFaAS/B80LfBVLIOr7LOyrFhykr+SFBa4mPgrh+LQmzyMQdWhT+ROh1t CNdiUv2iRqe6RYEHTPYIXav8kt2DNbDwV0hpcNX1MCKQBXMfg0mJEfiPvFEjLLsvWdbm mMXzPoQ2DMnJ1CPVjP0VqBVzS7bSu2w9kY0RTRLIuXogFqE+o2KgGFfBcua21mudyQJ4 ig4wk9l34yAvp5nTK3Cwx1Qt4jv3RrKEiOEL71JypzIO1XcqbbS11Bkh4W+peIob+t8F k/SNKL+mw9ons8C7F65I1eA8rvM+I8E4UP473Cby15QjbLE69eEkskru1m19I+q/19ub /fcw== X-Gm-Message-State: ALoCoQlpjB1MW+Y7chxMi1Sg4BYCspVWeSWWf6sI541YN8xN2+ofXJ11pAWaMQq2zb7m0mQKBE6U X-Received: by 10.50.50.210 with SMTP id e18mr7357285igo.0.1434148701197; Fri, 12 Jun 2015 15:38:21 -0700 (PDT) Received: from [10.4.0.237] ([67.137.71.162]) by mx.google.com with ESMTPSA id m193sm3383521iom.19.2015.06.12.15.38.20 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Jun 2015 15:38:20 -0700 (PDT) Message-ID: <557B5F4F.1060703@cococorp.com> Date: Fri, 12 Jun 2015 15:38:07 -0700 From: Alexis Green Reply-To: agreen@cococorp.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Johannes Berg CC: linux-wireless@vger.kernel.org, Jesse Jones Subject: [PATCH] mac80211: Check SN for deactivated mpaths Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jesse Jones 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 --- -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);