Lines Matching refs:ep

57 static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,  in sctp_endpoint_init()  argument
67 ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); in sctp_endpoint_init()
68 if (!ep->digest) in sctp_endpoint_init()
71 ep->auth_enable = net->sctp.auth_enable; in sctp_endpoint_init()
72 if (ep->auth_enable) { in sctp_endpoint_init()
114 ep->base.type = SCTP_EP_TYPE_SOCKET; in sctp_endpoint_init()
117 atomic_set(&ep->base.refcnt, 1); in sctp_endpoint_init()
118 ep->base.dead = false; in sctp_endpoint_init()
121 sctp_inq_init(&ep->base.inqueue); in sctp_endpoint_init()
124 sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv); in sctp_endpoint_init()
127 sctp_bind_addr_init(&ep->base.bind_addr, 0); in sctp_endpoint_init()
130 ep->base.sk = sk; in sctp_endpoint_init()
131 sock_hold(ep->base.sk); in sctp_endpoint_init()
134 INIT_LIST_HEAD(&ep->asocs); in sctp_endpoint_init()
137 ep->sndbuf_policy = net->sctp.sndbuf_policy; in sctp_endpoint_init()
144 ep->rcvbuf_policy = net->sctp.rcvbuf_policy; in sctp_endpoint_init()
147 get_random_bytes(ep->secret_key, sizeof(ep->secret_key)); in sctp_endpoint_init()
150 INIT_LIST_HEAD(&ep->endpoint_shared_keys); in sctp_endpoint_init()
155 list_add(&null_key->key_list, &ep->endpoint_shared_keys); in sctp_endpoint_init()
158 err = sctp_auth_init_hmacs(ep, gfp); in sctp_endpoint_init()
165 ep->auth_hmacs_list = auth_hmacs; in sctp_endpoint_init()
166 ep->auth_chunk_list = auth_chunks; in sctp_endpoint_init()
168 return ep; in sctp_endpoint_init()
171 sctp_auth_destroy_keys(&ep->endpoint_shared_keys); in sctp_endpoint_init()
176 kfree(ep->digest); in sctp_endpoint_init()
186 struct sctp_endpoint *ep; in sctp_endpoint_new() local
189 ep = kzalloc(sizeof(*ep), gfp); in sctp_endpoint_new()
190 if (!ep) in sctp_endpoint_new()
193 if (!sctp_endpoint_init(ep, sk, gfp)) in sctp_endpoint_new()
196 SCTP_DBG_OBJCNT_INC(ep); in sctp_endpoint_new()
197 return ep; in sctp_endpoint_new()
200 kfree(ep); in sctp_endpoint_new()
206 void sctp_endpoint_add_asoc(struct sctp_endpoint *ep, in sctp_endpoint_add_asoc() argument
209 struct sock *sk = ep->base.sk; in sctp_endpoint_add_asoc()
219 list_add_tail(&asoc->asocs, &ep->asocs); in sctp_endpoint_add_asoc()
229 void sctp_endpoint_free(struct sctp_endpoint *ep) in sctp_endpoint_free() argument
231 ep->base.dead = true; in sctp_endpoint_free()
233 ep->base.sk->sk_state = SCTP_SS_CLOSED; in sctp_endpoint_free()
236 sctp_unhash_endpoint(ep); in sctp_endpoint_free()
238 sctp_endpoint_put(ep); in sctp_endpoint_free()
242 static void sctp_endpoint_destroy(struct sctp_endpoint *ep) in sctp_endpoint_destroy() argument
246 if (unlikely(!ep->base.dead)) { in sctp_endpoint_destroy()
247 WARN(1, "Attempt to destroy undead endpoint %p!\n", ep); in sctp_endpoint_destroy()
252 kfree(ep->digest); in sctp_endpoint_destroy()
257 sctp_auth_destroy_keys(&ep->endpoint_shared_keys); in sctp_endpoint_destroy()
258 kfree(ep->auth_hmacs_list); in sctp_endpoint_destroy()
259 kfree(ep->auth_chunk_list); in sctp_endpoint_destroy()
262 sctp_auth_destroy_hmacs(ep->auth_hmacs); in sctp_endpoint_destroy()
265 sctp_inq_free(&ep->base.inqueue); in sctp_endpoint_destroy()
266 sctp_bind_addr_free(&ep->base.bind_addr); in sctp_endpoint_destroy()
268 memset(ep->secret_key, 0, sizeof(ep->secret_key)); in sctp_endpoint_destroy()
271 sk = ep->base.sk; in sctp_endpoint_destroy()
280 kfree(ep); in sctp_endpoint_destroy()
281 SCTP_DBG_OBJCNT_DEC(ep); in sctp_endpoint_destroy()
285 void sctp_endpoint_hold(struct sctp_endpoint *ep) in sctp_endpoint_hold() argument
287 atomic_inc(&ep->base.refcnt); in sctp_endpoint_hold()
293 void sctp_endpoint_put(struct sctp_endpoint *ep) in sctp_endpoint_put() argument
295 if (atomic_dec_and_test(&ep->base.refcnt)) in sctp_endpoint_put()
296 sctp_endpoint_destroy(ep); in sctp_endpoint_put()
300 struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, in sctp_endpoint_is_match() argument
306 if ((htons(ep->base.bind_addr.port) == laddr->v4.sin_port) && in sctp_endpoint_is_match()
307 net_eq(sock_net(ep->base.sk), net)) { in sctp_endpoint_is_match()
308 if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, in sctp_endpoint_is_match()
309 sctp_sk(ep->base.sk))) in sctp_endpoint_is_match()
310 retval = ep; in sctp_endpoint_is_match()
321 const struct sctp_endpoint *ep, in __sctp_endpoint_lookup_assoc() argument
338 if (!ep->base.bind_addr.port) in __sctp_endpoint_lookup_assoc()
343 hash = sctp_assoc_hashfn(sock_net(ep->base.sk), ep->base.bind_addr.port, in __sctp_endpoint_lookup_assoc()
349 if (tmp->ep != ep || rport != tmp->peer.port) in __sctp_endpoint_lookup_assoc()
366 const struct sctp_endpoint *ep, in sctp_endpoint_lookup_assoc() argument
373 asoc = __sctp_endpoint_lookup_assoc(ep, paddr, transport); in sctp_endpoint_lookup_assoc()
382 int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep, in sctp_endpoint_is_peeled_off() argument
387 struct net *net = sock_net(ep->base.sk); in sctp_endpoint_is_peeled_off()
389 bp = &ep->base.bind_addr; in sctp_endpoint_is_peeled_off()
406 struct sctp_endpoint *ep = in sctp_endpoint_bh_rcv() local
420 if (ep->base.dead) in sctp_endpoint_bh_rcv()
424 inqueue = &ep->base.inqueue; in sctp_endpoint_bh_rcv()
425 sk = ep->base.sk; in sctp_endpoint_bh_rcv()
461 asoc = sctp_endpoint_lookup_assoc(ep, in sctp_endpoint_bh_rcv()
478 SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_INCTRLCHUNKS); in sctp_endpoint_bh_rcv()
487 ep, asoc, chunk, GFP_ATOMIC); in sctp_endpoint_bh_rcv()
495 if (!sctp_sk(sk)->ep) in sctp_endpoint_bh_rcv()