Page MenuHomeFreeBSD

D56213.id174724.diff
No OneTemporary

D56213.id174724.diff

Index: sys/netinet/tcp_fastopen.c
===================================================================
--- sys/netinet/tcp_fastopen.c
+++ sys/netinet/tcp_fastopen.c
@@ -897,7 +897,7 @@
memcpy(tp->t_tfo_cookie.client, &psk_cookie,
TCP_FASTOPEN_COOKIE_LEN);
}
- tcp_mss(tp, server_mss ? server_mss : -1);
+ tcp_mss(tp, server_mss ? server_mss : -1, 0);
tp->snd_wnd = tp->t_maxseg;
} else {
/*
@@ -928,7 +928,7 @@
tp->t_flags &= ~TF_FASTOPEN;
}
CCB_UNLOCK(ccb);
- tcp_mss(tp, -1);
+ tcp_mss(tp, -1, 0);
/*
* snd_wnd is irrelevant since we are either forcing
* a TFO cookie request or disabling TFO - either
@@ -941,7 +941,7 @@
* comes back, or the attempt otherwise fails.
*/
CCB_UNLOCK(ccb);
- tcp_mss(tp, -1);
+ tcp_mss(tp, -1, 0);
/*
* snd_wnd is irrelevant since we are forcing a TFO cookie
* request.
Index: sys/netinet/tcp_input.c
===================================================================
--- sys/netinet/tcp_input.c
+++ sys/netinet/tcp_input.c
@@ -1628,7 +1628,7 @@
tp->t_flags &= ~TF_REQ_TSTMP;
}
if (to.to_flags & TOF_MSS) {
- tcp_mss(tp, to.to_mss);
+ tcp_mss(tp, to.to_mss, 1);
}
if ((tp->t_flags & TF_SACK_PERMIT) &&
(!(to.to_flags & TOF_SACKPERM) ||
@@ -3861,7 +3861,7 @@
}
void
-tcp_mss(struct tcpcb *tp, int offer)
+tcp_mss(struct tcpcb *tp, int offer, int skip_sockbuf)
{
int mss;
uint32_t bufsize;
@@ -3877,29 +3877,39 @@
mss = tp->t_maxseg;
+ so = inp->inp_socket;
/*
- * If there's a pipesize, change the socket buffer to that size,
- * don't change if sb_hiwat is different than default (then it
- * has been changed on purpose with setsockopt).
- * Make the socket buffers an integral number of mss units;
- * if the mss is larger than the socket buffer, decrease the mss.
+ * If skip_sockbuf is set, we are called with the inpcb lock held
+ * (e.g. from syncache_socket or tcp_input). Taking so_snd/so_rcv
+ * here would establish lock order tcpinp -> so_rcv, which reverses
+ * the canonical so_rcv -> tcpinp order used elsewhere and triggers
+ * WITNESS. Skip socket buffer adjustment; it will be done when
+ * tcp_mss is called without the inpcb lock (e.g. from tcp_usrreq).
*/
- so = inp->inp_socket;
- SOCK_SENDBUF_LOCK(so);
- if ((so->so_snd.sb_hiwat == V_tcp_sendspace) && metrics.hc_sendpipe)
- bufsize = metrics.hc_sendpipe;
- else
- bufsize = so->so_snd.sb_hiwat;
- if (bufsize < mss)
- mss = bufsize;
- else {
- bufsize = roundup(bufsize, mss);
- if (bufsize > sb_max)
- bufsize = sb_max;
- if (bufsize > so->so_snd.sb_hiwat)
- (void)sbreserve_locked(so, SO_SND, bufsize, NULL);
+ if (!skip_sockbuf) {
+ /*
+ * If there's a pipesize, change the socket buffer to that size,
+ * don't change if sb_hiwat is different than default (then it
+ * has been changed on purpose with setsockopt).
+ * Make the socket buffers an integral number of mss units;
+ * if the mss is larger than the socket buffer, decrease the mss.
+ */
+ SOCK_SENDBUF_LOCK(so);
+ if ((so->so_snd.sb_hiwat == V_tcp_sendspace) && metrics.hc_sendpipe)
+ bufsize = metrics.hc_sendpipe;
+ else
+ bufsize = so->so_snd.sb_hiwat;
+ if (bufsize < mss)
+ mss = bufsize;
+ else {
+ bufsize = roundup(bufsize, mss);
+ if (bufsize > sb_max)
+ bufsize = sb_max;
+ if (bufsize > so->so_snd.sb_hiwat)
+ (void)sbreserve_locked(so, SO_SND, bufsize, NULL);
+ }
+ SOCK_SENDBUF_UNLOCK(so);
}
- SOCK_SENDBUF_UNLOCK(so);
/*
* Sanity check: make sure that maxseg will be large
* enough to allow some data on segments even if the
@@ -3920,19 +3930,21 @@
tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT;
}
- SOCK_RECVBUF_LOCK(so);
- if ((so->so_rcv.sb_hiwat == V_tcp_recvspace) && metrics.hc_recvpipe)
- bufsize = metrics.hc_recvpipe;
- else
- bufsize = so->so_rcv.sb_hiwat;
- if (bufsize > mss) {
- bufsize = roundup(bufsize, mss);
- if (bufsize > sb_max)
- bufsize = sb_max;
- if (bufsize > so->so_rcv.sb_hiwat)
- (void)sbreserve_locked(so, SO_RCV, bufsize, NULL);
+ if (!skip_sockbuf) {
+ SOCK_RECVBUF_LOCK(so);
+ if ((so->so_rcv.sb_hiwat == V_tcp_recvspace) && metrics.hc_recvpipe)
+ bufsize = metrics.hc_recvpipe;
+ else
+ bufsize = so->so_rcv.sb_hiwat;
+ if (bufsize > mss) {
+ bufsize = roundup(bufsize, mss);
+ if (bufsize > sb_max)
+ bufsize = sb_max;
+ if (bufsize > so->so_rcv.sb_hiwat)
+ (void)sbreserve_locked(so, SO_RCV, bufsize, NULL);
+ }
+ SOCK_RECVBUF_UNLOCK(so);
}
- SOCK_RECVBUF_UNLOCK(so);
/* Check the interface for TSO capabilities. */
if (cap.ifcap & CSUM_TSO) {
Index: sys/netinet/tcp_stacks/bbr.c
===================================================================
--- sys/netinet/tcp_stacks/bbr.c
+++ sys/netinet/tcp_stacks/bbr.c
@@ -11411,7 +11411,7 @@
} else
tp->t_flags &= ~TF_REQ_TSTMP;
if (to.to_flags & TOF_MSS)
- tcp_mss(tp, to.to_mss);
+ tcp_mss(tp, to.to_mss, 0);
if ((tp->t_flags & TF_SACK_PERMIT) &&
(to.to_flags & TOF_SACKPERM) == 0)
tp->t_flags &= ~TF_SACK_PERMIT;
Index: sys/netinet/tcp_stacks/rack.c
===================================================================
--- sys/netinet/tcp_stacks/rack.c
+++ sys/netinet/tcp_stacks/rack.c
@@ -16641,7 +16641,7 @@
} else
tp->t_flags &= ~TF_REQ_TSTMP;
if (to.to_flags & TOF_MSS) {
- tcp_mss(tp, to.to_mss);
+ tcp_mss(tp, to.to_mss, 0);
}
if ((tp->t_flags & TF_SACK_PERMIT) &&
(to.to_flags & TOF_SACKPERM) == 0)
Index: sys/netinet/tcp_syncache.c
===================================================================
--- sys/netinet/tcp_syncache.c
+++ sys/netinet/tcp_syncache.c
@@ -963,7 +963,7 @@
* Set up MSS and get cached values from tcp_hostcache.
* This might overwrite some of the defaults we just set.
*/
- tcp_mss(tp, sc->sc_peer_mss);
+ tcp_mss(tp, sc->sc_peer_mss, 1);
/*
* If the SYN,ACK was retransmitted, indicate that CWND to be
Index: sys/netinet/tcp_usrreq.c
===================================================================
--- sys/netinet/tcp_usrreq.c
+++ sys/netinet/tcp_usrreq.c
@@ -1100,7 +1100,7 @@
tcp_fastopen_connect(tp);
else {
tp->snd_wnd = TTCP_CLIENT_SND_WND;
- tcp_mss(tp, -1);
+ tcp_mss(tp, -1, 0);
}
}
if (flags & PRUS_EOF) {
@@ -1188,7 +1188,7 @@
goto out;
}
tp->snd_wnd = TTCP_CLIENT_SND_WND;
- tcp_mss(tp, -1);
+ tcp_mss(tp, -1, 0);
}
tp->snd_up = tp->snd_una + sbavail(&so->so_snd);
if ((flags & PRUS_NOTREADY) == 0) {
Index: sys/netinet/tcp_var.h
===================================================================
--- sys/netinet/tcp_var.h
+++ sys/netinet/tcp_var.h
@@ -1481,7 +1481,7 @@
u_int tcp_fixed_maxseg(const struct tcpcb *);
void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *,
struct tcp_ifcap *);
-void tcp_mss(struct tcpcb *, int);
+void tcp_mss(struct tcpcb *, int, int);
int tcp_mssopt(struct in_conninfo *);
struct tcpcb *
tcp_newtcpcb(struct inpcb *, struct tcpcb *);

File Metadata

Mime Type
text/plain
Expires
Wed, May 27, 12:03 PM (4 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33548089
Default Alt Text
D56213.id174724.diff (6 KB)

Event Timeline