Lines Matching refs:psock
131 static void sock_map_add_link(struct sk_psock *psock, in sock_map_add_link() argument
137 spin_lock_bh(&psock->link_lock); in sock_map_add_link()
138 list_add_tail(&link->list, &psock->link); in sock_map_add_link()
139 spin_unlock_bh(&psock->link_lock); in sock_map_add_link()
143 struct sk_psock *psock, void *link_raw) in sock_map_del_link() argument
148 spin_lock_bh(&psock->link_lock); in sock_map_del_link()
149 list_for_each_entry_safe(link, tmp, &psock->link, list) { in sock_map_del_link()
154 if (psock->saved_data_ready && progs->stream_parser) in sock_map_del_link()
156 if (psock->saved_data_ready && progs->stream_verdict) in sock_map_del_link()
158 if (psock->saved_data_ready && progs->skb_verdict) in sock_map_del_link()
164 spin_unlock_bh(&psock->link_lock); in sock_map_del_link()
168 sk_psock_stop_strp(sk, psock); in sock_map_del_link()
170 sk_psock_stop_verdict(sk, psock); in sock_map_del_link()
172 if (psock->psock_update_sk_prot) in sock_map_del_link()
173 psock->psock_update_sk_prot(sk, psock, false); in sock_map_del_link()
180 struct sk_psock *psock = sk_psock(sk); in sock_map_unref() local
182 if (likely(psock)) { in sock_map_unref()
183 sock_map_del_link(sk, psock, link_raw); in sock_map_unref()
184 sk_psock_put(sk, psock); in sock_map_unref()
188 static int sock_map_init_proto(struct sock *sk, struct sk_psock *psock) in sock_map_init_proto() argument
192 psock->psock_update_sk_prot = sk->sk_prot->psock_update_sk_prot; in sock_map_init_proto()
193 return sk->sk_prot->psock_update_sk_prot(sk, psock, false); in sock_map_init_proto()
198 struct sk_psock *psock; in sock_map_psock_get_checked() local
201 psock = sk_psock(sk); in sock_map_psock_get_checked()
202 if (psock) { in sock_map_psock_get_checked()
204 psock = ERR_PTR(-EBUSY); in sock_map_psock_get_checked()
208 if (!refcount_inc_not_zero(&psock->refcnt)) in sock_map_psock_get_checked()
209 psock = ERR_PTR(-EBUSY); in sock_map_psock_get_checked()
213 return psock; in sock_map_psock_get_checked()
223 struct sk_psock *psock; in sock_map_link() local
260 psock = sock_map_psock_get_checked(sk); in sock_map_link()
261 if (IS_ERR(psock)) { in sock_map_link()
262 ret = PTR_ERR(psock); in sock_map_link()
266 if (psock) { in sock_map_link()
267 if ((msg_parser && READ_ONCE(psock->progs.msg_parser)) || in sock_map_link()
268 (stream_parser && READ_ONCE(psock->progs.stream_parser)) || in sock_map_link()
269 (skb_verdict && READ_ONCE(psock->progs.skb_verdict)) || in sock_map_link()
270 (skb_verdict && READ_ONCE(psock->progs.stream_verdict)) || in sock_map_link()
271 (stream_verdict && READ_ONCE(psock->progs.skb_verdict)) || in sock_map_link()
272 (stream_verdict && READ_ONCE(psock->progs.stream_verdict))) { in sock_map_link()
273 sk_psock_put(sk, psock); in sock_map_link()
278 psock = sk_psock_init(sk, map->numa_node); in sock_map_link()
279 if (IS_ERR(psock)) { in sock_map_link()
280 ret = PTR_ERR(psock); in sock_map_link()
286 psock_set_prog(&psock->progs.msg_parser, msg_parser); in sock_map_link()
288 psock_set_prog(&psock->progs.stream_parser, stream_parser); in sock_map_link()
290 psock_set_prog(&psock->progs.stream_verdict, stream_verdict); in sock_map_link()
292 psock_set_prog(&psock->progs.skb_verdict, skb_verdict); in sock_map_link()
297 ret = sock_map_init_proto(sk, psock); in sock_map_link()
299 sk_psock_put(sk, psock); in sock_map_link()
304 if (stream_parser && stream_verdict && !psock->saved_data_ready) { in sock_map_link()
305 ret = sk_psock_init_strp(sk, psock); in sock_map_link()
308 sk_psock_put(sk, psock); in sock_map_link()
311 sk_psock_start_strp(sk, psock); in sock_map_link()
312 } else if (!stream_parser && stream_verdict && !psock->saved_data_ready) { in sock_map_link()
313 sk_psock_start_verdict(sk,psock); in sock_map_link()
314 } else if (!stream_verdict && skb_verdict && !psock->saved_data_ready) { in sock_map_link()
315 sk_psock_start_verdict(sk, psock); in sock_map_link()
472 struct sk_psock *psock; in sock_map_update_common() local
490 psock = sk_psock(sk); in sock_map_update_common()
491 WARN_ON_ONCE(!psock); in sock_map_update_common()
503 sock_map_add_link(psock, link, map, &stab->sks[idx]); in sock_map_update_common()
511 if (psock) in sock_map_update_common()
512 sk_psock_put(sk, psock); in sock_map_update_common()
993 struct sk_psock *psock; in sock_hash_update_common() local
1008 psock = sk_psock(sk); in sock_hash_update_common()
1009 WARN_ON_ONCE(!psock); in sock_hash_update_common()
1030 sock_map_add_link(psock, link, map, elem_new); in sock_hash_update_common()
1044 sk_psock_put(sk, psock); in sock_hash_update_common()
1612 static void sock_map_remove_links(struct sock *sk, struct sk_psock *psock) in sock_map_remove_links() argument
1616 while ((link = sk_psock_link_pop(psock))) { in sock_map_remove_links()
1625 struct sk_psock *psock; in sock_map_unhash() local
1628 psock = sk_psock(sk); in sock_map_unhash()
1629 if (unlikely(!psock)) { in sock_map_unhash()
1633 saved_unhash = psock->saved_unhash; in sock_map_unhash()
1634 sock_map_remove_links(sk, psock); in sock_map_unhash()
1647 struct sk_psock *psock; in sock_map_destroy() local
1650 psock = sk_psock_get(sk); in sock_map_destroy()
1651 if (unlikely(!psock)) { in sock_map_destroy()
1655 saved_destroy = psock->saved_destroy; in sock_map_destroy()
1656 sock_map_remove_links(sk, psock); in sock_map_destroy()
1658 sk_psock_stop(psock); in sock_map_destroy()
1659 sk_psock_put(sk, psock); in sock_map_destroy()
1671 struct sk_psock *psock; in sock_map_close() local
1675 psock = sk_psock(sk); in sock_map_close()
1676 if (likely(psock)) { in sock_map_close()
1677 saved_close = psock->saved_close; in sock_map_close()
1678 sock_map_remove_links(sk, psock); in sock_map_close()
1679 psock = sk_psock_get(sk); in sock_map_close()
1680 if (unlikely(!psock)) in sock_map_close()
1683 sk_psock_stop(psock); in sock_map_close()
1685 cancel_delayed_work_sync(&psock->work); in sock_map_close()
1686 sk_psock_put(sk, psock); in sock_map_close()