Lines Matching +full:use +full:- +full:handshake
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Generic netlink handshake service
23 #include <uapi/linux/handshake.h>
24 #include "handshake.h"
27 #include <trace/events/handshake.h>
30 * handshake_genl_notify - Notify handlers that a request is waiting
32 * @proto: handshake protocol
44 if (!test_bit(HANDSHAKE_F_PROTO_NOTIFY, &proto->hp_flags)) in handshake_genl_notify()
48 proto->hp_handler_class)) in handshake_genl_notify()
49 return -ESRCH; in handshake_genl_notify()
53 return -ENOMEM; in handshake_genl_notify()
61 proto->hp_handler_class) < 0) { in handshake_genl_notify()
68 0, proto->hp_handler_class, flags); in handshake_genl_notify()
72 return -EMSGSIZE; in handshake_genl_notify()
76 * handshake_genl_put - Create a generic netlink message header
80 * Returns a ready-to-use header, or NULL.
85 return genlmsg_put(msg, info->snd_portid, info->snd_seq, in handshake_genl_put()
86 &handshake_nl_family, 0, info->genlhdr->cmd); in handshake_genl_put()
92 struct net *net = sock_net(skb->sk); in handshake_nl_accept_doit()
98 err = -EOPNOTSUPP; in handshake_nl_accept_doit()
102 err = -EINVAL; in handshake_nl_accept_doit()
105 class = nla_get_u32(info->attrs[HANDSHAKE_A_ACCEPT_HANDLER_CLASS]); in handshake_nl_accept_doit()
107 err = -EAGAIN; in handshake_nl_accept_doit()
112 sock = req->hr_sk->sk_socket; in handshake_nl_accept_doit()
119 err = req->hr_proto->hp_accept(req, info, fd); in handshake_nl_accept_doit()
125 fd_install(fd, get_file(sock->file)); in handshake_nl_accept_doit()
127 trace_handshake_cmd_accept(net, req, req->hr_sk, fd); in handshake_nl_accept_doit()
131 handshake_complete(req, -EIO, NULL); in handshake_nl_accept_doit()
139 struct net *net = sock_net(skb->sk); in handshake_nl_done_doit()
145 return -EINVAL; in handshake_nl_done_doit()
146 fd = nla_get_s32(info->attrs[HANDSHAKE_A_DONE_SOCKFD]); in handshake_nl_done_doit()
152 req = handshake_req_hash_lookup(sock->sk); in handshake_nl_done_doit()
154 err = -EBUSY; in handshake_nl_done_doit()
155 trace_handshake_cmd_done_err(net, req, sock->sk, err); in handshake_nl_done_doit()
160 trace_handshake_cmd_done(net, req, sock->sk, fd); in handshake_nl_done_doit()
162 status = -EIO; in handshake_nl_done_doit()
163 if (info->attrs[HANDSHAKE_A_DONE_STATUS]) in handshake_nl_done_doit()
164 status = nla_get_u32(info->attrs[HANDSHAKE_A_DONE_STATUS]); in handshake_nl_done_doit()
186 hn->hn_pending_max = clamp(tmp, 3UL, 50UL); in handshake_net_init()
188 spin_lock_init(&hn->hn_lock); in handshake_net_init()
189 hn->hn_pending = 0; in handshake_net_init()
190 hn->hn_flags = 0; in handshake_net_init()
191 INIT_LIST_HEAD(&hn->hn_requests); in handshake_net_init()
206 spin_lock(&hn->hn_lock); in handshake_net_exit()
207 set_bit(HANDSHAKE_F_NET_DRAINING, &hn->hn_flags); in handshake_net_exit()
208 list_splice_init(&requests, &hn->hn_requests); in handshake_net_exit()
209 spin_unlock(&hn->hn_lock); in handshake_net_exit()
213 list_del(&req->hr_list); in handshake_net_exit()
220 handshake_complete(req, -ETIMEDOUT, NULL); in handshake_net_exit()
232 * handshake_pernet - Get the handshake private per-net structure
235 * Returns a pointer to the net's private per-net structure for the
236 * handshake module, or NULL if handshake_init() failed.
251 pr_warn("handshake: hash initialization failed (%d)\n", ret); in handshake_init()
257 pr_warn("handshake: netlink registration failed (%d)\n", ret); in handshake_init()
267 * shunts the handshake consumer API to return ENOTSUPP in handshake_init()
273 pr_warn("handshake: pernet registration failed (%d)\n", ret); in handshake_init()