Lines Matching full:if
31 * along with GNU CC; see the file COPYING. If not, write to
134 if (asoc->ep->sndbuf_policy) in sctp_wspace()
139 if (amt >= asoc->base.sk->sk_sndbuf) { in sctp_wspace()
140 if (asoc->base.sk->sk_userlocks & SOCK_SNDBUF_LOCK) in sctp_wspace()
144 if (amt < 0) in sctp_wspace()
193 if (!af) in sctp_verify_addr()
197 if (!af->addr_valid(addr, sctp_sk(sk), NULL)) in sctp_verify_addr()
200 if (!sctp_sk(sk)->pf->send_verify(sctp_sk(sk), (addr))) in sctp_verify_addr()
206 /* Look up the association by its id. If this is not a UDP-style
213 /* If this is not a UDP-style socket, assoc id should be ignored. */ in sctp_id2assoc()
214 if (!sctp_style(sk, UDP)) { in sctp_id2assoc()
215 /* Return NULL if the socket state is not ESTABLISHED. It in sctp_id2assoc()
219 if (!sctp_sstate(sk, ESTABLISHED)) in sctp_id2assoc()
223 if (!list_empty(&sctp_sk(sk)->ep->asocs)) in sctp_id2assoc()
230 if (!id || (id == (sctp_assoc_t)-1)) in sctp_id2assoc()
237 if (!asoc || (asoc->base.sk != sk) || asoc->base.dead) in sctp_id2assoc()
243 /* Look up the transport from an address and an assoc id. If both address and
259 if (!addr_asoc) in sctp_addr_id2transport()
263 if (id_asoc && (id_asoc != addr_asoc)) in sctp_addr_id2transport()
292 if (!sctp_sk(sk)->ep->base.bind_addr.port) in sctp_bind()
312 if (len < sizeof (struct sockaddr)) in sctp_sockaddr_af()
316 if (addr->sa.sa_family == AF_INET6 && in sctp_sockaddr_af()
318 if (!opt->pf->af_supported(AF_INET, opt)) in sctp_sockaddr_af()
322 if (!opt->pf->af_supported(addr->sa.sa_family, opt)) in sctp_sockaddr_af()
326 /* If we get this far, af is valid. */ in sctp_sockaddr_af()
329 if (len < af->sockaddr_len) in sctp_sockaddr_af()
347 if (!af) { in sctp_do_bind()
363 if (!sp->pf->bind_verify(sp, addr)) in sctp_do_bind()
367 * It's OK to allow 0 ports if we are already bound. in sctp_do_bind()
370 if (bp->port) { in sctp_do_bind()
371 if (!snum) in sctp_do_bind()
373 else if (snum != bp->port) { in sctp_do_bind()
381 if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) in sctp_do_bind()
384 /* See if the address matches any of the addresses we may have in sctp_do_bind()
387 if (sctp_bind_addr_match(bp, addr, sp)) in sctp_do_bind()
395 if ((ret = sctp_get_port_local(sk, addr))) { in sctp_do_bind()
400 if (!bp->port) in sctp_do_bind()
409 if (!ret) { in sctp_do_bind()
420 * at any one time. If a sender, after sending an ASCONF chunk, decides
432 /* If there is an outstanding ASCONF chunk, queue it for later in sctp_send_asconf()
435 if (asoc->addip_last_asconf) { in sctp_send_asconf()
443 if (retval) in sctp_send_asconf()
456 * array/length pair, determine if it is IPv6 or IPv4 and call
459 * If any of them fails, then the operation will be reversed and the
482 if (!af) { in sctp_bindx_add()
493 if (retval < 0) { in sctp_bindx_add()
495 if (cnt > 0) in sctp_bindx_add()
508 * If any of the addresses is already in the bind address list of the
532 if (!sctp_addip_enable) in sctp_send_asconf_add_ip()
543 if (!asoc->peer.asconf_capable) in sctp_send_asconf_add_ip()
546 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_ADD_IP) in sctp_send_asconf_add_ip()
549 if (!sctp_state(asoc, ESTABLISHED)) in sctp_send_asconf_add_ip()
552 /* Check if any address in the packed array of addresses is in sctp_send_asconf_add_ip()
553 * in the bind address list of the association. If so, in sctp_send_asconf_add_ip()
561 if (!af) { in sctp_send_asconf_add_ip()
566 if (sctp_assoc_lookup_laddr(asoc, addr)) in sctp_send_asconf_add_ip()
571 if (i < addrcnt) in sctp_send_asconf_add_ip()
582 if (!chunk) { in sctp_send_asconf_add_ip()
599 if (asoc->src_out_of_asoc_ok) { in sctp_send_asconf_add_ip()
626 * array/length pair, determine if it is IPv6 or IPv4 and call
629 * If any of them fails, then the operation will be reversed and the
632 * At least one address has to be left; if only one address is
653 /* If the bind address list is empty or if there is only one in sctp_bindx_rem()
657 if (list_empty(&bp->address_list) || in sctp_bindx_rem()
665 if (!af) { in sctp_bindx_rem()
670 if (!af->addr_valid(sa_addr, sp, NULL)) { in sctp_bindx_rem()
675 if (sa_addr->v4.sin_port && in sctp_bindx_rem()
681 if (!sa_addr->v4.sin_port) in sctp_bindx_rem()
684 /* FIXME - There is probably a need to check if sk->sk_saddr and in sctp_bindx_rem()
695 if (retval < 0) { in sctp_bindx_rem()
697 if (cnt > 0) in sctp_bindx_rem()
710 * If any of the addresses is already in the bind address list of the
735 if (!sctp_addip_enable) in sctp_send_asconf_del_ip()
746 if (!asoc->peer.asconf_capable) in sctp_send_asconf_del_ip()
749 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_DEL_IP) in sctp_send_asconf_del_ip()
752 if (!sctp_state(asoc, ESTABLISHED)) in sctp_send_asconf_del_ip()
755 /* Check if any address in the packed array of addresses is in sctp_send_asconf_del_ip()
757 * If so, do not send the asconf chunk to its peer, but in sctp_send_asconf_del_ip()
764 if (!af) { in sctp_send_asconf_del_ip()
769 if (!sctp_assoc_lookup_laddr(asoc, laddr)) in sctp_send_asconf_del_ip()
774 if (i < addrcnt) in sctp_send_asconf_del_ip()
785 if ((laddr == NULL) && (addrcnt == 1)) { in sctp_send_asconf_del_ip()
786 if (asoc->asconf_addr_del_pending) in sctp_send_asconf_del_ip()
790 if (asoc->asconf_addr_del_pending == NULL) { in sctp_send_asconf_del_ip()
798 if (addrs->sa_family == AF_INET) { in sctp_send_asconf_del_ip()
803 } else if (addrs->sa_family == AF_INET6) { in sctp_send_asconf_del_ip()
823 if (!chunk) { in sctp_send_asconf_del_ip()
837 if (sctp_cmp_addr_exact(&saddr->a, laddr)) in sctp_send_asconf_del_ip()
854 if (stored) in sctp_send_asconf_del_ip()
874 if (!af) in sctp_asconf_mgmt()
876 if (sctp_verify_addr(sk, addr, af->sockaddr_len)) in sctp_asconf_mgmt()
879 if (addrw->state == SCTP_ADDR_NEW) in sctp_asconf_mgmt()
891 * If sd is an IPv4 socket, the addresses passed must be IPv4 addresses.
892 * If the sd is an IPv6 socket, the addresses passed can either be IPv4
921 * if both are given, sctp_bindx() will fail with EINVAL. A caller may
929 * associated with those addresses. If the endpoint supports dynamic
945 * pointer); if all of those succeed, then we can alloc the memory
959 * Returns 0 if ok, <0 errno code on error.
976 if (unlikely(addrs_size <= 0)) in sctp_setsockopt_bindx()
980 if (unlikely(!access_ok(VERIFY_READ, addrs, addrs_size))) in sctp_setsockopt_bindx()
985 if (unlikely(!kaddrs)) in sctp_setsockopt_bindx()
988 if (__copy_from_user(kaddrs, addrs, addrs_size)) { in sctp_setsockopt_bindx()
996 if (walk_size + sizeof(sa_family_t) > addrs_size) { in sctp_setsockopt_bindx()
1004 /* If the address family is not supported or if this address in sctp_setsockopt_bindx()
1007 if (!af || (walk_size + af->sockaddr_len) > addrs_size) { in sctp_setsockopt_bindx()
1020 if (err) in sctp_setsockopt_bindx()
1027 if (err) in sctp_setsockopt_bindx()
1078 if (sctp_sstate(sk, ESTABLISHED) || in __sctp_connect()
1087 if (walk_size + sizeof(sa_family_t) > addrs_size) { in __sctp_connect()
1095 /* If the address family is not supported or if this address in __sctp_connect()
1098 if (!af || (walk_size + af->sockaddr_len) > addrs_size) { in __sctp_connect()
1109 if (err) in __sctp_connect()
1115 if (asoc && asoc->peer.port && asoc->peer.port != port) in __sctp_connect()
1119 /* Check if there already is a matching association on the in __sctp_connect()
1123 if (asoc2 && asoc2 != asoc) { in __sctp_connect()
1124 if (asoc2->state >= SCTP_STATE_ESTABLISHED) in __sctp_connect()
1131 /* If we could not find a matching association on the endpoint, in __sctp_connect()
1135 if (sctp_endpoint_is_peeled_off(ep, &to)) { in __sctp_connect()
1140 if (!asoc) { in __sctp_connect()
1141 /* If a bind() or sctp_bindx() is not called prior to in __sctp_connect()
1146 if (!ep->base.bind_addr.port) { in __sctp_connect()
1147 if (sctp_autobind(sk)) { in __sctp_connect()
1153 * If an unprivileged user inherits a 1-many in __sctp_connect()
1159 if (ep->base.bind_addr.port < PROT_SOCK && in __sctp_connect()
1168 if (!asoc) { in __sctp_connect()
1175 if (err < 0) { in __sctp_connect()
1184 if (!transport) { in __sctp_connect()
1197 if (assoc_id) { in __sctp_connect()
1199 if (err < 0) in __sctp_connect()
1204 if (err < 0) { in __sctp_connect()
1215 * if all they do is call sock_create_kern(). in __sctp_connect()
1217 if (sk->sk_socket->file) in __sctp_connect()
1223 if ((err == 0 || err == -EINPROGRESS) && assoc_id) in __sctp_connect()
1234 if (asoc) in __sctp_connect()
1245 * If sd is an IPv4 socket, the addresses passed must be IPv4 addresses.
1246 * If the sd is an IPv6 socket, the addresses passed can either be IPv4
1277 * the peer uses for the resulting association. If the caller wants to
1287 * pointer); if all of those succeed, then we can alloc the memory
1299 * Returns >=0 if ok, <0 errno code on error.
1312 if (unlikely(addrs_size <= 0)) in __sctp_setsockopt_connectx()
1316 if (unlikely(!access_ok(VERIFY_READ, addrs, addrs_size))) in __sctp_setsockopt_connectx()
1321 if (unlikely(!kaddrs)) in __sctp_setsockopt_connectx()
1324 if (__copy_from_user(kaddrs, addrs, addrs_size)) { in __sctp_setsockopt_connectx()
1361 if (err) in sctp_setsockopt_connectx()
1383 if (len < sizeof(param)) in sctp_getsockopt_connectx3()
1386 if (copy_from_user(¶m, optval, sizeof(param))) in sctp_getsockopt_connectx3()
1393 if (err == 0 || err == -EINPROGRESS) { in sctp_getsockopt_connectx3()
1394 if (copy_to_user(optval, &assoc_id, sizeof(assoc_id))) in sctp_getsockopt_connectx3()
1396 if (put_user(sizeof(assoc_id), optlen)) in sctp_getsockopt_connectx3()
1419 * If sd in the close() call is a branched-off socket representing only
1445 * To enable the option, set l_onoff to 1. If the l_linger value is set
1446 * to 0, calling close() is the same as the ABORT primitive. If the
1448 * an error. If the value is set to a positive value linger_time, the
1449 * close() can be blocked for at most linger_time ms. If the graceful
1476 if (sctp_style(sk, TCP)) { in sctp_close()
1477 /* A closed association can still be in the list if in sctp_close()
1479 * not yet accepted. If so, free it. If not, send an in sctp_close()
1482 if (sctp_state(asoc, CLOSED)) { in sctp_close()
1489 if (data_was_unread || !skb_queue_empty(&asoc->ulpq.lobby) || in sctp_close()
1495 if (chunk) in sctp_close()
1501 /* On a TCP-style socket, block for at most linger_time if set. */ in sctp_close()
1502 if (sctp_style(sk, TCP) && timeout) in sctp_close()
1531 if (err == -EPIPE) in sctp_error()
1533 if (err == -EPIPE && !(flags & MSG_NOSIGNAL)) in sctp_error()
1595 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) { in sctp_sendmsg()
1603 if (err) { in sctp_sendmsg()
1613 if (!sctp_style(sk, UDP_HIGH_BANDWIDTH) && msg->msg_name) { in sctp_sendmsg()
1618 if (err) in sctp_sendmsg()
1621 if (msg_namelen > sizeof(to)) in sctp_sendmsg()
1631 if (sinfo) { in sctp_sendmsg()
1640 if (sctp_style(sk, TCP) && (sinfo_flags & (SCTP_EOF | SCTP_ABORT))) { in sctp_sendmsg()
1645 /* If SCTP_EOF is set, no data can be sent. Disallow sending zero in sctp_sendmsg()
1647 * If SCTP_ABORT is set, the message length could be non zero with in sctp_sendmsg()
1650 if (((sinfo_flags & SCTP_EOF) && (msg_len > 0)) || in sctp_sendmsg()
1656 /* If SCTP_ADDR_OVER is set, there must be an address in sctp_sendmsg()
1659 if ((sinfo_flags & SCTP_ADDR_OVER) && (!msg->msg_name)) { in sctp_sendmsg()
1670 /* If a msg_name has been specified, assume this is to be used. */ in sctp_sendmsg()
1671 if (msg_name) { in sctp_sendmsg()
1674 if (!asoc) { in sctp_sendmsg()
1675 /* If we could not find a matching association on the in sctp_sendmsg()
1680 if ((sctp_style(sk, TCP) && in sctp_sendmsg()
1689 if (!asoc) { in sctp_sendmsg()
1695 if (asoc) { in sctp_sendmsg()
1703 if (sctp_state(asoc, CLOSED) && sctp_style(sk, TCP)) { in sctp_sendmsg()
1708 if (sinfo_flags & SCTP_EOF) { in sctp_sendmsg()
1715 if (sinfo_flags & SCTP_ABORT) { in sctp_sendmsg()
1718 if (!chunk) { in sctp_sendmsg()
1731 if (!asoc) { in sctp_sendmsg()
1734 if (sinfo_flags & (SCTP_EOF | SCTP_ABORT)) { in sctp_sendmsg()
1742 if (sinfo) { in sctp_sendmsg()
1743 if (!sinit || (sinit && !sinit->sinit_num_ostreams)) { in sctp_sendmsg()
1745 if (sinfo->sinfo_stream >= in sctp_sendmsg()
1752 if (sinfo->sinfo_stream >= in sctp_sendmsg()
1762 * If a bind() or sctp_bindx() is not called prior to a in sctp_sendmsg()
1767 if (!ep->base.bind_addr.port) { in sctp_sendmsg()
1768 if (sctp_autobind(sk)) { in sctp_sendmsg()
1774 * If an unprivileged user inherits a one-to-many in sctp_sendmsg()
1780 if (ep->base.bind_addr.port < PROT_SOCK && in sctp_sendmsg()
1789 if (!new_asoc) { in sctp_sendmsg()
1795 if (err < 0) { in sctp_sendmsg()
1800 /* If the SCTP_INIT ancillary data is specified, set all in sctp_sendmsg()
1803 if (sinit) { in sctp_sendmsg()
1804 if (sinit->sinit_num_ostreams) { in sctp_sendmsg()
1808 if (sinit->sinit_max_instreams) { in sctp_sendmsg()
1812 if (sinit->sinit_max_attempts) { in sctp_sendmsg()
1816 if (sinit->sinit_max_init_timeo) { in sctp_sendmsg()
1824 if (!transport) { in sctp_sendmsg()
1833 if (!sinfo) { in sctp_sendmsg()
1834 /* If the user didn't specify SNDRCVINFO, make up one with in sctp_sendmsg()
1850 if (msg_len > sk->sk_sndbuf) { in sctp_sendmsg()
1855 if (asoc->pmtu_pending) in sctp_sendmsg()
1858 /* If fragmentation is disabled and the message length exceeds the in sctp_sendmsg()
1863 if (sctp_sk(sk)->disable_fragments && (msg_len > asoc->frag_point)) { in sctp_sendmsg()
1869 if (sinfo->sinfo_stream >= asoc->c.sinit_num_ostreams) { in sctp_sendmsg()
1875 if (!sctp_wspace(asoc)) { in sctp_sendmsg()
1877 if (err) in sctp_sendmsg()
1881 /* If an address is passed with the sendto/sendmsg call, it is used in sctp_sendmsg()
1885 if ((sctp_style(sk, TCP) && msg_name) || in sctp_sendmsg()
1888 if (!chunk_tp) { in sctp_sendmsg()
1895 /* Auto-connect, if we aren't connected already. */ in sctp_sendmsg()
1896 if (sctp_state(asoc, CLOSED)) { in sctp_sendmsg()
1898 if (err < 0) in sctp_sendmsg()
1905 if (!datamsg) { in sctp_sendmsg()
1927 if (err) in sctp_sendmsg()
1934 if (err) in sctp_sendmsg()
1939 /* If we are already past ASSOCIATE, the lower in sctp_sendmsg()
1945 if (new_asoc) in sctp_sendmsg()
1953 #if 0 in sctp_sendmsg()
1955 if (msg_len) in sctp_sendmsg()
1962 if (msg_len) in sctp_sendmsg()
1972 * If 'len' exceeds the total skb length, it returns the no. of bytes that
1981 if (len <= skb_len) { in sctp_skb_pull()
1993 if (!rlen) in sctp_skb_pull()
2037 if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED)) { in sctp_recvmsg()
2043 if (!skb) in sctp_recvmsg()
2052 if (copied > len) in sctp_recvmsg()
2059 if (err) in sctp_recvmsg()
2063 if (sctp_ulpevent_is_notification(event)) { in sctp_recvmsg()
2070 /* Check if we allow SCTP_SNDRCVINFO. */ in sctp_recvmsg()
2071 if (sp->subscribe.sctp_data_io_event) in sctp_recvmsg()
2073 #if 0 in sctp_recvmsg()
2075 if (sk->sk_protinfo.af_inet.cmsg_flags) in sctp_recvmsg()
2081 /* If skb's length exceeds the user's buffer, update the skb and in sctp_recvmsg()
2085 if (skb_len > copied) { in sctp_recvmsg()
2087 if (flags & MSG_PEEK) in sctp_recvmsg()
2093 * rwnd by that amount. If all the data in the skb is read, in sctp_recvmsg()
2096 if (!sctp_ulpevent_is_notification(event)) in sctp_recvmsg()
2099 } else if ((event->msg_flags & MSG_NOTIFICATION) || in sctp_recvmsg()
2106 if (flags & MSG_PEEK) { in sctp_recvmsg()
2125 * This option is a on/off flag. If enabled no SCTP message
2126 * fragmentation will be performed. Instead if a message being sent
2136 if (optlen < sizeof(int)) in sctp_setsockopt_disable_fragments()
2139 if (get_user(val, (int __user *)optval)) in sctp_setsockopt_disable_fragments()
2153 if (optlen > sizeof(struct sctp_event_subscribe)) in sctp_setsockopt_events()
2155 if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen)) in sctp_setsockopt_events()
2160 * if there is no data to be sent or retransmit, the stack will in sctp_setsockopt_events()
2163 if (sctp_ulpevent_type_enabled(SCTP_SENDER_DRY_EVENT, in sctp_setsockopt_events()
2167 if (asoc && sctp_outq_is_empty(&asoc->outqueue)) { in sctp_setsockopt_events()
2170 if (!event) in sctp_setsockopt_events()
2197 if (sctp_style(sk, TCP)) in sctp_setsockopt_autoclose()
2199 if (optlen != sizeof(int)) in sctp_setsockopt_autoclose()
2201 if (copy_from_user(&sp->autoclose, optval, optlen)) in sctp_setsockopt_autoclose()
2231 * in milliseconds. If a value of zero
2236 * considered unreachable. If a value of zero
2241 * Note that if the spp_address field is empty
2248 * association if the spp_address field is empty. Note
2249 * also, that if delayed sack is enabled and this
2258 * specified address. Note that if the address
2263 * speicifed address. Note that if the address
2280 * if the address feild is empty then all addresses
2285 * if the address feild is empty then all addresses
2294 * that if spp_address is empty then all addresses will
2298 * off delayed sack. If the spp_address field is blank then
2314 if (params->spp_flags & SPP_HB_DEMAND && trans) { in sctp_apply_peer_addr_params()
2316 if (error) in sctp_apply_peer_addr_params()
2324 if (params->spp_flags & SPP_HB_ENABLE) { in sctp_apply_peer_addr_params()
2326 /* Re-zero the interval if the SPP_HB_TIME_IS_ZERO is in sctp_apply_peer_addr_params()
2330 if (params->spp_flags & SPP_HB_TIME_IS_ZERO) in sctp_apply_peer_addr_params()
2333 if (params->spp_hbinterval || in sctp_apply_peer_addr_params()
2335 if (trans) { in sctp_apply_peer_addr_params()
2338 } else if (asoc) { in sctp_apply_peer_addr_params()
2347 if (hb_change) { in sctp_apply_peer_addr_params()
2348 if (trans) { in sctp_apply_peer_addr_params()
2351 } else if (asoc) { in sctp_apply_peer_addr_params()
2365 if ((params->spp_flags & SPP_PMTUD_DISABLE) && params->spp_pathmtu) { in sctp_apply_peer_addr_params()
2366 if (trans) { in sctp_apply_peer_addr_params()
2369 } else if (asoc) { in sctp_apply_peer_addr_params()
2377 if (pmtud_change) { in sctp_apply_peer_addr_params()
2378 if (trans) { in sctp_apply_peer_addr_params()
2383 if (update) { in sctp_apply_peer_addr_params()
2387 } else if (asoc) { in sctp_apply_peer_addr_params()
2400 if ((params->spp_flags & SPP_SACKDELAY_ENABLE) && params->spp_sackdelay) { in sctp_apply_peer_addr_params()
2401 if (trans) { in sctp_apply_peer_addr_params()
2404 } else if (asoc) { in sctp_apply_peer_addr_params()
2412 if (sackdelay_change) { in sctp_apply_peer_addr_params()
2413 if (trans) { in sctp_apply_peer_addr_params()
2417 } else if (asoc) { in sctp_apply_peer_addr_params()
2431 if (params->spp_pathmaxrxt) { in sctp_apply_peer_addr_params()
2432 if (trans) { in sctp_apply_peer_addr_params()
2434 } else if (asoc) { in sctp_apply_peer_addr_params()
2455 if (optlen != sizeof(struct sctp_paddrparams)) in sctp_setsockopt_peer_addr_params()
2458 if (copy_from_user(¶ms, optval, optlen)) in sctp_setsockopt_peer_addr_params()
2466 if (hb_change == SPP_HB || in sctp_setsockopt_peer_addr_params()
2474 /* If an address other than INADDR_ANY is specified, and in sctp_setsockopt_peer_addr_params()
2477 if (!sctp_is_any(sk, ( union sctp_addr *)¶ms.spp_address)) { in sctp_setsockopt_peer_addr_params()
2480 if (!trans) in sctp_setsockopt_peer_addr_params()
2484 /* Get association, if assoc_id != 0 and the socket is a one in sctp_setsockopt_peer_addr_params()
2489 if (!asoc && params.spp_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_peer_addr_params()
2495 if (params.spp_flags & SPP_HB_DEMAND && !trans && !asoc) in sctp_setsockopt_peer_addr_params()
2503 if (error) in sctp_setsockopt_peer_addr_params()
2506 /* If changes are for association, also apply parameters to each in sctp_setsockopt_peer_addr_params()
2509 if (!trans && asoc) { in sctp_setsockopt_peer_addr_params()
2527 * Changing the frequency to 1 disables the delayed sack algorithm. If
2529 * values. If the assoc_id field is non-zero, then the set or get
2531 * assoc_id field is ignored by the one to one model). Note that if
2542 * is performing an action upon. Note that if this field's value is
2565 if (optlen == sizeof(struct sctp_sack_info)) { in sctp_setsockopt_delayed_ack()
2566 if (copy_from_user(¶ms, optval, optlen)) in sctp_setsockopt_delayed_ack()
2569 if (params.sack_delay == 0 && params.sack_freq == 0) in sctp_setsockopt_delayed_ack()
2571 } else if (optlen == sizeof(struct sctp_assoc_value)) { in sctp_setsockopt_delayed_ack()
2574 if (copy_from_user(¶ms, optval, optlen)) in sctp_setsockopt_delayed_ack()
2577 if (params.sack_delay == 0) in sctp_setsockopt_delayed_ack()
2585 if (params.sack_delay > 500) in sctp_setsockopt_delayed_ack()
2588 /* Get association, if sack_assoc_id != 0 and the socket is a one in sctp_setsockopt_delayed_ack()
2593 if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_delayed_ack()
2596 if (params.sack_delay) { in sctp_setsockopt_delayed_ack()
2597 if (asoc) { in sctp_setsockopt_delayed_ack()
2611 if (params.sack_freq == 1) { in sctp_setsockopt_delayed_ack()
2612 if (asoc) { in sctp_setsockopt_delayed_ack()
2621 } else if (params.sack_freq > 1) { in sctp_setsockopt_delayed_ack()
2622 if (asoc) { in sctp_setsockopt_delayed_ack()
2635 /* If change is for association, also apply to each transport. */ in sctp_setsockopt_delayed_ack()
2636 if (asoc) { in sctp_setsockopt_delayed_ack()
2639 if (params.sack_delay) { in sctp_setsockopt_delayed_ack()
2646 if (params.sack_freq == 1) { in sctp_setsockopt_delayed_ack()
2650 } else if (params.sack_freq > 1) { in sctp_setsockopt_delayed_ack()
2678 if (optlen != sizeof(struct sctp_initmsg)) in sctp_setsockopt_initmsg()
2680 if (copy_from_user(&sinit, optval, optlen)) in sctp_setsockopt_initmsg()
2683 if (sinit.sinit_num_ostreams) in sctp_setsockopt_initmsg()
2685 if (sinit.sinit_max_instreams) in sctp_setsockopt_initmsg()
2687 if (sinit.sinit_max_attempts) in sctp_setsockopt_initmsg()
2689 if (sinit.sinit_max_init_timeo) in sctp_setsockopt_initmsg()
2707 * to this call if the caller is using the UDP model.
2717 if (optlen != sizeof(struct sctp_sndrcvinfo)) in sctp_setsockopt_default_send_param()
2719 if (copy_from_user(&info, optval, optlen)) in sctp_setsockopt_default_send_param()
2723 if (!asoc && info.sinfo_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_default_send_param()
2726 if (asoc) { in sctp_setsockopt_default_send_param()
2755 if (optlen != sizeof(struct sctp_prim)) in sctp_setsockopt_primary_addr()
2758 if (copy_from_user(&prim, optval, sizeof(struct sctp_prim))) in sctp_setsockopt_primary_addr()
2762 if (!trans) in sctp_setsockopt_primary_addr()
2783 if (optlen < sizeof(int)) in sctp_setsockopt_nodelay()
2785 if (get_user(val, (int __user *)optval)) in sctp_setsockopt_nodelay()
2809 if (optlen != sizeof (struct sctp_rtoinfo)) in sctp_setsockopt_rtoinfo()
2812 if (copy_from_user(&rtoinfo, optval, optlen)) in sctp_setsockopt_rtoinfo()
2818 if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_rtoinfo()
2821 if (asoc) { in sctp_setsockopt_rtoinfo()
2822 if (rtoinfo.srto_initial != 0) in sctp_setsockopt_rtoinfo()
2825 if (rtoinfo.srto_max != 0) in sctp_setsockopt_rtoinfo()
2827 if (rtoinfo.srto_min != 0) in sctp_setsockopt_rtoinfo()
2830 /* If there is no association or the association-id = 0 in sctp_setsockopt_rtoinfo()
2835 if (rtoinfo.srto_initial != 0) in sctp_setsockopt_rtoinfo()
2837 if (rtoinfo.srto_max != 0) in sctp_setsockopt_rtoinfo()
2839 if (rtoinfo.srto_min != 0) in sctp_setsockopt_rtoinfo()
2852 * Returns an error if the new association retransmission value is
2863 if (optlen != sizeof(struct sctp_assocparams)) in sctp_setsockopt_associnfo()
2865 if (copy_from_user(&assocparams, optval, optlen)) in sctp_setsockopt_associnfo()
2870 if (!asoc && assocparams.sasoc_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_associnfo()
2874 if (asoc) { in sctp_setsockopt_associnfo()
2875 if (assocparams.sasoc_asocmaxrxt != 0) { in sctp_setsockopt_associnfo()
2886 /* Only validate asocmaxrxt if we have more than in sctp_setsockopt_associnfo()
2891 if (paths > 1 && in sctp_setsockopt_associnfo()
2898 if (assocparams.sasoc_cookie_life != 0) { in sctp_setsockopt_associnfo()
2909 if (assocparams.sasoc_asocmaxrxt != 0) in sctp_setsockopt_associnfo()
2912 if (assocparams.sasoc_cookie_life != 0) in sctp_setsockopt_associnfo()
2923 * addresses. If this option is turned on and the socket is type
2925 * If this option is turned off, then no mapping will be done of V4
2934 if (optlen < sizeof(int)) in sctp_setsockopt_mappedv4()
2936 if (get_user(val, (int __user *)optval)) in sctp_setsockopt_mappedv4()
2938 if (val) in sctp_setsockopt_mappedv4()
2949 * SCTP DATA chunk. If a message is larger than this size it will be
2968 * association the user is performing an action upon. Note that if
2980 if (optlen == sizeof(int)) { in sctp_setsockopt_maxseg()
2983 if (copy_from_user(&val, optval, optlen)) in sctp_setsockopt_maxseg()
2986 } else if (optlen == sizeof(struct sctp_assoc_value)) { in sctp_setsockopt_maxseg()
2987 if (copy_from_user(¶ms, optval, optlen)) in sctp_setsockopt_maxseg()
2993 if ((val != 0) && ((val < 8) || (val > SCTP_MAX_CHUNK_LEN))) in sctp_setsockopt_maxseg()
2997 if (!asoc && params.assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_maxseg()
3000 if (asoc) { in sctp_setsockopt_maxseg()
3001 if (val == 0) { in sctp_setsockopt_maxseg()
3037 if (!sctp_addip_enable) in sctp_setsockopt_peer_primary_addr()
3040 if (optlen != sizeof(struct sctp_setpeerprim)) in sctp_setsockopt_peer_primary_addr()
3043 if (copy_from_user(&prim, optval, optlen)) in sctp_setsockopt_peer_primary_addr()
3047 if (!asoc) in sctp_setsockopt_peer_primary_addr()
3050 if (!asoc->peer.asconf_capable) in sctp_setsockopt_peer_primary_addr()
3053 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_SET_PRIMARY) in sctp_setsockopt_peer_primary_addr()
3056 if (!sctp_state(asoc, ESTABLISHED)) in sctp_setsockopt_peer_primary_addr()
3060 if (!af) in sctp_setsockopt_peer_primary_addr()
3063 if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL)) in sctp_setsockopt_peer_primary_addr()
3066 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) in sctp_setsockopt_peer_primary_addr()
3072 if (!chunk) in sctp_setsockopt_peer_primary_addr()
3087 if (optlen != sizeof(struct sctp_setadaptation)) in sctp_setsockopt_adaptation_layer()
3089 if (copy_from_user(&adaptation, optval, optlen)) in sctp_setsockopt_adaptation_layer()
3118 if (optlen != sizeof(struct sctp_assoc_value)) in sctp_setsockopt_context()
3120 if (copy_from_user(¶ms, optval, optlen)) in sctp_setsockopt_context()
3125 if (params.assoc_id != 0) { in sctp_setsockopt_context()
3127 if (!asoc) in sctp_setsockopt_context()
3140 * This options will at a minimum specify if the implementation is doing
3144 * may allow you to turn this value on or off. If so, when turned off,
3167 if (optlen != sizeof(int)) in sctp_setsockopt_fragment_interleave()
3169 if (get_user(val, (int __user *)optval)) in sctp_setsockopt_fragment_interleave()
3186 * point. Note also that the call will fail if the user attempts to set
3200 if (optlen != sizeof(u32)) in sctp_setsockopt_partial_delivery_point()
3202 if (get_user(val, (int __user *)optval)) in sctp_setsockopt_partial_delivery_point()
3208 if (val > (sk->sk_rcvbuf >> 1)) in sctp_setsockopt_partial_delivery_point()
3237 if (optlen == sizeof(int)) { in sctp_setsockopt_maxburst()
3240 if (copy_from_user(&val, optval, optlen)) in sctp_setsockopt_maxburst()
3242 } else if (optlen == sizeof(struct sctp_assoc_value)) { in sctp_setsockopt_maxburst()
3243 if (copy_from_user(¶ms, optval, optlen)) in sctp_setsockopt_maxburst()
3252 if (assoc_id != 0) { in sctp_setsockopt_maxburst()
3254 if (!asoc) in sctp_setsockopt_maxburst()
3276 if (!sctp_auth_enable) in sctp_setsockopt_auth_chunk()
3279 if (optlen != sizeof(struct sctp_authchunk)) in sctp_setsockopt_auth_chunk()
3281 if (copy_from_user(&val, optval, optlen)) in sctp_setsockopt_auth_chunk()
3310 if (!sctp_auth_enable) in sctp_setsockopt_hmac_ident()
3313 if (optlen < sizeof(struct sctp_hmacalgo)) in sctp_setsockopt_hmac_ident()
3317 if (IS_ERR(hmacs)) in sctp_setsockopt_hmac_ident()
3321 if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || in sctp_setsockopt_hmac_ident()
3347 if (!sctp_auth_enable) in sctp_setsockopt_auth_key()
3350 if (optlen <= sizeof(struct sctp_authkey)) in sctp_setsockopt_auth_key()
3354 if (IS_ERR(authkey)) in sctp_setsockopt_auth_key()
3357 if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) { in sctp_setsockopt_auth_key()
3363 if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { in sctp_setsockopt_auth_key()
3387 if (!sctp_auth_enable) in sctp_setsockopt_active_key()
3390 if (optlen != sizeof(struct sctp_authkeyid)) in sctp_setsockopt_active_key()
3392 if (copy_from_user(&val, optval, optlen)) in sctp_setsockopt_active_key()
3396 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_active_key()
3415 if (!sctp_auth_enable) in sctp_setsockopt_del_key()
3418 if (optlen != sizeof(struct sctp_authkeyid)) in sctp_setsockopt_del_key()
3420 if (copy_from_user(&val, optval, optlen)) in sctp_setsockopt_del_key()
3424 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_del_key()
3452 if (optlen < sizeof(int)) in sctp_setsockopt_auto_asconf()
3454 if (get_user(val, (int __user *)optval)) in sctp_setsockopt_auto_asconf()
3456 if (!sctp_is_ep_boundall(sk) && val) in sctp_setsockopt_auto_asconf()
3458 if ((val && sp->do_auto_asconf) || (!val && !sp->do_auto_asconf)) in sctp_setsockopt_auto_asconf()
3461 if (val == 0 && sp->do_auto_asconf) { in sctp_setsockopt_auto_asconf()
3464 } else if (val && !sp->do_auto_asconf) { in sctp_setsockopt_auto_asconf()
3506 if (level != SOL_SCTP) { in sctp_setsockopt()
3662 if (!af || addr_len < af->sockaddr_len) { in sctp_connect()
3702 if (!sctp_style(sk, TCP)) { in sctp_accept()
3707 if (!sctp_sstate(sk, LISTENING)) { in sctp_accept()
3715 if (error) in sctp_accept()
3724 if (!newsk) { in sctp_accept()
3751 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) in sctp_ioctl()
3760 if (skb != NULL) { in sctp_ioctl()
3858 /* If enabled no SCTP message fragmentation will be performed. in sctp_init_sock()
3888 /* Create a per socket endpoint structure. Even if we in sctp_init_sock()
3893 if (!ep) in sctp_init_sock()
3904 if (sctp_default_auto_asconf) { in sctp_init_sock()
3924 if (sp->do_auto_asconf) { in sctp_destroy_sock()
3956 if (!sctp_style(sk, TCP)) in sctp_shutdown()
3959 if (how & SEND_SHUTDOWN) { in sctp_shutdown()
3961 if (!list_empty(&ep->asocs)) { in sctp_shutdown()
3986 if (len < sizeof(status)) { in sctp_getsockopt_sctp_status()
3992 if (copy_from_user(&status, optval, len)) { in sctp_getsockopt_sctp_status()
3999 if (!asoc) { in sctp_getsockopt_sctp_status()
4027 if (status.sstat_primary.spinfo_state == SCTP_UNKNOWN) in sctp_getsockopt_sctp_status()
4030 if (put_user(len, optlen)) { in sctp_getsockopt_sctp_status()
4039 if (copy_to_user(optval, &status, len)) { in sctp_getsockopt_sctp_status()
4064 if (len < sizeof(pinfo)) { in sctp_getsockopt_peer_addr_info()
4070 if (copy_from_user(&pinfo, optval, len)) { in sctp_getsockopt_peer_addr_info()
4077 if (!transport) in sctp_getsockopt_peer_addr_info()
4087 if (pinfo.spinfo_state == SCTP_UNKNOWN) in sctp_getsockopt_peer_addr_info()
4090 if (put_user(len, optlen)) { in sctp_getsockopt_peer_addr_info()
4095 if (copy_to_user(optval, &pinfo, len)) { in sctp_getsockopt_peer_addr_info()
4106 * This option is a on/off flag. If enabled no SCTP message
4107 * fragmentation will be performed. Instead if a message being sent
4116 if (len < sizeof(int)) in sctp_getsockopt_disable_fragments()
4121 if (put_user(len, optlen)) in sctp_getsockopt_disable_fragments()
4123 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_disable_fragments()
4136 if (len < sizeof(struct sctp_event_subscribe)) in sctp_getsockopt_events()
4139 if (put_user(len, optlen)) in sctp_getsockopt_events()
4141 if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len)) in sctp_getsockopt_events()
4160 if (sctp_style(sk, TCP)) in sctp_getsockopt_autoclose()
4162 if (len < sizeof(int)) in sctp_getsockopt_autoclose()
4165 if (put_user(len, optlen)) in sctp_getsockopt_autoclose()
4167 if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int))) in sctp_getsockopt_autoclose()
4184 if (!sctp_style(sk, UDP)) in sctp_do_peeloff()
4189 if (err < 0) in sctp_do_peeloff()
4217 if (len < sizeof(sctp_peeloff_arg_t)) in sctp_getsockopt_peeloff()
4220 if (copy_from_user(&peeloff, optval, len)) in sctp_getsockopt_peeloff()
4224 if (!asoc) { in sctp_getsockopt_peeloff()
4232 if (retval < 0) in sctp_getsockopt_peeloff()
4237 if (retval < 0) { in sctp_getsockopt_peeloff()
4247 if (put_user(len, optlen)) in sctp_getsockopt_peeloff()
4249 if (copy_to_user(optval, &peeloff, len)) in sctp_getsockopt_peeloff()
4280 * in milliseconds. If a value of zero
4285 * considered unreachable. If a value of zero
4290 * Note that if the spp_address field is empty
4297 * association if the spp_address field is empty. Note
4298 * also, that if delayed sack is enabled and this
4307 * specified address. Note that if the address
4312 * speicifed address. Note that if the address
4325 * if the address feild is empty then all addresses
4330 * if the address feild is empty then all addresses
4339 * that if spp_address is empty then all addresses will
4343 * off delayed sack. If the spp_address field is blank then
4357 if (len < sizeof(struct sctp_paddrparams)) in sctp_getsockopt_peer_addr_params()
4360 if (copy_from_user(¶ms, optval, len)) in sctp_getsockopt_peer_addr_params()
4363 /* If an address other than INADDR_ANY is specified, and in sctp_getsockopt_peer_addr_params()
4366 if (!sctp_is_any(sk, ( union sctp_addr *)¶ms.spp_address)) { in sctp_getsockopt_peer_addr_params()
4369 if (!trans) { in sctp_getsockopt_peer_addr_params()
4375 /* Get association, if assoc_id != 0 and the socket is a one in sctp_getsockopt_peer_addr_params()
4380 if (!asoc && params.spp_assoc_id && sctp_style(sk, UDP)) { in sctp_getsockopt_peer_addr_params()
4385 if (trans) { in sctp_getsockopt_peer_addr_params()
4394 } else if (asoc) { in sctp_getsockopt_peer_addr_params()
4414 if (copy_to_user(optval, ¶ms, len)) in sctp_getsockopt_peer_addr_params()
4417 if (put_user(len, optlen)) in sctp_getsockopt_peer_addr_params()
4429 * Changing the frequency to 1 disables the delayed sack algorithm. If
4431 * values. If the assoc_id field is non-zero, then the set or get
4433 * assoc_id field is ignored by the one to one model). Note that if
4444 * is performing an action upon. Note that if this field's value is
4466 if (len >= sizeof(struct sctp_sack_info)) { in sctp_getsockopt_delayed_ack()
4469 if (copy_from_user(¶ms, optval, len)) in sctp_getsockopt_delayed_ack()
4471 } else if (len == sizeof(struct sctp_assoc_value)) { in sctp_getsockopt_delayed_ack()
4474 if (copy_from_user(¶ms, optval, len)) in sctp_getsockopt_delayed_ack()
4479 /* Get association, if sack_assoc_id != 0 and the socket is a one in sctp_getsockopt_delayed_ack()
4484 if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_delayed_ack()
4487 if (asoc) { in sctp_getsockopt_delayed_ack()
4489 if (asoc->param_flags & SPP_SACKDELAY_ENABLE) { in sctp_getsockopt_delayed_ack()
4500 if (sp->param_flags & SPP_SACKDELAY_ENABLE) { in sctp_getsockopt_delayed_ack()
4509 if (copy_to_user(optval, ¶ms, len)) in sctp_getsockopt_delayed_ack()
4512 if (put_user(len, optlen)) in sctp_getsockopt_delayed_ack()
4531 if (len < sizeof(struct sctp_initmsg)) in sctp_getsockopt_initmsg()
4534 if (put_user(len, optlen)) in sctp_getsockopt_initmsg()
4536 if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len)) in sctp_getsockopt_initmsg()
4556 if (len < sizeof(struct sctp_getaddrs)) in sctp_getsockopt_peer_addrs()
4559 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) in sctp_getsockopt_peer_addrs()
4564 if (!asoc) in sctp_getsockopt_peer_addrs()
4575 if (space_left < addrlen) in sctp_getsockopt_peer_addrs()
4577 if (copy_to_user(to, &temp, addrlen)) in sctp_getsockopt_peer_addrs()
4584 if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) in sctp_getsockopt_peer_addrs()
4587 if (put_user(bytes_copied, optlen)) in sctp_getsockopt_peer_addrs()
4603 if (!addr->valid) in sctp_copy_laddrs()
4606 if ((PF_INET == sk->sk_family) && in sctp_copy_laddrs()
4609 if ((PF_INET6 == sk->sk_family) && in sctp_copy_laddrs()
4614 if (!temp.v4.sin_port) in sctp_copy_laddrs()
4620 if (space_left < addrlen) { in sctp_copy_laddrs()
4655 if (len < sizeof(struct sctp_getaddrs)) in sctp_getsockopt_local_addrs()
4658 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) in sctp_getsockopt_local_addrs()
4663 * If the id field is set to the value '0' then the locally bound in sctp_getsockopt_local_addrs()
4667 if (0 == getaddrs.assoc_id) { in sctp_getsockopt_local_addrs()
4671 if (!asoc) in sctp_getsockopt_local_addrs()
4680 if (!addrs) in sctp_getsockopt_local_addrs()
4683 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid in sctp_getsockopt_local_addrs()
4686 if (sctp_list_single_entry(&bp->address_list)) { in sctp_getsockopt_local_addrs()
4689 if (sctp_is_any(sk, &addr->a)) { in sctp_getsockopt_local_addrs()
4692 if (cnt < 0) { in sctp_getsockopt_local_addrs()
4709 if (space_left < addrlen) { in sctp_getsockopt_local_addrs()
4721 if (copy_to_user(to, addrs, bytes_copied)) { in sctp_getsockopt_local_addrs()
4725 if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) { in sctp_getsockopt_local_addrs()
4729 if (put_user(bytes_copied, optlen)) in sctp_getsockopt_local_addrs()
4749 if (len < sizeof(struct sctp_prim)) in sctp_getsockopt_primary_addr()
4754 if (copy_from_user(&prim, optval, len)) in sctp_getsockopt_primary_addr()
4758 if (!asoc) in sctp_getsockopt_primary_addr()
4761 if (!asoc->peer.primary_path) in sctp_getsockopt_primary_addr()
4770 if (put_user(len, optlen)) in sctp_getsockopt_primary_addr()
4772 if (copy_to_user(optval, &prim, len)) in sctp_getsockopt_primary_addr()
4789 if (len < sizeof(struct sctp_setadaptation)) in sctp_getsockopt_adaptation_layer()
4796 if (put_user(len, optlen)) in sctp_getsockopt_adaptation_layer()
4798 if (copy_to_user(optval, &adaptation, len)) in sctp_getsockopt_adaptation_layer()
4819 * to this call if the caller is using the UDP model.
4831 if (len < sizeof(struct sctp_sndrcvinfo)) in sctp_getsockopt_default_send_param()
4836 if (copy_from_user(&info, optval, len)) in sctp_getsockopt_default_send_param()
4840 if (!asoc && info.sinfo_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_default_send_param()
4843 if (asoc) { in sctp_getsockopt_default_send_param()
4857 if (put_user(len, optlen)) in sctp_getsockopt_default_send_param()
4859 if (copy_to_user(optval, &info, len)) in sctp_getsockopt_default_send_param()
4880 if (len < sizeof(int)) in sctp_getsockopt_nodelay()
4885 if (put_user(len, optlen)) in sctp_getsockopt_nodelay()
4887 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_nodelay()
4910 if (len < sizeof (struct sctp_rtoinfo)) in sctp_getsockopt_rtoinfo()
4915 if (copy_from_user(&rtoinfo, optval, len)) in sctp_getsockopt_rtoinfo()
4920 if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_rtoinfo()
4924 if (asoc) { in sctp_getsockopt_rtoinfo()
4937 if (put_user(len, optlen)) in sctp_getsockopt_rtoinfo()
4940 if (copy_to_user(optval, &rtoinfo, len)) in sctp_getsockopt_rtoinfo()
4952 * Returns an error if the new association retransmission value is
4967 if (len < sizeof (struct sctp_assocparams)) in sctp_getsockopt_associnfo()
4972 if (copy_from_user(&assocparams, optval, len)) in sctp_getsockopt_associnfo()
4977 if (!asoc && assocparams.sasoc_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_associnfo()
4981 if (asoc) { in sctp_getsockopt_associnfo()
5009 if (put_user(len, optlen)) in sctp_getsockopt_associnfo()
5012 if (copy_to_user(optval, &assocparams, len)) in sctp_getsockopt_associnfo()
5022 * addresses. If this option is turned on and the socket is type
5024 * If this option is turned off, then no mapping will be done of V4
5034 if (len < sizeof(int)) in sctp_getsockopt_mappedv4()
5039 if (put_user(len, optlen)) in sctp_getsockopt_mappedv4()
5041 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_mappedv4()
5058 if (len < sizeof(struct sctp_assoc_value)) in sctp_getsockopt_context()
5063 if (copy_from_user(¶ms, optval, len)) in sctp_getsockopt_context()
5068 if (params.assoc_id != 0) { in sctp_getsockopt_context()
5070 if (!asoc) in sctp_getsockopt_context()
5077 if (put_user(len, optlen)) in sctp_getsockopt_context()
5079 if (copy_to_user(optval, ¶ms, len)) in sctp_getsockopt_context()
5088 * SCTP DATA chunk. If a message is larger than this size it will be
5107 * association the user is performing an action upon. Note that if
5118 if (len == sizeof(int)) { in sctp_getsockopt_maxseg()
5122 } else if (len >= sizeof(struct sctp_assoc_value)) { in sctp_getsockopt_maxseg()
5124 if (copy_from_user(¶ms, optval, sizeof(params))) in sctp_getsockopt_maxseg()
5130 if (!asoc && params.assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_maxseg()
5133 if (asoc) in sctp_getsockopt_maxseg()
5138 if (put_user(len, optlen)) in sctp_getsockopt_maxseg()
5140 if (len == sizeof(int)) { in sctp_getsockopt_maxseg()
5141 if (copy_to_user(optval, ¶ms.assoc_value, len)) in sctp_getsockopt_maxseg()
5144 if (copy_to_user(optval, ¶ms, len)) in sctp_getsockopt_maxseg()
5160 if (len < sizeof(int)) in sctp_getsockopt_fragment_interleave()
5166 if (put_user(len, optlen)) in sctp_getsockopt_fragment_interleave()
5168 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_fragment_interleave()
5184 if (len < sizeof(u32)) in sctp_getsockopt_partial_delivery_point()
5190 if (put_user(len, optlen)) in sctp_getsockopt_partial_delivery_point()
5192 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_partial_delivery_point()
5210 if (len == sizeof(int)) { in sctp_getsockopt_maxburst()
5214 } else if (len >= sizeof(struct sctp_assoc_value)) { in sctp_getsockopt_maxburst()
5216 if (copy_from_user(¶ms, optval, len)) in sctp_getsockopt_maxburst()
5223 if (params.assoc_id != 0) { in sctp_getsockopt_maxburst()
5225 if (!asoc) in sctp_getsockopt_maxburst()
5231 if (len == sizeof(int)) { in sctp_getsockopt_maxburst()
5232 if (copy_to_user(optval, ¶ms.assoc_value, len)) in sctp_getsockopt_maxburst()
5235 if (copy_to_user(optval, ¶ms, len)) in sctp_getsockopt_maxburst()
5251 if (!sctp_auth_enable) in sctp_getsockopt_hmac_ident()
5257 if (len < sizeof(struct sctp_hmacalgo) + data_len) in sctp_getsockopt_hmac_ident()
5263 if (put_user(len, optlen)) in sctp_getsockopt_hmac_ident()
5265 if (put_user(num_idents, &p->shmac_num_idents)) in sctp_getsockopt_hmac_ident()
5267 if (copy_to_user(p->shmac_idents, hmacs->hmac_ids, data_len)) in sctp_getsockopt_hmac_ident()
5278 if (!sctp_auth_enable) in sctp_getsockopt_active_key()
5281 if (len < sizeof(struct sctp_authkeyid)) in sctp_getsockopt_active_key()
5283 if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid))) in sctp_getsockopt_active_key()
5287 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_active_key()
5290 if (asoc) in sctp_getsockopt_active_key()
5296 if (put_user(len, optlen)) in sctp_getsockopt_active_key()
5298 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_active_key()
5314 if (!sctp_auth_enable) in sctp_getsockopt_peer_auth_chunks()
5317 if (len < sizeof(struct sctp_authchunks)) in sctp_getsockopt_peer_auth_chunks()
5320 if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) in sctp_getsockopt_peer_auth_chunks()
5325 if (!asoc) in sctp_getsockopt_peer_auth_chunks()
5329 if (!ch) in sctp_getsockopt_peer_auth_chunks()
5332 /* See if the user provided enough room for all the data */ in sctp_getsockopt_peer_auth_chunks()
5334 if (len < num_chunks) in sctp_getsockopt_peer_auth_chunks()
5337 if (copy_to_user(to, ch->chunks, num_chunks)) in sctp_getsockopt_peer_auth_chunks()
5341 if (put_user(len, optlen)) return -EFAULT; in sctp_getsockopt_peer_auth_chunks()
5342 if (put_user(num_chunks, &p->gauth_number_of_chunks)) in sctp_getsockopt_peer_auth_chunks()
5357 if (!sctp_auth_enable) in sctp_getsockopt_local_auth_chunks()
5360 if (len < sizeof(struct sctp_authchunks)) in sctp_getsockopt_local_auth_chunks()
5363 if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) in sctp_getsockopt_local_auth_chunks()
5368 if (!asoc && val.gauth_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_local_auth_chunks()
5371 if (asoc) in sctp_getsockopt_local_auth_chunks()
5376 if (!ch) in sctp_getsockopt_local_auth_chunks()
5380 if (len < sizeof(struct sctp_authchunks) + num_chunks) in sctp_getsockopt_local_auth_chunks()
5383 if (copy_to_user(to, ch->chunks, num_chunks)) in sctp_getsockopt_local_auth_chunks()
5387 if (put_user(len, optlen)) in sctp_getsockopt_local_auth_chunks()
5389 if (put_user(num_chunks, &p->gauth_number_of_chunks)) in sctp_getsockopt_local_auth_chunks()
5407 if (sctp_style(sk, TCP)) in sctp_getsockopt_assoc_number()
5410 if (len < sizeof(u32)) in sctp_getsockopt_assoc_number()
5419 if (put_user(len, optlen)) in sctp_getsockopt_assoc_number()
5421 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_assoc_number()
5436 if (len < sizeof(int)) in sctp_getsockopt_auto_asconf()
5440 if (sctp_sk(sk)->do_auto_asconf && sctp_is_ep_boundall(sk)) in sctp_getsockopt_auto_asconf()
5442 if (put_user(len, optlen)) in sctp_getsockopt_auto_asconf()
5444 if (copy_to_user(optval, &val, len)) in sctp_getsockopt_auto_asconf()
5464 if (sctp_style(sk, TCP)) in sctp_getsockopt_assoc_ids()
5467 if (len < sizeof(struct sctp_assoc_ids)) in sctp_getsockopt_assoc_ids()
5474 if (len < sizeof(struct sctp_assoc_ids) + sizeof(sctp_assoc_t) * num) in sctp_getsockopt_assoc_ids()
5480 if (unlikely(!ids)) in sctp_getsockopt_assoc_ids()
5489 if (put_user(len, optlen) || copy_to_user(optval, ids, len)) { in sctp_getsockopt_assoc_ids()
5513 if (level != SOL_SCTP) { in sctp_getsockopt()
5520 if (get_user(len, optlen)) in sctp_getsockopt()
5655 /* Check if port is acceptable. Possibly find first available port.
5683 if (snum == 0) { in sctp_get_port_local()
5694 if ((rover < low) || (rover > high)) in sctp_get_port_local()
5696 if (inet_is_reserved_local_port(rover)) in sctp_get_port_local()
5702 if (pp->port == rover) in sctp_get_port_local()
5711 if (remaining <= 0) in sctp_get_port_local()
5721 * that it is not being used. If it is used, we will in sctp_get_port_local()
5729 if (pp->port == snum) in sctp_get_port_local()
5736 if (!hlist_empty(&pp->owner)) { in sctp_get_port_local()
5746 if (pp->fastreuse && sk->sk_reuse && in sctp_get_port_local()
5756 * the socket sk. If we find a match, then that means in sctp_get_port_local()
5764 if (sk == sk2 || in sctp_get_port_local()
5769 if (sctp_bind_addr_conflict(&ep2->base.bind_addr, addr, in sctp_get_port_local()
5778 /* If there was a hash table miss, create a new port. */ in sctp_get_port_local()
5780 if (!pp && !(pp = sctp_bucket_create(head, snum))) in sctp_get_port_local()
5784 * if sk->sk_reuse is too (that is, if the caller requested in sctp_get_port_local()
5787 if (hlist_empty(&pp->owner)) { in sctp_get_port_local()
5788 if (sk->sk_reuse && sk->sk_state != SCTP_SS_LISTENING) in sctp_get_port_local()
5792 } else if (pp->fastreuse && in sctp_get_port_local()
5801 if (!sctp_sk(sk)->bind_hash) { in sctp_get_port_local()
5816 /* Assign a 'snum' port to the socket. If snum == 0, an ephemeral
5829 /* Note: sk->sk_num gets filled in if ephemeral port request. */ in sctp_get_port()
5845 if (!sctp_sk(sk)->hmac && sctp_hmac_alg) { in sctp_listen_start()
5847 if (IS_ERR(tfm)) { in sctp_listen_start()
5848 if (net_ratelimit()) { in sctp_listen_start()
5858 * If a bind() or sctp_bindx() is not called prior to a listen() in sctp_listen_start()
5869 if (!ep->base.bind_addr.port) { in sctp_listen_start()
5870 if (sctp_autobind(sk)) in sctp_listen_start()
5873 if (sctp_get_port(sk, inet_sk(sk)->inet_num)) { in sctp_listen_start()
5904 if (unlikely(backlog < 0)) in sctp_inet_listen()
5910 if (sctp_style(sk, UDP_HIGH_BANDWIDTH)) in sctp_inet_listen()
5913 if (sock->state != SS_UNCONNECTED) in sctp_inet_listen()
5916 /* If backlog is zero, disable listening. */ in sctp_inet_listen()
5917 if (!backlog) { in sctp_inet_listen()
5918 if (sctp_sstate(sk, CLOSED)) in sctp_inet_listen()
5924 if (sk->sk_reuse) in sctp_inet_listen()
5929 /* If we are already listening, just update the backlog */ in sctp_inet_listen()
5930 if (sctp_sstate(sk, LISTENING)) in sctp_inet_listen()
5934 if (err) in sctp_inet_listen()
5968 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) in sctp_poll()
5975 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) in sctp_poll()
5977 if (sk->sk_shutdown & RCV_SHUTDOWN) in sctp_poll()
5979 if (sk->sk_shutdown == SHUTDOWN_MASK) in sctp_poll()
5983 if (!skb_queue_empty(&sk->sk_receive_queue)) in sctp_poll()
5987 if (!sctp_style(sk, UDP) && sctp_sstate(sk, CLOSED)) in sctp_poll()
5991 if (sctp_writeable(sk)) { in sctp_poll()
6003 if (sctp_writeable(sk)) in sctp_poll()
6019 if (pp) { in sctp_bucket_create()
6032 if (pp && hlist_empty(&pp->owner)) { in sctp_bucket_destroy()
6131 if (!CMSG_OK(my_msg, cmsg)) in sctp_msghdr_parse()
6135 if (cmsg->cmsg_level != IPPROTO_SCTP) in sctp_msghdr_parse()
6154 if (cmsg->cmsg_len != in sctp_msghdr_parse()
6172 if (cmsg->cmsg_len != in sctp_msghdr_parse()
6180 if (cmsgs->info->sinfo_flags & in sctp_msghdr_parse()
6207 if (error) in sctp_wait_for_packet()
6210 if (!skb_queue_empty(&sk->sk_receive_queue)) in sctp_wait_for_packet()
6214 if (sk->sk_shutdown & RCV_SHUTDOWN) in sctp_wait_for_packet()
6217 /* Sequenced packets can come disconnected. If so we report the in sctp_wait_for_packet()
6223 if (list_empty(&sctp_sk(sk)->ep->asocs) && !sctp_sstate(sk, LISTENING)) in sctp_wait_for_packet()
6227 if (signal_pending(current)) in sctp_wait_for_packet()
6231 * anyway. Note: This may cause odd behaviors if the message in sctp_wait_for_packet()
6276 if (flags & MSG_PEEK) { in sctp_skb_recv_datagram()
6279 if (skb) in sctp_skb_recv_datagram()
6286 if (skb) in sctp_skb_recv_datagram()
6291 if (error) in sctp_skb_recv_datagram()
6294 if (sk->sk_shutdown & RCV_SHUTDOWN) in sctp_skb_recv_datagram()
6299 if (!timeo) in sctp_skb_recv_datagram()
6310 /* If sndbuf has changed, wake up per association sndbuf waiters. */
6316 if ((sctp_wspace(asoc) > 0) && sock) { in __sctp_write_space()
6317 if (waitqueue_active(&asoc->wait)) in __sctp_write_space()
6320 if (sctp_writeable(sk)) { in __sctp_write_space()
6323 if (wq && waitqueue_active(wq)) in __sctp_write_space()
6330 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) in __sctp_write_space()
6407 if (!*timeo_p) in sctp_wait_for_sndbuf()
6409 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || in sctp_wait_for_sndbuf()
6412 if (signal_pending(current)) in sctp_wait_for_sndbuf()
6414 if (msg_len <= sctp_wspace(asoc)) in sctp_wait_for_sndbuf()
6455 if (wq_has_sleeper(wq)) in sctp_data_ready()
6462 /* If socket sndbuf has changed, wake up all per association waiters. */
6489 if (amt < 0) in sctp_writeable()
6494 /* Wait for an association to go into ESTABLISHED state. If timeout is 0,
6513 if (!*timeo_p) in sctp_wait_for_connect()
6515 if (sk->sk_shutdown & RCV_SHUTDOWN) in sctp_wait_for_connect()
6517 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || in sctp_wait_for_connect()
6520 if (signal_pending(current)) in sctp_wait_for_connect()
6523 if (sctp_state(asoc, ESTABLISHED)) in sctp_wait_for_connect()
6545 if (asoc->init_err_counter + 1 > asoc->max_init_attempts) in sctp_wait_for_connect()
6573 if (list_empty(&ep->asocs)) { in sctp_wait_for_accept()
6580 if (!sctp_sstate(sk, LISTENING)) in sctp_wait_for_accept()
6584 if (!list_empty(&ep->asocs)) in sctp_wait_for_accept()
6588 if (signal_pending(current)) in sctp_wait_for_accept()
6592 if (!timeo) in sctp_wait_for_accept()
6607 if (list_empty(&sctp_sk(sk)->ep->asocs)) in sctp_wait_for_close()
6621 if (!skb->data_len) in sctp_skb_set_owner_r_frag()
6696 if (oldsp->do_auto_asconf) { in sctp_sock_migrate()
6731 if (event->asoc == assoc) { in sctp_sock_migrate()
6747 if (atomic_read(&sctp_sk(oldsk)->pd_mode)) { in sctp_sock_migrate()
6751 if (assoc->ulpq.pd_mode) { in sctp_sock_migrate()
6761 if (event->asoc == assoc) { in sctp_sock_migrate()
6771 if (assoc->ulpq.pd_mode) in sctp_sock_migrate()
6800 /* If the association on the newsk is already closed before accept() in sctp_sock_migrate()
6803 if (sctp_state(assoc, CLOSED) && sctp_style(newsk, TCP)) in sctp_sock_migrate()
6842 #if IS_ENABLED(CONFIG_IPV6)