/** * handshake_genl_notify - Notify handlers that a request is waiting * @net: target network namespace * @proto: handshake protocol * @flags: memory allocation control flags * * Returns zero on success or a negative errno if notification failed.
*/ int handshake_genl_notify(struct net *net, conststruct handshake_proto *proto,
gfp_t flags)
{ struct sk_buff *msg; void *hdr;
/* Disable notifications during unit testing */ if (!test_bit(HANDSHAKE_F_PROTO_NOTIFY, &proto->hp_flags)) return 0;
if (!genl_has_listeners(&handshake_nl_family, net,
proto->hp_handler_class)) return -ESRCH;
msg = genlmsg_new(GENLMSG_DEFAULT_SIZE, flags); if (!msg) return -ENOMEM;
/* * Arbitrary limit to prevent handshakes that do not make * progress from clogging up the system. The cap scales up * with the amount of physical memory on the system.
*/
si_meminfo(&si);
tmp = si.totalram / (25 * si.mem_unit);
hn->hn_pending_max = clamp(tmp, 3UL, 50UL);
/* * Drain the net's pending list. Requests that have been * accepted and are in progress will be destroyed when * the socket is closed.
*/
spin_lock(&hn->hn_lock);
set_bit(HANDSHAKE_F_NET_DRAINING, &hn->hn_flags);
list_splice_init(&requests, &hn->hn_requests);
spin_unlock(&hn->hn_lock);
while (!list_empty(&requests)) {
req = list_first_entry(&requests, struct handshake_req, hr_list);
list_del(&req->hr_list);
/* * Requests on this list have not yet been * accepted, so they do not have an fd to put.
*/
/** * handshake_pernet - Get the handshake private per-net structure * @net: network namespace * * Returns a pointer to the net's private per-net structure for the * handshake module, or NULL if handshake_init() failed.
*/ struct handshake_net *handshake_pernet(struct net *net)
{ return handshake_net_id ?
net_generic(net, handshake_net_id) : NULL;
}
EXPORT_SYMBOL_IF_KUNIT(handshake_pernet);
staticint __init handshake_init(void)
{ int ret;
ret = handshake_req_hash_init(); if (ret) {
pr_warn("handshake: hash initialization failed (%d)\n", ret); return ret;
}
ret = genl_register_family(&handshake_nl_family); if (ret) {
pr_warn("handshake: netlink registration failed (%d)\n", ret);
handshake_req_hash_destroy(); return ret;
}
/* * ORDER: register_pernet_subsys must be done last. * * If initialization does not make it past pernet_subsys * registration, then handshake_net_id will remain 0. That * shunts the handshake consumer API to return ENOTSUPP * to prevent it from dereferencing something that hasn't * been allocated.
*/
ret = register_pernet_subsys(&handshake_genl_net_ops); if (ret) {
pr_warn("handshake: pernet registration failed (%d)\n", ret);
genl_unregister_family(&handshake_nl_family);
handshake_req_hash_destroy();
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.31Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.