diff options
author | Daniel Jurgens <danielj@mellanox.com> | 2017-05-19 08:48:51 -0400 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2017-05-23 10:24:17 -0400 |
commit | 883c71feaf2e810e0331cf780c738cbb09e93b58 (patch) | |
tree | 35c4bf3f56bce25fd38c2ccab50eaa08ff9607ad | |
parent | 270e8573145a26de924e2dc644596332d400445b (diff) |
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 <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>
-rw-r--r-- | drivers/infiniband/core/cache.c | 22 | ||||
-rw-r--r-- | drivers/infiniband/core/core_priv.h | 3 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 1 |
3 files changed, 26 insertions, 0 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index b1371eb9f46c..b9c0066b704e 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
@@ -911,6 +911,26 @@ int ib_get_cached_pkey(struct ib_device *device, | |||
911 | } | 911 | } |
912 | EXPORT_SYMBOL(ib_get_cached_pkey); | 912 | EXPORT_SYMBOL(ib_get_cached_pkey); |
913 | 913 | ||
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 | |||
914 | int ib_find_cached_pkey(struct ib_device *device, | 934 | int ib_find_cached_pkey(struct ib_device *device, |
915 | u8 port_num, | 935 | u8 port_num, |
916 | u16 pkey, | 936 | u16 pkey, |
@@ -1108,6 +1128,8 @@ static void ib_cache_update(struct ib_device *device, | |||
1108 | device->cache.ports[port - rdma_start_port(device)].port_state = | 1128 | device->cache.ports[port - rdma_start_port(device)].port_state = |
1109 | tprops->state; | 1129 | tprops->state; |
1110 | 1130 | ||
1131 | device->cache.ports[port - rdma_start_port(device)].subnet_prefix = | ||
1132 | tprops->subnet_prefix; | ||
1111 | write_unlock_irq(&device->cache.lock); | 1133 | write_unlock_irq(&device->cache.lock); |
1112 | 1134 | ||
1113 | kfree(gid_cache); | 1135 | kfree(gid_cache); |
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index cb7d372e4bdf..249e3ed90365 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h | |||
@@ -176,4 +176,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb, | |||
176 | int ib_nl_handle_ip_res_resp(struct sk_buff *skb, | 176 | int ib_nl_handle_ip_res_resp(struct sk_buff *skb, |
177 | struct netlink_callback *cb); | 177 | struct netlink_callback *cb); |
178 | 178 | ||
179 | int ib_get_cached_subnet_prefix(struct ib_device *device, | ||
180 | u8 port_num, | ||
181 | u64 *sn_pfx); | ||
179 | #endif /* _CORE_PRIV_H */ | 182 | #endif /* _CORE_PRIV_H */ |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index ba8314ec5768..9dc4e7e0aba4 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1891,6 +1891,7 @@ enum ib_mad_result { | |||
1891 | }; | 1891 | }; |
1892 | 1892 | ||
1893 | struct ib_port_cache { | 1893 | struct ib_port_cache { |
1894 | u64 subnet_prefix; | ||
1894 | struct ib_pkey_cache *pkey; | 1895 | struct ib_pkey_cache *pkey; |
1895 | struct ib_gid_table *gid; | 1896 | struct ib_gid_table *gid; |
1896 | u8 lmc; | 1897 | u8 lmc; |