From patchwork Tue Apr 19 19:51:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jurgens X-Patchwork-Id: 8883041 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 742D4BF29F for ; Tue, 19 Apr 2016 19:53:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A948202C8 for ; Tue, 19 Apr 2016 19:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B7042024D for ; Tue, 19 Apr 2016 19:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754865AbcDSTxz (ORCPT ); Tue, 19 Apr 2016 15:53:55 -0400 Received: from [193.47.165.129] ([193.47.165.129]:39886 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754729AbcDSTxy (ORCPT ); Tue, 19 Apr 2016 15:53:54 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from danielj@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Apr 2016 22:52:04 +0300 Received: from x-vnc01.mtx.labs.mlnx (x-vnc01.mtx.labs.mlnx [10.12.150.16]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u3JJph1k011960; Tue, 19 Apr 2016 22:52:03 +0300 From: Dan Jurgens To: selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, linux-rdma@vger.kernel.org Cc: yevgenyp@mellanox.com, Daniel Jurgens Subject: [RFC PATCH v3 12/12] ib/core: Implement the Infiniband flush callback. Date: Tue, 19 Apr 2016 22:51:29 +0300 Message-Id: <1461095489-18732-13-git-send-email-danielj@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1461095489-18732-1-git-send-email-danielj@mellanox.com> References: <1461095489-18732-1-git-send-email-danielj@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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: Daniel Jurgens Register the callback at init and unregister it at cleanup. When called walk the device list and call ib_security_cache_change for each port on each device. Signed-off-by: Daniel Jurgens Reviewed-by: Eli Cohen Reviewed-by: Leon Romanovsky --- v2: Added patch to series. v3: 1. Removed unrelated formatting changes in core_priv.h and security.c. --- drivers/infiniband/core/device.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index f39a2a1..3647098 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -335,6 +335,29 @@ static int setup_port_pkey_list(struct ib_device *device) return 0; } +static void ib_security_flush(void) +{ + struct ib_device *dev; + + down_read(&lists_rwsem); + list_for_each_entry(dev, &device_list, core_list) { + int i; + + for (i = rdma_start_port(dev); i <= rdma_end_port(dev); i++) { + u64 sp; + int ret = ib_get_cached_subnet_prefix(dev, + i, + &sp); + + WARN_ONCE(ret, + "ib_get_cached_subnet_prefix err: %d, this should never happen here\n", + ret); + ib_security_cache_change(dev, i, sp); + } + } + up_read(&lists_rwsem); +} + /** * ib_register_device - Register an IB device with IB core * @device:Device to register @@ -1016,6 +1039,8 @@ static int __init ib_core_init(void) goto err_sysfs; } + security_register_ib_flush_callback(&ib_security_flush); + ib_cache_setup(); return 0; @@ -1031,6 +1056,7 @@ err: static void __exit ib_core_cleanup(void) { + security_unregister_ib_flush_callback(); ib_cache_cleanup(); ibnl_cleanup(); class_unregister(&ib_class);