Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F175993443
D60731.id189924.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D60731.id189924.diff
View Options
diff --git a/sys/netinet/in_kdtrace.c b/sys/netinet/in_kdtrace.c
--- a/sys/netinet/in_kdtrace.c
+++ b/sys/netinet/in_kdtrace.c
@@ -539,13 +539,9 @@
"void *", "void *",
"int", "tcplsinfo_t *");
-SDT_PROBE_DEFINE6_XLATE(tcp, , , receive__autoresize,
- "void *", "void *",
- "struct tcpcb *", "csinfo_t *",
- "struct mbuf *", "ipinfo_t *",
+SDT_PROBE_DEFINE2_XLATE(tcp, , , receive__autoresize,
"struct tcpcb *", "tcpsinfo_t *" ,
- "struct tcphdr *", "tcpinfoh_t *",
- "int", "int");
+ "u_int", "u_int");
SDT_PROBE_DEFINE5_XLATE(udp, , , receive,
"void *", "pktinfo_t *",
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -208,18 +208,19 @@
&VNET_NAME(tcp_insecure_ack), 0,
"Follow RFC793 criteria for validating SEG.ACK");
-VNET_DEFINE(int, tcp_recvspace) = 1024*64;
+VNET_DEFINE(u_int, tcp_recvspace) = 1024*64;
#define V_tcp_recvspace VNET(tcp_recvspace)
-SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_VNET | CTLFLAG_RW,
- &VNET_NAME(tcp_recvspace), 0, "Initial receive socket buffer size");
+SYSCTL_UINT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace,
+ CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_recvspace), 0,
+ "Initial receive socket buffer size");
-VNET_DEFINE(int, tcp_do_autorcvbuf) = 1;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_VNET | CTLFLAG_RW,
+VNET_DEFINE(bool, tcp_do_autorcvbuf) = true;
+SYSCTL_BOOL(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_VNET | CTLFLAG_RW,
&VNET_NAME(tcp_do_autorcvbuf), 0,
"Enable automatic receive buffer sizing");
-VNET_DEFINE(int, tcp_autorcvbuf_max) = 8*1024*1024;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_VNET | CTLFLAG_RW,
+VNET_DEFINE(u_int, tcp_autorcvbuf_max) = 8*1024*1024;
+SYSCTL_UINT(_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_VNET | CTLFLAG_RW,
&VNET_NAME(tcp_autorcvbuf_max), 0,
"Max size of automatic receive buffer");
@@ -1430,11 +1431,12 @@
* TODO: Only step up if the application is actually serving
* the buffer to better manage the socket buffer resources.
*/
-int
-tcp_autorcvbuf(struct mbuf *m, struct tcphdr *th, struct socket *so,
- struct tcpcb *tp, int tlen)
+void
+tcp_autorcvbuf(struct tcpcb *tp, u_int tlen)
{
- int newsize = 0;
+ struct socket *so = tptosocket(tp);
+
+ SOCK_RECVBUF_LOCK_ASSERT(so);
if (V_tcp_do_autorcvbuf && (so->so_rcv.sb_flags & SB_AUTOSIZE) &&
tp->t_srtt != 0 && tp->rfbuf_ts != 0 &&
@@ -1442,17 +1444,22 @@
((tp->t_srtt >> TCP_RTT_SHIFT)/2)) {
if (tp->rfbuf_cnt > ((so->so_rcv.sb_hiwat / 2)/ 4 * 3) &&
so->so_rcv.sb_hiwat < V_tcp_autorcvbuf_max) {
- newsize = min((so->so_rcv.sb_hiwat + (so->so_rcv.sb_hiwat/2)), V_tcp_autorcvbuf_max);
- }
- TCP_PROBE6(receive__autoresize, NULL, tp, m, tp, th, newsize);
+ u_int newsize;
+ newsize = min((so->so_rcv.sb_hiwat +
+ (so->so_rcv.sb_hiwat / 2)), V_tcp_autorcvbuf_max);
+ if (sbreserve_locked(so, SO_RCV, newsize, NULL)) {
+ TCP_PROBE2(receive__autoresize, tp, newsize);
+ } else {
+ so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
+ }
+ }
/* Start over with next RTT. */
tp->rfbuf_ts = 0;
tp->rfbuf_cnt = 0;
} else {
tp->rfbuf_cnt += tlen; /* add up */
}
- return (newsize);
}
int
@@ -1853,8 +1860,6 @@
}
} else if (th->th_ack == tp->snd_una &&
tlen <= sbspace(&so->so_rcv)) {
- int newsize = 0; /* automatic sockbuf scaling */
-
/*
* This is a pure, in-sequence data packet with
* nothing on the reassembly queue and we have enough
@@ -1888,21 +1893,12 @@
TCPSTAT_ADD(tcps_rcvbyte, tlen);
TCP_PROBE3(debug__input, tp, th, m);
- newsize = tcp_autorcvbuf(m, th, so, tp, tlen);
-
/* Add data to socket buffer. */
SOCK_RECVBUF_LOCK(so);
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
m_freem(m);
} else {
- /*
- * Set new socket buffer size.
- * Give up when limit is reached.
- */
- if (newsize)
- if (!sbreserve_locked(so, SO_RCV,
- newsize, NULL))
- so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
+ tcp_autorcvbuf(tp, tlen);
m_adj(m, drop_hdrlen); /* delayed header drop */
sbappendstream_locked(&so->so_rcv, m, 0);
}
diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c
--- a/sys/netinet/tcp_stacks/bbr.c
+++ b/sys/netinet/tcp_stacks/bbr.c
@@ -8419,7 +8419,6 @@
uint32_t tiwin, int32_t nxt_pkt)
{
uint16_t nsegs;
- int32_t newsize = 0; /* automatic sockbuf scaling */
struct tcp_bbr *bbr;
#ifdef NETFLIX_SB_LIMITS
u_int mcnt, appended;
@@ -8499,22 +8498,14 @@
tp->rcv_up = tp->rcv_nxt;
KMOD_TCPSTAT_ADD(tcps_rcvpack, (int)nsegs);
KMOD_TCPSTAT_ADD(tcps_rcvbyte, tlen);
- newsize = tcp_autorcvbuf(m, th, so, tp, tlen);
/* Add data to socket buffer. */
SOCK_RECVBUF_LOCK(so);
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
m_freem(m);
} else {
- /*
- * Set new socket buffer size. Give up when limit is
- * reached.
- */
- if (newsize)
- if (!sbreserve_locked(so, SO_RCV, newsize, NULL))
- so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
+ tcp_autorcvbuf(tp, tlen);
m_adj(m, drop_hdrlen); /* delayed header drop */
-
#ifdef NETFLIX_SB_LIMITS
appended =
#endif
diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -12234,14 +12234,8 @@
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
m_freem(m);
} else {
- int32_t newsize;
-
- if (tlen > 0) {
- newsize = tcp_autorcvbuf(m, th, so, tp, tlen);
- if (newsize)
- if (!sbreserve_locked(so, SO_RCV, newsize, NULL))
- so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
- }
+ if (tlen > 0)
+ tcp_autorcvbuf(tp, tlen);
#ifdef NETFLIX_SB_LIMITS
appended =
#endif
@@ -12391,7 +12385,6 @@
uint32_t tiwin, int32_t nxt_pkt, uint8_t iptos)
{
int32_t nsegs;
- int32_t newsize = 0; /* automatic sockbuf scaling */
struct tcp_rack *rack;
#ifdef NETFLIX_SB_LIMITS
u_int mcnt, appended;
@@ -12469,20 +12462,13 @@
tp->rcv_up = tp->rcv_nxt;
KMOD_TCPSTAT_ADD(tcps_rcvpack, nsegs);
KMOD_TCPSTAT_ADD(tcps_rcvbyte, tlen);
- newsize = tcp_autorcvbuf(m, th, so, tp, tlen);
/* Add data to socket buffer. */
SOCK_RECVBUF_LOCK(so);
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
m_freem(m);
} else {
- /*
- * Set new socket buffer size. Give up when limit is
- * reached.
- */
- if (newsize)
- if (!sbreserve_locked(so, SO_RCV, newsize, NULL))
- so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
+ tcp_autorcvbuf(tp, tlen);
m_adj(m, drop_hdrlen); /* delayed header drop */
#ifdef NETFLIX_SB_LIMITS
appended =
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -2884,7 +2884,7 @@
/* Skip sackblks, sackhint. */
db_print_indent(indent);
- db_printf("t_rttlow: %d rfbuf_ts: %u rfbuf_cnt: %d\n",
+ db_printf("t_rttlow: %d rfbuf_ts: %u rfbuf_cnt: %u\n",
tp->t_rttlow, tp->rfbuf_ts, tp->rfbuf_cnt);
db_print_indent(indent);
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -422,7 +422,7 @@
struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */
struct sackhint sackhint; /* SACK scoreboard hint */
int t_rttlow; /* smallest observerved RTT */
- int rfbuf_cnt; /* recv buffer autoscaling byte count */
+ u_int rfbuf_cnt; /* recv buffer autoscaling byte count */
struct toedev *tod; /* toedev handling this connection */
int t_sndrexmitpack; /* retransmit packets sent */
int t_rcvoopack; /* out-of-order packets received */
@@ -1303,13 +1303,13 @@
VNET_DECLARE(int, tcp_abc_l_var);
VNET_DECLARE(uint32_t, tcp_ack_war_cnt);
VNET_DECLARE(uint32_t, tcp_ack_war_time_window);
-VNET_DECLARE(int, tcp_autorcvbuf_max);
+VNET_DECLARE(u_int, tcp_autorcvbuf_max);
VNET_DECLARE(int, tcp_autosndbuf_inc);
VNET_DECLARE(int, tcp_autosndbuf_max);
VNET_DECLARE(int, tcp_bind_all_fibs);
VNET_DECLARE(int, tcp_delack_enabled);
-VNET_DECLARE(int, tcp_do_autorcvbuf);
VNET_DECLARE(int, tcp_do_autosndbuf);
+VNET_DECLARE(bool, tcp_do_autorcvbuf);
VNET_DECLARE(int, tcp_do_ecn);
VNET_DECLARE(int, tcp_do_lrd);
VNET_DECLARE(int, tcp_do_prr);
@@ -1336,7 +1336,7 @@
VNET_DECLARE(int, tcp_perconn_stats_dflt_tpl);
VNET_DECLARE(int, tcp_perconn_stats_enable);
#endif /* STATS */
-VNET_DECLARE(int, tcp_recvspace);
+VNET_DECLARE(u_int, tcp_recvspace);
VNET_DECLARE(int, tcp_retries);
VNET_DECLARE(int, tcp_sack_globalholes);
VNET_DECLARE(int, tcp_sack_globalmaxholes);
@@ -1403,6 +1403,7 @@
#define V_tcp_hhh VNET(tcp_hhh)
#endif
+void tcp_autorcvbuf(struct tcpcb *, u_int);
void tcp_account_for_send(struct tcpcb *, uint32_t, uint8_t, uint8_t, bool);
int tcp_addoptions(struct tcpopt *, u_char *);
struct tcpcb *
@@ -1437,8 +1438,6 @@
#endif
int tcp_input(struct mbuf **, int *, int);
-int tcp_autorcvbuf(struct mbuf *, struct tcphdr *, struct socket *,
- struct tcpcb *, int);
int tcp_input_with_port(struct mbuf **, int *, int, uint16_t);
void tcp_do_segment(struct tcpcb *, struct mbuf *, struct tcphdr *, int,
int, uint8_t);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 16, 3:02 AM (6 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40878989
Default Alt Text
D60731.id189924.diff (9 KB)
Attached To
Mode
D60731: tcp: refactor tcp_autorcvbuf() and associated sysctls
Attached
Detach File
Event Timeline
Log In to Comment