aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/sockmap.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2018-09-05 18:21:22 -0400
committerJason Gunthorpe <jgg@mellanox.com>2018-09-05 18:21:22 -0400
commit2c910cb75e1fe6de52d95c8e32caedd1629a33a5 (patch)
tree94a0eea6f8cde689d11e7583ddd0a930b8785ab4 /kernel/bpf/sockmap.c
parent627212c9d49ba2759b699450f5d8f45f73e062fa (diff)
parentb53b1c08a23eb1091982daacb2122f90a7094a77 (diff)
Merge branch 'uverbs_dev_cleanups' into rdma.git for-next
For dependencies, branch based on rdma.git 'for-rc' of https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/ Pull 'uverbs_dev_cleanups' from Leon Romanovsky: ==================== Reuse the char device code interfaces to simplify ib_uverbs_device creation and destruction. As part of this series, we are sending fix to cleanup path, which was discovered during internal review, The fix definitely can go to -rc, but it means that this series will be dependent on rdma-rc. ==================== * branch 'uverbs_dev_cleanups': RDMA/uverbs: Use device.groups to initialize device attributes RDMA/uverbs: Use cdev_device_add() instead of cdev_add() RDMA/core: Depend on device_add() to add device attributes RDMA/uverbs: Fix error cleanup path of ib_uverbs_add_one() Resolved conflict in ib_device_unregister_sysfs() Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'kernel/bpf/sockmap.c')
-rw-r--r--kernel/bpf/sockmap.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index 98e621a29e8e..cf5195c7c331 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -1427,12 +1427,15 @@ out:
1427static void smap_write_space(struct sock *sk) 1427static void smap_write_space(struct sock *sk)
1428{ 1428{
1429 struct smap_psock *psock; 1429 struct smap_psock *psock;
1430 void (*write_space)(struct sock *sk);
1430 1431
1431 rcu_read_lock(); 1432 rcu_read_lock();
1432 psock = smap_psock_sk(sk); 1433 psock = smap_psock_sk(sk);
1433 if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state))) 1434 if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state)))
1434 schedule_work(&psock->tx_work); 1435 schedule_work(&psock->tx_work);
1436 write_space = psock->save_write_space;
1435 rcu_read_unlock(); 1437 rcu_read_unlock();
1438 write_space(sk);
1436} 1439}
1437 1440
1438static void smap_stop_sock(struct smap_psock *psock, struct sock *sk) 1441static void smap_stop_sock(struct smap_psock *psock, struct sock *sk)
@@ -2140,7 +2143,9 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr)
2140 return ERR_PTR(-EPERM); 2143 return ERR_PTR(-EPERM);
2141 2144
2142 /* check sanity of attributes */ 2145 /* check sanity of attributes */
2143 if (attr->max_entries == 0 || attr->value_size != 4 || 2146 if (attr->max_entries == 0 ||
2147 attr->key_size == 0 ||
2148 attr->value_size != 4 ||
2144 attr->map_flags & ~SOCK_CREATE_FLAG_MASK) 2149 attr->map_flags & ~SOCK_CREATE_FLAG_MASK)
2145 return ERR_PTR(-EINVAL); 2150 return ERR_PTR(-EINVAL);
2146 2151
@@ -2267,8 +2272,10 @@ static struct htab_elem *alloc_sock_hash_elem(struct bpf_htab *htab,
2267 } 2272 }
2268 l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, 2273 l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
2269 htab->map.numa_node); 2274 htab->map.numa_node);
2270 if (!l_new) 2275 if (!l_new) {
2276 atomic_dec(&htab->count);
2271 return ERR_PTR(-ENOMEM); 2277 return ERR_PTR(-ENOMEM);
2278 }
2272 2279
2273 memcpy(l_new->key, key, key_size); 2280 memcpy(l_new->key, key, key_size);
2274 l_new->sk = sk; 2281 l_new->sk = sk;