From patchwork Mon Aug 25 14:54:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Hugne X-Patchwork-Id: 382760 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 828581400AA for ; Tue, 26 Aug 2014 00:50:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933273AbaHYOuA (ORCPT ); Mon, 25 Aug 2014 10:50:00 -0400 Received: from sessmg23.ericsson.net ([193.180.251.45]:51152 "EHLO sessmg23.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933008AbaHYOt6 (ORCPT ); Mon, 25 Aug 2014 10:49:58 -0400 X-AuditID: c1b4fb2d-f793d6d000005356-95-53fb4d1423d5 Received: from ESESSHC011.ericsson.se (Unknown_Domain [153.88.253.124]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 8C.93.21334.41D4BF35; Mon, 25 Aug 2014 16:49:56 +0200 (CEST) Received: from megatron.ki.sw.ericsson.se (147.214.199.9) by ESESSHC011.ericsson.se (153.88.183.51) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 25 Aug 2014 16:49:55 +0200 From: To: , , , CC: , Erik Hugne Subject: [PATCH net-next 1/2] tipc: refactor name table updates out of named packet receive routine Date: Mon, 25 Aug 2014 16:54:28 +0200 Message-ID: <1408978469-10584-1-git-send-email-erik.hugne@ericsson.com> X-Mailer: git-send-email 1.8.3.2 MIME-Version: 1.0 X-Originating-IP: [147.214.199.9] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnluLIzCtJLcpLzFFi42KZGfG3RlfE93ewwZPJohbHFohZbDmfZfH4 +nVmB2aP3Qs+M3l83iTnsX7LVqYA5igum5TUnMyy1CJ9uwSujNkN/xgLfklWXHoj3cDYINLF yMkhIWAiceHND0YIW0ziwr31bF2MXBxCAkcZJSau/cwK4WxnlFh2r4cJpIpNQF7i/KLbYLaI QL7E6d9PWUFsZoFgiX3r28EmCQskS7TumABWwyKgKrH7zSpmEJtXwF3i6u4rUNsUJJZ9WQsV F5Q4OfMJC8QcCYmDL16AxYUEVCTuv5zN3sXIAVSvKPFvB88ERv5ZSDpmIelYwMi0ilG0OLW4 ODfdyFgvtSgzubg4P08vL7VkEyMw5A5u+a27g3H1a8dDjAIcjEo8vAoav4KFWBPLiitzDzFK c7AoifMuOjcvWEggPbEkNTs1tSC1KL6oNCe1+BAjEwenVANjTOCzvG/5q56k1R0S+2RbYPJE zbeF8zffh4q5fOvnzt5VZrz7lDJvnM39tSVafyJ22p3fe1ZoauuPNetmTz6W+TEy4oSF3Bee l89N3E3WyRmL8fcmsM78+s+Ff9uirhbL624HZp3cbjzt6led/AkJE4xmC4XzHVDUbdBzKj0n ovO0RyHhq3CxEktxRqKhFnNRcSIABIEUthoCAAA= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Erik Hugne We need to perform the same actions when processing deferred name table updates, so this functionality is moved to a separate function. Signed-off-by: Erik Hugne Signed-off-by: Jon Maloy --- net/tipc/name_distr.c | 74 ++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index dcc15bc..0591f33 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -263,52 +263,54 @@ static void named_purge_publ(struct publication *publ) } /** + * tipc_update_nametbl - try to process a nametable update and notify + * subscribers + * + * tipc_nametbl_lock must be held. + * Returns the publication item if successful, otherwise NULL. + */ +struct publication *tipc_update_nametbl(struct distr_item *i, u32 node, + u32 dtype) +{ + struct publication *publ = NULL; + + if (dtype == PUBLICATION) { + publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower), + ntohl(i->upper), + TIPC_CLUSTER_SCOPE, node, + ntohl(i->ref), ntohl(i->key)); + if (publ) { + tipc_nodesub_subscribe(&publ->subscr, node, publ, + (net_ev_handler) + named_purge_publ); + } + } else if (dtype == WITHDRAWAL) { + publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower), + node, ntohl(i->ref), + ntohl(i->key)); + if (publ) { + tipc_nodesub_unsubscribe(&publ->subscr); + kfree(publ); + } + } else { + pr_warn("Unrecognized name table message received\n"); + } + return publ; +} + +/** * tipc_named_rcv - process name table update message sent by another node */ void tipc_named_rcv(struct sk_buff *buf) { - struct publication *publ; struct tipc_msg *msg = buf_msg(buf); struct distr_item *item = (struct distr_item *)msg_data(msg); u32 count = msg_data_sz(msg) / ITEM_SIZE; write_lock_bh(&tipc_nametbl_lock); while (count--) { - if (msg_type(msg) == PUBLICATION) { - publ = tipc_nametbl_insert_publ(ntohl(item->type), - ntohl(item->lower), - ntohl(item->upper), - TIPC_CLUSTER_SCOPE, - msg_orignode(msg), - ntohl(item->ref), - ntohl(item->key)); - if (publ) { - tipc_nodesub_subscribe(&publ->subscr, - msg_orignode(msg), - publ, - (net_ev_handler) - named_purge_publ); - } - } else if (msg_type(msg) == WITHDRAWAL) { - publ = tipc_nametbl_remove_publ(ntohl(item->type), - ntohl(item->lower), - msg_orignode(msg), - ntohl(item->ref), - ntohl(item->key)); - - if (publ) { - tipc_nodesub_unsubscribe(&publ->subscr); - kfree(publ); - } else { - pr_err("Unable to remove publication by node 0x%x\n" - " (type=%u, lower=%u, ref=%u, key=%u)\n", - msg_orignode(msg), ntohl(item->type), - ntohl(item->lower), ntohl(item->ref), - ntohl(item->key)); - } - } else { - pr_warn("Unrecognized name table message received\n"); - } + tipc_update_nametbl(item, msg_orignode(msg), + msg_type(msg)); item++; } write_unlock_bh(&tipc_nametbl_lock);