Last active
December 4, 2021 21:10
-
-
Save brendanashworth/fb98885c7585a897821d9b8c22a04aa5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 16ab1b6b97313fcfc43110d5ba9f1fd37d5b3939 | |
Author: Brendan Ashworth <[email protected]> | |
Date: Sat Dec 4 15:46:43 2021 -0500 | |
add getsockopt for last packet size | |
diff --git a/include/linux/tcp.h b/include/linux/tcp.h | |
index 48d8a3633..1bbb1398e 100644 | |
--- a/include/linux/tcp.h | |
+++ b/include/linux/tcp.h | |
@@ -412,6 +412,9 @@ struct tcp_sock { | |
*/ | |
struct request_sock __rcu *fastopen_rsk; | |
struct saved_syn *saved_syn; | |
+ | |
+/* TCP Nagle's algorithm optimization */ | |
+ unsigned int opt_last_write_size; | |
}; | |
enum tsq_enum { | |
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h | |
index 8fc09e863..be298cfc9 100644 | |
--- a/include/uapi/linux/tcp.h | |
+++ b/include/uapi/linux/tcp.h | |
@@ -129,6 +129,7 @@ enum { | |
#define TCP_TX_DELAY 37 /* delay outgoing packets by XX usec */ | |
+#define TCP_OPT_PKT_LEN 38 /* packet length of last skb sent *// | |
#define TCP_REPAIR_ON 1 | |
#define TCP_REPAIR_OFF 0 | |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c | |
index bbb3d39c6..e63c8e153 100644 | |
--- a/net/ipv4/tcp.c | |
+++ b/net/ipv4/tcp.c | |
@@ -4155,6 +4155,9 @@ static int do_tcp_getsockopt(struct sock *sk, int level, | |
} | |
return 0; | |
} | |
+ case TCP_OPT_PKT_LEN: | |
+ val = tp->opt_last_write_size; | |
+ break; | |
#ifdef CONFIG_MMU | |
case TCP_ZEROCOPY_RECEIVE: { | |
struct scm_timestamping_internal tss; | |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c | |
index 2e6e5a701..e6e9d801d 100644 | |
--- a/net/ipv4/tcp_output.c | |
+++ b/net/ipv4/tcp_output.c | |
@@ -2689,6 +2689,9 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, | |
tcp_minshall_update(tp, mss_now, skb); | |
sent_pkts += tcp_skb_pcount(skb); | |
+ /* Record the sent packet size for optimization. */ | |
+ tcp_sock->opt_last_write_size = skb->data_len; | |
+ | |
if (push_one) | |
break; | |
} | |
diff --git a/tools/include/uapi/linux/tcp.h b/tools/include/uapi/linux/tcp.h | |
index 13ceeb395..f6f3e7bc3 100644 | |
--- a/tools/include/uapi/linux/tcp.h | |
+++ b/tools/include/uapi/linux/tcp.h | |
@@ -129,7 +129,6 @@ enum { | |
#define TCP_TX_DELAY 37 /* delay outgoing packets by XX usec */ | |
- | |
#define TCP_REPAIR_ON 1 | |
#define TCP_REPAIR_OFF 0 | |
#define TCP_REPAIR_OFF_NO_WP -1 /* Turn off without window probes */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment