]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/core: IB cache enhancements to support Infiniband security
authorDaniel Jurgens <danielj@mellanox.com>
Fri, 19 May 2017 12:48:51 +0000 (15:48 +0300)
committerPaul Moore <paul@paul-moore.com>
Tue, 23 May 2017 14:24:17 +0000 (10:24 -0400)
Cache the subnet prefix and add a function to access it. Enforcing
security requires frequent queries of the subnet prefix and the pkeys in
the pkey table.

Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Acked-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
drivers/infiniband/core/cache.c
drivers/infiniband/core/core_priv.h
include/rdma/ib_verbs.h

index b1371eb9f46cd1c052503a556daca5d424c4d28b..b9c0066b704e889eb0555497b8a96cf0847149b2 100644 (file)
@@ -911,6 +911,26 @@ int ib_get_cached_pkey(struct ib_device *device,
 }
 EXPORT_SYMBOL(ib_get_cached_pkey);
 
+int ib_get_cached_subnet_prefix(struct ib_device *device,
+                               u8                port_num,
+                               u64              *sn_pfx)
+{
+       unsigned long flags;
+       int p;
+
+       if (port_num < rdma_start_port(device) ||
+           port_num > rdma_end_port(device))
+               return -EINVAL;
+
+       p = port_num - rdma_start_port(device);
+       read_lock_irqsave(&device->cache.lock, flags);
+       *sn_pfx = device->cache.ports[p].subnet_prefix;
+       read_unlock_irqrestore(&device->cache.lock, flags);
+
+       return 0;
+}
+EXPORT_SYMBOL(ib_get_cached_subnet_prefix);
+
 int ib_find_cached_pkey(struct ib_device *device,
                        u8                port_num,
                        u16               pkey,
@@ -1108,6 +1128,8 @@ static void ib_cache_update(struct ib_device *device,
        device->cache.ports[port - rdma_start_port(device)].port_state =
                tprops->state;
 
+       device->cache.ports[port - rdma_start_port(device)].subnet_prefix =
+                                                       tprops->subnet_prefix;
        write_unlock_irq(&device->cache.lock);
 
        kfree(gid_cache);
index cb7d372e4bdf877206d8da9141d46a590395bcd9..249e3ed9036573ad175588f4b0dc33a3057d1fe0 100644 (file)
@@ -176,4 +176,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
 int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
                             struct netlink_callback *cb);
 
+int ib_get_cached_subnet_prefix(struct ib_device *device,
+                               u8                port_num,
+                               u64              *sn_pfx);
 #endif /* _CORE_PRIV_H */
index ba8314ec576844ddb7148364617a768c81acd90f..9dc4e7e0aba4e8d686a74272200352902f83a23e 100644 (file)
@@ -1891,6 +1891,7 @@ enum ib_mad_result {
 };
 
 struct ib_port_cache {
+       u64                   subnet_prefix;
        struct ib_pkey_cache  *pkey;
        struct ib_gid_table   *gid;
        u8                     lmc;