diff options
author | rrs <rrs@FreeBSD.org> | 2006-12-29 20:21:42 +0000 |
---|---|---|
committer | rrs <rrs@FreeBSD.org> | 2006-12-29 20:21:42 +0000 |
commit | d392a291a28a8cbedf2cc9398d4a03c8467d8c3d (patch) | |
tree | ca49939e7d34d46ab49b2ec2d88653e27f3e43a1 /sys/netinet/sctp_usrreq.c | |
parent | c2bdc9dc5c518c1a3f29bb61d0d469bb1b6b68a9 (diff) | |
download | FreeBSD-src-d392a291a28a8cbedf2cc9398d4a03c8467d8c3d.zip FreeBSD-src-d392a291a28a8cbedf2cc9398d4a03c8467d8c3d.tar.gz |
a) macro-ization of all mbuf and random number
access plus timers. This makes the code
more portable and able to change out the
mbuf or timer system used more easily ;-)
b) removal of all use of pkt-hdr's until only
the places we need them (before ip_output routines).
c) remove a bunch of code not needed due to <b> aka
worrying about pkthdr's :-)
d) There was one last reorder problem it looks where
if a restart occur's and we release and relock (at
the point where we setup our alias vtag) we would
end up possibly getting the wrong TSN in place. The
code that fixed the TSN's just needed to be shifted
around BEFORE the release of the lock.. also code that
set the state (since this also could contribute).
Approved by: gnn
Diffstat (limited to 'sys/netinet/sctp_usrreq.c')
-rw-r--r-- | sys/netinet/sctp_usrreq.c | 247 |
1 files changed, 120 insertions, 127 deletions
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index c650e35..79a62a0 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -163,6 +163,7 @@ unsigned int sctp_early_fr_msec = SCTP_MINFR_MSEC_TIMER; unsigned int sctp_use_rttvar_cc = 0; int sctp_says_check_for_deadlock = 0; unsigned int sctp_asconf_auth_nochk = 0; +unsigned int sctp_nat_friendly = 1; unsigned int sctp_auth_disable = 0; unsigned int sctp_auth_random_len = SCTP_AUTH_RANDOM_SIZE_DEFAULT; unsigned int sctp_auth_hmac_id_default = SCTP_AUTH_HMAC_ID_SHA1; @@ -314,7 +315,7 @@ sctp_notify_mbuf(struct sctp_inpcb *inp, nxtsz = find_next_best_mtu(totsz); } /* Stop any PMTU timer */ - if (callout_pending(&net->pmtu_timer.timer)) { + if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) { tmr_stopped = 1; sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_1); @@ -923,6 +924,10 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD, 0, 0, sctp_assoclist, "S,xassoc", "List of active SCTP associations"); +SYSCTL_UINT(_net_inet_sctp, OID_AUTO, nat_friendly, CTLFLAG_RW, + &sctp_nat_friendly, 0, + "SCTP NAT friendly operation"); + #ifdef SCTP_DEBUG SYSCTL_INT(_net_inet_sctp, OID_AUTO, debug, CTLFLAG_RW, &sctp_debug_on, 0, "Configure debug output"); @@ -1179,21 +1184,9 @@ connected_type: } inp->control = control; } - /* add it in possibly */ - if ((inp->pkt) && (inp->pkt->m_flags & M_PKTHDR)) { - struct mbuf *x; - int c_len; - - c_len = 0; - /* How big is it */ - for (x = m; x; x = x->m_next) { - c_len += x->m_len; - } - inp->pkt->m_pkthdr.len += c_len; - } /* Place the data */ if (inp->pkt) { - inp->pkt_last->m_next = m; + SCTP_BUF_NEXT(inp->pkt_last) = m; inp->pkt_last = m; } else { inp->pkt_last = inp->pkt = m; @@ -1275,9 +1268,9 @@ sctp_disconnect(struct socket *so) struct sctp_paramhdr *ph; ph = mtod(err, struct sctp_paramhdr *); - err->m_len = sizeof(struct sctp_paramhdr); + SCTP_BUF_LEN(err) = sizeof(struct sctp_paramhdr); ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); - ph->param_length = htons(err->m_len); + ph->param_length = htons(SCTP_BUF_LEN(err)); } sctp_send_abort_tcb(stcb, err); SCTP_STAT_INCR_COUNTER32(sctps_aborted); @@ -1360,13 +1353,13 @@ sctp_disconnect(struct socket *so) struct sctp_paramhdr *ph; uint32_t *ippp; - op_err->m_len = + SCTP_BUF_LEN(op_err) = (sizeof(struct sctp_paramhdr) + sizeof(uint32_t)); ph = mtod(op_err, struct sctp_paramhdr *); ph->param_type = htons( SCTP_CAUSE_USER_INITIATED_ABT); - ph->param_length = htons(op_err->m_len); + ph->param_length = htons(SCTP_BUF_LEN(op_err)); ippp = (uint32_t *) (ph + 1); *ippp = htonl(SCTP_FROM_SCTP_USRREQ + SCTP_LOC_4); } @@ -1499,13 +1492,13 @@ sctp_shutdown(struct socket *so) struct sctp_paramhdr *ph; uint32_t *ippp; - op_err->m_len = + SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr) + sizeof(uint32_t); ph = mtod(op_err, struct sctp_paramhdr *); ph->param_type = htons( SCTP_CAUSE_USER_INITIATED_ABT); - ph->param_length = htons(op_err->m_len); + ph->param_length = htons(SCTP_BUF_LEN(op_err)); ippp = (uint32_t *) (ph + 1); *ippp = htonl(SCTP_FROM_SCTP_USRREQ + SCTP_LOC_6); } @@ -1869,7 +1862,7 @@ sctp_do_connect_x(struct socket *so, error = EALREADY; goto out_now; } - if ((at + incr) > m->m_len) { + if ((at + incr) > SCTP_BUF_LEN(m)) { totaddr = i; break; } @@ -2040,57 +2033,57 @@ sctp_optsget(struct socket *so, /* make it an "on/off" value */ optval = (optval != 0); } - if ((size_t)m->m_len < sizeof(int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(int)) { error = EINVAL; } SCTP_INP_RUNLOCK(inp); if (error == 0) { /* return the option value */ *mtod(m, int *)= optval; - m->m_len = sizeof(optval); + SCTP_BUF_LEN(m) = sizeof(optval); } break; case SCTP_PARTIAL_DELIVERY_POINT: { - if ((size_t)m->m_len < sizeof(unsigned int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(unsigned int)) { error = EINVAL; break; } *mtod(m, unsigned int *)= inp->partial_delivery_point; - m->m_len = sizeof(unsigned int); + SCTP_BUF_LEN(m) = sizeof(unsigned int); } break; case SCTP_FRAGMENT_INTERLEAVE: { - if ((size_t)m->m_len < sizeof(unsigned int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(unsigned int)) { error = EINVAL; break; } *mtod(m, unsigned int *)= sctp_is_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE); - m->m_len = sizeof(unsigned int); + SCTP_BUF_LEN(m) = sizeof(unsigned int); } break; case SCTP_CMT_ON_OFF: { - if ((size_t)m->m_len < sizeof(unsigned int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(unsigned int)) { error = EINVAL; break; } *mtod(m, unsigned int *)= sctp_cmt_sockopt_on_off; - m->m_len = sizeof(unsigned int); + SCTP_BUF_LEN(m) = sizeof(unsigned int); } break; case SCTP_CMT_USE_DAC: { *mtod(m, unsigned int *)= sctp_cmt_sockopt_use_dac; - m->m_len = sizeof(unsigned int); + SCTP_BUF_LEN(m) = sizeof(unsigned int); } break; case SCTP_GET_ADDR_LEN: { struct sctp_assoc_value *av; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_value)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_value)) { error = EINVAL; break; } @@ -2116,7 +2109,7 @@ sctp_optsget(struct socket *so, int cnt, at; uint16_t orig; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_ids)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_ids)) { error = EINVAL; break; } @@ -2164,7 +2157,7 @@ sctp_optsget(struct socket *so, struct sctp_assoc_value *av; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_value)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_value)) { error = EINVAL; break; } @@ -2186,7 +2179,7 @@ sctp_optsget(struct socket *so, { struct sctp_get_nonce_values *gnv; - if ((size_t)m->m_len < sizeof(struct sctp_get_nonce_values)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_get_nonce_values)) { error = EINVAL; break; } @@ -2206,7 +2199,7 @@ sctp_optsget(struct socket *so, { struct sctp_assoc_value *tm; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_value)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_value)) { error = EINVAL; break; } @@ -2237,7 +2230,7 @@ sctp_optsget(struct socket *so, break; case SCTP_GET_SNDBUF_USE: - if ((size_t)m->m_len < sizeof(struct sctp_sockstat)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_sockstat)) { error = EINVAL; } else { struct sctp_sockstat *ss; @@ -2255,7 +2248,7 @@ sctp_optsget(struct socket *so, asoc->size_on_all_streams); SCTP_TCB_UNLOCK(stcb); error = 0; - m->m_len = sizeof(struct sctp_sockstat); + SCTP_BUF_LEN(m) = sizeof(struct sctp_sockstat); } } break; @@ -2267,7 +2260,7 @@ sctp_optsget(struct socket *so, SCTP_INP_RLOCK(inp); *burst = inp->sctp_ep.max_burst; SCTP_INP_RUNLOCK(inp); - m->m_len = sizeof(uint8_t); + SCTP_BUF_LEN(m) = sizeof(uint8_t); } break; @@ -2277,17 +2270,17 @@ sctp_optsget(struct socket *so, sctp_assoc_t *assoc_id; int ovh; - if ((size_t)m->m_len < sizeof(uint32_t)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(uint32_t)) { error = EINVAL; break; } - if ((size_t)m->m_len < sizeof(sctp_assoc_t)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(sctp_assoc_t)) { error = EINVAL; break; } assoc_id = mtod(m, sctp_assoc_t *); segsize = mtod(m, uint32_t *); - m->m_len = sizeof(uint32_t); + SCTP_BUF_LEN(m) = sizeof(uint32_t); if (((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) || @@ -2332,14 +2325,14 @@ sctp_optsget(struct socket *so, { uint32_t *level; - if ((size_t)m->m_len < sizeof(uint32_t)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(uint32_t)) { error = EINVAL; break; } level = mtod(m, uint32_t *); error = 0; *level = sctp_debug_on; - m->m_len = sizeof(uint32_t); + SCTP_BUF_LEN(m) = sizeof(uint32_t); printf("Returning DEBUG LEVEL %x is set\n", (uint32_t) sctp_debug_on); } @@ -2358,7 +2351,7 @@ sctp_optsget(struct socket *so, { struct sctp_event_subscribe *events; - if ((size_t)m->m_len < sizeof(struct sctp_event_subscribe)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_event_subscribe)) { error = EINVAL; break; } @@ -2395,40 +2388,40 @@ sctp_optsget(struct socket *so, if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) events->sctp_stream_reset_events = 1; SCTP_INP_RUNLOCK(inp); - m->m_len = sizeof(struct sctp_event_subscribe); + SCTP_BUF_LEN(m) = sizeof(struct sctp_event_subscribe); } break; case SCTP_ADAPTATION_LAYER: - if ((size_t)m->m_len < sizeof(int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(int)) { error = EINVAL; break; } SCTP_INP_RLOCK(inp); *mtod(m, int *)= inp->sctp_ep.adaptation_layer_indicator; SCTP_INP_RUNLOCK(inp); - m->m_len = sizeof(int); + SCTP_BUF_LEN(m) = sizeof(int); break; case SCTP_SET_INITIAL_DBG_SEQ: - if ((size_t)m->m_len < sizeof(int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(int)) { error = EINVAL; break; } SCTP_INP_RLOCK(inp); *mtod(m, int *)= inp->sctp_ep.initial_sequence_debug; SCTP_INP_RUNLOCK(inp); - m->m_len = sizeof(int); + SCTP_BUF_LEN(m) = sizeof(int); break; case SCTP_GET_LOCAL_ADDR_SIZE: - if ((size_t)m->m_len < sizeof(int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(int)) { error = EINVAL; break; } SCTP_INP_RLOCK(inp); *mtod(m, int *)= sctp_count_max_addresses(inp); SCTP_INP_RUNLOCK(inp); - m->m_len = sizeof(int); + SCTP_BUF_LEN(m) = sizeof(int); break; case SCTP_GET_REMOTE_ADDR_SIZE: { @@ -2436,7 +2429,7 @@ sctp_optsget(struct socket *so, uint32_t *val, sz; struct sctp_nets *net; - if ((size_t)m->m_len < sizeof(sctp_assoc_t)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(sctp_assoc_t)) { error = EINVAL; break; } @@ -2473,7 +2466,7 @@ sctp_optsget(struct socket *so, } SCTP_TCB_UNLOCK(stcb); *val = sz; - m->m_len = sizeof(uint32_t); + SCTP_BUF_LEN(m) = sizeof(uint32_t); } break; case SCTP_GET_PEER_ADDRESSES: @@ -2487,11 +2480,11 @@ sctp_optsget(struct socket *so, struct sctp_nets *net; struct sctp_getaddresses *saddr; - if ((size_t)m->m_len < sizeof(struct sctp_getaddresses)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_getaddresses)) { error = EINVAL; break; } - left = m->m_len - sizeof(struct sctp_getaddresses); + left = SCTP_BUF_LEN(m) - sizeof(struct sctp_getaddresses); saddr = mtod(m, struct sctp_getaddresses *); if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { SCTP_INP_RLOCK(inp); @@ -2506,7 +2499,7 @@ sctp_optsget(struct socket *so, error = ENOENT; break; } - m->m_len = sizeof(struct sctp_getaddresses); + SCTP_BUF_LEN(m) = sizeof(struct sctp_getaddresses); sas = (struct sockaddr_storage *)&saddr->addr[0]; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { @@ -2535,7 +2528,7 @@ sctp_optsget(struct socket *so, sas = (struct sockaddr_storage *)((caddr_t)sas + cpsz); left -= cpsz; - m->m_len += cpsz; + SCTP_BUF_LEN(m) += cpsz; } SCTP_TCB_UNLOCK(stcb); } @@ -2546,7 +2539,7 @@ sctp_optsget(struct socket *so, struct sockaddr_storage *sas; struct sctp_getaddresses *saddr; - if ((size_t)m->m_len < sizeof(struct sctp_getaddresses)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_getaddresses)) { error = EINVAL; break; } @@ -2578,11 +2571,11 @@ sctp_optsget(struct socket *so, SCTP_INP_RUNLOCK(inp); } sas = (struct sockaddr_storage *)&saddr->addr[0]; - limit = m->m_len - sizeof(sctp_assoc_t); + limit = SCTP_BUF_LEN(m) - sizeof(sctp_assoc_t); actual = sctp_fill_up_addresses(inp, stcb, limit, sas); if (stcb) SCTP_TCB_UNLOCK(stcb); - m->m_len = sizeof(struct sockaddr_storage) + actual; + SCTP_BUF_LEN(m) = sizeof(struct sockaddr_storage) + actual; } break; case SCTP_PEER_ADDR_PARAMS: @@ -2590,7 +2583,7 @@ sctp_optsget(struct socket *so, struct sctp_paddrparams *paddrp; struct sctp_nets *net; - if ((size_t)m->m_len < sizeof(struct sctp_paddrparams)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_paddrparams)) { error = EINVAL; break; } @@ -2653,7 +2646,7 @@ sctp_optsget(struct socket *so, else paddrp->spp_flags |= SPP_HB_ENABLE; /* get flags for PMTU */ - if (callout_pending(&net->pmtu_timer.timer)) { + if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) { paddrp->spp_flags |= SPP_PMTUD_ENABLE; } else { paddrp->spp_flags |= SPP_PMTUD_DISABLE; @@ -2725,7 +2718,7 @@ sctp_optsget(struct socket *so, SCTP_INP_RUNLOCK(inp); } - m->m_len = sizeof(struct sctp_paddrparams); + SCTP_BUF_LEN(m) = sizeof(struct sctp_paddrparams); } break; case SCTP_GET_PEER_ADDR_INFO: @@ -2733,7 +2726,7 @@ sctp_optsget(struct socket *so, struct sctp_paddrinfo *paddri; struct sctp_nets *net; - if ((size_t)m->m_len < sizeof(struct sctp_paddrinfo)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_paddrinfo)) { error = EINVAL; break; } @@ -2771,7 +2764,7 @@ sctp_optsget(struct socket *so, error = ENOENT; break; } - m->m_len = sizeof(struct sctp_paddrinfo); + SCTP_BUF_LEN(m) = sizeof(struct sctp_paddrinfo); paddri->spinfo_state = net->dest_state & (SCTP_REACHABLE_MASK | SCTP_ADDR_NOHB); paddri->spinfo_cwnd = net->cwnd; paddri->spinfo_srtt = ((net->lastsa >> 2) + net->lastsv) >> 1; @@ -2784,13 +2777,13 @@ sctp_optsget(struct socket *so, { struct sctp_pcbinfo *spcb; - if ((size_t)m->m_len < sizeof(struct sctp_pcbinfo)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_pcbinfo)) { error = EINVAL; break; } spcb = mtod(m, struct sctp_pcbinfo *); sctp_fill_pcbinfo(spcb); - m->m_len = sizeof(struct sctp_pcbinfo); + SCTP_BUF_LEN(m) = sizeof(struct sctp_pcbinfo); } break; case SCTP_STATUS: @@ -2798,7 +2791,7 @@ sctp_optsget(struct socket *so, struct sctp_nets *net; struct sctp_status *sstat; - if ((size_t)m->m_len < sizeof(struct sctp_status)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_status)) { error = EINVAL; break; } @@ -2852,14 +2845,14 @@ sctp_optsget(struct socket *so, sstat->sstat_primary.spinfo_mtu = net->mtu; sstat->sstat_primary.spinfo_assoc_id = sctp_get_associd(stcb); SCTP_TCB_UNLOCK(stcb); - m->m_len = sizeof(*sstat); + SCTP_BUF_LEN(m) = sizeof(*sstat); } break; case SCTP_RTOINFO: { struct sctp_rtoinfo *srto; - if ((size_t)m->m_len < sizeof(struct sctp_rtoinfo)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_rtoinfo)) { error = EINVAL; break; } @@ -2890,14 +2883,14 @@ sctp_optsget(struct socket *so, srto->srto_max = stcb->asoc.maxrto; srto->srto_min = stcb->asoc.minrto; SCTP_TCB_UNLOCK(stcb); - m->m_len = sizeof(*srto); + SCTP_BUF_LEN(m) = sizeof(*srto); } break; case SCTP_ASSOCINFO: { struct sctp_assocparams *sasoc; - if ((size_t)m->m_len < sizeof(struct sctp_assocparams)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assocparams)) { error = EINVAL; break; } @@ -2938,14 +2931,14 @@ sctp_optsget(struct socket *so, sasoc->sasoc_cookie_life = inp->sctp_ep.def_cookie_life; SCTP_INP_RUNLOCK(inp); } - m->m_len = sizeof(*sasoc); + SCTP_BUF_LEN(m) = sizeof(*sasoc); } break; case SCTP_DEFAULT_SEND_PARAM: { struct sctp_sndrcvinfo *s_info; - if (m->m_len != sizeof(struct sctp_sndrcvinfo)) { + if (SCTP_BUF_LEN(m) != sizeof(struct sctp_sndrcvinfo)) { error = EINVAL; break; } @@ -2966,14 +2959,14 @@ sctp_optsget(struct socket *so, /* Copy it out */ *s_info = stcb->asoc.def_send; SCTP_TCB_UNLOCK(stcb); - m->m_len = sizeof(*s_info); + SCTP_BUF_LEN(m) = sizeof(*s_info); } break; case SCTP_INITMSG: { struct sctp_initmsg *sinit; - if ((size_t)m->m_len < sizeof(struct sctp_initmsg)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_initmsg)) { error = EINVAL; break; } @@ -2984,7 +2977,7 @@ sctp_optsget(struct socket *so, sinit->sinit_max_attempts = inp->sctp_ep.max_init_times; sinit->sinit_max_init_timeo = inp->sctp_ep.initial_init_rto_max; SCTP_INP_RUNLOCK(inp); - m->m_len = sizeof(*sinit); + SCTP_BUF_LEN(m) = sizeof(*sinit); } break; case SCTP_PRIMARY_ADDR: @@ -2992,7 +2985,7 @@ sctp_optsget(struct socket *so, { struct sctp_setprim *ssp; - if ((size_t)m->m_len < sizeof(struct sctp_setprim)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_setprim)) { error = EINVAL; break; } @@ -3030,7 +3023,7 @@ sctp_optsget(struct socket *so, &stcb->asoc.primary_destination->ro._l_addr, ((struct sockaddr *)&stcb->asoc.primary_destination->ro._l_addr)->sa_len); SCTP_TCB_UNLOCK(stcb); - m->m_len = sizeof(*ssp); + SCTP_BUF_LEN(m) = sizeof(*ssp); } break; @@ -3041,7 +3034,7 @@ sctp_optsget(struct socket *so, uint32_t size; int i; - if ((size_t)(m->m_len) < sizeof(*shmac)) { + if ((size_t)(SCTP_BUF_LEN(m)) < sizeof(*shmac)) { error = EINVAL; break; } @@ -3050,13 +3043,13 @@ sctp_optsget(struct socket *so, hmaclist = inp->sctp_ep.local_hmacs; if (hmaclist == NULL) { /* no HMACs to return */ - m->m_len = sizeof(*shmac); + SCTP_BUF_LEN(m) = sizeof(*shmac); break; } /* is there room for all of the hmac ids? */ size = sizeof(*shmac) + (hmaclist->num_algo * sizeof(shmac->shmac_idents[0])); - if ((size_t)(m->m_len) < size) { + if ((size_t)(SCTP_BUF_LEN(m)) < size) { error = EINVAL; SCTP_INP_RUNLOCK(inp); break; @@ -3065,14 +3058,14 @@ sctp_optsget(struct socket *so, for (i = 0; i < hmaclist->num_algo; i++) shmac->shmac_idents[i] = hmaclist->hmac[i]; SCTP_INP_RUNLOCK(inp); - m->m_len = size; + SCTP_BUF_LEN(m) = size; break; } case SCTP_AUTH_ACTIVE_KEY: { struct sctp_authkeyid *scact; - if ((size_t)(m->m_len) < sizeof(*scact)) { + if ((size_t)(SCTP_BUF_LEN(m)) < sizeof(*scact)) { error = EINVAL; break; } @@ -3104,7 +3097,7 @@ sctp_optsget(struct socket *so, scact->scact_keynumber = inp->sctp_ep.default_keyid; SCTP_INP_RUNLOCK(inp); } - m->m_len = sizeof(*scact); + SCTP_BUF_LEN(m) = sizeof(*scact); break; } case SCTP_LOCAL_AUTH_CHUNKS: @@ -3113,7 +3106,7 @@ sctp_optsget(struct socket *so, sctp_auth_chklist_t *chklist = NULL; int size = 0; - if ((size_t)(m->m_len) < sizeof(*sac)) { + if ((size_t)(SCTP_BUF_LEN(m)) < sizeof(*sac)) { error = EINVAL; break; } @@ -3145,7 +3138,7 @@ sctp_optsget(struct socket *so, } /* is there enough space? */ size = sctp_auth_get_chklist_size(chklist); - if ((size_t)m->m_len < (sizeof(struct sctp_authchunks) + size)) { + if ((size_t)SCTP_BUF_LEN(m) < (sizeof(struct sctp_authchunks) + size)) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); break; @@ -3164,7 +3157,7 @@ sctp_optsget(struct socket *so, } /* is there enough space? */ size = sctp_auth_get_chklist_size(chklist); - if ((size_t)m->m_len < (sizeof(struct sctp_authchunks) + size)) { + if ((size_t)SCTP_BUF_LEN(m) < (sizeof(struct sctp_authchunks) + size)) { error = EINVAL; SCTP_INP_RUNLOCK(inp); break; @@ -3173,7 +3166,7 @@ sctp_optsget(struct socket *so, sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); SCTP_INP_RUNLOCK(inp); } - m->m_len = sizeof(struct sctp_authchunks) + size; + SCTP_BUF_LEN(m) = sizeof(struct sctp_authchunks) + size; break; } case SCTP_PEER_AUTH_CHUNKS: @@ -3182,7 +3175,7 @@ sctp_optsget(struct socket *so, sctp_auth_chklist_t *chklist = NULL; int size = 0; - if ((size_t)(m->m_len) < sizeof(*sac)) { + if ((size_t)(SCTP_BUF_LEN(m)) < sizeof(*sac)) { error = EINVAL; break; } @@ -3213,7 +3206,7 @@ sctp_optsget(struct socket *so, } /* is there enough space? */ size = sctp_auth_get_chklist_size(chklist); - if ((size_t)m->m_len < (sizeof(struct sctp_authchunks) + size)) { + if ((size_t)SCTP_BUF_LEN(m) < (sizeof(struct sctp_authchunks) + size)) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); break; @@ -3221,14 +3214,14 @@ sctp_optsget(struct socket *so, /* copy in the chunks */ sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); SCTP_TCB_UNLOCK(stcb); - m->m_len = sizeof(struct sctp_authchunks) + size; + SCTP_BUF_LEN(m) = sizeof(struct sctp_authchunks) + size; break; } default: error = ENOPROTOOPT; - m->m_len = 0; + SCTP_BUF_LEN(m) = 0; break; } /* end switch (sopt->sopt_name) */ return (error); @@ -3268,7 +3261,7 @@ sctp_optsset(struct socket *so, case SCTP_USE_EXT_RCVINFO: case SCTP_I_WANT_MAPPED_V4_ADDR: /* copy in the option value */ - if ((size_t)m->m_len < sizeof(int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(int)) { error = EINVAL; break; } @@ -3318,12 +3311,12 @@ sctp_optsset(struct socket *so, break; case SCTP_PARTIAL_DELIVERY_POINT: { - if ((size_t)m->m_len < sizeof(unsigned int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(unsigned int)) { error = EINVAL; break; } inp->partial_delivery_point = *mtod(m, unsigned int *); - m->m_len = sizeof(unsigned int); + SCTP_BUF_LEN(m) = sizeof(unsigned int); } break; case SCTP_FRAGMENT_INTERLEAVE: @@ -3331,7 +3324,7 @@ sctp_optsset(struct socket *so, { int on_off; - if ((size_t)m->m_len < sizeof(int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(int)) { error = EINVAL; break; } @@ -3347,7 +3340,7 @@ sctp_optsset(struct socket *so, { struct sctp_assoc_value *av; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_value)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_value)) { error = EINVAL; break; } @@ -3371,7 +3364,7 @@ sctp_optsset(struct socket *so, break; case SCTP_CMT_USE_DAC: { - if ((size_t)m->m_len < sizeof(unsigned int)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(unsigned int)) { error = EINVAL; break; } @@ -3392,7 +3385,7 @@ sctp_optsset(struct socket *so, struct sctp_assoc_value *av; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_value)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_value)) { error = EINVAL; break; } @@ -3414,7 +3407,7 @@ sctp_optsset(struct socket *so, { struct sctp_assoc_value *tm; - if ((size_t)m->m_len < sizeof(struct sctp_assoc_value)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assoc_value)) { error = EINVAL; break; } @@ -3453,7 +3446,7 @@ sctp_optsset(struct socket *so, { struct sctp_authchunk *sauth; - if ((size_t)m->m_len < sizeof(*sauth)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(*sauth)) { error = EINVAL; break; } @@ -3471,7 +3464,7 @@ sctp_optsset(struct socket *so, sctp_key_t *key = NULL; int size; - size = m->m_len - sizeof(*sca); + size = SCTP_BUF_LEN(m) - sizeof(*sca); if (size < 0) { error = EINVAL; break; @@ -3564,7 +3557,7 @@ sctp_optsset(struct socket *so, uint32_t hmacid; int size, i; - size = m->m_len - sizeof(*shmac); + size = SCTP_BUF_LEN(m) - sizeof(*shmac); if (size < 0) { error = EINVAL; break; @@ -3598,7 +3591,7 @@ sctp_optsset(struct socket *so, { struct sctp_authkeyid *scact; - if ((size_t)m->m_len < sizeof(*scact)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(*scact)) { error = EINVAL; break; } @@ -3639,7 +3632,7 @@ sctp_optsset(struct socket *so, { struct sctp_authkeyid *scdel; - if ((size_t)m->m_len < sizeof(*scdel)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(*scdel)) { error = EINVAL; break; } @@ -3681,7 +3674,7 @@ sctp_optsset(struct socket *so, uint8_t send_in = 0, send_tsn = 0, send_out = 0; int i; - if ((size_t)m->m_len < sizeof(struct sctp_stream_reset)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_stream_reset)) { error = EINVAL; break; } @@ -3760,7 +3753,7 @@ sctp_optsset(struct socket *so, } break; case SCTP_CONNECT_X: - if ((size_t)m->m_len < (sizeof(int) + sizeof(struct sockaddr_in))) { + if ((size_t)SCTP_BUF_LEN(m) < (sizeof(int) + sizeof(struct sockaddr_in))) { error = EINVAL; break; } @@ -3768,7 +3761,7 @@ sctp_optsset(struct socket *so, break; case SCTP_CONNECT_X_DELAYED: - if ((size_t)m->m_len < (sizeof(int) + sizeof(struct sockaddr_in))) { + if ((size_t)SCTP_BUF_LEN(m) < (sizeof(int) + sizeof(struct sockaddr_in))) { error = EINVAL; break; } @@ -3780,7 +3773,7 @@ sctp_optsset(struct socket *so, struct sockaddr *sa; struct sctp_nets *net; - if ((size_t)m->m_len < sizeof(struct sockaddr_in)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sockaddr_in)) { error = EINVAL; break; } @@ -3863,7 +3856,7 @@ sctp_optsset(struct socket *so, { uint32_t *level; - if ((size_t)m->m_len < sizeof(uint32_t)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(uint32_t)) { error = EINVAL; break; } @@ -3883,7 +3876,7 @@ sctp_optsset(struct socket *so, { struct sctp_event_subscribe *events; - if ((size_t)m->m_len < sizeof(struct sctp_event_subscribe)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_event_subscribe)) { error = EINVAL; break; } @@ -3956,7 +3949,7 @@ sctp_optsset(struct socket *so, { struct sctp_setadaptation *adap_bits; - if ((size_t)m->m_len < sizeof(struct sctp_setadaptation)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_setadaptation)) { error = EINVAL; break; } @@ -3970,7 +3963,7 @@ sctp_optsset(struct socket *so, { uint32_t *vvv; - if ((size_t)m->m_len < sizeof(uint32_t)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(uint32_t)) { error = EINVAL; break; } @@ -3984,7 +3977,7 @@ sctp_optsset(struct socket *so, { struct sctp_sndrcvinfo *s_info; - if (m->m_len != sizeof(struct sctp_sndrcvinfo)) { + if (SCTP_BUF_LEN(m) != sizeof(struct sctp_sndrcvinfo)) { error = EINVAL; break; } @@ -4027,7 +4020,7 @@ sctp_optsset(struct socket *so, struct sctp_paddrparams *paddrp; struct sctp_nets *net; - if ((size_t)m->m_len < sizeof(struct sctp_paddrparams)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_paddrparams)) { error = EINVAL; break; } @@ -4112,7 +4105,7 @@ sctp_optsset(struct socket *so, net->dest_state &= ~SCTP_ADDR_NOHB; } if (paddrp->spp_flags & SPP_PMTUD_DISABLE) { - if (callout_pending(&net->pmtu_timer.timer)) { + if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_10); } @@ -4123,7 +4116,7 @@ sctp_optsset(struct socket *so, } } if (paddrp->spp_flags & SPP_PMTUD_ENABLE) { - if (callout_pending(&net->pmtu_timer.timer)) { + if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) { sctp_timer_start(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net); } } @@ -4220,7 +4213,7 @@ sctp_optsset(struct socket *so, { struct sctp_rtoinfo *srto; - if ((size_t)m->m_len < sizeof(struct sctp_rtoinfo)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_rtoinfo)) { error = EINVAL; break; } @@ -4266,7 +4259,7 @@ sctp_optsset(struct socket *so, { struct sctp_assocparams *sasoc; - if ((size_t)m->m_len < sizeof(struct sctp_assocparams)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_assocparams)) { error = EINVAL; break; } @@ -4314,7 +4307,7 @@ sctp_optsset(struct socket *so, { struct sctp_initmsg *sinit; - if ((size_t)m->m_len < sizeof(struct sctp_initmsg)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_initmsg)) { error = EINVAL; break; } @@ -4343,7 +4336,7 @@ sctp_optsset(struct socket *so, struct sctp_setprim *spa; struct sctp_nets *net, *lnet; - if ((size_t)m->m_len < sizeof(struct sctp_setprim)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_setprim)) { error = EINVAL; break; } @@ -4405,7 +4398,7 @@ sctp_optsset(struct socket *so, { struct sctp_setpeerprim *sspp; - if ((size_t)m->m_len < sizeof(struct sctp_setpeerprim)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_setpeerprim)) { error = EINVAL; break; } @@ -4441,7 +4434,7 @@ sctp_optsset(struct socket *so, error = EINVAL; break; } - if ((size_t)m->m_len < sizeof(struct sctp_getaddresses)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_getaddresses)) { error = EINVAL; break; } @@ -4517,7 +4510,7 @@ sctp_optsset(struct socket *so, error = EINVAL; break; } - if ((size_t)m->m_len < sizeof(struct sctp_getaddresses)) { + if ((size_t)SCTP_BUF_LEN(m) < sizeof(struct sctp_getaddresses)) { error = EINVAL; break; } @@ -4606,7 +4599,7 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) (void)sctp_m_free(m); goto out; } - m->m_len = sopt->sopt_valsize; + SCTP_BUF_LEN(m) = sopt->sopt_valsize; } if (sopt->sopt_dir == SOPT_SET) { error = sctp_optsset(so, sopt->sopt_name, &m, sopt->sopt_td); @@ -4616,7 +4609,7 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) error = EINVAL; } if ((error == 0) && (m != NULL)) { - error = sooptcopyout(sopt, mtod(m, caddr_t), m->m_len); + error = sooptcopyout(sopt, mtod(m, caddr_t), SCTP_BUF_LEN(m)); sctp_m_freem(m); } else if (m != NULL) { sctp_m_freem(m); |