Skip to content

Commit 883c71f

Browse files
Daniel Jurgenspcmoore
authored andcommitted
IB/core: IB cache enhancements to support Infiniband security
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 <[email protected]> Reviewed-by: Eli Cohen <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Reviewed-by: James Morris <[email protected]> Acked-by: Doug Ledford <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 270e857 commit 883c71f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

drivers/infiniband/core/cache.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,26 @@ int ib_get_cached_pkey(struct ib_device *device,
911911
}
912912
EXPORT_SYMBOL(ib_get_cached_pkey);
913913

914+
int ib_get_cached_subnet_prefix(struct ib_device *device,
915+
u8 port_num,
916+
u64 *sn_pfx)
917+
{
918+
unsigned long flags;
919+
int p;
920+
921+
if (port_num < rdma_start_port(device) ||
922+
port_num > rdma_end_port(device))
923+
return -EINVAL;
924+
925+
p = port_num - rdma_start_port(device);
926+
read_lock_irqsave(&device->cache.lock, flags);
927+
*sn_pfx = device->cache.ports[p].subnet_prefix;
928+
read_unlock_irqrestore(&device->cache.lock, flags);
929+
930+
return 0;
931+
}
932+
EXPORT_SYMBOL(ib_get_cached_subnet_prefix);
933+
914934
int ib_find_cached_pkey(struct ib_device *device,
915935
u8 port_num,
916936
u16 pkey,
@@ -1108,6 +1128,8 @@ static void ib_cache_update(struct ib_device *device,
11081128
device->cache.ports[port - rdma_start_port(device)].port_state =
11091129
tprops->state;
11101130

1131+
device->cache.ports[port - rdma_start_port(device)].subnet_prefix =
1132+
tprops->subnet_prefix;
11111133
write_unlock_irq(&device->cache.lock);
11121134

11131135
kfree(gid_cache);

drivers/infiniband/core/core_priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
176176
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
177177
struct netlink_callback *cb);
178178

179+
int ib_get_cached_subnet_prefix(struct ib_device *device,
180+
u8 port_num,
181+
u64 *sn_pfx);
179182
#endif /* _CORE_PRIV_H */

include/rdma/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,7 @@ enum ib_mad_result {
18911891
};
18921892

18931893
struct ib_port_cache {
1894+
u64 subnet_prefix;
18941895
struct ib_pkey_cache *pkey;
18951896
struct ib_gid_table *gid;
18961897
u8 lmc;

0 commit comments

Comments
 (0)