• Home
  • Raw
  • Download

Lines Matching +full:endpoint +full:- +full:base

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 1999-2000 Cisco, Inc.
4 * Copyright (c) 1999-2001 Motorola, Inc.
5 * Copyright (c) 2001-2002 International Business Machines, Corp.
12 * This abstraction represents an SCTP endpoint.
16 * lksctp developers <linux-sctp@vger.kernel.org>
39 * Initialize the base fields of the endpoint structure.
48 ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); in sctp_endpoint_init()
49 if (!ep->digest) in sctp_endpoint_init()
52 ep->asconf_enable = net->sctp.addip_enable; in sctp_endpoint_init()
53 ep->auth_enable = net->sctp.auth_enable; in sctp_endpoint_init()
54 if (ep->auth_enable) { in sctp_endpoint_init()
57 if (ep->asconf_enable) { in sctp_endpoint_init()
63 /* Initialize the base structure. */ in sctp_endpoint_init()
64 /* What type of endpoint are we? */ in sctp_endpoint_init()
65 ep->base.type = SCTP_EP_TYPE_SOCKET; in sctp_endpoint_init()
68 refcount_set(&ep->base.refcnt, 1); in sctp_endpoint_init()
69 ep->base.dead = false; in sctp_endpoint_init()
72 sctp_inq_init(&ep->base.inqueue); in sctp_endpoint_init()
74 /* Set its top-half handler */ in sctp_endpoint_init()
75 sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv); in sctp_endpoint_init()
78 sctp_bind_addr_init(&ep->base.bind_addr, 0); in sctp_endpoint_init()
81 INIT_LIST_HEAD(&ep->asocs); in sctp_endpoint_init()
84 ep->sndbuf_policy = net->sctp.sndbuf_policy; in sctp_endpoint_init()
86 sk->sk_data_ready = sctp_data_ready; in sctp_endpoint_init()
87 sk->sk_write_space = sctp_write_space; in sctp_endpoint_init()
90 /* Get the receive buffer policy for this endpoint */ in sctp_endpoint_init()
91 ep->rcvbuf_policy = net->sctp.rcvbuf_policy; in sctp_endpoint_init()
94 get_random_bytes(ep->secret_key, sizeof(ep->secret_key)); in sctp_endpoint_init()
96 /* SCTP-AUTH extensions*/ in sctp_endpoint_init()
97 INIT_LIST_HEAD(&ep->endpoint_shared_keys); in sctp_endpoint_init()
102 list_add(&null_key->key_list, &ep->endpoint_shared_keys); in sctp_endpoint_init()
104 /* Add the null key to the endpoint shared keys list and in sctp_endpoint_init()
107 ep->prsctp_enable = net->sctp.prsctp_enable; in sctp_endpoint_init()
108 ep->reconf_enable = net->sctp.reconf_enable; in sctp_endpoint_init()
109 ep->ecn_enable = net->sctp.ecn_enable; in sctp_endpoint_init()
112 ep->base.sk = sk; in sctp_endpoint_init()
113 ep->base.net = sock_net(sk); in sctp_endpoint_init()
114 sock_hold(ep->base.sk); in sctp_endpoint_init()
121 kfree(ep->digest); in sctp_endpoint_init()
133 /* Build a local endpoint. */ in sctp_endpoint_new()
150 /* Add an association to an endpoint. */
154 struct sock *sk = ep->base.sk; in sctp_endpoint_add_asoc()
160 if (asoc->temp) in sctp_endpoint_add_asoc()
164 list_add_tail(&asoc->asocs, &ep->asocs); in sctp_endpoint_add_asoc()
166 /* Increment the backlog value for a TCP-style listening socket. */ in sctp_endpoint_add_asoc()
171 /* Free the endpoint structure. Delay cleanup until
176 ep->base.dead = true; in sctp_endpoint_free()
178 inet_sk_set_state(ep->base.sk, SCTP_SS_CLOSED); in sctp_endpoint_free()
180 /* Unlink this endpoint, so we can't find it again! */ in sctp_endpoint_free()
186 /* Final destructor for endpoint. */
190 struct sock *sk = ep->base.sk; in sctp_endpoint_destroy_rcu()
192 sctp_sk(sk)->ep = NULL; in sctp_endpoint_destroy_rcu()
203 if (unlikely(!ep->base.dead)) { in sctp_endpoint_destroy()
204 WARN(1, "Attempt to destroy undead endpoint %p!\n", ep); in sctp_endpoint_destroy()
209 kfree(ep->digest); in sctp_endpoint_destroy()
211 /* SCTP-AUTH: Free up AUTH releated data such as shared keys in sctp_endpoint_destroy()
214 sctp_auth_destroy_keys(&ep->endpoint_shared_keys); in sctp_endpoint_destroy()
218 sctp_inq_free(&ep->base.inqueue); in sctp_endpoint_destroy()
219 sctp_bind_addr_free(&ep->base.bind_addr); in sctp_endpoint_destroy()
221 memset(ep->secret_key, 0, sizeof(ep->secret_key)); in sctp_endpoint_destroy()
223 sk = ep->base.sk; in sctp_endpoint_destroy()
225 if (sctp_sk(sk)->bind_hash) in sctp_endpoint_destroy()
228 call_rcu(&ep->rcu, sctp_endpoint_destroy_rcu); in sctp_endpoint_destroy()
231 /* Hold a reference to an endpoint. */
234 return refcount_inc_not_zero(&ep->base.refcnt); in sctp_endpoint_hold()
237 /* Release a reference to an endpoint and clean up if there are
242 if (refcount_dec_and_test(&ep->base.refcnt)) in sctp_endpoint_put()
246 /* Is this the endpoint we are looking for? */
253 if ((htons(ep->base.bind_addr.port) == laddr->v4.sin_port) && in sctp_endpoint_is_match()
254 net_eq(ep->base.net, net)) { in sctp_endpoint_is_match()
255 if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, in sctp_endpoint_is_match()
256 sctp_sk(ep->base.sk))) in sctp_endpoint_is_match()
265 * through t->assoc.
278 * on this endpoint. in sctp_endpoint_lookup_assoc()
280 if (!ep->base.bind_addr.port) in sctp_endpoint_lookup_assoc()
289 asoc = t->asoc; in sctp_endpoint_lookup_assoc()
295 /* Look for any peeled off association from the endpoint that matches the
302 struct net *net = ep->base.net; in sctp_endpoint_is_peeled_off()
305 bp = &ep->base.bind_addr; in sctp_endpoint_is_peeled_off()
309 list_for_each_entry(addr, &bp->address_list, list) { in sctp_endpoint_is_peeled_off()
310 if (sctp_has_association(net, &addr->a, paddr)) in sctp_endpoint_is_peeled_off()
324 base.inqueue.immediate); in sctp_endpoint_bh_rcv()
336 if (ep->base.dead) in sctp_endpoint_bh_rcv()
340 inqueue = &ep->base.inqueue; in sctp_endpoint_bh_rcv()
341 sk = ep->base.sk; in sctp_endpoint_bh_rcv()
345 subtype = SCTP_ST_CHUNK(chunk->chunk_hdr->type); in sctp_endpoint_bh_rcv()
348 * processing specified in Section 6.3 of SCTP-AUTH spec in sctp_endpoint_bh_rcv()
357 /* If the next chunk is COOKIE-ECHO, skip the AUTH in sctp_endpoint_bh_rcv()
359 * Authentication later (during cookie-echo in sctp_endpoint_bh_rcv()
362 if (next_hdr->type == SCTP_CID_COOKIE_ECHO) { in sctp_endpoint_bh_rcv()
363 chunk->auth_chunk = skb_clone(chunk->skb, in sctp_endpoint_bh_rcv()
365 chunk->auth = 1; in sctp_endpoint_bh_rcv()
374 * COOKIE-ECHO chunk. in sctp_endpoint_bh_rcv()
376 if (NULL == chunk->asoc) { in sctp_endpoint_bh_rcv()
380 chunk->asoc = asoc; in sctp_endpoint_bh_rcv()
381 chunk->transport = transport; in sctp_endpoint_bh_rcv()
384 state = asoc ? asoc->state : SCTP_STATE_CLOSED; in sctp_endpoint_bh_rcv()
385 if (sctp_auth_recv_cid(subtype.chunk, asoc) && !chunk->auth) in sctp_endpoint_bh_rcv()
392 asoc->peer.last_data_from = chunk->transport; in sctp_endpoint_bh_rcv()
394 SCTP_INC_STATS(ep->base.net, SCTP_MIB_INCTRLCHUNKS); in sctp_endpoint_bh_rcv()
396 asoc->stats.ictrlchunks++; in sctp_endpoint_bh_rcv()
399 if (chunk->transport) in sctp_endpoint_bh_rcv()
400 chunk->transport->last_time_heard = ktime_get(); in sctp_endpoint_bh_rcv()
406 chunk->pdiscard = 1; in sctp_endpoint_bh_rcv()
408 /* Check to see if the endpoint is freed in response to in sctp_endpoint_bh_rcv()
411 if (!sctp_sk(sk)->ep) in sctp_endpoint_bh_rcv()