Lines Matching defs:prot
1666 const struct proto *prot = READ_ONCE(osk->sk_prot);
1673 prot->obj_size - offsetof(struct sock, sk_dontcopy_end));
1681 static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
1687 slab = prot->slab;
1693 sk_prot_clear_nulls(sk, prot->obj_size);
1695 sk = kmalloc(prot->obj_size, priority);
1701 if (!try_module_get(prot->owner))
1718 static void sk_prot_free(struct proto *prot, struct sock *sk)
1723 owner = prot->owner;
1724 slab = prot->slab;
1741 * @prot: struct proto associated with this new sock instance
1745 struct proto *prot, int kern)
1749 sk = sk_prot_alloc(prot, priority | __GFP_ZERO, family);
1756 sk->sk_prot = sk->sk_prot_creator = prot;
1889 struct proto *prot = READ_ONCE(sk->sk_prot);
1894 newsk = sk_prot_alloc(prot, priority, sk->sk_family);
1900 newsk->sk_prot_creator = prot;
2617 struct proto *prot = sk->sk_prot;
2641 if (atomic_read(&sk->sk_rmem_alloc) < sk_get_rmem0(sk, prot))
2645 int wmem0 = sk_get_wmem0(sk, prot);
2681 trace_sock_exceed_buf_limit(sk, prot, allocated, kind);
3346 void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
3348 __this_cpu_add(net->core.prot_inuse->val[prot->inuse_idx], val);
3352 int sock_prot_inuse_get(struct net *net, struct proto *prot)
3354 int cpu, idx = prot->inuse_idx;
3419 static int assign_proto_idx(struct proto *prot)
3421 prot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR);
3423 if (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) {
3428 set_bit(prot->inuse_idx, proto_inuse_idx);
3432 static void release_proto_idx(struct proto *prot)
3434 if (prot->inuse_idx != PROTO_INUSE_NR - 1)
3435 clear_bit(prot->inuse_idx, proto_inuse_idx);
3438 static inline int assign_proto_idx(struct proto *prot)
3443 static inline void release_proto_idx(struct proto *prot)
3472 static int req_prot_init(const struct proto *prot)
3474 struct request_sock_ops *rsk_prot = prot->rsk_prot;
3480 prot->name);
3486 SLAB_ACCOUNT | prot->slab_flags,
3491 prot->name);
3497 int proto_register(struct proto *prot, int alloc_slab)
3502 prot->slab = kmem_cache_create_usercopy(prot->name,
3503 prot->obj_size, 0,
3505 prot->slab_flags,
3506 prot->useroffset, prot->usersize,
3509 if (prot->slab == NULL) {
3511 prot->name);
3515 if (req_prot_init(prot))
3518 if (prot->twsk_prot != NULL) {
3519 prot->twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", prot->name);
3521 if (prot->twsk_prot->twsk_slab_name == NULL)
3524 prot->twsk_prot->twsk_slab =
3525 kmem_cache_create(prot->twsk_prot->twsk_slab_name,
3526 prot->twsk_prot->twsk_obj_size,
3529 prot->slab_flags,
3531 if (prot->twsk_prot->twsk_slab == NULL)
3537 ret = assign_proto_idx(prot);
3542 list_add(&prot->node, &proto_list);
3547 if (alloc_slab && prot->twsk_prot)
3548 tw_prot_cleanup(prot->twsk_prot);
3551 req_prot_cleanup(prot->rsk_prot);
3553 kmem_cache_destroy(prot->slab);
3554 prot->slab = NULL;
3561 void proto_unregister(struct proto *prot)
3564 release_proto_idx(prot);
3565 list_del(&prot->node);
3568 kmem_cache_destroy(prot->slab);
3569 prot->slab = NULL;
3571 req_prot_cleanup(prot->rsk_prot);
3572 tw_prot_cleanup(prot->twsk_prot);