From patchwork Mon Feb 11 21:07:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Pedersen X-Patchwork-Id: 2126051 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 93492DF2A1 for ; Mon, 11 Feb 2013 21:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932512Ab3BKVIt (ORCPT ); Mon, 11 Feb 2013 16:08:49 -0500 Received: from mail-da0-f42.google.com ([209.85.210.42]:45712 "EHLO mail-da0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932078Ab3BKVIs (ORCPT ); Mon, 11 Feb 2013 16:08:48 -0500 Received: by mail-da0-f42.google.com with SMTP id z17so2906796dal.1 for ; Mon, 11 Feb 2013 13:08:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=RPHCFX08BCU5Ld0HAQMiCrqvSf0QO3B/mQ8Syhp0Ry4=; b=Ahn8U5BlxagWqbevo0G9cqprn/2MAyZpMy20th70agadGkfTXneOXuwlRQEhgepArx PHuPIq6mRGfEMINWv7d7I9BijZUrffLxBS6+jR/0rLpN7/tWRQ/yp8QO+BudxPFogpw7 I/8jsklnwMuSqwOnVejN2qMPy40SmGkJFw01FwV4Idy8FRQ2oY4oBzOtWQ0nBD/kM1ok uTQIFKVIXCjYGtEp3k0pbTIjQTjQ0y9XElqizdWfpTSynnrekeVLVPCpypdu7/E+gnqZ b1iK6oSdSaaarnF5KPqg3vCVyoRYilvU/W7+ugZMYpugyjmqc5TQ/vkDM4hIgfX512m6 k1rg== X-Received: by 10.66.82.103 with SMTP id h7mr44741052pay.6.1360616927635; Mon, 11 Feb 2013 13:08:47 -0800 (PST) Received: from cable.lan (70-35-43-50.static.wiline.com. [70.35.43.50]) by mx.google.com with ESMTPS id k7sm55887935paz.13.2013.02.11.13.08.45 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Feb 2013 13:08:46 -0800 (PST) From: Thomas Pedersen To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, devel@lists.open80211s.org, Thomas Pedersen Subject: [PATCH 3/3] mac80211: generate mesh probe responses Date: Mon, 11 Feb 2013 13:07:23 -0800 Message-Id: <1360616843-24618-3-git-send-email-thomas@cozybit.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360616843-24618-1-git-send-email-thomas@cozybit.com> References: <1360616843-24618-1-git-send-email-thomas@cozybit.com> X-Gm-Message-State: ALoCoQk1xG1Q+V8C29VOP9nN5S9Us7ThgLNtClQwGQSWZr10PojkcsIpC5cQF9DhWELVbgDoynrD Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Mesh interfaces will now respond to any broadcast (or matching directed mesh) probe requests with a probe response. Signed-off-by: Thomas Pedersen --- net/mac80211/mesh.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/rx.c | 5 ++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index ffbe1d5..0bb7754 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -862,6 +862,66 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) sdata->u.mesh.timers_running = 0; } +static void +ieee80211_mesh_rx_probe_req(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; + struct sk_buff *presp; + struct beacon_data *bcn; + struct ieee80211_mgmt *hdr; + struct ieee802_11_elems elems; + size_t baselen; + u8 *pos, *end; + + end = ((u8 *) mgmt) + len; + pos = mgmt->u.probe_req.variable; + baselen = (u8 *) pos - (u8 *) mgmt; + if (baselen > len) + return; + + ieee802_11_parse_elems(pos, len - baselen, &elems); + + /* 802.11-2012 10.1.4.3.2 */ + if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) && + !is_broadcast_ether_addr(mgmt->da)) || + elems.ssid_len != 0) + return; + + if (elems.mesh_id_len != 0 && + (elems.mesh_id_len != ifmsh->mesh_id_len || + memcmp(elems.mesh_id, ifmsh->mesh_id, ifmsh->mesh_id_len))) { + mpl_dbg(sdata, "ignoring probe request for different MBSS\n"); + return; + } + + rcu_read_lock(); + bcn = rcu_dereference(ifmsh->beacon); + + if (!bcn) + goto out; + + presp = dev_alloc_skb(local->tx_headroom + + bcn->head_len + bcn->tail_len); + if (WARN_ON(!presp)) + goto out; + + skb_reserve(presp, local->tx_headroom); + memcpy(skb_put(presp, bcn->head_len), bcn->head, bcn->head_len); + memcpy(skb_put(presp, bcn->tail_len), bcn->tail, bcn->tail_len); + hdr = (struct ieee80211_mgmt *) presp->data; + hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_PROBE_RESP); + memcpy(hdr->da, mgmt->sa, ETH_ALEN); + mpl_dbg(sdata, "sending probe resp. to %pM\n", hdr->da); + IEEE80211_SKB_CB(presp)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; + ieee80211_tx_skb(sdata, presp); +out: + rcu_read_unlock(); + return; +} + static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, u16 stype, struct ieee80211_mgmt *mgmt, @@ -951,6 +1011,9 @@ void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, ieee80211_mesh_rx_bcn_presp(sdata, stype, mgmt, skb->len, rx_status); break; + case IEEE80211_STYPE_PROBE_REQ: + ieee80211_mesh_rx_probe_req(sdata, mgmt, skb->len); + break; case IEEE80211_STYPE_ACTION: ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status); break; diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index b5f1bba..34aa975 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2692,8 +2692,9 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) return RX_DROP_MONITOR; break; case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): - /* process only for ibss */ - if (sdata->vif.type != NL80211_IFTYPE_ADHOC) + /* process only for ibss and mesh */ + if (sdata->vif.type != NL80211_IFTYPE_ADHOC && + sdata->vif.type != NL80211_IFTYPE_MESH_POINT) return RX_DROP_MONITOR; break; default: