From 0577772720a4ecb050a230f75346f90b246e93c8 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 9 Jan 2017 14:47:04 +0100 Subject: Update to FreeBSD head 2017-01-09 Git mirror commit 1f8e4a995a6ede4bdb24e6d335ccda2bdb0175ab. --- freebsd/sys/netinet/sctp_usrreq.c | 124 +++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 48 deletions(-) (limited to 'freebsd/sys/netinet/sctp_usrreq.c') diff --git a/freebsd/sys/netinet/sctp_usrreq.c b/freebsd/sys/netinet/sctp_usrreq.c index e3e398d4..ebaa58d4 100644 --- a/freebsd/sys/netinet/sctp_usrreq.c +++ b/freebsd/sys/netinet/sctp_usrreq.c @@ -72,9 +72,9 @@ sctp_init(void) * Allow a user to take no more than 1/2 the number of clusters or * the SB_MAX whichever is smaller for the send window. */ - sb_max_adj = (u_long)((u_quad_t) (SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES)); + sb_max_adj = (u_long)((u_quad_t)(SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES)); SCTP_BASE_SYSCTL(sctp_sendspace) = min(sb_max_adj, - (((uint32_t) nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT)); + (((uint32_t)nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT)); /* * Now for the recv window, should we take the same amount? or * should I do 1/2 the SB_MAX instead in the SB_MAX min above. For @@ -136,7 +136,7 @@ sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint16_t nxtsz) sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU, chk->whoTo->flight_size, chk->book_size, - (uint32_t) (uintptr_t) chk->whoTo, + (uint32_t)(uintptr_t)chk->whoTo, chk->rec.data.tsn); } /* Clear any time so NO RTT is being done */ @@ -977,8 +977,10 @@ sctp_shutdown(struct socket *so) } } sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, netp); - /* XXX: Why do this in the case where we have still data - * queued? */ + /* + * XXX: Why do this in the case where we have still data + * queued? + */ sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED); SCTP_TCB_UNLOCK(stcb); SCTP_INP_RUNLOCK(inp); @@ -1481,7 +1483,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_7); goto out_now; } - a_id = (sctp_assoc_t *) optval; + a_id = (sctp_assoc_t *)optval; *a_id = sctp_get_associd(stcb); /* initialize authentication parameters for the assoc */ @@ -1813,8 +1815,10 @@ flags_out: } SCTP_TCB_UNLOCK(stcb); } else { - /* Can't get stream value without - * association */ + /* + * Can't get stream value without + * association + */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } @@ -2178,7 +2182,7 @@ flags_out: SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); /* FIXME MT: change to sctp_assoc_value? */ - SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) * value); + SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value); if (stcb) { size = 0; @@ -2208,7 +2212,7 @@ flags_out: } } SCTP_TCB_UNLOCK(stcb); - *value = (uint32_t) size; + *value = (uint32_t)size; *optsize = sizeof(uint32_t); } else { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); @@ -2934,7 +2938,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); - sac->gauth_number_of_chunks = (uint32_t) size; + sac->gauth_number_of_chunks = (uint32_t)size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_TCB_UNLOCK(stcb); @@ -2953,7 +2957,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); - sac->gauth_number_of_chunks = (uint32_t) size; + sac->gauth_number_of_chunks = (uint32_t)size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_INP_RUNLOCK(inp); @@ -2984,7 +2988,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); - sac->gauth_number_of_chunks = (uint32_t) size; + sac->gauth_number_of_chunks = (uint32_t)size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_TCB_UNLOCK(stcb); @@ -3590,14 +3594,14 @@ flags_out: SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - av->assoc_value = (uint32_t) stcb->asoc.local_strreset_support; + av->assoc_value = (uint32_t)stcb->asoc.local_strreset_support; SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || (av->assoc_id == SCTP_FUTURE_ASSOC)) { SCTP_INP_RLOCK(inp); - av->assoc_value = (uint32_t) inp->local_strreset_support; + av->assoc_value = (uint32_t)inp->local_strreset_support; SCTP_INP_RUNLOCK(inp); } else { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -3889,10 +3893,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS))) { inp->idata_supported = 1; } else { - /* Must have Frag + /* + * Must have Frag * interleave and * stream interleave - * on */ + * on + */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } @@ -4103,8 +4109,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } SCTP_INP_RUNLOCK(inp); } else { - /* Can't set stream value without - * association */ + /* + * Can't set stream value without + * association + */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } @@ -4270,7 +4278,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, * insert/replace it */ if (size > 0) { - key = sctp_set_key(sca->sca_key, (uint32_t) size); + key = sctp_set_key(sca->sca_key, (uint32_t)size); if (key == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM); error = ENOMEM; @@ -4307,7 +4315,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, * insert/replace it */ if (size > 0) { - key = sctp_set_key(sca->sca_key, (uint32_t) size); + key = sctp_set_key(sca->sca_key, (uint32_t)size); if (key == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM); error = ENOMEM; @@ -4334,15 +4342,17 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { SCTP_TCB_LOCK(stcb); shared_keys = &stcb->asoc.shared_keys; - /* clear the cached keys for - * this key id */ + /* + * clear the cached keys for + * this key id + */ sctp_clear_cachedkeys(stcb, sca->sca_keynumber); /* * create the new shared key * and insert/replace it */ if (size > 0) { - key = sctp_set_key(sca->sca_key, (uint32_t) size); + key = sctp_set_key(sca->sca_key, (uint32_t)size); if (key == NULL) { SCTP_TCB_UNLOCK(stcb); continue; @@ -4378,7 +4388,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, error = EINVAL; break; } - hmaclist = sctp_alloc_hmaclist((uint16_t) shmac->shmac_number_of_idents); + hmaclist = sctp_alloc_hmaclist((uint16_t)shmac->shmac_number_of_idents); if (hmaclist == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM); error = ENOMEM; @@ -4549,7 +4559,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value; + stcb->asoc.local_strreset_support = (uint8_t)av->assoc_value; SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || @@ -4557,7 +4567,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, (av->assoc_id == SCTP_FUTURE_ASSOC) || (av->assoc_id == SCTP_ALL_ASSOC)) { SCTP_INP_WLOCK(inp); - inp->local_strreset_support = (uint8_t) av->assoc_value; + inp->local_strreset_support = (uint8_t)av->assoc_value; SCTP_INP_WUNLOCK(inp); } if ((av->assoc_id == SCTP_CURRENT_ASSOC) || @@ -4565,7 +4575,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_INP_RLOCK(inp); LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { SCTP_TCB_LOCK(stcb); - stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value; + stcb->asoc.local_strreset_support = (uint8_t)av->assoc_value; SCTP_TCB_UNLOCK(stcb); } SCTP_INP_RUNLOCK(inp); @@ -4734,8 +4744,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, int cnt; addstream |= 2; - /* We allocate inside - * sctp_send_str_reset_req() */ + /* + * We allocate inside + * sctp_send_str_reset_req() + */ add_i_strmcnt = stradd->sas_instrms; cnt = add_i_strmcnt; cnt += stcb->asoc.streamincnt; @@ -4762,7 +4774,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, uint32_t *value; SCTP_CHECK_AND_CAST(value, optval, uint32_t, optsize); - SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) * value); + SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value); if (stcb == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); error = ENOENT; @@ -4783,8 +4795,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_TCB_UNLOCK(stcb); break; } - /* Is there any data pending in the send or sent - * queues? */ + /* + * Is there any data pending in the send or sent + * queues? + */ if (!TAILQ_EMPTY(&stcb->asoc.send_queue) || !TAILQ_EMPTY(&stcb->asoc.sent_queue)) { busy_out: @@ -4930,8 +4944,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || (av->assoc_id == SCTP_FUTURE_ASSOC)) { SCTP_INP_WLOCK(inp); - /* FIXME MT: I think this is not in - * tune with the API ID */ + /* + * FIXME MT: I think this is not in + * tune with the API ID + */ if (av->assoc_value) { inp->sctp_frag_point = (av->assoc_value + ovh); } else { @@ -5074,8 +5090,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } SCTP_TCB_UNLOCK(stcb); } - /* Send up the sender dry event only for 1-to-1 - * style sockets. */ + /* + * Send up the sender dry event only for 1-to-1 + * style sockets. + */ if (events->sctp_sender_dry_event) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { @@ -5786,8 +5804,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, goto out_of_it; } if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) { - /* Must validate the ifa found is in - * our ep */ + /* + * Must validate the ifa found is in + * our ep + */ struct sctp_laddr *laddr; int found = 0; @@ -6543,8 +6563,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, (av->assoc_id == SCTP_FUTURE_ASSOC)) { if ((av->assoc_value == 0) && (inp->asconf_supported == 1)) { - /* AUTH is required for - * ASCONF */ + /* + * AUTH is required for + * ASCONF + */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } else { @@ -6580,8 +6602,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, (av->assoc_id == SCTP_FUTURE_ASSOC)) { if ((av->assoc_value != 0) && (inp->auth_supported == 0)) { - /* AUTH is required for - * ASCONF */ + /* + * AUTH is required for + * ASCONF + */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } else { @@ -7013,8 +7037,10 @@ sctp_listen(struct socket *so, int backlog, struct thread *p) ((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) == 0) && ((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && (tinp->sctp_socket->so_qlimit)) { - /* we have a listener already and - * its not this inp. */ + /* + * we have a listener already and + * its not this inp. + */ SCTP_INP_DECR_REF(tinp); return (EADDRINUSE); } else if (tinp) { @@ -7055,8 +7081,10 @@ sctp_listen(struct socket *so, int backlog, struct thread *p) ((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) == 0) && ((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && (tinp->sctp_socket->so_qlimit)) { - /* we have a listener already and its not - * this inp. */ + /* + * we have a listener already and its not + * this inp. + */ SCTP_INP_DECR_REF(tinp); return (EADDRINUSE); } else if (tinp) { @@ -7296,7 +7324,7 @@ sctp_ingetaddr(struct socket *so, struct sockaddr **addr) vrf_id = inp->def_vrf_id; sctp_ifa = sctp_source_address_selection(inp, stcb, - (sctp_route_t *) & net->ro, + (sctp_route_t *)&net->ro, net, 0, vrf_id); if (sctp_ifa) { sin->sin_addr = sctp_ifa->address.sin.sin_addr; -- cgit v1.2.3