diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-06-18 14:10:49 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-06-18 13:53:24 +0000 |
commit | 813fbf95af77a531c57a8c497345ad2c61d475b3 (patch) | |
tree | 821b2c8de8365f21b6c9ba17a236fb3006a1d506 /chromium/third_party/usrsctp | |
parent | af6588f8d723931a298c995fa97259bb7f7deb55 (diff) | |
download | qtwebengine-chromium-813fbf95af77a531c57a8c497345ad2c61d475b3.tar.gz |
BASELINE: Update chromium to 44.0.2403.47
Change-Id: Ie056fedba95cf5e5c76b30c4b2c80fca4764aa2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/third_party/usrsctp')
28 files changed, 996 insertions, 809 deletions
diff --git a/chromium/third_party/usrsctp/BUILD.gn b/chromium/third_party/usrsctp/BUILD.gn index 254adceec4f..3e3cabb8c4b 100644 --- a/chromium/third_party/usrsctp/BUILD.gn +++ b/chromium/third_party/usrsctp/BUILD.gn @@ -73,13 +73,14 @@ static_library("usrsctp") { "usrsctplib/user_socket.c", "usrsctplib/user_socketvar.h", "usrsctplib/user_uma.h", - "usrsctplib/usrsctp.h" + "usrsctplib/usrsctp.h", ] defines = [ "SCTP_PROCESS_LEVEL_LOCKS", "SCTP_SIMPLE_ALLOCATOR", "__Userspace__", + # "SCTP_DEBUG", # Uncomment for SCTP debugging. ] @@ -108,6 +109,7 @@ static_library("usrsctp") { if (is_win) { defines += [ "__Userspace_os_Windows", + # Manually setting WINVER and _WIN32_WINNT is needed because Chrome # sets WINVER to a newer version of windows. But compiling usrsctp # this way would is incompatible with windows XP. @@ -120,6 +122,11 @@ static_library("usrsctp") { if (is_clang) { cflags = [ "-Wno-incompatible-pointer-types" ] + } else if (target_cpu == "mipsel") { + # mipsel is still using gcc (4.9), + # which does not support "-Wno-incompatible-pointer-types" + # so let's disable all warnings for this module. + cflags = [ "-w" ] } deps = [ diff --git a/chromium/third_party/usrsctp/usrsctp.gyp b/chromium/third_party/usrsctp/usrsctp.gyp index 6e9fae3bbf2..e0eefea831b 100644 --- a/chromium/third_party/usrsctp/usrsctp.gyp +++ b/chromium/third_party/usrsctp/usrsctp.gyp @@ -155,8 +155,8 @@ ], 'defines!': [ # Remove Chrome's WINVER defines to avoid redefinition warnings. - 'WINVER=0x0602', - '_WIN32_WINNT=0x0602', + 'WINVER=0x0603', + '_WIN32_WINNT=0x0603', ], 'cflags!': [ '/W3', '/WX' ], 'cflags': [ '/w' ], diff --git a/chromium/third_party/usrsctp/usrsctp_nacl.gyp b/chromium/third_party/usrsctp/usrsctp_nacl.gyp index bf5c84f9df7..7cce5e7b870 100644 --- a/chromium/third_party/usrsctp/usrsctp_nacl.gyp +++ b/chromium/third_party/usrsctp/usrsctp_nacl.gyp @@ -16,7 +16,6 @@ 'build_pnacl_newlib': 1, }, 'dependencies': [ - '<(DEPTH)/native_client/tools.gyp:prep_toolchain', '<(DEPTH)/native_client_sdk/native_client_sdk_untrusted.gyp:nacl_io_untrusted', '<(DEPTH)/third_party/boringssl/boringssl_nacl.gyp:boringssl_nacl', ], diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp.h b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp.h index a2ab878a237..a5ff4eb0bc5 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 269945 2014-08-13 15:50:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 279859 2015-03-10 19:49:25Z tuexen $"); #endif #ifndef _NETINET_SCTP_H_ @@ -138,6 +138,7 @@ struct sctp_paramhdr { #define SCTP_RECONFIG_SUPPORTED 0x00000029 #define SCTP_NRSACK_SUPPORTED 0x00000030 #define SCTP_PKTDROP_SUPPORTED 0x00000031 +#define SCTP_MAX_CWND 0x00000032 /* * read-only options diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_asconf.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_asconf.c index a0d5ceed390..438879885e7 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_asconf.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_asconf.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 271228 2014-09-07 17:07:19Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 277347 2015-01-18 20:53:20Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -601,7 +601,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset, uint32_t serial_num; struct mbuf *n, *m_ack, *m_result, *m_tail; struct sctp_asconf_ack_chunk *ack_cp; - struct sctp_asconf_paramhdr *aph, *ack_aph; + struct sctp_asconf_paramhdr *aph; struct sctp_ipv6addr_param *p_addr; unsigned int asconf_limit, cnt; int error = 0; /* did an error occur? */ @@ -686,13 +686,6 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset, } /* param_length is already validated in process_control... */ offset += ntohs(p_addr->ph.param_length); /* skip lookup addr */ - - /* get pointer to first asconf param in ASCONF-ACK */ - ack_aph = (struct sctp_asconf_paramhdr *)(mtod(m_ack, caddr_t) + sizeof(struct sctp_asconf_ack_chunk)); - if (ack_aph == NULL) { - SCTPDBG(SCTP_DEBUG_ASCONF1, "Gak in asconf2\n"); - return; - } /* get pointer to first asconf param in ASCONF */ aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, sizeof(struct sctp_asconf_paramhdr), (uint8_t *)&aparam_buf); if (aph == NULL) { @@ -1429,7 +1422,6 @@ sctp_asconf_queue_sa_delete(struct sctp_tcb *stcb, struct sockaddr *sa) { struct sctp_ifa *ifa; struct sctp_asconf_addr *aa, *aa_next; - uint32_t vrf_id; if (stcb == NULL) { return (-1); @@ -1461,12 +1453,7 @@ sctp_asconf_queue_sa_delete(struct sctp_tcb *stcb, struct sockaddr *sa) } /* for each aa */ /* find any existing ifa-- NOTE ifa CAN be allowed to be NULL */ - if (stcb) { - vrf_id = stcb->asoc.vrf_id; - } else { - vrf_id = SCTP_DEFAULT_VRFID; - } - ifa = sctp_find_ifa_by_addr(sa, vrf_id, SCTP_ADDR_NOT_LOCKED); + ifa = sctp_find_ifa_by_addr(sa, stcb->asoc.vrf_id, SCTP_ADDR_NOT_LOCKED); /* adding new request to the queue */ SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), @@ -2795,7 +2782,6 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, #ifdef INET struct sctp_ipv4addr_param addr4_store; #endif - uint32_t vrf_id; SCTPDBG(SCTP_DEBUG_ASCONF2, "processing init-ack addresses\n"); if (stcb == NULL) /* Un-needed check for SA */ @@ -2867,12 +2853,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, } /* see if this address really (still) exists */ - if (stcb) { - vrf_id = stcb->asoc.vrf_id; - } else { - vrf_id = SCTP_DEFAULT_VRFID; - } - sctp_ifa = sctp_find_ifa_by_addr(&store.sa, vrf_id, + sctp_ifa = sctp_find_ifa_by_addr(&store.sa, stcb->asoc.vrf_id, SCTP_ADDR_NOT_LOCKED); if (sctp_ifa == NULL) { /* address doesn't exist anymore */ @@ -3386,6 +3367,11 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); break; #endif + default: + SCTPDBG(SCTP_DEBUG_ASCONF1, + "sctp_asconf_send_nat_state_update: unknown address family\n"); + SCTP_FREE(aa, SCTP_M_ASC_ADDR); + return; } SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), SCTP_M_ASC_ADDR); @@ -3419,6 +3405,11 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); break; #endif + default: + SCTPDBG(SCTP_DEBUG_ASCONF1, + "sctp_asconf_send_nat_state_update: unknown address family\n"); + SCTP_FREE(aa, SCTP_M_ASC_ADDR); + return; } /* Now we must hunt the addresses and add all global addresses */ if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_auth.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_auth.c index 50432ad8a59..1e628758260 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_auth.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_auth.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 271673 2014-09-16 14:20:33Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 280642 2015-03-25 22:45:54Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -578,13 +578,12 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked /* decrement the ref count */ if (skey) { - sctp_free_sharedkey(skey); SCTPDBG(SCTP_DEBUG_AUTH2, "%s: stcb %p key %u refcount release to %d\n", __FUNCTION__, (void *)stcb, key_id, skey->refcount); /* see if a notification should be generated */ - if ((skey->refcount <= 1) && (skey->deactivated)) { + if ((skey->refcount <= 2) && (skey->deactivated)) { /* notify ULP that key is no longer used */ sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, key_id, 0, so_locked); @@ -592,6 +591,7 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked "%s: stcb %p key %u no longer used, %d\n", __FUNCTION__, (void *)stcb, key_id, skey->refcount); } + sctp_free_sharedkey(skey); } } diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_bsd_addr.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_bsd_addr.c index b9ddb48bb99..f5f2a3b6bf9 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_bsd_addr.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_bsd_addr.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 258765 2013-11-30 12:51:19Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 276914 2015-01-10 20:49:57Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -837,24 +837,41 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, } if (SCTP_BUF_IS_EXTENDED(m) == 0) { - sctp_m_freem(m); - return (NULL); + sctp_m_freem(m); + return (NULL); } } SCTP_BUF_LEN(m) = 0; SCTP_BUF_NEXT(m) = SCTP_BUF_NEXT_PKT(m) = NULL; -#if defined(__Userspace__) /* __Userspace__ * Check if anything need to be done to ensure logging works */ -#endif #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - if (SCTP_BUF_IS_EXTENDED(m)) { - sctp_log_mb(m, SCTP_MBUF_IALLOC); + sctp_log_mb(m, SCTP_MBUF_IALLOC); + } +#endif +#elif defined(__FreeBSD__) && __FreeBSD_version > 1100052 + m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0); + if (m == NULL) { + /* bad, no memory */ + return (m); + } + if (allonebuf) { + if (SCTP_BUF_SIZE(m) < space_needed) { + m_freem(m); + return (NULL); } } + if (SCTP_BUF_NEXT(m)) { + sctp_m_freem(SCTP_BUF_NEXT(m)); + SCTP_BUF_NEXT(m) = NULL; + } +#ifdef SCTP_MBUF_LOGGING + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { + sctp_log_mb(m, SCTP_MBUF_IALLOC); + } #endif #elif defined(__FreeBSD__) && __FreeBSD_version > 602000 m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0); @@ -878,14 +895,12 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, } } if (SCTP_BUF_NEXT(m)) { - sctp_m_freem( SCTP_BUF_NEXT(m)); + sctp_m_freem(SCTP_BUF_NEXT(m)); SCTP_BUF_NEXT(m) = NULL; } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - if (SCTP_BUF_IS_EXTENDED(m)) { - sctp_log_mb(m, SCTP_MBUF_IALLOC); - } + sctp_log_mb(m, SCTP_MBUF_IALLOC); } #endif #else @@ -946,9 +961,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, SCTP_BUF_NEXT(m) = SCTP_BUF_NEXT_PKT(m) = NULL; #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - if (SCTP_BUF_IS_EXTENDED(m)) { - sctp_log_mb(m, SCTP_MBUF_IALLOC); - } + sctp_log_mb(m, SCTP_MBUF_IALLOC); } #endif #endif diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_cc_functions.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_cc_functions.c index 3027e46f731..0e01c9860d4 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_cc_functions.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_cc_functions.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 271672 2014-09-16 13:48:46Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 279859 2015-03-10 19:49:25Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -57,6 +57,19 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 271672 2014-09-16 13:48 #define SHIFT_MPTCP_MULTI 8 static void +sctp_enforce_cwnd_limit(struct sctp_association *assoc, struct sctp_nets *net) +{ + if ((assoc->max_cwnd > 0) && + (net->cwnd > assoc->max_cwnd) && + (net->cwnd > (net->mtu - sizeof(struct sctphdr)))) { + net->cwnd = assoc->max_cwnd ; + if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) { + net->cwnd = net->mtu - sizeof(struct sctphdr); + } + } +} + +static void sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) { struct sctp_association *assoc; @@ -84,6 +97,7 @@ sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) net->cwnd = net->mtu - sizeof(struct sctphdr); } } + sctp_enforce_cwnd_limit(assoc, net); net->ssthresh = assoc->peers_rwnd; #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, init, @@ -179,6 +193,7 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb, } } net->cwnd = net->ssthresh; + sctp_enforce_cwnd_limit(asoc, net); #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, fr, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -300,7 +315,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb } return (1); } - if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) { + if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) { /* * rtt decreased, there could be more room. * we update both the bw and the rtt here to @@ -461,6 +476,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cc_mod.rtcc.vol_reduce) && (inst_ind != SCTP_INST_GAINING)) { net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(&stcb->asoc, net); net->cc_mod.rtcc.vol_reduce--; } net->cc_mod.rtcc.last_step_state = 2; @@ -496,6 +512,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cc_mod.rtcc.vol_reduce) && (inst_ind != SCTP_INST_GAINING)) { net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(&stcb->asoc, net); net->cc_mod.rtcc.vol_reduce--; } net->cc_mod.rtcc.last_step_state = 3; @@ -531,6 +548,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cc_mod.rtcc.vol_reduce) && (inst_ind != SCTP_INST_GAINING)) { net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(&stcb->asoc, net); net->cc_mod.rtcc.vol_reduce--; } net->cc_mod.rtcc.last_step_state = 4; @@ -961,6 +979,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, break; } net->cwnd += incr; + sctp_enforce_cwnd_limit(asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS); @@ -1028,6 +1047,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, break; } net->cwnd += incr; + sctp_enforce_cwnd_limit(asoc, net); #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, ack, stcb->asoc.my_vtag, @@ -1315,7 +1335,7 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, /* We always have 1 MTU */ net->cwnd = net->mtu; } - + sctp_enforce_cwnd_limit(&stcb->asoc, net); if (net->cwnd - old_cwnd != 0) { /* log only changes */ #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 @@ -1342,6 +1362,7 @@ sctp_cwnd_update_after_output(struct sctp_tcb *stcb, net->ssthresh = net->cwnd; if (burst_limit) { net->cwnd = (net->flight_size + (burst_limit * net->mtu)); + sctp_enforce_cwnd_limit(&stcb->asoc, net); #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, bl, stcb->asoc.my_vtag, @@ -1681,6 +1702,7 @@ static void sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net) { int cur_val, i, indx, incr; + int old_cwnd = net->cwnd; cur_val = net->cwnd >> 10; indx = SCTP_HS_TABLE_SIZE - 1; @@ -1689,14 +1711,8 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net) /* normal mode */ if (net->net_ack > net->mtu) { net->cwnd += net->mtu; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { - sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_SS); - } } else { net->cwnd += net->net_ack; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { - sctp_log_cwnd(stcb, net, net->net_ack, SCTP_CWND_LOG_FROM_SS); - } } } else { for (i = net->last_hs_used; i < SCTP_HS_TABLE_SIZE; i++) { @@ -1708,9 +1724,10 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net) net->last_hs_used = indx; incr = ((sctp_cwnd_adjust[indx].increase) << 10); net->cwnd += incr; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { - sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS); - } + } + sctp_enforce_cwnd_limit(&stcb->asoc, net); + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { + sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SS); } } @@ -1749,6 +1766,7 @@ sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net) net->last_hs_used = indx; } } + sctp_enforce_cwnd_limit(&stcb->asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR); } @@ -1877,9 +1895,7 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, if (net->cwnd <= net->ssthresh) { /* We are in slow start */ if (net->flight_size + net->net_ack >= net->cwnd) { - sctp_hs_cwnd_increase(stcb, net); - } else { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) { sctp_log_cwnd(stcb, net, net->net_ack, @@ -1893,6 +1909,7 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, (net->partial_bytes_acked >= net->cwnd)) { net->partial_bytes_acked -= net->cwnd; net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_CA); @@ -2131,6 +2148,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) } } + sctp_enforce_cwnd_limit(&stcb->asoc, net); } else { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) { sctp_log_cwnd(stcb, net, net->net_ack, @@ -2151,6 +2169,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) */ net->cwnd += net->mtu; net->partial_bytes_acked = 0; + sctp_enforce_cwnd_limit(&stcb->asoc, net); htcp_alpha_update(&net->cc_mod.htcp_ca); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, net->mtu, @@ -2196,6 +2215,7 @@ sctp_htcp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) */ net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND)); net->ssthresh = stcb->asoc.peers_rwnd; + sctp_enforce_cwnd_limit(&stcb->asoc, net); htcp_init(net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & (SCTP_CWND_MONITOR_ENABLE|SCTP_CWND_LOGGING_ENABLE)) { @@ -2275,7 +2295,7 @@ sctp_htcp_cwnd_update_after_fr(struct sctp_tcb *stcb, struct sctp_association *asoc) { struct sctp_nets *net; - /* + /* * CMT fast recovery code. Need to debug. ((sctp_cmt_on_off > 0) && * (net->fast_retran_loss_recovery == 0))) */ @@ -2297,6 +2317,7 @@ sctp_htcp_cwnd_update_after_fr(struct sctp_tcb *stcb, htcp_reset(&net->cc_mod.htcp_ca); net->ssthresh = htcp_recalc_ssthresh(net); net->cwnd = net->ssthresh; + sctp_enforce_cwnd_limit(asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR); @@ -2375,6 +2396,7 @@ sctp_htcp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, net->RTO <<= 1; } net->cwnd = net->ssthresh; + sctp_enforce_cwnd_limit(&stcb->asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT); } diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_indata.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_indata.c index 22a551f3ef2..f697d0ced94 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_indata.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_indata.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 269448 2014-08-02 21:36:40Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 280440 2015-03-24 15:05:36Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -1509,13 +1509,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, the_len, M_NOWAIT); #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = dmbuf; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(dmbuf, SCTP_MBUF_ICOPY); } #endif } else { @@ -2310,7 +2304,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct sctphdr *sh, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t *high_tsn, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -2408,7 +2402,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (2); @@ -2425,7 +2419,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (2); @@ -2496,7 +2490,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (2); @@ -2625,12 +2619,14 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 * cumack trackers for first transmissions, * and retransmissions. */ - if ((tp1->whoTo->find_pseudo_cumack == 1) && (tp1->sent < SCTP_DATAGRAM_RESEND) && + if ((tp1->sent < SCTP_DATAGRAM_RESEND) && + (tp1->whoTo->find_pseudo_cumack == 1) && (tp1->snd_count == 1)) { tp1->whoTo->pseudo_cumack = tp1->rec.data.TSN_seq; tp1->whoTo->find_pseudo_cumack = 0; } - if ((tp1->whoTo->find_rtx_pseudo_cumack == 1) && (tp1->sent < SCTP_DATAGRAM_RESEND) && + if ((tp1->sent < SCTP_DATAGRAM_RESEND) && + (tp1->whoTo->find_rtx_pseudo_cumack == 1) && (tp1->snd_count > 1)) { tp1->whoTo->rtx_pseudo_cumack = tp1->rec.data.TSN_seq; tp1->whoTo->find_rtx_pseudo_cumack = 0; @@ -3526,7 +3522,7 @@ sctp_window_probe_recovery(struct sctp_tcb *stcb, if ((tp1->sent >= SCTP_DATAGRAM_ACKED) || (tp1->data == NULL)) { /* TSN's skipped we do NOT move back. */ sctp_misc_ints(SCTP_FLIGHT_LOG_DWN_WP_FWD, - tp1->whoTo->flight_size, + tp1->whoTo ? tp1->whoTo->flight_size : 0, tp1->book_size, (uintptr_t)tp1->whoTo, tp1->rec.data.TSN_seq); diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_input.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_input.c index da9c62547f3..54f2f9ba354 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_input.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_input.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 273168 2014-10-16 15:36:04Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 279859 2015-03-10 19:49:25Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -96,7 +96,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, struct sctp_init_chunk *cp, struct sctp_inpcb *inp, struct sctp_tcb *stcb, int *abort_no_unlock, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -113,7 +113,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) @@ -127,7 +127,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) @@ -139,7 +139,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) @@ -151,7 +151,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) @@ -163,7 +163,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) @@ -177,7 +177,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, "Problem with AUTH parameters"); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) @@ -207,7 +207,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, "No listener"); sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } @@ -223,7 +223,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, sctp_send_initiate_ack(inp, stcb, m, iphlen, offset, src, dst, sh, cp, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port, ((stcb == NULL) ? SCTP_HOLDS_LOCK : SCTP_NOT_LOCKED)); @@ -458,7 +458,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_no_unlock, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id) { @@ -500,7 +500,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -578,7 +578,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -1320,7 +1320,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_no_unlock, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id) { @@ -1341,7 +1341,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -1355,7 +1355,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -1367,7 +1367,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -1379,7 +1379,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -1391,7 +1391,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); *abort_no_unlock = 1; @@ -1418,7 +1418,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, if (sctp_process_init_ack(m, iphlen, offset, src, dst, sh, cp, stcb, net, abort_no_unlock, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id) < 0) { /* error in parsing parameters */ @@ -1477,7 +1477,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port); @@ -1496,7 +1496,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -1529,7 +1529,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_COOKIE_IN_SHUTDOWN, ""); sctp_send_operr_to(src, dst, sh, cookie->peers_vtag, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, net->port); if (how_indx < sizeof(asoc->cookie_how)) @@ -1736,7 +1736,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_NAT_COLLIDING_STATE, ""); sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (NULL); @@ -1903,7 +1903,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, inp, netp, init_src,notification, auth_skipped, auth_offset, auth_len, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port)); } @@ -2061,7 +2061,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -2154,7 +2154,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, sctp_abort_association(inp, (struct sctp_tcb *)NULL, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (NULL); @@ -2190,7 +2190,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, sctp_abort_association(inp, (struct sctp_tcb *)NULL, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) @@ -2454,7 +2454,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, struct sctp_tcb **locked_tcb, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -2525,13 +2525,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m_sig; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_SPLIT); - } - } + sctp_log_mbc(m_sig, SCTP_MBUF_SPLIT); } #endif @@ -2647,7 +2641,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, scm->time_usec = htonl(tim); sctp_send_operr_to(src, dst, sh, cookie->peers_vtag, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (NULL); @@ -2705,7 +2699,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, /* This should not happen */ return (NULL); } - if ((*stcb == NULL) && to) { + if (*stcb == NULL) { /* Yep, lets check */ *stcb = sctp_findassociation_ep_addr(inp_p, to, netp, dst, NULL); if (*stcb == NULL) { @@ -2741,9 +2735,6 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, } } } - if (to == NULL) { - return (NULL); - } cookie_len -= SCTP_SIGNATURE_SIZE; if (*stcb == NULL) { @@ -2753,7 +2744,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, netp, to, ¬ification, auth_skipped, auth_offset, auth_len, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } else { @@ -2764,7 +2755,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, cookie, cookie_len, *inp_p, *stcb, netp, to, ¬ification, auth_skipped, auth_offset, auth_len, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } @@ -2774,11 +2765,8 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, return (NULL); } #if defined(__FreeBSD__) - if ((*netp != NULL) && (use_mflowid != 0)) { - (*netp)->flowid = mflowid; -#ifdef INVARIANTS - (*netp)->flowidset = 1; -#endif + if ((*netp != NULL) && (mflowtype != M_HASHTYPE_NONE)) { + (*netp)->flowtype = mflowtype; } #endif /* @@ -2875,7 +2863,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, sctp_abort_association(*inp_p, NULL, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) @@ -2909,6 +2897,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, inp->sctp_mobility_features = (*inp_p)->sctp_mobility_features; inp->sctp_socket = so; inp->sctp_frag_point = (*inp_p)->sctp_frag_point; + inp->max_cwnd = (*inp_p)->max_cwnd; inp->sctp_cmt_on_off = (*inp_p)->sctp_cmt_on_off; inp->ecn_supported = (*inp_p)->ecn_supported; inp->prsctp_supported = (*inp_p)->prsctp_supported; @@ -3254,8 +3243,8 @@ sctp_handle_ecn_cwr(struct sctp_cwr_chunk *cp, struct sctp_tcb *stcb, struct sct struct sctp_ecne_chunk *ecne; int override; uint32_t cwr_tsn; - cwr_tsn = ntohl(cp->tsn); + cwr_tsn = ntohl(cp->tsn); override = cp->ch.chunk_flags & SCTP_CWR_REDUCE_OVERRIDE; TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) { if (chk->rec.chunk_id.id != SCTP_ECN_ECHO) { @@ -3271,10 +3260,8 @@ sctp_handle_ecn_cwr(struct sctp_cwr_chunk *cp, struct sctp_tcb *stcb, struct sct stcb->asoc.ecn_echo_cnt_onq--; TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, sctp_next); - if (chk->data) { - sctp_m_freem(chk->data); - chk->data = NULL; - } + sctp_m_freem(chk->data); + chk->data = NULL; stcb->asoc.ctrl_queue_cnt--; sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED); if (override == 0) { @@ -3793,6 +3780,9 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb, /* huh ? */ return (0); } + if (ntohs(respin->ph.param_length) < sizeof(struct sctp_stream_reset_response_tsn)) { + return (0); + } if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { resp = (struct sctp_stream_reset_response_tsn *)respin; asoc->stream_reset_outstanding--; @@ -4185,7 +4175,7 @@ static int sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, struct sctp_chunkhdr *ch_req) { - int chk_length, param_len, ptype; + uint16_t remaining_length, param_len, ptype; struct sctp_paramhdr pstore; uint8_t cstore[SCTP_CHUNK_BUFFER_SIZE]; uint32_t seq = 0; @@ -4198,7 +4188,7 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, int num_param = 0; /* now it may be a reset or a reset-response */ - chk_length = ntohs(ch_req->chunk_length); + remaining_length = ntohs(ch_req->chunk_length) - sizeof(struct sctp_chunkhdr); /* setup for adding the response */ sctp_alloc_a_chunk(stcb, chk); @@ -4236,20 +4226,27 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, ch->chunk_length = htons(chk->send_size); SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size); offset += sizeof(struct sctp_chunkhdr); - while ((size_t)chk_length >= sizeof(struct sctp_stream_reset_tsn_request)) { + while (remaining_length >= sizeof(struct sctp_paramhdr)) { ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, sizeof(pstore), (uint8_t *)&pstore); - if (ph == NULL) + if (ph == NULL) { + /* TSNH */ break; + } param_len = ntohs(ph->param_length); - if (param_len < (int)sizeof(struct sctp_stream_reset_tsn_request)) { - /* bad param */ + if ((param_len > remaining_length) || + (param_len < (sizeof(struct sctp_paramhdr) + sizeof(uint32_t)))) { + /* bad parameter length */ break; } - ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, min(param_len, (int)sizeof(cstore)), + ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, min(param_len, sizeof(cstore)), (uint8_t *)&cstore); + if (ph == NULL) { + /* TSNH */ + break; + } ptype = ntohs(ph->param_type); num_param++; - if (param_len > (int)sizeof(cstore)) { + if (param_len > sizeof(cstore)) { trunc = 1; } else { trunc = 0; @@ -4260,6 +4257,10 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, } if (ptype == SCTP_STR_RESET_OUT_REQUEST) { struct sctp_stream_reset_out_request *req_out; + + if (param_len < sizeof(struct sctp_stream_reset_out_request)) { + break; + } req_out = (struct sctp_stream_reset_out_request *)ph; num_req++; if (stcb->asoc.stream_reset_outstanding) { @@ -4272,21 +4273,31 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, sctp_handle_str_reset_request_out(stcb, chk, req_out, trunc); } else if (ptype == SCTP_STR_RESET_ADD_OUT_STREAMS) { struct sctp_stream_reset_add_strm *str_add; + + if (param_len < sizeof(struct sctp_stream_reset_add_strm)) { + break; + } str_add = (struct sctp_stream_reset_add_strm *)ph; num_req++; sctp_handle_str_reset_add_strm(stcb, chk, str_add); } else if (ptype == SCTP_STR_RESET_ADD_IN_STREAMS) { struct sctp_stream_reset_add_strm *str_add; + + if (param_len < sizeof(struct sctp_stream_reset_add_strm)) { + break; + } str_add = (struct sctp_stream_reset_add_strm *)ph; num_req++; sctp_handle_str_reset_add_out_strm(stcb, chk, str_add); } else if (ptype == SCTP_STR_RESET_IN_REQUEST) { struct sctp_stream_reset_in_request *req_in; + num_req++; req_in = (struct sctp_stream_reset_in_request *)ph; sctp_handle_str_reset_request_in(stcb, chk, req_in, trunc); } else if (ptype == SCTP_STR_RESET_TSN_REQUEST) { struct sctp_stream_reset_tsn_request *req_tsn; + num_req++; req_tsn = (struct sctp_stream_reset_tsn_request *)ph; if (sctp_handle_str_reset_request_tsn(stcb, chk, req_tsn)) { @@ -4298,6 +4309,10 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, } else if (ptype == SCTP_STR_RESET_RESPONSE) { struct sctp_stream_reset_response *resp; uint32_t result; + + if (param_len < sizeof(struct sctp_stream_reset_response)) { + break; + } resp = (struct sctp_stream_reset_response *)ph; seq = ntohl(resp->response_seq); result = ntohl(resp->result); @@ -4309,7 +4324,11 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, break; } offset += SCTP_SIZE32(param_len); - chk_length -= SCTP_SIZE32(param_len); + if (remaining_length >= SCTP_SIZE32(param_len)) { + remaining_length -= SCTP_SIZE32(param_len); + } else { + remaining_length = 0; + } } if (num_req == 0) { /* we have no response free the stuff */ @@ -4499,7 +4518,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, struct sctphdr *sh, struct sctp_chunkhdr *ch, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets **netp, int *fwd_tsn_seen, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -4662,7 +4681,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, /* no association, so it's out of the blue... */ sctp_handle_ootb(m, iphlen, *offset, src, dst, sh, inp, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); *offset = length; @@ -4708,7 +4727,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, sctp_handle_ootb(m, iphlen, *offset, src, dst, sh, inp, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return (NULL); @@ -4856,7 +4875,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); *offset = length; @@ -4868,7 +4887,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); *offset = length; @@ -4878,7 +4897,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, (struct sctp_init_chunk *)ch, inp, stcb, &abort_no_unlock, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); *offset = length; @@ -4934,7 +4953,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, stcb, *netp, &abort_no_unlock, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id); } else { @@ -5234,7 +5253,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } @@ -5271,7 +5290,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, auth_len, &locked_tcb, #if defined(__FreeBSD__) - use_mflowid, + mflowtype, mflowid, #endif vrf_id, @@ -5623,10 +5642,12 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if ((ch->chunk_type & 0x40) && (stcb != NULL)) { struct mbuf *mm; struct sctp_paramhdr *phd; + int len; mm = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_NOWAIT, 1, MT_DATA); if (mm) { + len = min(SCTP_SIZE32(chk_length), (uint32_t)(length - *offset)); phd = mtod(mm, struct sctp_paramhdr *); /* * We cheat and use param type since @@ -5636,22 +5657,16 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, * names. */ phd->param_type = htons(SCTP_CAUSE_UNRECOG_CHUNK); - phd->param_length = htons(chk_length + sizeof(*phd)); + phd->param_length = htons(len + sizeof(*phd)); SCTP_BUF_LEN(mm) = sizeof(*phd); - SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, chk_length, M_NOWAIT); + SCTP_BUF_NEXT(mm) = SCTP_M_COPYM(m, *offset, len, M_NOWAIT); if (SCTP_BUF_NEXT(mm)) { - if (sctp_pad_lastmbuf(SCTP_BUF_NEXT(mm), SCTP_SIZE32(chk_length) - chk_length, NULL) == NULL) { + if (sctp_pad_lastmbuf(SCTP_BUF_NEXT(mm), SCTP_SIZE32(len) - len, NULL) == NULL) { sctp_m_freem(mm); } else { #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = SCTP_BUF_NEXT(mm); mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(SCTP_BUF_NEXT(mm), SCTP_MBUF_ICOPY); } #endif sctp_queue_op_err(stcb, mm); @@ -5732,7 +5747,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt #endif uint8_t ecn_bits, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -5773,11 +5788,8 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt } #endif #if defined(__FreeBSD__) - if ((net != NULL) && (use_mflowid != 0)) { - net->flowid = mflowid; -#ifdef INVARIANTS - net->flowidset = 1; -#endif + if ((net != NULL) && (mflowtype != M_HASHTYPE_NONE)) { + net->flowtype = mflowtype; } #endif if ((inp != NULL) && (stcb != NULL)) { @@ -5808,11 +5820,8 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt } #endif #if defined(__FreeBSD__) - if ((net != NULL) && (use_mflowid != 0)) { - net->flowid = mflowid; -#ifdef INVARIANTS - net->flowidset = 1; -#endif + if ((net != NULL) && (mflowtype != M_HASHTYPE_NONE)) { + net->flowtype = mflowtype; } #endif if (inp == NULL) { @@ -5825,7 +5834,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt if (ch->chunk_type == SCTP_SHUTDOWN_ACK) { sctp_send_shutdown_complete2(src, dst, sh, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); goto out; @@ -5842,7 +5851,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } @@ -5861,11 +5870,6 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt #ifdef INET case AF_INET: if (ipsec4_in_reject(m, &inp->ip_inp.inp)) { -#if defined(__FreeBSD__) && (__FreeBSD_version > 1000036) - IPSECSTAT_INC(ips_in_polvio); -#else - MODULE_GLOBAL(ipsec4stat).in_polvio++; -#endif SCTP_STAT_INCR(sctps_hdrops); goto out; } @@ -5874,11 +5878,6 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt #ifdef INET6 case AF_INET6: if (ipsec6_in_reject(m, &inp->ip_inp.inp)) { -#if defined(__FreeBSD__) && (__FreeBSD_version > 1000036) - IPSEC6STAT_INC(ips_in_polvio); -#else - MODULE_GLOBAL(ipsec6stat).in_polvio++; -#endif SCTP_STAT_INCR(sctps_hdrops); goto out; } @@ -5913,7 +5912,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt msg); sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); goto out; @@ -5927,7 +5926,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt src, dst, sh, ch, inp, stcb, &net, &fwd_tsn_seen, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb) { @@ -5969,7 +5968,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt msg); sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); goto out; @@ -6044,7 +6043,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt msg); sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); goto out; @@ -6067,7 +6066,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt src, dst, sh, inp, stcb, net, &high_tsn, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (retval == 2) { @@ -6153,18 +6152,6 @@ trigger_send: return; } -#if 0 -static void -sctp_print_mbuf_chain(struct mbuf *m) -{ - for (; m; m = SCTP_BUF_NEXT(m)) { - SCTP_PRINTF("%p: m_len = %ld\n", (void *)m, SCTP_BUF_LEN(m)); - if (SCTP_BUF_IS_EXTENDED(m)) - SCTP_PRINTF("%p: extend_size = %d\n", (void *)m, SCTP_BUF_EXTEND_SIZE(m)); - } -} -#endif - #ifdef INET #if !defined(__Userspace__) #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) @@ -6197,7 +6184,7 @@ sctp_input(i_pak, va_alist) #endif #if defined(__FreeBSD__) uint32_t mflowid; - uint8_t use_mflowid; + uint8_t mflowtype; #endif #if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)) uint16_t port = 0; @@ -6221,13 +6208,7 @@ sctp_input(i_pak, va_alist) #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_INPUT); - } - } + sctp_log_mbc(m, SCTP_MBUF_INPUT); } #endif #ifdef SCTP_PACKET_LOGGING @@ -6272,13 +6253,8 @@ sctp_input(i_pak, va_alist) m->m_pkthdr.csum_flags); #endif #if defined(__FreeBSD__) - if (m->m_flags & M_FLOWID) { - mflowid = m->m_pkthdr.flowid; - use_mflowid = 1; - } else { - mflowid = 0; - use_mflowid = 0; - } + mflowid = m->m_pkthdr.flowid; + mflowtype = M_HASHTYPE_GET(m); #endif SCTP_STAT_INCR(sctps_recvpackets); SCTP_STAT_INCR_COUNTER64(sctps_inpackets); @@ -6375,7 +6351,7 @@ sctp_input(i_pak, va_alist) #endif ecn_bits, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); out: @@ -6411,7 +6387,7 @@ sctp_input(struct mbuf *m, int off) int cpu_to_use; uint32_t flowid, tag; - if (m->m_flags & M_FLOWID) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { flowid = m->m_pkthdr.flowid; } else { /* No flow id built by lower layers @@ -6433,7 +6409,7 @@ sctp_input(struct mbuf *m, int off) tag = htonl(sh->v_tag); flowid = tag ^ ntohs(sh->dest_port) ^ ntohs(sh->src_port); m->m_pkthdr.flowid = flowid; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } cpu_to_use = sctp_cpuarry[flowid % mp_ncpus]; sctp_queue_to_mcore(m, off, cpu_to_use); diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_os_userspace.h b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_os_userspace.h index a8d1f08a0e1..13df4242388 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_os_userspace.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_os_userspace.h @@ -218,7 +218,9 @@ typedef char* caddr_t; #define bzero(buf, len) memset(buf, 0, len) #define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len) +#if _MSC_VER < 1900 #define snprintf(data, size, format, ...) _snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__) +#endif #define inline __inline #define __inline__ __inline #define MSG_EOR 0x8 /* data completes record */ @@ -271,7 +273,6 @@ typedef char* caddr_t; #endif #else /* !defined(Userspace_os_Windows) */ -#include <sys/cdefs.h> /* needed? added from old __FreeBSD__ */ #include <sys/socket.h> #if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) #include <pthread.h> @@ -435,10 +436,10 @@ struct sx {int dummy;}; /* #include <sys/param.h> in FreeBSD defines MSIZE */ /* #include <sys/ktr.h> */ /* #include <sys/systm.h> */ -#if defined(__Userspace_os_Windows) -#include <user_queue.h> -#else +#if defined(HAVE_SYS_QUEUE_H) #include <sys/queue.h> +#else +#include <user_queue.h> #endif #include <user_malloc.h> /* #include <sys/kernel.h> */ @@ -483,12 +484,10 @@ struct sx {int dummy;}; #include <netinet/in_systm.h> #include <netinet/ip.h> #endif -#if defined INET -#if defined(__Userspace_os_Windows) -#include <user_ip_icmp.h> -#else +#if defined(HAVE_NETINET_IP_ICMP_H) #include <netinet/ip_icmp.h> -#endif +#else +#include <user_ip_icmp.h> #endif /* #include <netinet/in_pcb.h> ported to userspace */ #include <user_inpcb.h> diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_output.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_output.c index 57cc8c665ef..49447fa9da4 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_output.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_output.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 273634 2014-10-25 09:25:29Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 280371 2015-03-23 15:12:02Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -3948,13 +3948,7 @@ sctp_add_cookie(struct mbuf *init, int init_offset, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = copy_init; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(copy_init, SCTP_MBUF_ICOPY); } #endif copy_initack = SCTP_M_COPYM(initack, initack_offset, M_COPYALL, @@ -3966,13 +3960,7 @@ sctp_add_cookie(struct mbuf *init, int init_offset, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = copy_initack; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(copy_initack, SCTP_MBUF_ICOPY); } #endif /* easy side we just drop it on the end */ @@ -4101,7 +4089,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, uint16_t port, union sctp_sockstore *over_addr, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) int so_locked SCTP_UNUSED @@ -4203,19 +4191,12 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, m = newm; #if defined(__FreeBSD__) if (net != NULL) { -#ifdef INVARIANTS - if (net->flowidset == 0) { - panic("Flow ID not set"); - } -#endif m->m_pkthdr.flowid = net->flowid; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, net->flowtype); } else { - if (use_mflowid != 0) { - m->m_pkthdr.flowid = mflowid; - m->m_flags |= M_FLOWID; - } - } + m->m_pkthdr.flowid = mflowid; + M_HASHTYPE_SET(m, mflowtype); + } #endif packet_length = sctp_calculate_len(m); ip = mtod(m, struct ip *); @@ -4564,19 +4545,12 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, m = newm; #if defined(__FreeBSD__) if (net != NULL) { -#ifdef INVARIANTS - if (net->flowidset == 0) { - panic("Flow ID not set"); - } -#endif m->m_pkthdr.flowid = net->flowid; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, net->flowtype); } else { - if (use_mflowid != 0) { - m->m_pkthdr.flowid = mflowid; - m->m_flags |= M_FLOWID; - } - } + m->m_pkthdr.flowid = mflowid; + M_HASHTYPE_SET(m, mflowtype); + } #endif packet_length = sctp_calculate_len(m); @@ -5843,7 +5817,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_init_chunk *init_chk, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port, int hold_inp_lock) { @@ -5899,7 +5873,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, "Address added"); sctp_send_abort(init_pkt, iphlen, src, dst, sh, 0, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return; @@ -5920,7 +5894,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, sctp_send_abort(init_pkt, iphlen, src, dst, sh, init_chk->init.initiate_tag, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return; @@ -6539,7 +6513,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag, port, over_addr, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif SCTP_SO_NOT_LOCKED); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); @@ -6924,13 +6898,7 @@ sctp_copy_mbufchain(struct mbuf *clonechain, appendchain = SCTP_M_COPYM(clonechain, 0, M_COPYALL, M_NOWAIT); #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = appendchain; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(appendchain, SCTP_MBUF_ICOPY); } #endif } @@ -7024,13 +6992,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(m, SCTP_MBUF_ICOPY); } #endif } else { @@ -7808,13 +7770,7 @@ re_look: } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = chk->data; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(chk->data, SCTP_MBUF_ICOPY); } #endif /* Pull off the data */ @@ -7875,6 +7831,7 @@ re_look: if (M_LEADINGSPACE(chk->data) < (int)sizeof(struct sctp_data_chunk)) { /* Not enough room for a chunk header, get some */ struct mbuf *m; + m = sctp_get_mbuf_for_msg(1, 0, M_NOWAIT, 0, MT_DATA); if (m == NULL) { /* @@ -7886,7 +7843,7 @@ re_look: SCTP_TCB_SEND_LOCK(stcb); send_lock_up = 1; } - if (chk->data == NULL) { + if (sp->data == NULL) { /* unsteal the data */ sp->data = chk->data; sp->tail_mbuf = chk->last_mbuf; @@ -8436,24 +8393,6 @@ again_one_more_time: } else { skip_data_for_this_net = 0; } -#if !(defined(__Panda__) || defined(__Windows__) || defined(__Userspace__) || defined(__APPLE__)) - if ((net->ro.ro_rt) && (net->ro.ro_rt->rt_ifp)) { - /* - * if we have a route and an ifp check to see if we - * have room to send to this guy - */ - struct ifnet *ifp; - - ifp = net->ro.ro_rt->rt_ifp; - if ((ifp->if_snd.ifq_len + 2) >= ifp->if_snd.ifq_maxlen) { - SCTP_STAT_INCR(sctps_ifnomemqueued); - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_MAXBURST_ENABLE) { - sctp_log_maxburst(stcb, net, ifp->if_snd.ifq_len, ifp->if_snd.ifq_maxlen, SCTP_MAX_IFP_APPLIED); - } - continue; - } - } -#endif switch (((struct sockaddr *)&net->ro._l_addr)->sa_family) { #ifdef INET case AF_INET: @@ -9407,12 +9346,11 @@ sctp_send_cookie_echo(struct mbuf *m, struct sctp_tmit_chunk *chk; uint16_t ptype, plen; + SCTP_TCB_LOCK_ASSERT(stcb); /* First find the cookie in the param area */ cookie = NULL; at = offset + sizeof(struct sctp_init_chunk); - - SCTP_TCB_LOCK_ASSERT(stcb); - do { + for (;;) { phdr = sctp_get_next_param(m, at, &parm, sizeof(parm)); if (phdr == NULL) { return (-3); @@ -9433,25 +9371,14 @@ sctp_send_cookie_echo(struct mbuf *m, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = cookie; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(cookie, SCTP_MBUF_ICOPY); } #endif break; } at += SCTP_SIZE32(plen); - } while (phdr); - if (cookie == NULL) { - /* Did not find the cookie */ - return (-3); } /* ok, we got the cookie lets change it into a cookie echo chunk */ - /* first the change from param to cookie */ hdr = mtod(cookie, struct sctp_chunkhdr *); hdr->chunk_type = SCTP_COOKIE_ECHO; @@ -9505,13 +9432,7 @@ sctp_send_heartbeat_ack(struct sctp_tcb *stcb, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = outchain; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(outchain, SCTP_MBUF_ICOPY); } #endif chdr = mtod(outchain, struct sctp_chunkhdr *); @@ -9794,13 +9715,7 @@ sctp_send_asconf_ack(struct sctp_tcb *stcb) } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m_ack; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(m_ack, SCTP_MBUF_ICOPY); } #endif @@ -9820,8 +9735,6 @@ sctp_send_asconf_ack(struct sctp_tcb *stcb) atomic_add_int(&chk->whoTo->ref_count, 1); } chk->data = m_ack; - chk->send_size = 0; - /* Get size */ chk->send_size = ack->len; chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; @@ -11446,7 +11359,7 @@ static void sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, uint32_t vtag, uint8_t type, struct mbuf *cause, - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, uint32_t vrf_id, uint16_t port) #else static void @@ -11552,10 +11465,8 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, SCTP_BUF_LEN(mout) = len; SCTP_BUF_NEXT(mout) = cause; #if defined(__FreeBSD__) - if (use_mflowid != 0) { - mout->m_pkthdr.flowid = mflowid; - mout->m_flags |= M_FLOWID; - } + mout->m_pkthdr.flowid = mflowid; + M_HASHTYPE_SET(mout, mflowtype); #endif #ifdef INET ip = NULL; @@ -11843,13 +11754,13 @@ void sctp_send_shutdown_complete2(struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { sctp_send_resp_msg(src, dst, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } @@ -12695,7 +12606,7 @@ void sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, uint32_t vtag, struct mbuf *cause, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -12707,7 +12618,7 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockadd } sctp_send_resp_msg(src, dst, sh, vtag, SCTP_ABORT_ASSOCIATION, cause, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return; @@ -12717,13 +12628,13 @@ void sctp_send_operr_to(struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, uint32_t vtag, struct mbuf *cause, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { sctp_send_resp_msg(src, dst, sh, vtag, SCTP_OPERATION_ERROR, cause, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return; @@ -13523,7 +13434,7 @@ sctp_lower_sosend(struct socket *so, if (inp->recv_callback) { non_blocking = 1; } -#else +#endif if (SCTP_SO_IS_NBIO(so) #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 || (flags & MSG_NBIO) @@ -13531,7 +13442,6 @@ sctp_lower_sosend(struct socket *so, ) { non_blocking = 1; } -#endif /* would we block? */ if (non_blocking) { if (hold_tcblock == 0) { diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.c index 9e0145ea2ad..2970970250a 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 271673 2014-09-16 14:20:33Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 280459 2015-03-24 21:12:45Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -71,6 +71,9 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 271673 2014-09-16 14:20:33Z tuex #endif #if defined(__Userspace__) #include <user_socketvar.h> +#if !defined(__Userspace_os_Windows) +#include <netdb.h> +#endif #endif #if defined(__APPLE__) @@ -1689,10 +1692,7 @@ sctp_findassociation_ep_addr(struct sctp_inpcb **inp_p, struct sockaddr *remote, goto null_return; } head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(rport, - inp->sctp_hashmark)]; - if (head == NULL) { - goto null_return; - } + inp->sctp_hashmark)]; LIST_FOREACH(stcb, head, sctp_tcbhash) { if (stcb->rport != rport) { /* remote port does not match */ @@ -2204,7 +2204,7 @@ sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) { /* For 1-2-1 with port reuse */ struct sctppcbhead *head; - struct sctp_inpcb *tinp; + struct sctp_inpcb *tinp, *ninp; if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) { /* only works with port reuse on */ @@ -2214,10 +2214,11 @@ sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) return (0); } SCTP_INP_RUNLOCK(inp); + SCTP_INP_INFO_WLOCK(); head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))]; /* Kick out all non-listeners to the TCP hash */ - LIST_FOREACH(tinp, head, sctp_hash) { + LIST_FOREACH_SAFE(tinp, head, sctp_hash, ninp) { if (tinp->sctp_lport != inp->sctp_lport) { continue; } @@ -2245,6 +2246,7 @@ sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) LIST_INSERT_HEAD(head, inp, sctp_hash); SCTP_INP_WUNLOCK(inp); SCTP_INP_RLOCK(inp); + SCTP_INP_INFO_WUNLOCK(); return (0); } @@ -2507,12 +2509,7 @@ sctp_findassoc_by_vtag(struct sockaddr *from, struct sockaddr *to, uint32_t vtag SCTP_INP_INFO_RLOCK(); head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(vtag, - SCTP_BASE_INFO(hashasocmark))]; - if (head == NULL) { - /* invalid vtag */ - SCTP_INP_INFO_RUNLOCK(); - return (NULL); - } + SCTP_BASE_INFO(hashasocmark))]; LIST_FOREACH(stcb, head, sctp_asocs) { SCTP_INP_RLOCK(stcb->sctp_ep); if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { @@ -2840,6 +2837,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) inp->sctp_associd_counter = 1; inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT; inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT; + inp->max_cwnd = 0; inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off); inp->ecn_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_ecn_enable); inp->prsctp_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pr_enable); @@ -4764,9 +4762,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, net->flowid = stcb->asoc.my_vtag ^ ntohs(stcb->rport) ^ ntohs(stcb->sctp_ep->sctp_lport); -#ifdef INVARIANTS - net->flowidset = 1; -#endif + net->flowtype = M_HASHTYPE_OPAQUE; #endif if (netp) { *netp = net; @@ -7483,6 +7479,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, switch (pr_supported->chunk_types[i]) { case SCTP_ASCONF: peer_supports_asconf = 1; + break; case SCTP_ASCONF_ACK: peer_supports_asconf_ack = 1; break; @@ -7771,10 +7768,6 @@ sctp_is_vtag_good(uint32_t tag, uint16_t lport, uint16_t rport, struct timeval * SCTP_INP_INFO_RLOCK(); head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(tag, SCTP_BASE_INFO(hashasocmark))]; - if (head == NULL) { - /* invalid vtag */ - goto skip_vtag_check; - } LIST_FOREACH(stcb, head, sctp_asocs) { /* We choose not to lock anything here. TCB's can't be * removed since we have the read lock, so they can't @@ -7798,8 +7791,6 @@ sctp_is_vtag_good(uint32_t tag, uint16_t lport, uint16_t rport, struct timeval * return (0); } } -skip_vtag_check: - chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; /* Now what about timed wait ? */ LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.h b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.h index d09bb59d149..0f124c7e412 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_pcb.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 269858 2014-08-12 11:30:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 279859 2015-03-10 19:49:25Z tuexen $"); #endif #ifndef _NETINET_SCTP_PCB_H_ @@ -478,6 +478,7 @@ struct sctp_inpcb { uint32_t sctp_frag_point; uint32_t partial_delivery_point; uint32_t sctp_context; + uint32_t max_cwnd; uint8_t local_strreset_support; uint32_t sctp_cmt_on_off; uint8_t ecn_supported; diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_peeloff.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_peeloff.c index beb11fbeadc..7f21f86f98c 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_peeloff.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_peeloff.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 269858 2014-08-12 11:30:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 279859 2015-03-10 19:49:25Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -134,6 +134,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id) n_inp->pktdrop_supported = inp->pktdrop_supported; n_inp->partial_delivery_point = inp->partial_delivery_point; n_inp->sctp_context = inp->sctp_context; + n_inp->max_cwnd = inp->max_cwnd; n_inp->local_strreset_support = inp->local_strreset_support; n_inp->inp_starting_point_for_iterator = NULL; /* copy in the authentication parameters from the original endpoint */ @@ -249,6 +250,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) n_inp->pktdrop_supported = inp->pktdrop_supported; n_inp->partial_delivery_point = inp->partial_delivery_point; n_inp->sctp_context = inp->sctp_context; + n_inp->max_cwnd = inp->max_cwnd; n_inp->local_strreset_support = inp->local_strreset_support; n_inp->inp_starting_point_for_iterator = NULL; #if defined(__Userspace__) diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_structs.h b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_structs.h index eadd44ee412..7047b418865 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_structs.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_structs.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 271643 2014-09-15 19:38:34Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 279859 2015-03-10 19:49:25Z tuexen $"); #endif #ifndef _NETINET_SCTP_STRUCTS_H_ @@ -428,9 +428,7 @@ struct sctp_nets { uint8_t rto_needed; #if defined(__FreeBSD__) uint32_t flowid; -#ifdef INVARIANTS - uint8_t flowidset; -#endif + uint8_t flowtype; #endif }; @@ -1251,6 +1249,7 @@ struct sctp_association { uint8_t sctp_cmt_pf; uint8_t use_precise_time; uint64_t sctp_features; + uint32_t max_cwnd; uint16_t port; /* remote UDP encapsulation port */ /* * The mapping array is used to track out of order sequences above diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_sysctl.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_sysctl.c index 5b2a483cdab..43f59313e1b 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_sysctl.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_sysctl.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 271221 2014-09-07 09:06:26Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 277424 2015-01-20 19:08:55Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -706,8 +706,12 @@ sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) sctp_over_udp_restart(); SCTP_INP_INFO_WUNLOCK(); #else +#if (SCTPCTL_UDP_TUNNELING_PORT_MIN == 0) + if (new > SCTPCTL_UDP_TUNNELING_PORT_MAX) { +#else if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) || (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) { +#endif error = EINVAL; } else { SCTP_INP_INFO_WLOCK(); @@ -787,9 +791,14 @@ sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) #else (req->newptr != NULL)) { #endif +#if (SCTPCTL_AUTH_ENABLE_MIN == 0) + if ((new > SCTPCTL_AUTH_ENABLE_MAX) || + ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { +#else if ((new < SCTPCTL_AUTH_ENABLE_MIN) || (new > SCTPCTL_AUTH_ENABLE_MAX) || ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { +#endif error = EINVAL; } else { SCTP_BASE_SYSCTL(sctp_auth_enable) = new; @@ -827,9 +836,14 @@ sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) #else (req->newptr != NULL)) { #endif +#if (SCTPCTL_ASCONF_ENABLE_MIN == 0) + if ((new > SCTPCTL_ASCONF_ENABLE_MAX) || + ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { +#else if ((new < SCTPCTL_ASCONF_ENABLE_MIN) || (new > SCTPCTL_ASCONF_ENABLE_MAX) || ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { +#endif error = EINVAL; } else { SCTP_BASE_SYSCTL(sctp_asconf_enable) = new; @@ -851,9 +865,11 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) int error; #if defined(__FreeBSD__) #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + struct sctpstat *sarry; + struct sctpstat sb; int cpu; - struct sctpstat sb, *sarry; #endif + struct sctpstat sb_temp; #endif #if defined (__APPLE__) @@ -865,8 +881,16 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) return (EINVAL); } #if defined(__FreeBSD__) + memset(&sb_temp, 0, sizeof(struct sctpstat)); + + if (req->newptr != NULL) { + error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat)); + if (error != 0) { + return (error); + } + } #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) - memset(&sb, 0, sizeof(struct sctpstat)); + memset(&sb, 0, sizeof(sb)); for (cpu = 0; cpu < mp_maxid; cpu++) { sarry = &SCTP_BASE_STATS[cpu]; if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) { @@ -995,12 +1019,18 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; if (req->newptr != NULL) { - memcpy(sarry, req->newptr, sizeof(struct sctpstat)); + memcpy(sarry, &sb_temp, sizeof(struct sctpstat)); } } error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat)); #else error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); + if (error != 0) { + return (error); + } + if (req->newptr != NULL) { + memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat)); + } #endif #else error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_timer.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_timer.c index 574a213e59e..48ad4590287 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_timer.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_timer.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 269448 2014-08-02 21:36:40Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 279841 2015-03-10 09:16:31Z tuexen $"); #endif #define _IP_VHL @@ -162,7 +162,7 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct mbuf *op_err; op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, - "Association error couter exceeded"); + "Association error counter exceeded"); inp->last_abort_code = SCTP_FROM_SCTP_TIMER+SCTP_LOC_1; sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); return (1); @@ -332,10 +332,9 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, return (NULL); } } - do { + for (;;) { alt = TAILQ_NEXT(mnet, sctp_next); - if (alt == NULL) - { + if (alt == NULL) { once++; if (once > 1) { break; @@ -352,7 +351,6 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, } alt->src_addr_selected = 0; } - /*sa_ignore NO_NULL_CHK*/ if (((alt->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE) && (alt->ro.ro_rt != NULL) && (!(alt->dest_state & SCTP_ADDR_UNCONFIRMED))) { @@ -360,14 +358,14 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, break; } mnet = alt; - } while (alt != NULL); + } if (alt == NULL) { /* Case where NO insv network exists (dormant state) */ /* we rotate destinations */ once = 0; mnet = net; - do { + for (;;) { if (mnet == NULL) { return (TAILQ_FIRST(&stcb->asoc.nets)); } @@ -378,15 +376,17 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, break; } alt = TAILQ_FIRST(&stcb->asoc.nets); + if (alt == NULL) { + break; + } } - /*sa_ignore NO_NULL_CHK*/ if ((!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) && (alt != net)) { /* Found an alternate address */ break; } mnet = alt; - } while (alt != NULL); + } } if (alt == NULL) { return (net); diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_usrreq.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_usrreq.c index 362d3530711..408f705e9f4 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_usrreq.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_usrreq.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 272750 2014-10-08 15:29:49Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 280634 2015-03-25 21:41:20Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -43,10 +43,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 272750 2014-10-08 15:29:49Z t #include <netinet/sctp_header.h> #include <netinet/sctp_var.h> #ifdef INET6 -#if defined(__Userspace_os_FreeBSD) #include <netinet6/sctp6_var.h> #endif -#endif #include <netinet/sctp_sysctl.h> #include <netinet/sctp_output.h> #include <netinet/sctp_uio.h> @@ -297,21 +295,19 @@ sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint16_t nxtsz) if (chk->sent < SCTP_DATAGRAM_RESEND) { sctp_flight_size_decrease(chk); sctp_total_flight_decrease(stcb, chk); - } - if (chk->sent != SCTP_DATAGRAM_RESEND) { + chk->sent = SCTP_DATAGRAM_RESEND; sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); + chk->rec.data.doing_fast_retransmit = 0; + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) { + sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU, + chk->whoTo->flight_size, + chk->book_size, + (uintptr_t)chk->whoTo, + chk->rec.data.TSN_seq); + } + /* Clear any time so NO RTT is being done */ + chk->do_rtt = 0; } - chk->sent = SCTP_DATAGRAM_RESEND; - chk->rec.data.doing_fast_retransmit = 0; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) { - sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU, - chk->whoTo->flight_size, - chk->book_size, - (uintptr_t)chk->whoTo, - chk->rec.data.TSN_seq); - } - /* Clear any time so NO RTT is being done */ - chk->do_rtt = 0; } } } @@ -1697,7 +1693,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, continue; } #ifdef INET6 - if (sctp_is_feature_on(inp,SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *)sas); ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport; sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in6)); @@ -1938,10 +1934,14 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) switch (sctp_ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - if (sctp_is_feature_on(inp,SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) +#ifdef INET6 + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) cnt += sizeof(struct sockaddr_in6); else cnt += sizeof(struct sockaddr_in); +#else + cnt += sizeof(struct sockaddr_in); +#endif break; #endif #ifdef INET6 @@ -1966,10 +1966,14 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) switch (laddr->ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - if (sctp_is_feature_on(inp,SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) +#ifdef INET6 + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) cnt += sizeof(struct sockaddr_in6); else cnt += sizeof(struct sockaddr_in); +#else + cnt += sizeof(struct sockaddr_in); +#endif break; #endif #ifdef INET6 @@ -2456,8 +2460,9 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, SCTP_CHECK_AND_CAST(av, optval, struct sctp_stream_value, *optsize); SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - if (stcb->asoc.ss_functions.sctp_ss_get_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id], - &av->stream_value) < 0) { + if ((av->stream_id >= stcb->asoc.streamoutcnt) || + (stcb->asoc.ss_functions.sctp_ss_get_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id], + &av->stream_value) < 0)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } else { @@ -2851,28 +2856,32 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, size = 0; /* Count the sizes */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { - size += sizeof(struct sockaddr_in6); - } else { - switch (((struct sockaddr *)&net->ro._l_addr)->sa_family) { + switch (net->ro._l_addr.sa.sa_family) { #ifdef INET - case AF_INET: + case AF_INET: +#ifdef INET6 + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { + size += sizeof(struct sockaddr_in6); + } else { size += sizeof(struct sockaddr_in); - break; + } +#else + size += sizeof(struct sockaddr_in); +#endif + break; #endif #ifdef INET6 - case AF_INET6: - size += sizeof(struct sockaddr_in6); - break; + case AF_INET6: + size += sizeof(struct sockaddr_in6); + break; #endif #if defined(__Userspace__) - case AF_CONN: - size += sizeof(struct sockaddr_conn); - break; + case AF_CONN: + size += sizeof(struct sockaddr_conn); + break; #endif - default: - break; - } + default: + break; } } SCTP_TCB_UNLOCK(stcb); @@ -2904,29 +2913,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, sas = (struct sockaddr_storage *)&saddr->addr[0]; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { - cpsz = sizeof(struct sockaddr_in6); - } else { - switch (((struct sockaddr *)&net->ro._l_addr)->sa_family) { + switch (net->ro._l_addr.sa.sa_family) { #ifdef INET - case AF_INET: + case AF_INET: +#ifdef INET6 + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { + cpsz = sizeof(struct sockaddr_in6); + } else { cpsz = sizeof(struct sockaddr_in); - break; + } +#else + cpsz = sizeof(struct sockaddr_in); +#endif + break; #endif #ifdef INET6 - case AF_INET6: - cpsz = sizeof(struct sockaddr_in6); - break; + case AF_INET6: + cpsz = sizeof(struct sockaddr_in6); + break; #endif #if defined(__Userspace__) - case AF_CONN: - cpsz = sizeof(struct sockaddr_conn); - break; + case AF_CONN: + cpsz = sizeof(struct sockaddr_conn); + break; #endif - default: - cpsz = 0; - break; - } + default: + cpsz = 0; + break; } if (cpsz == 0) { break; @@ -2937,15 +2950,15 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } #if defined(INET) && defined(INET6) if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) && - (((struct sockaddr *)&net->ro._l_addr)->sa_family == AF_INET)) { + (net->ro._l_addr.sa.sa_family == AF_INET)) { /* Must map the address */ - in6_sin_2_v4mapsin6((struct sockaddr_in *)&net->ro._l_addr, + in6_sin_2_v4mapsin6(&net->ro._l_addr.sin, (struct sockaddr_in6 *)sas); } else { -#endif memcpy(sas, &net->ro._l_addr, cpsz); -#if defined(INET) && defined(INET6) } +#else + memcpy(sas, &net->ro._l_addr, cpsz); #endif ((struct sockaddr_in *)sas)->sin_port = stcb->rport; @@ -2982,34 +2995,52 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, { struct sctp_paddrparams *paddrp; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(paddrp, optval, struct sctp_paddrparams, *optsize); SCTP_FIND_STCB(inp, stcb, paddrp->spp_assoc_id); - net = NULL; - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&paddrp->spp_address); +#if defined(INET) && defined(INET6) + if (paddrp->spp_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&paddrp->spp_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&paddrp->spp_address; + } + } else { + addr = (struct sockaddr *)&paddrp->spp_address; + } +#else + addr = (struct sockaddr *)&paddrp->spp_address; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked * tcb (last argument) is NOT a TCB.. aka NULL. */ + net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, (struct sockaddr *)&paddrp->spp_address, &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if (stcb && (net == NULL)) { - struct sockaddr *sa; - - sa = (struct sockaddr *)&paddrp->spp_address; + if ((stcb != NULL) && (net == NULL)) { #ifdef INET - if (sa->sa_family == AF_INET) { + if (addr->sa_family == AF_INET) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr) { + sin = (struct sockaddr_in *)addr; + if (sin->sin_addr.s_addr != INADDR_ANY) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); @@ -3018,10 +3049,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } else #endif #ifdef INET6 - if (sa->sa_family == AF_INET6) { + if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = (struct sockaddr_in6 *)addr; if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); @@ -3031,10 +3062,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } else #endif #if defined(__Userspace__) - if (sa->sa_family == AF_CONN) { + if (addr->sa_family == AF_CONN) { struct sockaddr_conn *sconn; - sconn = (struct sockaddr_conn *)sa; + sconn = (struct sockaddr_conn *)addr; if (sconn->sconn_addr != NULL) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); @@ -3051,10 +3082,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } } - if (stcb) { + if (stcb != NULL) { /* Applies to the specific association */ paddrp->spp_flags = 0; - if (net) { + if (net != NULL) { int ovh; if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { ovh = SCTP_MED_OVERHEAD; @@ -3169,26 +3200,47 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, { struct sctp_paddrinfo *paddri; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(paddri, optval, struct sctp_paddrinfo, *optsize); SCTP_FIND_STCB(inp, stcb, paddri->spinfo_assoc_id); - net = NULL; - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&paddri->spinfo_address); +#if defined(INET) && defined(INET6) + if (paddri->spinfo_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&paddri->spinfo_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&paddri->spinfo_address; + } + } else { + addr = (struct sockaddr *)&paddri->spinfo_address; + } +#else + addr = (struct sockaddr *)&paddri->spinfo_address; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked * tcb (last argument) is NOT a TCB.. aka NULL. */ + net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, (struct sockaddr *)&paddri->spinfo_address, &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if ((stcb) && (net)) { + if ((stcb != NULL) && (net != NULL)) { if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { /* It's unconfirmed */ paddri->spinfo_state = SCTP_UNCONFIRMED; @@ -3207,7 +3259,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, SCTP_TCB_UNLOCK(stcb); *optsize = sizeof(struct sctp_paddrinfo); } else { - if (stcb) { + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); @@ -3436,26 +3488,37 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, SCTP_FIND_STCB(inp, stcb, ssp->ssp_assoc_id); if (stcb) { - /* simply copy out the sockaddr_storage... */ - size_t len; + union sctp_sockstore *addr; - len = *optsize; -#ifdef HAVE_SA_LEN - if (len > stcb->asoc.primary_destination->ro._l_addr.sa.sa_len) - len = stcb->asoc.primary_destination->ro._l_addr.sa.sa_len; + addr = &stcb->asoc.primary_destination->ro._l_addr; + switch (addr->sa.sa_family) { +#ifdef INET + case AF_INET: +#ifdef INET6 + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { + in6_sin_2_v4mapsin6(&addr->sin, + (struct sockaddr_in6 *)&ssp->ssp_addr); + } else { + memcpy(&ssp->ssp_addr, &addr->sin, sizeof(struct sockaddr_in)); + } #else - if (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family == AF_INET && - len > sizeof(struct sockaddr_in)) - len = sizeof(struct sockaddr_in); - else if ( - stcb->asoc.primary_destination->ro._l_addr.sa.sa_family == AF_INET6 && - len > sizeof(struct sockaddr_in6)) - len = sizeof(struct sockaddr_in6); + memcpy(&ssp->ssp_addr, &addr->sin, sizeof(struct sockaddr_in)); #endif - - memcpy(&ssp->ssp_addr, - &stcb->asoc.primary_destination->ro._l_addr, - len); + break; +#endif +#ifdef INET6 + case AF_INET6: + memcpy(&ssp->ssp_addr, &addr->sin6, sizeof(struct sockaddr_in6)); + break; +#endif +#if defined(__Userspace__) + case AF_CONN: + memcpy(&ssp->ssp_addr, &addr->sconn, sizeof(struct sockaddr_conn)); + break; +#endif + default: + break; + } SCTP_TCB_UNLOCK(stcb); *optsize = sizeof(struct sctp_setprim); } else { @@ -3809,34 +3872,52 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, { struct sctp_paddrthlds *thlds; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(thlds, optval, struct sctp_paddrthlds, *optsize); SCTP_FIND_STCB(inp, stcb, thlds->spt_assoc_id); - net = NULL; - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&thlds->spt_address); +#if defined(INET) && defined(INET6) + if (thlds->spt_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&thlds->spt_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&thlds->spt_address; + } + } else { + addr = (struct sockaddr *)&thlds->spt_address; + } +#else + addr = (struct sockaddr *)&thlds->spt_address; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked * tcb (last argument) is NOT a TCB.. aka NULL. */ + net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, (struct sockaddr *)&thlds->spt_address, &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if (stcb && (net == NULL)) { - struct sockaddr *sa; - - sa = (struct sockaddr *)&thlds->spt_address; + if ((stcb != NULL) && (net == NULL)) { #ifdef INET - if (sa->sa_family == AF_INET) { + if (addr->sa_family == AF_INET) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr) { + sin = (struct sockaddr_in *)addr; + if (sin->sin_addr.s_addr != INADDR_ANY) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); @@ -3845,10 +3926,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } else #endif #ifdef INET6 - if (sa->sa_family == AF_INET6) { + if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = (struct sockaddr_in6 *)addr; if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); @@ -3858,10 +3939,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } else #endif #if defined(__Userspace__) - if (sa->sa_family == AF_CONN) { + if (addr->sa_family == AF_CONN) { struct sockaddr_conn *sconn; - sconn = (struct sockaddr_conn *)sa; + sconn = (struct sockaddr_conn *)addr; if (sconn->sconn_addr != NULL) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); @@ -3878,8 +3959,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } } - if (stcb) { - if (net) { + if (stcb != NULL) { + if (net != NULL) { thlds->spt_pathmaxrxt = net->failure_threshold; thlds->spt_pathpfthld = net->pf_threshold; } else { @@ -3911,12 +3992,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, { struct sctp_udpencaps *encaps; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(encaps, optval, struct sctp_udpencaps, *optsize); SCTP_FIND_STCB(inp, stcb, encaps->sue_assoc_id); +#if defined(INET) && defined(INET6) + if (encaps->sue_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&encaps->sue_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&encaps->sue_address; + } + } else { + addr = (struct sockaddr *)&encaps->sue_address; + } +#else + addr = (struct sockaddr *)&encaps->sue_address; +#endif if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&encaps->sue_address); + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked @@ -3924,21 +4026,18 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, */ net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, (struct sockaddr *)&encaps->sue_address, &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if (stcb && (net == NULL)) { - struct sockaddr *sa; - - sa = (struct sockaddr *)&encaps->sue_address; + if ((stcb != NULL) && (net == NULL)) { #ifdef INET - if (sa->sa_family == AF_INET) { + if (addr->sa_family == AF_INET) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr) { + sin = (struct sockaddr_in *)addr; + if (sin->sin_addr.s_addr != INADDR_ANY) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); @@ -3947,10 +4046,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } else #endif #ifdef INET6 - if (sa->sa_family == AF_INET6) { + if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = (struct sockaddr_in6 *)addr; if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); @@ -3960,10 +4059,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } else #endif #if defined(__Userspace__) - if (sa->sa_family == AF_CONN) { + if (addr->sa_family == AF_CONN) { struct sockaddr_conn *sconn; - sconn = (struct sockaddr_conn *)sa; + sconn = (struct sockaddr_conn *)addr; if (sconn->sconn_addr != NULL) { error = EINVAL; SCTP_TCB_UNLOCK(stcb); @@ -3980,7 +4079,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } } - if (stcb) { + if (stcb != NULL) { if (net) { encaps->sue_port = net->port; } else { @@ -4233,16 +4332,10 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, policy = sprstat->sprstat_policy; #if defined(SCTP_DETAILED_STR_STATS) if ((stcb != NULL) && - (policy != SCTP_PR_SCTP_NONE) && (sid < stcb->asoc.streamoutcnt) && - ((policy == SCTP_PR_SCTP_ALL) || - (PR_SCTP_VALID_POLICY(policy)))) { -#else - if ((stcb != NULL) && (policy != SCTP_PR_SCTP_NONE) && - (sid < stcb->asoc.streamoutcnt) && - (policy == SCTP_PR_SCTP_ALL)) { -#endif + ((policy <= SCTP_PR_SCTP_MAX) || + (policy == SCTP_PR_SCTP_ALL))) { if (policy == SCTP_PR_SCTP_ALL) { sprstat->sprstat_abandoned_unsent = stcb->asoc.strmout[sid].abandoned_unsent[0]; sprstat->sprstat_abandoned_sent = stcb->asoc.strmout[sid].abandoned_sent[0]; @@ -4250,6 +4343,13 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, sprstat->sprstat_abandoned_unsent = stcb->asoc.strmout[sid].abandoned_unsent[policy]; sprstat->sprstat_abandoned_sent = stcb->asoc.strmout[sid].abandoned_sent[policy]; } +#else + if ((stcb != NULL) && + (sid < stcb->asoc.streamoutcnt) && + (policy == SCTP_PR_SCTP_ALL)) { + sprstat->sprstat_abandoned_unsent = stcb->asoc.strmout[sid].abandoned_unsent[0]; + sprstat->sprstat_abandoned_sent = stcb->asoc.strmout[sid].abandoned_sent[0]; +#endif SCTP_TCB_UNLOCK(stcb); *optsize = sizeof(struct sctp_prstatus); } else { @@ -4269,8 +4369,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, policy = sprstat->sprstat_policy; if ((stcb != NULL) && (policy != SCTP_PR_SCTP_NONE) && - ((policy == SCTP_PR_SCTP_ALL) || - (PR_SCTP_VALID_POLICY(policy)))) { + ((policy <= SCTP_PR_SCTP_MAX) || + (policy == SCTP_PR_SCTP_ALL))) { if (policy == SCTP_PR_SCTP_ALL) { sprstat->sprstat_abandoned_unsent = stcb->asoc.abandoned_unsent[0]; sprstat->sprstat_abandoned_sent = stcb->asoc.abandoned_sent[0]; @@ -4286,6 +4386,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } break; } + case SCTP_MAX_CWND: + { + struct sctp_assoc_value *av; + + SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); + SCTP_FIND_STCB(inp, stcb, av->assoc_id); + + if (stcb) { + av->assoc_value = stcb->asoc.max_cwnd; + 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 = inp->max_cwnd; + SCTP_INP_RUNLOCK(inp); + } else { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + } + } + if (error == 0) { + *optsize = sizeof(struct sctp_assoc_value); + } + break; + } default: SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOPROTOOPT); error = ENOPROTOOPT; @@ -4629,8 +4756,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_CHECK_AND_CAST(av, optval, struct sctp_stream_value, optsize); SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - if (stcb->asoc.ss_functions.sctp_ss_set_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id], - av->stream_value) < 0) { + if ((av->stream_id >= stcb->asoc.streamoutcnt) || + (stcb->asoc.ss_functions.sctp_ss_set_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id], + av->stream_value) < 0)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } @@ -4640,14 +4768,15 @@ 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.ss_functions.sctp_ss_set_value(stcb, - &stcb->asoc, - &stcb->asoc.strmout[av->stream_id], - av->stream_value); + if (av->stream_id < stcb->asoc.streamoutcnt) { + stcb->asoc.ss_functions.sctp_ss_set_value(stcb, + &stcb->asoc, + &stcb->asoc.strmout[av->stream_id], + av->stream_value); + } SCTP_TCB_UNLOCK(stcb); } SCTP_INP_RUNLOCK(inp); - } else { /* Can't set stream value without association */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -5423,7 +5552,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, case SCTP_CONNECT_X_COMPLETE: { struct sockaddr *sa; - struct sctp_nets *net; /* FIXME MT: check correct? */ SCTP_CHECK_AND_CAST(sa, optval, struct sockaddr, optsize); @@ -5434,7 +5562,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, stcb = LIST_FIRST(&inp->sctp_asoc_list); if (stcb) { SCTP_TCB_LOCK(stcb); - net = sctp_findnet(stcb, sa); } SCTP_INP_RUNLOCK(inp); } else { @@ -5443,7 +5570,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, * tcb (last argument) is NOT a TCB.. aka NULL. */ SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, sa, &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, sa, NULL, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } @@ -5767,35 +5894,53 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, { struct sctp_paddrparams *paddrp; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(paddrp, optval, struct sctp_paddrparams, optsize); SCTP_FIND_STCB(inp, stcb, paddrp->spp_assoc_id); - net = NULL; - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&paddrp->spp_address); + +#if defined(INET) && defined(INET6) + if (paddrp->spp_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&paddrp->spp_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&paddrp->spp_address; + } + } else { + addr = (struct sockaddr *)&paddrp->spp_address; + } +#else + addr = (struct sockaddr *)&paddrp->spp_address; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked * tcb (last argument) is NOT a TCB.. aka NULL. */ + net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, - (struct sockaddr *)&paddrp->spp_address, - &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, + &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if (stcb && (net == NULL)) { - struct sockaddr *sa; - - sa = (struct sockaddr *)&paddrp->spp_address; + if ((stcb != NULL) && (net == NULL)) { #ifdef INET - if (sa->sa_family == AF_INET) { + if (addr->sa_family == AF_INET) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr) { + sin = (struct sockaddr_in *)addr; + if (sin->sin_addr.s_addr != INADDR_ANY) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); error = EINVAL; @@ -5804,10 +5949,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #ifdef INET6 - if (sa->sa_family == AF_INET6) { + if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = (struct sockaddr_in6 *)addr; if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); @@ -5817,10 +5962,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #if defined(__Userspace__) - if (sa->sa_family == AF_CONN) { + if (addr->sa_family == AF_CONN) { struct sockaddr_conn *sconn; - sconn = (struct sockaddr_conn *)sa; + sconn = (struct sockaddr_conn *)addr; if (sconn->sconn_addr != NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); @@ -5851,7 +5996,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, return (EINVAL); } - if (stcb) { + if (stcb != NULL) { /************************TCB SPECIFIC SET ******************/ /* * do we change the timer for HB, we run @@ -5866,7 +6011,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } /* network sets ? */ - if (net) { + if (net != NULL) { /************************NET SPECIFIC SET ******************/ if (paddrp->spp_flags & SPP_HB_DISABLE) { if (!(net->dest_state & SCTP_ADDR_UNCONFIRMED) && @@ -5951,7 +6096,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, #endif } else { /************************ASSOC ONLY -- NO NET SPECIFIC SET ******************/ - if (paddrp->spp_pathmaxrxt) { + if (paddrp->spp_pathmaxrxt != 0) { stcb->asoc.def_net_failure = paddrp->spp_pathmaxrxt; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { if (net->dest_state & SCTP_ADDR_PF) { @@ -5983,14 +6128,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } if (paddrp->spp_flags & SPP_HB_ENABLE) { - if (paddrp->spp_hbinterval) { + if (paddrp->spp_hbinterval != 0) { stcb->asoc.heart_beat_delay = paddrp->spp_hbinterval; } else if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) { stcb->asoc.heart_beat_delay = 0; } /* Turn back on the timer */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - if (paddrp->spp_hbinterval) { + if (paddrp->spp_hbinterval != 0) { net->heart_beat_delay = paddrp->spp_hbinterval; } else if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) { net->heart_beat_delay = 0; @@ -6070,13 +6215,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, * For the TOS/FLOWLABEL stuff you set it * with the options on the socket */ - if (paddrp->spp_pathmaxrxt) { + if (paddrp->spp_pathmaxrxt != 0) { inp->sctp_ep.def_net_failure = paddrp->spp_pathmaxrxt; } if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = 0; - else if (paddrp->spp_hbinterval) { + else if (paddrp->spp_hbinterval != 0) { if (paddrp->spp_hbinterval > SCTP_MAX_HB_INTERVAL) paddrp->spp_hbinterval= SCTP_MAX_HB_INTERVAL; inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(paddrp->spp_hbinterval); @@ -6243,28 +6388,48 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, { struct sctp_setprim *spa; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(spa, optval, struct sctp_setprim, optsize); SCTP_FIND_STCB(inp, stcb, spa->ssp_assoc_id); - net = NULL; - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&spa->ssp_addr); +#if defined(INET) && defined(INET6) + if (spa->ssp_addr.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&spa->ssp_addr; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&spa->ssp_addr; + } + } else { + addr = (struct sockaddr *)&spa->ssp_addr; + } +#else + addr = (struct sockaddr *)&spa->ssp_addr; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked * tcb (last argument) is NOT a TCB.. aka NULL. */ + net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, - (struct sockaddr *)&spa->ssp_addr, - &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, + &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if ((stcb) && (net)) { + if ((stcb != NULL) && (net != NULL)) { if ((net != stcb->asoc.primary_destination) && (!(net->dest_state & SCTP_ADDR_UNCONFIRMED))) { /* Ok we need to set it */ @@ -6281,7 +6446,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } - if (stcb) { + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } break; @@ -6340,13 +6505,34 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, case SCTP_SET_PEER_PRIMARY_ADDR: { struct sctp_setpeerprim *sspp; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(sspp, optval, struct sctp_setpeerprim, optsize); SCTP_FIND_STCB(inp, stcb, sspp->sspp_assoc_id); if (stcb != NULL) { struct sctp_ifa *ifa; - ifa = sctp_find_ifa_by_addr((struct sockaddr *)&sspp->sspp_addr, - stcb->asoc.vrf_id, SCTP_ADDR_NOT_LOCKED); + +#if defined(INET) && defined(INET6) + if (sspp->sspp_addr.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&sspp->sspp_addr; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&sspp->sspp_addr; + } + } else { + addr = (struct sockaddr *)&sspp->sspp_addr; + } +#else + addr = (struct sockaddr *)&sspp->sspp_addr; +#endif + ifa = sctp_find_ifa_by_addr(addr, stcb->asoc.vrf_id, SCTP_ADDR_NOT_LOCKED); if (ifa == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; @@ -6356,6 +6542,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, /* Must validate the ifa found is in our ep */ struct sctp_laddr *laddr; int found = 0; + LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { if (laddr->ifa == NULL) { SCTPDBG(SCTP_DEBUG_OUTPUT1, "%s: NULL ifa\n", @@ -6374,13 +6561,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } #if defined(__FreeBSD__) } else { - switch (sspp->sspp_addr.ss_family) { + switch (addr->sa_family) { #ifdef INET case AF_INET: { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&sspp->sspp_addr; + sin = (struct sockaddr_in *)addr; if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -6395,7 +6582,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&sspp->sspp_addr; + sin6 = (struct sockaddr_in6 *)addr; if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -6412,8 +6599,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } #endif } - if (sctp_set_primary_ip_address_sa(stcb, - (struct sockaddr *)&sspp->sspp_addr) != 0) { + if (sctp_set_primary_ip_address_sa(stcb, addr) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } @@ -6746,7 +6932,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_CHECK_AND_CAST(info, optval, struct sctp_default_prinfo, optsize); SCTP_FIND_STCB(inp, stcb, info->pr_assoc_id); - if (PR_SCTP_INVALID_POLICY(info->pr_policy)) { + if (info->pr_policy > SCTP_PR_SCTP_MAX) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; @@ -6787,35 +6973,53 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, { struct sctp_paddrthlds *thlds; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(thlds, optval, struct sctp_paddrthlds, optsize); SCTP_FIND_STCB(inp, stcb, thlds->spt_assoc_id); - net = NULL; - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&thlds->spt_address); + +#if defined(INET) && defined(INET6) + if (thlds->spt_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&thlds->spt_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&thlds->spt_address; + } + } else { + addr = (struct sockaddr *)&thlds->spt_address; + } +#else + addr = (struct sockaddr *)&thlds->spt_address; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked * tcb (last argument) is NOT a TCB.. aka NULL. */ + net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, - (struct sockaddr *)&thlds->spt_address, - &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, + &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if (stcb && (net == NULL)) { - struct sockaddr *sa; - - sa = (struct sockaddr *)&thlds->spt_address; + if ((stcb != NULL) && (net == NULL)) { #ifdef INET - if (sa->sa_family == AF_INET) { + if (addr->sa_family == AF_INET) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr) { + sin = (struct sockaddr_in *)addr; + if (sin->sin_addr.s_addr != INADDR_ANY) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); error = EINVAL; @@ -6824,10 +7028,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #ifdef INET6 - if (sa->sa_family == AF_INET6) { + if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = (struct sockaddr_in6 *)addr; if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); @@ -6837,10 +7041,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #if defined(__Userspace__) - if (sa->sa_family == AF_CONN) { + if (addr->sa_family == AF_CONN) { struct sockaddr_conn *sconn; - sconn = (struct sockaddr_conn *)sa; + sconn = (struct sockaddr_conn *)addr; if (sconn->sconn_addr != NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); @@ -6856,16 +7060,18 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, break; } } - if (stcb) { - if (net) { + if (stcb != NULL) { + if (net != NULL) { + net->failure_threshold = thlds->spt_pathmaxrxt; + net->pf_threshold = thlds->spt_pathpfthld; if (net->dest_state & SCTP_ADDR_PF) { - if ((net->failure_threshold > thlds->spt_pathmaxrxt) || - (net->failure_threshold <= thlds->spt_pathpfthld)) { + if ((net->error_count > net->failure_threshold) || + (net->error_count <= net->pf_threshold)) { net->dest_state &= ~SCTP_ADDR_PF; } } else { - if ((net->failure_threshold > thlds->spt_pathpfthld) && - (net->failure_threshold <= thlds->spt_pathmaxrxt)) { + if ((net->error_count > net->pf_threshold) && + (net->error_count <= net->failure_threshold)) { net->dest_state |= SCTP_ADDR_PF; sctp_send_hb(stcb, net, SCTP_SO_LOCKED); sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_TIMER + SCTP_LOC_3); @@ -6873,28 +7079,28 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } } if (net->dest_state & SCTP_ADDR_REACHABLE) { - if (net->failure_threshold > thlds->spt_pathmaxrxt) { + if (net->error_count > net->failure_threshold) { net->dest_state &= ~SCTP_ADDR_REACHABLE; sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_DOWN, stcb, 0, net, SCTP_SO_LOCKED); } } else { - if (net->failure_threshold <= thlds->spt_pathmaxrxt) { + if (net->error_count <= net->failure_threshold) { net->dest_state |= SCTP_ADDR_REACHABLE; sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_UP, stcb, 0, net, SCTP_SO_LOCKED); } } - net->failure_threshold = thlds->spt_pathmaxrxt; - net->pf_threshold = thlds->spt_pathpfthld; } else { TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { + net->failure_threshold = thlds->spt_pathmaxrxt; + net->pf_threshold = thlds->spt_pathpfthld; if (net->dest_state & SCTP_ADDR_PF) { - if ((net->failure_threshold > thlds->spt_pathmaxrxt) || - (net->failure_threshold <= thlds->spt_pathpfthld)) { + if ((net->error_count > net->failure_threshold) || + (net->error_count <= net->pf_threshold)) { net->dest_state &= ~SCTP_ADDR_PF; } } else { - if ((net->failure_threshold > thlds->spt_pathpfthld) && - (net->failure_threshold <= thlds->spt_pathmaxrxt)) { + if ((net->error_count > net->pf_threshold) && + (net->error_count <= net->failure_threshold)) { net->dest_state |= SCTP_ADDR_PF; sctp_send_hb(stcb, net, SCTP_SO_LOCKED); sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_TIMER + SCTP_LOC_3); @@ -6902,22 +7108,21 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } } if (net->dest_state & SCTP_ADDR_REACHABLE) { - if (net->failure_threshold > thlds->spt_pathmaxrxt) { + if (net->error_count > net->failure_threshold) { net->dest_state &= ~SCTP_ADDR_REACHABLE; sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_DOWN, stcb, 0, net, SCTP_SO_LOCKED); } } else { - if (net->failure_threshold <= thlds->spt_pathmaxrxt) { + if (net->error_count <= net->failure_threshold) { net->dest_state |= SCTP_ADDR_REACHABLE; sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_UP, stcb, 0, net, SCTP_SO_LOCKED); } } - net->failure_threshold = thlds->spt_pathmaxrxt; - net->pf_threshold = thlds->spt_pathpfthld; } stcb->asoc.def_net_failure = thlds->spt_pathmaxrxt; stcb->asoc.def_net_pf_threshold = thlds->spt_pathpfthld; } + SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || @@ -6937,11 +7142,33 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, { struct sctp_udpencaps *encaps; struct sctp_nets *net; + struct sockaddr *addr; +#if defined(INET) && defined(INET6) + struct sockaddr_in sin_store; +#endif SCTP_CHECK_AND_CAST(encaps, optval, struct sctp_udpencaps, optsize); SCTP_FIND_STCB(inp, stcb, encaps->sue_assoc_id); - if (stcb) { - net = sctp_findnet(stcb, (struct sockaddr *)&encaps->sue_address); + +#if defined(INET) && defined(INET6) + if (encaps->sue_address.ss_family == AF_INET6) { + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *)&encaps->sue_address; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + in6_sin6_2_sin(&sin_store, sin6); + addr = (struct sockaddr *)&sin_store; + } else { + addr = (struct sockaddr *)&encaps->sue_address; + } + } else { + addr = (struct sockaddr *)&encaps->sue_address; + } +#else + addr = (struct sockaddr *)&encaps->sue_address; +#endif + if (stcb != NULL) { + net = sctp_findnet(stcb, addr); } else { /* We increment here since sctp_findassociation_ep_addr() wil * do a decrement if it finds the stcb as long as the locked @@ -6949,21 +7176,18 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, */ net = NULL; SCTP_INP_INCR_REF(inp); - stcb = sctp_findassociation_ep_addr(&inp, (struct sockaddr *)&encaps->sue_address, &net, NULL, NULL); + stcb = sctp_findassociation_ep_addr(&inp, addr, &net, NULL, NULL); if (stcb == NULL) { SCTP_INP_DECR_REF(inp); } } - if (stcb && (net == NULL)) { - struct sockaddr *sa; - - sa = (struct sockaddr *)&encaps->sue_address; + if ((stcb != NULL) && (net == NULL)) { #ifdef INET - if (sa->sa_family == AF_INET) { + if (addr->sa_family == AF_INET) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr) { + sin = (struct sockaddr_in *)addr; + if (sin->sin_addr.s_addr != INADDR_ANY) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); error = EINVAL; @@ -6972,10 +7196,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #ifdef INET6 - if (sa->sa_family == AF_INET6) { + if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = (struct sockaddr_in6 *)addr; if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); @@ -6985,10 +7209,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #if defined(__Userspace__) - if (sa->sa_family == AF_CONN) { + if (addr->sa_family == AF_CONN) { struct sockaddr_conn *sconn; - sconn = (struct sockaddr_conn *)sa; + sconn = (struct sockaddr_conn *)addr; if (sconn->sconn_addr != NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_TCB_UNLOCK(stcb); @@ -7005,8 +7229,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } } - if (stcb) { - if (net) { + if (stcb != NULL) { + if (net != NULL) { net->port = encaps->sue_port; } else { stcb->asoc.port = encaps->sue_port; @@ -7251,6 +7475,42 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } break; } + case SCTP_MAX_CWND: + { + struct sctp_assoc_value *av; + struct sctp_nets *net; + + SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); + SCTP_FIND_STCB(inp, stcb, av->assoc_id); + + if (stcb) { + stcb->asoc.max_cwnd = av->assoc_value; + if (stcb->asoc.max_cwnd > 0) { + TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { + if ((net->cwnd > stcb->asoc.max_cwnd) && + (net->cwnd > (net->mtu - sizeof(struct sctphdr)))) { + net->cwnd = stcb->asoc.max_cwnd; + if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) { + net->cwnd = net->mtu - sizeof(struct sctphdr); + } + } + } + } + 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_WLOCK(inp); + inp->max_cwnd = av->assoc_value; + SCTP_INP_WUNLOCK(inp); + } else { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + } + } + break; + } default: SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOPROTOOPT); error = ENOPROTOOPT; @@ -7836,7 +8096,7 @@ sctp_listen(struct socket *so, struct proc *p) SCTP_INP_DECR_REF(tinp); return (EADDRINUSE); } else if (tinp) { - SCTP_INP_DECR_REF(inp); + SCTP_INP_DECR_REF(tinp); } } } @@ -7849,8 +8109,8 @@ sctp_listen(struct socket *so, struct proc *p) SOCK_LOCK(so); #if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Userspace__) error = solisten_proto_check(so); + SOCK_UNLOCK(so); if (error) { - SOCK_UNLOCK(so); SCTP_INP_RUNLOCK(inp); return (error); } @@ -7864,29 +8124,28 @@ sctp_listen(struct socket *so, struct proc *p) * - We must then move the guy that was listener to the TCP Pool. */ if (sctp_swap_inpcb_for_listen(inp)) { - goto in_use; + SCTP_INP_RUNLOCK(inp); + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EADDRINUSE); + return (EADDRINUSE); } } if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { /* We are already connected AND the TCP model */ - in_use: SCTP_INP_RUNLOCK(inp); - SOCK_UNLOCK(so); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EADDRINUSE); return (EADDRINUSE); } SCTP_INP_RUNLOCK(inp); if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) { /* We must do a bind. */ - SOCK_UNLOCK(so); if ((error = sctp_inpcb_bind(so, NULL, NULL, p))) { /* bind error, probably perm */ return (error); } - SOCK_LOCK(so); } + SOCK_LOCK(so); #if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Windows__) || defined(__Userspace__) #if __FreeBSD_version >= 700000 || defined(__Windows__) || defined(__Userspace__) /* It appears for 7.0 and on, we must always call this. */ diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_var.h b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_var.h index be2f2b9ee6b..fcc954ebdcf 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_var.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctp_var.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 269699 2014-08-08 01:57:15Z kevlo $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 275427 2014-12-02 20:29:29Z tuexen $"); #endif #ifndef _NETINET_SCTP_VAR_H_ diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.c b/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.c index bf2d2125bd9..6d0c66a2d9e 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 271674 2014-09-16 14:39:24Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 280439 2015-03-24 14:51:46Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -252,6 +252,7 @@ sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new_tsn, uint32_t tsn, int fr #endif } +#ifdef SCTP_MBUF_LOGGING void sctp_log_mb(struct mbuf *m, int from) { @@ -284,6 +285,17 @@ sctp_log_mb(struct mbuf *m, int from) } void +sctp_log_mbc(struct mbuf *m, int from) +{ + struct mbuf *mat; + + for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { + sctp_log_mb(mat, from); + } +} +#endif + +void sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_read *poschk, int from) { #if defined(__FreeBSD__) || defined(SCTP_LOCAL_TRACE_BUF) @@ -474,7 +486,8 @@ sctp_log_rwnd_set(uint8_t from, uint32_t peers_rwnd, uint32_t flight_size, uint3 #endif } -void +#ifdef SCTP_MBCNT_LOGGING +static void sctp_log_mbcnt(uint8_t from, uint32_t total_oq, uint32_t book, uint32_t total_mbcnt_q, uint32_t mbcnt) { #if defined(__FreeBSD__) || defined(SCTP_LOCAL_TRACE_BUF) @@ -493,6 +506,7 @@ sctp_log_mbcnt(uint8_t from, uint32_t total_oq, uint32_t book, uint32_t total_mb sctp_clog.x.misc.log4); #endif } +#endif void sctp_misc_ints(uint8_t from, uint32_t a, uint32_t b, uint32_t c, uint32_t d) @@ -986,6 +1000,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, asoc->sctp_frag_point = inp->sctp_frag_point; asoc->sctp_features = inp->sctp_features; asoc->default_dscp = inp->sctp_ep.default_dscp; + asoc->max_cwnd = inp->max_cwnd; #ifdef INET6 if (inp->sctp_ep.default_flowlabel) { asoc->default_flowlabel = inp->sctp_ep.default_flowlabel; @@ -2067,7 +2082,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * though we use a different timer. We also add the HB timer * PLUS a random jitter. */ - if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { + if ((stcb == NULL) || (net == NULL)) { return; } else { uint32_t rndval; @@ -2122,9 +2137,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * nothing needed but the endpoint here ususually about 60 * minutes. */ - if (inp == NULL) { - return; - } tmr = &inp->sctp_ep.signature_change; to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_SIGNATURE]; break; @@ -2141,9 +2153,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * timer since that has stopped and we are in the GONE * state. */ - if (inp == NULL) { - return; - } tmr = &inp->sctp_ep.signature_change; to_ticks = MSEC_TO_TICKS(SCTP_INP_KILL_TIMEOUT); break; @@ -2152,10 +2161,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * Here we use the value found in the EP for PMTU ususually * about 10 minutes. */ - if ((stcb == NULL) || (inp == NULL)) { - return; - } - if (net == NULL) { + if ((stcb == NULL) || (net == NULL)) { return; } if (net->dest_state & SCTP_ADDR_NO_PMTUD) { @@ -2181,7 +2187,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * Here we use the endpoints shutdown guard timer usually * about 3 minutes. */ - if ((inp == NULL) || (stcb == NULL)) { + if (stcb == NULL) { return; } to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN]; @@ -2858,7 +2864,11 @@ set_error: static void sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state, - struct sockaddr *sa, uint32_t error) + struct sockaddr *sa, uint32_t error, int so_locked +#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) + SCTP_UNUSED +#endif +) { struct mbuf *m_notify; struct sctp_paddr_change *spc; @@ -2881,7 +2891,16 @@ sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state, switch (sa->sa_family) { #ifdef INET case AF_INET: +#ifdef INET6 + if (sctp_is_feature_on(stcb->sctp_ep, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { + in6_sin_2_v4mapsin6((struct sockaddr_in *)sa, + (struct sockaddr_in6 *)&spc->spc_aaddr); + } else { + memcpy(&spc->spc_aaddr, sa, sizeof(struct sockaddr_in)); + } +#else memcpy(&spc->spc_aaddr, sa, sizeof(struct sockaddr_in)); +#endif break; #endif #ifdef INET6 @@ -2945,7 +2964,7 @@ sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state, control, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, - SCTP_SO_NOT_LOCKED); + so_locked); } @@ -3743,7 +3762,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, net = (struct sctp_nets *)data; sctp_notify_peer_addr_change(stcb, SCTP_ADDR_UNREACHABLE, - (struct sockaddr *)&net->ro._l_addr, error); + (struct sockaddr *)&net->ro._l_addr, error, so_locked); break; } case SCTP_NOTIFY_INTERFACE_UP: @@ -3752,7 +3771,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, net = (struct sctp_nets *)data; sctp_notify_peer_addr_change(stcb, SCTP_ADDR_AVAILABLE, - (struct sockaddr *)&net->ro._l_addr, error); + (struct sockaddr *)&net->ro._l_addr, error, so_locked); break; } case SCTP_NOTIFY_INTERFACE_CONFIRMED: @@ -3761,7 +3780,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, net = (struct sctp_nets *)data; sctp_notify_peer_addr_change(stcb, SCTP_ADDR_CONFIRMED, - (struct sockaddr *)&net->ro._l_addr, error); + (struct sockaddr *)&net->ro._l_addr, error, so_locked); break; } case SCTP_NOTIFY_SPECIAL_SP_FAIL: @@ -3831,15 +3850,15 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, break; case SCTP_NOTIFY_ASCONF_ADD_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data, - error); + error, so_locked); break; case SCTP_NOTIFY_ASCONF_DELETE_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_REMOVED, data, - error); + error, so_locked); break; case SCTP_NOTIFY_ASCONF_SET_PRIMARY: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_MADE_PRIM, data, - error); + error, so_locked); break; case SCTP_NOTIFY_PEER_SHUTDOWN: sctp_notify_shutdown_event(stcb); @@ -4034,7 +4053,7 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct mbuf *op_err, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -4054,7 +4073,7 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } sctp_send_abort(m, iphlen, src, dst, sh, vtag, op_err, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); if (stcb != NULL) { @@ -4223,7 +4242,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, struct sctp_inpcb *inp, struct mbuf *cause, #if defined(__FreeBSD__) - uint8_t use_mflowid, uint32_t mflowid, + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -4273,7 +4292,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, case SCTP_SHUTDOWN_ACK: sctp_send_shutdown_complete2(src, dst, sh, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); return; @@ -4289,7 +4308,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, (contains_init_chunk == 0))) { sctp_send_abort(m, iphlen, src, dst, sh, 0, cause, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); } @@ -5323,17 +5342,13 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, chk->rec.data.payloadtype = sp->ppid; chk->rec.data.context = sp->context; chk->flags = sp->act_flags; - if (sp->net) - chk->whoTo = sp->net; - else - chk->whoTo = stcb->asoc.primary_destination; - atomic_add_int(&chk->whoTo->ref_count, 1); + chk->whoTo = NULL; #if defined(__FreeBSD__) || defined(__Panda__) chk->rec.data.TSN_seq = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1); #else chk->rec.data.TSN_seq = stcb->asoc.sending_seq++; #endif - stcb->asoc.pr_sctp_cnt++; + strq->chunks_on_queues++; TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, chk, sctp_next); stcb->asoc.sent_queue_cnt++; stcb->asoc.pr_sctp_cnt++; @@ -5518,7 +5533,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) vrf = sctp_find_vrf(vrf_id); if (vrf == NULL) { - stage_right: if (holds_lock == 0) SCTP_IPI_ADDR_RUNLOCK(); return (NULL); @@ -5539,15 +5553,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) return (NULL); } LIST_FOREACH(sctp_ifap, hash_head, next_bucket) { - if (sctp_ifap == NULL) { -#ifdef INVARIANTS - panic("Huh LIST_FOREACH corrupt"); - goto stage_right; -#else - SCTP_PRINTF("LIST corrupt of sctp_ifap's?\n"); - goto stage_right; -#endif - } if (addr->sa_family != sctp_ifap->address.sa.sa_family) continue; #ifdef INET @@ -5694,7 +5699,7 @@ sctp_sorecvmsg(struct socket *so, */ struct sctp_inpcb *inp = NULL; int my_len = 0; - int cp_len = 0, error = 0; + int cp_len = 0, error = 0; struct sctp_queued_to_read *control = NULL, *ctl = NULL, *nxt = NULL; struct mbuf *m = NULL; struct sctp_tcb *stcb = NULL; @@ -6202,76 +6207,50 @@ sctp_sorecvmsg(struct socket *so, entry->flgs = control->sinfo_flags; } #endif - if (fromlen && from) { -#ifdef HAVE_SA_LEN - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sa.sa_len); -#endif + if ((fromlen > 0) && (from != NULL)) { + union sctp_sockstore store; + size_t len; + switch (control->whoFrom->ro._l_addr.sa.sa_family) { #ifdef INET6 case AF_INET6: -#ifndef HAVE_SA_LEN - cp_len = min((size_t)fromlen, sizeof(struct sockaddr_in6)); -#endif - ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + len = sizeof(struct sockaddr_in6); + store.sin6 = control->whoFrom->ro._l_addr.sin6; + store.sin6.sin6_port = control->port_from; break; #endif #ifdef INET case AF_INET: -#ifndef HAVE_SA_LEN - cp_len = min((size_t)fromlen, sizeof(struct sockaddr_in)); +#ifdef INET6 + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { + len = sizeof(struct sockaddr_in6); + in6_sin_2_v4mapsin6(&control->whoFrom->ro._l_addr.sin, + &store.sin6); + store.sin6.sin6_port = control->port_from; + } else { + len = sizeof(struct sockaddr_in); + store.sin = control->whoFrom->ro._l_addr.sin; + store.sin.sin_port = control->port_from; + } +#else + len = sizeof(struct sockaddr_in); + store.sin = control->whoFrom->ro._l_addr.sin; + store.sin.sin_port = control->port_from; #endif - ((struct sockaddr_in *)from)->sin_port = control->port_from; break; #endif #if defined(__Userspace__) case AF_CONN: -#ifndef HAVE_SA_LEN - cp_len = min((size_t)fromlen, sizeof(struct sockaddr_conn)); -#endif - ((struct sockaddr_conn *)from)->sconn_port = control->port_from; + len = sizeof(struct sockaddr_conn); + store.sconn = control->whoFrom->ro._l_addr.sconn; + store.sconn.sconn_port = control->port_from; break; #endif default: -#ifndef HAVE_SA_LEN - cp_len = min((size_t)fromlen, sizeof(struct sockaddr)); -#endif + len = 0; break; } - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - -#if defined(INET) && defined(INET6) - if ((sctp_is_feature_on(inp,SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) && - (from->sa_family == AF_INET) && - ((size_t)fromlen >= sizeof(struct sockaddr_in6))) { - struct sockaddr_in *sin; - struct sockaddr_in6 sin6; - - sin = (struct sockaddr_in *)from; - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; -#ifdef HAVE_SIN6_LEN - sin6.sin6_len = sizeof(struct sockaddr_in6); -#endif -#if defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Darwin) || defined(__Userspace_os_Windows) - ((uint32_t *)&sin6.sin6_addr)[2] = htonl(0xffff); - bcopy(&sin->sin_addr, - &(((uint32_t *)&sin6.sin6_addr)[3]), - sizeof(uint32_t)); -#elif defined(__Windows__) - ((uint32_t *)&sin6.sin6_addr)[2] = htonl(0xffff); - bcopy(&sin->sin_addr, - &((uint32_t *)&sin6.sin6_addr)[3], - sizeof(uint32_t)); -#else - sin6.sin6_addr.s6_addr32[2] = htonl(0xffff); - bcopy(&sin->sin_addr, - &sin6.sin6_addr.s6_addr32[3], - sizeof(sin6.sin6_addr.s6_addr32[3])); -#endif - sin6.sin6_port = sin->sin_port; - memcpy(from, &sin6, sizeof(struct sockaddr_in6)); - } -#endif + memcpy(from, &store, min((size_t)fromlen, len)); #if defined(SCTP_EMBEDDED_V6_SCOPE) #ifdef INET6 { @@ -6818,9 +6797,7 @@ struct mbuf * sctp_m_free(struct mbuf *m) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - if (SCTP_BUF_IS_EXTENDED(m)) { - sctp_log_mb(m, SCTP_MBUF_IFREE); - } + sctp_log_mb(m, SCTP_MBUF_IFREE); } return (m_free(m)); } @@ -7279,7 +7256,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, uint32_t vrf_id, int *error, void *p) { struct sockaddr *addr_touse; -#ifdef INET6 +#if defined(INET) && defined(INET6) struct sockaddr_in sin; #endif #ifdef SCTP_MVRF @@ -7309,7 +7286,10 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, addr_touse = sa; #ifdef INET6 if (sa->sa_family == AF_INET6) { +#ifdef INET struct sockaddr_in6 *sin6; + +#endif #ifdef HAVE_SA_LEN if (sa->sa_len != sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7323,6 +7303,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, *error = EINVAL; return; } +#ifdef INET sin6 = (struct sockaddr_in6 *)addr_touse; if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && @@ -7335,6 +7316,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, in6_sin6_2_sin(&sin, sin6); addr_touse = (struct sockaddr *)&sin; } +#endif } #endif #ifdef INET @@ -7429,7 +7411,7 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, uint32_t vrf_id, int *error) { struct sockaddr *addr_touse; -#ifdef INET6 +#if defined(INET) && defined(INET6) struct sockaddr_in sin; #endif #ifdef SCTP_MVRF @@ -7459,7 +7441,10 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, addr_touse = sa; #ifdef INET6 if (sa->sa_family == AF_INET6) { +#ifdef INET struct sockaddr_in6 *sin6; +#endif + #ifdef HAVE_SA_LEN if (sa->sa_len != sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7473,6 +7458,7 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, *error = EINVAL; return; } +#ifdef INET sin6 = (struct sockaddr_in6 *)addr_touse; if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && @@ -7485,6 +7471,7 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, in6_sin6_2_sin(&sin, sin6); addr_touse = (struct sockaddr *)&sin; } +#endif } #endif #ifdef INET @@ -7751,7 +7738,8 @@ sctp_log_trace(uint32_t subsys, const char *str SCTP_UNUSED, uint32_t a, uint32_ #if defined(__FreeBSD__) #if __FreeBSD_version >= 800044 static void -sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *ignored) +sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *ignored, + const struct sockaddr *sa SCTP_UNUSED, void *ctx SCTP_UNUSED) { struct ip *iph; #ifdef INET6 @@ -7886,7 +7874,7 @@ sctp_over_udp_start(void) } /* Call the special UDP hook. */ if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp4_tun_socket), - sctp_recv_udp_tunneled_packet))) { + sctp_recv_udp_tunneled_packet, NULL))) { sctp_over_udp_stop(); return (ret); } @@ -7910,7 +7898,7 @@ sctp_over_udp_start(void) } /* Call the special UDP hook. */ if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp6_tun_socket), - sctp_recv_udp_tunneled_packet))) { + sctp_recv_udp_tunneled_packet, NULL))) { sctp_over_udp_stop(); return (ret); } diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.h b/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.h index c807c6606d3..cca915bb450 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet/sctputil.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 269376 2014-08-01 12:42:37Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 276914 2015-01-10 20:49:57Z tuexen $"); #endif #ifndef _NETINET_SCTP_UTIL_H_ @@ -369,10 +369,15 @@ void sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t, uint16_t, uint16_t, void sctp_log_nagle_event(struct sctp_tcb *stcb, int action); +#ifdef SCTP_MBUF_LOGGING void sctp_log_mb(struct mbuf *m, int from); void +sctp_log_mbc(struct mbuf *m, int from); +#endif + +void sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr); @@ -389,7 +394,6 @@ void sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from); void sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *, int, int, uint8_t); void sctp_log_block(uint8_t, struct sctp_association *, int); void sctp_log_rwnd(uint8_t, uint32_t, uint32_t, uint32_t); -void sctp_log_mbcnt(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t); void sctp_log_rwnd_set(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t); int sctp_fill_stat_log(void *, size_t *); void sctp_log_fr(uint32_t, uint32_t, uint32_t, int); diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_usrreq.c b/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_usrreq.c index 38747945f39..4adb6719667 100644 --- a/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_usrreq.c +++ b/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_usrreq.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 271221 2014-09-07 09:06:26Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 276914 2015-01-10 20:49:57Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -79,6 +79,7 @@ extern struct protosw inetsw[]; int ip6_v6only=0; #endif #if defined(__Userspace__) +#ifdef INET void in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6) { @@ -96,7 +97,6 @@ in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6) temp = temp << 16; temp = temp | sin6->sin6_addr.s6_addr16[6]; sin->sin_addr.s_addr = temp; - sctp_print_address((struct sockaddr*)sin); #else sin->sin_addr.s_addr = sin6->sin6_addr.s6_addr32[3]; #endif @@ -113,6 +113,29 @@ in6_sin6_2_sin_in_sock(struct sockaddr *nam) sin_p = (struct sockaddr_in *)nam; in6_sin6_2_sin(sin_p, &sin6); } + +void +in6_sin_2_v4mapsin6(struct sockaddr_in *sin, struct sockaddr_in6 *sin6) +{ + bzero(sin6, sizeof(struct sockaddr_in6)); + sin6->sin6_family = AF_INET6; +#ifdef HAVE_SIN6_LEN + sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif + sin6->sin6_port = sin->sin_port; +#if defined(__Userspace_os_Windows) + ((uint32_t *)&sin6->sin6_addr)[0] = 0; + ((uint32_t *)&sin6->sin6_addr)[1] = 0; + ((uint32_t *)&sin6->sin6_addr)[2] = htonl(0xffff); + ((uint32_t *)&sin6->sin6_addr)[3] = sin->sin_addr.s_addr; +#else + sin6->sin6_addr.s6_addr32[0] = 0; + sin6->sin6_addr.s6_addr32[1] = 0; + sin6->sin6_addr.s6_addr32[2] = htonl(0xffff); + sin6->sin6_addr.s6_addr32[3] = sin->sin_addr.s_addr; +#endif +} +#endif #endif #if !defined(__Userspace__) @@ -139,7 +162,7 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) #endif #if defined(__FreeBSD__) uint32_t mflowid; - uint8_t use_mflowid; + uint8_t mflowtype; #endif #if !(defined(__APPLE__) || defined (__FreeBSD__)) uint16_t port = 0; @@ -163,13 +186,7 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_INPUT); - } - } + sctp_log_mbc(m, SCTP_MBUF_INPUT); } #endif #ifdef SCTP_PACKET_LOGGING @@ -214,14 +231,9 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) m->m_pkthdr.csum_flags); #endif #if defined(__FreeBSD__) - if (m->m_flags & M_FLOWID) { - mflowid = m->m_pkthdr.flowid; - use_mflowid = 1; - } else { - mflowid = 0; - use_mflowid = 0; - } -#endif + mflowid = m->m_pkthdr.flowid; + mflowtype = M_HASHTYPE_GET(m); + #endif SCTP_STAT_INCR(sctps_recvpackets); SCTP_STAT_INCR_COUNTER64(sctps_inpackets); /* Get IP, SCTP, and first chunk header together in the first mbuf. */ @@ -265,12 +277,6 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) goto out; } #endif -#ifdef __FreeBSD__ - if (faithprefix_p != NULL && (*faithprefix_p) (&dst.sin6_addr)) { - /* XXX send icmp6 host/port unreach? */ - goto out; - } -#endif #if defined(__APPLE__) #if defined(NFAITH) && 0 < NFAITH if (faithprefix(&dst.sin6_addr)) { @@ -318,7 +324,7 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) #endif ecn_bits, #if defined(__FreeBSD__) - use_mflowid, mflowid, + mflowtype, mflowid, #endif vrf_id, port); out: @@ -1544,8 +1550,13 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) } #ifdef SCTP_EMBEDDED_V6_SCOPE #ifdef SCTP_KAME - if ((error = sa6_recoverscope(sin6)) != 0) + if ((error = sa6_recoverscope(sin6)) != 0) { +#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) + SCTP_FREE_SONAME(sin6); +#endif + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, error); return (error); + } #else in6_recoverscope(sin6, &sin6->sin6_addr, NULL); #endif /* SCTP_KAME */ diff --git a/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_var.h b/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_var.h index 94e4b4555ad..3402bc08cd7 100755 --- a/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_var.h +++ b/chromium/third_party/usrsctp/usrsctplib/netinet6/sctp6_var.h @@ -39,7 +39,11 @@ __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 243186 2012-11-17 20:04:04Z tu #define _NETINET6_SCTP6_VAR_H_ #if defined(__Userspace__) -extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *sin6); +#ifdef INET +extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); +extern void in6_sin6_2_sin_in_sock(struct sockaddr *); +extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *); +#endif #endif #if defined(_KERNEL) @@ -73,10 +77,9 @@ int sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, void sctp6_ctlinput(int, struct sockaddr *, void *); #endif #if !(defined(__FreeBSD__) || defined(__APPLE__)) -extern void in6_sin_2_v4mapsin6(struct sockaddr_in *sin, - struct sockaddr_in6 *sin6); -extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *sin6); -extern void in6_sin6_2_sin_in_sock(struct sockaddr *nam); +extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *); +extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); +extern void in6_sin6_2_sin_in_sock(struct sockaddr *); #endif extern void sctp6_notify(struct sctp_inpcb *, struct icmp6_hdr *, struct sctphdr *, struct sockaddr *, diff --git a/chromium/third_party/usrsctp/usrsctplib/user_environment.h b/chromium/third_party/usrsctp/usrsctplib/user_environment.h index d00f47e0433..6de9d9a5a3e 100755 --- a/chromium/third_party/usrsctp/usrsctplib/user_environment.h +++ b/chromium/third_party/usrsctp/usrsctplib/user_environment.h @@ -107,11 +107,4 @@ extern u_short ip_id; /* necessary for sctp_pcb.c */ extern int ip_defttl; - - -/* dummy definitions used (temporarily?) for inpcb userspace port */ - -/* called in sctp_usrreq.c */ -#define in6_sin_2_v4mapsin6(arg1, arg2) /* STUB */ - #endif diff --git a/chromium/third_party/usrsctp/usrsctplib/user_queue.h b/chromium/third_party/usrsctp/usrsctplib/user_queue.h index 379450c7ae5..44f89949026 100755 --- a/chromium/third_party/usrsctp/usrsctplib/user_queue.h +++ b/chromium/third_party/usrsctp/usrsctplib/user_queue.h @@ -31,9 +31,6 @@ #ifndef _USER_QUEUE_H_ #define _USER_QUEUE_H_ -#if !defined (__Userspace_os_Windows) -#include <sys/cdefs.h> -#endif /* * This file defines four types of data structures: singly-linked lists, * singly-linked tail queues, lists and tail queues. diff --git a/chromium/third_party/usrsctp/usrsctplib/user_socket.c b/chromium/third_party/usrsctp/usrsctplib/user_socket.c index d92aac65677..7134001fe77 100755 --- a/chromium/third_party/usrsctp/usrsctplib/user_socket.c +++ b/chromium/third_party/usrsctp/usrsctplib/user_socket.c @@ -1936,7 +1936,7 @@ usrsctp_get_non_blocking(struct socket *so) return (-1); } SOCK_LOCK(so); - if (so->so_state | SS_NBIO) { + if (so->so_state & SS_NBIO) { result = 1; } else { result = 0; @@ -2345,6 +2345,12 @@ userspace_getsockopt(struct socket *so, int level, int option_name, } int +usrsctp_set_ulpinfo(struct socket *so, void *ulp_info) +{ + return (register_ulp_info(so, ulp_info)); +} + +int usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) { struct sctp_getaddresses *gaddrs; @@ -2556,6 +2562,7 @@ usrsctp_connectx(struct socket *so, return (-1); } #endif +#ifdef INET if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)at)->sin6_addr)) { in6_sin6_2_sin((struct sockaddr_in *)cpto, (struct sockaddr_in6 *)at); cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in)); @@ -2565,6 +2572,11 @@ usrsctp_connectx(struct socket *so, cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in6)); len += sizeof(struct sockaddr_in6); } +#else + memcpy(cpto, at, sizeof(struct sockaddr_in6)); + cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in6)); + len += sizeof(struct sockaddr_in6); +#endif at = (struct sockaddr *)((caddr_t)at + sizeof(struct sockaddr_in6)); break; #endif diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctp.h b/chromium/third_party/usrsctp/usrsctplib/usrsctp.h index 0e922bfa324..48b1e43926d 100644 --- a/chromium/third_party/usrsctp/usrsctplib/usrsctp.h +++ b/chromium/third_party/usrsctp/usrsctplib/usrsctp.h @@ -777,28 +777,6 @@ struct sctp_cc_option { struct sctp_assoc_value aid_value; }; -struct sctp_cwnd_args { - struct sctp_nets *net; /* network to */ /* FIXME: LP64 issue */ - uint32_t cwnd_new_value; /* cwnd in k */ - uint32_t pseudo_cumack; - uint16_t inflight; /* flightsize in k */ - uint16_t cwnd_augment; /* increment to it */ - uint8_t meets_pseudo_cumack; - uint8_t need_new_pseudo_cumack; - uint8_t cnt_in_send; - uint8_t cnt_in_str; -}; - -struct sctp_blk_args { - uint32_t onsb; /* in 1k bytes */ - uint32_t sndlen; /* len of send being attempted */ - uint32_t peer_rwnd; /* rwnd of peer */ - uint16_t send_sent_qcnt; /* chnk cnt */ - uint16_t stream_qcnt; /* chnk cnt */ - uint16_t chunks_on_oque; /* chunks out */ - uint16_t flight_size; /* flight size in k */ -}; - struct sctp_timeouts { sctp_assoc_t stimo_assoc_id; uint32_t stimo_init; @@ -849,6 +827,8 @@ struct sctp_timeouts { /******************** System calls *************/ +struct socket; + void usrsctp_init(uint16_t, int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), @@ -974,6 +954,9 @@ usrsctp_register_address(void *); void usrsctp_deregister_address(void *); +int +usrsctp_set_ulpinfo(struct socket *, void *); + #define SCTP_DUMP_OUTBOUND 1 #define SCTP_DUMP_INBOUND 0 |