From patchwork Mon Feb 29 01:03:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 8448241 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 41AF19F659 for ; Mon, 29 Feb 2016 01:04:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C00D20272 for ; Mon, 29 Feb 2016 01:04:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C62E20279 for ; Mon, 29 Feb 2016 01:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752497AbcB2BEJ (ORCPT ); Sun, 28 Feb 2016 20:04:09 -0500 Received: from mail-qg0-f65.google.com ([209.85.192.65]:34535 "EHLO mail-qg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbcB2BEI (ORCPT ); Sun, 28 Feb 2016 20:04:08 -0500 Received: by mail-qg0-f65.google.com with SMTP id e61so9657236qgf.1 for ; Sun, 28 Feb 2016 17:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bobcopeland-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oPM7I/eM4q9LMK9iM+GKrsq95Gs1We9ygwV334jaXNY=; b=V3ceFkHgXWn17WmahkzjImMAmJvf0jHOJt77orMZFIN/l/OTsVC3S0prdNHmDyujt3 qIF90Qlq/2eCGieHdbfuehWNVN1XwDP5wLEvNnb1W+xaq578mFlM1eMgskc0BDPBCwWG IPR98cCH0ye0DhBrSHh90knaJt2ecyQ8iBN4kkVyLJO01zSjY9mBhdWdhMQMaqfV/wxm PzmCbZ2rGfft0Pl7yMG4TJ6JHGHvWw/XwKsk04HVMa+B/0bPdXJbY0fZgNBHquJfBSnj ls4AX6qiYovvjVEqclhKgboG3XSVYFKETDIqr+nNwqqL0dynPk/jC8onYGwYuk8FY5Yb 3gmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oPM7I/eM4q9LMK9iM+GKrsq95Gs1We9ygwV334jaXNY=; b=UPIhxzSxa5HsSubju23SROMoxBIyg9V1P3Z9E6aqZMHpmLH05oq2GHlNtHiN1EzSGe eTICt1VW70pYlnYXR6BkD66pNzmyIhCSPcSGtcIYUtKgraqjbsQg1Tpf80X9788Nx48R PyLV8YJfxDwQJyN4R7qmyQfBaZcuCKgVTAsm099w+U8MWOiqYSGGmFbstxTSKFqJ5RTj gxBH4lUwS2pMJIGOCsqWd2Rtt7+T2ugusRVGCRrGZ50dAPXsgNoLYSjHiobamyahFiew y8pDMY9Yx9ez0xK41t8EAqPDF2ZrXQiSuymNW95PCY5auNvoOWlU/fzvr22khaBh4/kT HEFQ== X-Gm-Message-State: AD7BkJIVPbnI5lhGV7NGHdwwDRP8WmTWTKXWlmo5ypOQr4I4WTit2q5nKisXe2KYdh7Evg== X-Received: by 10.140.102.14 with SMTP id v14mr15798188qge.48.1456707847040; Sun, 28 Feb 2016 17:04:07 -0800 (PST) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id a77sm9979400qge.7.2016.02.28.17.04.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Feb 2016 17:04:06 -0800 (PST) Received: from glass.lan ([192.168.1.51] helo=glass) by hash with esmtp (Exim 4.84) (envelope-from ) id 1aaCFj-0005qH-HD; Sun, 28 Feb 2016 20:03:59 -0500 Received: from bob by glass with local (Exim 4.86) (envelope-from ) id 1aaCFp-00054s-3P; Sun, 28 Feb 2016 20:04:05 -0500 From: Bob Copeland To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Bob Copeland Subject: [PATCH 3/4] mesh: factor out common mesh path allocation code Date: Sun, 28 Feb 2016 20:03:58 -0500 Message-Id: <1456707839-19469-3-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1456707839-19469-1-git-send-email-me@bobcopeland.com> References: <1456707839-19469-1-git-send-email-me@bobcopeland.com> 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Remove duplicate code to allocate and initialize a mesh path or mesh proxy path. Signed-off-by: Bob Copeland --- net/mac80211/mesh_pathtbl.c | 51 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index fc3cc350df8c..4794240e8f94 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -501,6 +501,31 @@ int mesh_gate_num(struct ieee80211_sub_if_data *sdata) return sdata->u.mesh.num_gates; } +static +struct mesh_path *mesh_path_new(struct ieee80211_sub_if_data *sdata, + const u8 *dst, gfp_t gfp_flags) +{ + struct mesh_path *new_mpath; + + new_mpath = kzalloc(sizeof(struct mesh_path), gfp_flags); + if (!new_mpath) + return NULL; + + memcpy(new_mpath->dst, dst, ETH_ALEN); + eth_broadcast_addr(new_mpath->rann_snd_addr); + new_mpath->is_root = false; + new_mpath->sdata = sdata; + new_mpath->flags = 0; + skb_queue_head_init(&new_mpath->frame_queue); + new_mpath->timer.data = (unsigned long) new_mpath; + new_mpath->timer.function = mesh_path_timer; + new_mpath->exp_time = jiffies; + spin_lock_init(&new_mpath->state_lock); + init_timer(&new_mpath->timer); + + return new_mpath; +} + /** * mesh_path_add - allocate and add a new path to the mesh path table * @dst: destination address of the path (ETH_ALEN length) @@ -548,7 +573,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, } err = -ENOMEM; - new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC); + new_mpath = mesh_path_new(sdata, dst, GFP_ATOMIC); if (!new_mpath) goto err_path_alloc; @@ -556,19 +581,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, if (!new_node) goto err_node_alloc; - memcpy(new_mpath->dst, dst, ETH_ALEN); - eth_broadcast_addr(new_mpath->rann_snd_addr); - new_mpath->is_root = false; - new_mpath->sdata = sdata; - new_mpath->flags = 0; - skb_queue_head_init(&new_mpath->frame_queue); new_node->mpath = new_mpath; - new_mpath->timer.data = (unsigned long) new_mpath; - new_mpath->timer.function = mesh_path_timer; - new_mpath->exp_time = jiffies; - spin_lock_init(&new_mpath->state_lock); - init_timer(&new_mpath->timer); - hlist_add_head_rcu(&new_node->list, bucket); if (atomic_inc_return(&tbl->entries) >= MEAN_CHAIN_LEN * (tbl->hash_mask + 1)) @@ -664,7 +677,7 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata, return -ENOTSUPP; err = -ENOMEM; - new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC); + new_mpath = mesh_path_new(sdata, dst, GFP_ATOMIC); if (!new_mpath) goto err_path_alloc; @@ -672,17 +685,9 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata, if (!new_node) goto err_node_alloc; - read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock); - memcpy(new_mpath->dst, dst, ETH_ALEN); memcpy(new_mpath->mpp, mpp, ETH_ALEN); - new_mpath->sdata = sdata; - new_mpath->flags = 0; - skb_queue_head_init(&new_mpath->frame_queue); new_node->mpath = new_mpath; - init_timer(&new_mpath->timer); - new_mpath->exp_time = jiffies; - spin_lock_init(&new_mpath->state_lock); - + read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock); tbl = resize_dereference_mpp_paths(sdata); hash_idx = mesh_table_hash(dst, tbl);