+#if MPTCP
+ if (so->so_flags & SOF_MP_SUBFLOW) {
+ struct mptcb *mp_tp = tptomptp(tp);
+
+ if (mp_tp != NULL) {
+ mpte_lock_assert_held(mp_tp->mpt_mpte);
+ recwin = imin(recwin, mptcp_sbspace(mp_tp));
+ }
+ }
+#endif
+
+ if (recwin < (int32_t)(so->so_rcv.sb_hiwat / 4) &&
+ recwin < (int)tp->t_maxseg)
+ recwin = 0;
+
+#if TRAFFIC_MGT
+ if (tcp_recv_bg == 1 || IS_TCP_RECV_BG(so)) {
+ if (recwin > 0 && tcp_recv_throttle(tp)) {
+ uint32_t min_iaj_win = tcp_min_iaj_win * tp->t_maxseg;
+ uint32_t bg_rwintop = tp->rcv_adv;
+ if (SEQ_LT(bg_rwintop, tp->rcv_nxt + min_iaj_win))
+ bg_rwintop = tp->rcv_nxt + min_iaj_win;
+ recwin = imin((int32_t)(bg_rwintop - tp->rcv_nxt),
+ recwin);
+ if (recwin < 0)
+ recwin = 0;
+ }
+ }
+#endif /* TRAFFIC_MGT */
+
+ if (recwin > (int32_t)(TCP_MAXWIN << tp->rcv_scale))
+ recwin = (int32_t)(TCP_MAXWIN << tp->rcv_scale);
+
+ /*
+ * MPTCP needs to be able to announce a smaller window than previously,
+ * because the other subflow may have filled up the available window-
+ * space. So we have to be able to go backwards and announce a smaller
+ * window.
+ */
+ if (!(so->so_flags & SOF_MPTCP_TRUE) &&
+ recwin < (int32_t)(tp->rcv_adv - tp->rcv_nxt))
+ recwin = (int32_t)(tp->rcv_adv - tp->rcv_nxt);