SYSCTL_INT(_net_inet_mptcp, OID_AUTO, fail, CTLFLAG_RW | CTLFLAG_LOCKED,
&mptcp_fail_thresh, 0, "Failover threshold");
-
/*
* MPTCP subflows have TCP keepalives set to ON. Set a conservative keeptime
* as carrier networks mostly have a 30 minute to 60 minute NAT Timeout.
SYSCTL_INT(_net_inet_mptcp, OID_AUTO, rtthist_thresh, CTLFLAG_RW | CTLFLAG_LOCKED,
&mptcp_rtthist_rtthresh, 0, "Rtt threshold");
-/*
- * Use RTO history for sending new data
- */
-int mptcp_use_rto = 1;
-SYSCTL_INT(_net_inet_mptcp, OID_AUTO, userto, CTLFLAG_RW | CTLFLAG_LOCKED,
- &mptcp_use_rto, 0, "Disable RTO for subflow selection");
-
int mptcp_rtothresh = 1500;
SYSCTL_INT(_net_inet_mptcp, OID_AUTO, rto_thresh, CTLFLAG_RW | CTLFLAG_LOCKED,
&mptcp_rtothresh, 0, "RTO threshold");
SYSCTL_UINT(_net_inet_mptcp, OID_AUTO, probecnt, CTLFLAG_RW | CTLFLAG_LOCKED,
&mptcp_probecnt, 0, "Number of probe writes");
-/*
- * Static declarations
- */
-static uint16_t mptcp_input_csum(struct tcpcb *, struct mbuf *, uint64_t,
- uint32_t, uint16_t, uint16_t, uint16_t);
-
static int
mptcp_reass_present(struct socket *mp_so)
{
m_freem(q->tqe_m);
} else {
flags = !!(q->tqe_m->m_pkthdr.pkt_flags & PKTF_MPTCP_DFIN);
- if (sbappendstream_rcvdemux(mp_so, q->tqe_m, 0, 0)) {
+ if (sbappendstream_rcvdemux(mp_so, q->tqe_m)) {
dowakeup = 1;
}
}
struct tseg_qent *p = NULL;
struct tseg_qent *nq;
struct tseg_qent *te = NULL;
- u_int16_t qlimit;
+ uint32_t qlimit;
/*
* Limit the number of segments in the reassembly queue to prevent
* queue. Always keep one global queue entry spare to be able to
* process the missing segment.
*/
- qlimit = min(max(100, mp_so->so_rcv.sb_hiwat >> 10),
+ qlimit = MIN(MAX(100, mp_so->so_rcv.sb_hiwat >> 10),
(tcp_autorcvbuf_max >> 10));
if (mb_dsn != mp_tp->mpt_rcvnxt &&
(mp_tp->mpt_reassqlen + 1) >= qlimit) {
*/
goto out;
}
- m_adj(m, i);
+ VERIFY(i <= INT_MAX);
+ m_adj(m, (int)i);
*tlenp -= i;
phdr->mp_dsn += i;
}
if (i < q->tqe_len) {
q->tqe_m->m_pkthdr.mp_dsn += i;
q->tqe_len -= i;
- m_adj(q->tqe_m, i);
+
+ VERIFY(i <= INT_MAX);
+ m_adj(q->tqe_m, (int)i);
break;
}
* assume degraded flow as this may be the first packet
* without DSS, and the subflow state is not updated yet.
*/
- if (sbappendstream_rcvdemux(mp_so, m, 0, 0)) {
+ if (sbappendstream_rcvdemux(mp_so, m)) {
sorwakeup(mp_so);
}
prev = save = NULL;
continue;
} else {
- m_adj(m, -todrop);
+ VERIFY(todrop <= INT_MAX);
+ m_adj(m, (int)-todrop);
mb_datalen -= todrop;
m->m_pkthdr.mp_rlen -= todrop;
}
prev = save = NULL;
continue;
} else {
- m_adj(m, (mp_tp->mpt_rcvnxt - mb_dsn));
+ VERIFY((mp_tp->mpt_rcvnxt - mb_dsn) <= INT_MAX);
+ m_adj(m, (int)(mp_tp->mpt_rcvnxt - mb_dsn));
mb_datalen -= (mp_tp->mpt_rcvnxt - mb_dsn);
mb_dsn = mp_tp->mpt_rcvnxt;
- m->m_pkthdr.mp_rlen = mb_datalen;
+ VERIFY(mb_datalen >= 0 && mb_datalen <= USHRT_MAX);
+ m->m_pkthdr.mp_rlen = (uint16_t)mb_datalen;
m->m_pkthdr.mp_dsn = mb_dsn;
}
}
mptcp_sbrcv_grow(mp_tp);
- if (sbappendstream_rcvdemux(mp_so, m, 0, 0)) {
+ if (sbappendstream_rcvdemux(mp_so, m)) {
wakeup = 1;
}
int error = 0;
mp_so = mptetoso(mpte);
- socket_lock_assert_owned(mp_so);
mp_tp = mpte->mpte_mptcb;
+ socket_lock_assert_owned(mp_so);
+
+ if (mp_so->so_flags & SOF_DEFUNCT) {
+ return 0;
+ }
+
VERIFY(!(mpte->mpte_mppcb->mpp_flags & MPP_WUPCALL));
mpte->mpte_mppcb->mpp_flags |= MPP_WUPCALL;
* 2. send buffer is filled to 7/8th with data (so we actually
* have data to make use of it);
*/
- if (tcp_do_autosendbuf == 1 &&
- (mp_so->so_snd.sb_flags & (SB_AUTOSIZE | SB_TRIM)) == SB_AUTOSIZE &&
+ if ((mp_so->so_snd.sb_flags & (SB_AUTOSIZE | SB_TRIM)) == SB_AUTOSIZE &&
tcp_cansbgrow(&mp_so->so_snd)) {
if ((mp_tp->mpt_sndwnd / 4 * 5) >= mp_so->so_snd.sb_hiwat &&
mp_so->so_snd.sb_cc >= (mp_so->so_snd.sb_hiwat / 8 * 7)) {
struct tcpcb *tp = sototcpcb(mpts->mpts_socket);
int fail_thresh = mptcp_fail_thresh;
- if (mpte->mpte_svctype == MPTCP_SVCTYPE_HANDOVER) {
+ if (mpte->mpte_svctype == MPTCP_SVCTYPE_HANDOVER || mpte->mpte_svctype == MPTCP_SVCTYPE_PURE_HANDOVER) {
fail_thresh *= 2;
}
* Second Step: Among best and second_best. Choose the one that is
* most appropriate for this particular service-type.
*/
- if (mpte->mpte_svctype == MPTCP_SVCTYPE_HANDOVER) {
+ if (mpte->mpte_svctype == MPTCP_SVCTYPE_PURE_HANDOVER) {
+ return mptcp_return_subflow(best);
+ } else if (mpte->mpte_svctype == MPTCP_SVCTYPE_HANDOVER) {
/*
* Only handover if Symptoms tells us to do so.
*/
return 0;
}
-/*
- * MPTCP Checksum support
- * The checksum is calculated whenever the MPTCP DSS option is included
- * in the TCP packet. The checksum includes the sum of the MPTCP psuedo
- * header and the actual data indicated by the length specified in the
- * DSS option.
- */
-
-int
-mptcp_validate_csum(struct tcpcb *tp, struct mbuf *m, uint64_t dsn,
- uint32_t sseq, uint16_t dlen, uint16_t csum, uint16_t dfin)
-{
- uint16_t mptcp_csum;
-
- mptcp_csum = mptcp_input_csum(tp, m, dsn, sseq, dlen, csum, dfin);
- if (mptcp_csum) {
- tp->t_mpflags |= TMPF_SND_MPFAIL;
- mptcp_notify_mpfail(tp->t_inpcb->inp_socket);
- m_freem(m);
- tcpstat.tcps_mp_badcsum++;
- return -1;
- }
- return 0;
-}
-
static uint16_t
mptcp_input_csum(struct tcpcb *tp, struct mbuf *m, uint64_t dsn, uint32_t sseq,
- uint16_t dlen, uint16_t csum, uint16_t dfin)
+ uint16_t dlen, uint16_t csum, int dfin)
{
struct mptcb *mp_tp = tptomptp(tp);
- uint16_t real_len = dlen - dfin;
+ int real_len = dlen - dfin;
uint32_t sum = 0;
+ VERIFY(real_len >= 0);
+
if (mp_tp == NULL) {
return 0;
}
sum += in_pseudo64(htonll(dsn), htonl(sseq), htons(dlen) + csum);
ADDCARRY(sum);
+
DTRACE_MPTCP3(checksum__result, struct tcpcb *, tp, struct mbuf *, m,
uint32_t, sum);
- mptcplog((LOG_DEBUG, "%s: sum = %x \n", __func__, sum),
- MPTCP_RECEIVER_DBG, MPTCP_LOGLVL_VERBOSE);
return ~sum & 0xffff;
}
-uint32_t
+/*
+ * MPTCP Checksum support
+ * The checksum is calculated whenever the MPTCP DSS option is included
+ * in the TCP packet. The checksum includes the sum of the MPTCP psuedo
+ * header and the actual data indicated by the length specified in the
+ * DSS option.
+ */
+
+int
+mptcp_validate_csum(struct tcpcb *tp, struct mbuf *m, uint64_t dsn,
+ uint32_t sseq, uint16_t dlen, uint16_t csum, int dfin)
+{
+ uint16_t mptcp_csum;
+
+ mptcp_csum = mptcp_input_csum(tp, m, dsn, sseq, dlen, csum, dfin);
+ if (mptcp_csum) {
+ tp->t_mpflags |= TMPF_SND_MPFAIL;
+ mptcp_notify_mpfail(tp->t_inpcb->inp_socket);
+ m_freem(m);
+ tcpstat.tcps_mp_badcsum++;
+ return -1;
+ }
+ return 0;
+}
+
+uint16_t
mptcp_output_csum(struct mbuf *m, uint64_t dss_val, uint32_t sseq, uint16_t dlen)
{
uint32_t sum = 0;
mptcplog((LOG_DEBUG, "%s: sum = %x \n", __func__, sum),
MPTCP_SENDER_DBG, MPTCP_LOGLVL_VERBOSE);
- return sum;
+ return (uint16_t)sum;
}
/*
}
}
-void
-mptcp_ask_for_nat64(struct ifnet *ifp)
-{
- in6_post_msg(ifp, KEV_INET6_REQUEST_NAT64_PREFIX, NULL, NULL);
-
- os_log_info(mptcp_log_handle,
- "%s: asked for NAT64-prefix on %s\n", __func__,
- ifp->if_name);
-}
-
static void
mptcp_reset_itfinfo(struct mpt_itf_info *info)
{
struct mptses *mpte = mptompte(mp);
struct socket *mp_so;
struct mptcb *mp_tp;
- int locked = 0;
uint32_t i, ifindex;
+ struct ifnet *ifp;
+ int locked = 0;
ifindex = interface_index;
VERIFY(ifindex != IFSCOPE_NONE);
mp_tp = mpte->mpte_mptcb;
- os_log_info(mptcp_log_handle, "%s - %lx: action: %u ifindex %u usecount %u mpt_flags %#x state %u v4 %u v6 %u nat64 %u power %u\n",
+ ifnet_head_lock_shared();
+ ifp = ifindex2ifnet[ifindex];
+ ifnet_head_done();
+
+ os_log(mptcp_log_handle, "%s - %lx: action: %u ifindex %u delegated to %u usecount %u mpt_flags %#x state %u v4 %u v6 %u nat64 %u power %u\n",
__func__, (unsigned long)VM_KERNEL_ADDRPERM(mpte), action, ifindex,
+ ifp && ifp->if_delegated.ifp ? ifp->if_delegated.ifp->if_index : IFSCOPE_NONE,
mp->mpp_socket->so_usecount, mp_tp->mpt_flags, mp_tp->mpt_state,
has_v4, has_v6, has_nat64, low_power);
action == NECP_CLIENT_CBACTION_INITIAL) {
int found_slot = 0, slot_index = -1;
struct sockaddr *dst;
- struct ifnet *ifp;
-
- ifnet_head_lock_shared();
- ifp = ifindex2ifnet[ifindex];
- ifnet_head_done();
if (ifp == NULL) {
goto out;
}
+ if (IFNET_IS_COMPANION_LINK(ifp)) {
+ goto out;
+ }
+
if (IFNET_IS_EXPENSIVE(ifp) &&
(mp_so->so_restrictions & SO_RESTRICT_DENY_EXPENSIVE)) {
goto out;
}
dst = mptcp_get_session_dst(mpte, has_v6, has_v4);
- if (dst && (dst->sa_family == AF_INET || dst->sa_family == 0) &&
+ if (dst && dst->sa_family == AF_INET &&
has_v6 && !has_nat64 && !has_v4) {
if (found_slot) {
+ mpte->mpte_itfinfo[slot_index].ifindex = ifindex;
mpte->mpte_itfinfo[slot_index].has_v4_conn = has_v4;
mpte->mpte_itfinfo[slot_index].has_v6_conn = has_v6;
mpte->mpte_itfinfo[slot_index].has_nat64_conn = has_nat64;
}
- mptcp_ask_for_nat64(ifp);
goto out;
}