- tp->t_mpflags |= TMPF_PREESTABLISHED;
-
- } else if ((th->th_flags & TH_ACK) &&
- (tp->t_mpflags & TMPF_PREESTABLISHED)) {
-
- /*
- * Verify checksum flag is set, if we initially negotiated
- * checksum.
- */
- if ((mp_tp->mpt_flags & MPTCPF_CHECKSUM) &&
- !(((struct mptcp_mpcapable_opt_common *)cp)->mmco_flags &
- MPCAP_CHECKSUM_CBIT)) {
- mptcplog((LOG_ERR, "MPTCP Socket: "
- "%s: checksum negotiation failure \n", __func__),
- MPTCP_SOCKET_DBG, MPTCP_LOGLVL_ERR);
- MPTCP_OPT_ERROR_PATH(tp);
- return;
- }
-
- if (!(mp_tp->mpt_flags & MPTCPF_CHECKSUM) &&
- (((struct mptcp_mpcapable_opt_common *)cp)->mmco_flags &
- MPCAP_CHECKSUM_CBIT)) {
- mptcplog((LOG_ERR, "MPTCP Socket: "
- "%s: checksum negotiation failure 2.\n", __func__),
- MPTCP_SOCKET_DBG, MPTCP_LOGLVL_ERR);
- MPTCP_OPT_ERROR_PATH(tp);
- return;
- }
-
- /*
- * The ACK of a three way handshake contains peer's key and
- * flags.
- */
- if (optlen != sizeof (struct mptcp_mpcapable_opt_rsp1)) {
- /* complain */
- mptcplog((LOG_ERR, "MPTCP Socket: "
- "%s: ACK optlen = %d , sizeof mp option = %lu, "
- " state = %d \n", __func__, optlen,
- sizeof (struct mptcp_mpcapable_opt_rsp1),
- tp->t_state), MPTCP_SOCKET_DBG, MPTCP_LOGLVL_ERR);
- MPTCP_OPT_ERROR_PATH(tp);
- return;
- }
-
- rsp1 = (struct mptcp_mpcapable_opt_rsp1 *)cp;
-
- /* Skipping MPT_LOCK for invariant key */
- if (rsp1->mmc_remotekey != *mp_tp->mpt_localkey) {
- mptcplog((LOG_ERR, "MPTCP Socket: "
- "%s: key mismatch locally stored key. "
- "rsp = %llx local = %llx \n", __func__,
- rsp1->mmc_remotekey, *mp_tp->mpt_localkey),
- MPTCP_SOCKET_DBG, MPTCP_LOGLVL_ERR);
- MPTCP_OPT_ERROR_PATH(tp);
- return;
- } else {
- /* We received both keys. Almost an MPTCP connection */
- /* Skipping MPT_LOCK for invariant key */
- if (mp_tp->mpt_remotekey != rsp1->mmc_localkey) {
- mptcplog((LOG_ERR, "MPTCP Socket: "
- "%s: keys don't match\n", __func__),
- MPTCP_SOCKET_DBG, MPTCP_LOGLVL_ERR);
- tp->t_mpflags &= ~TMPF_PREESTABLISHED;
- MPTCP_OPT_ERROR_PATH(tp);
- return;
- }
- tp->t_mpflags &= ~TMPF_PREESTABLISHED;
- tp->t_mpflags |= TMPF_MPTCP_RCVD_KEY;
- tp->t_mpflags |= TMPF_MPTCP_TRUE;
- tp->t_inpcb->inp_socket->so_flags |= SOF_MPTCP_TRUE;
- MPT_LOCK(mp_tp);
- DTRACE_MPTCP2(state__change, struct mptcb *, mp_tp,
- uint32_t, 0 /* event */);
- mptcplog((LOG_DEBUG, "MPTCP State: "
- "MPTCPS_ESTABLISHED \n"),
- MPTCP_STATE_DBG, MPTCP_LOGLVL_LOG);
-
- mp_tp->mpt_state = MPTCPS_ESTABLISHED;
- MPT_UNLOCK(mp_tp);
- }
- if (tp->t_mpuna) {
- tp->t_mpuna = 0;
- }