--- /dev/null
+From 62748e97c4caa61e1230af527de23ed53d4314d4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz@true.cz>
+Date: Fri, 26 Aug 2022 09:10:54 +0200
+Subject: [PATCH] Make IP Type-Of-Service feature optional
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Add new -z commandline option which when set, disables new IP TOS
+feature.
+
+References: https://github.com/openwrt/openwrt/issues/10405
+Signed-off-by: Petr Štetiar <ynezz@true.cz>
+---
+ cli-runopts.c | 4 ++++
+ netio.c | 3 +++
+ runopts.h | 1 +
+ svr-runopts.c | 5 +++++
+ 4 files changed, 13 insertions(+)
+
+diff --git a/cli-runopts.c b/cli-runopts.c
+index 131330421673..1cadfc48f7d8 100644
+--- a/cli-runopts.c
++++ b/cli-runopts.c
+@@ -98,6 +98,7 @@ static void printhelp() {
+ #if DEBUG_TRACE
+ "-v verbose (repeat for more verbose)\n"
+ #endif
++ "-z disable IP Type-Of-Service feature\n"
+ ,DROPBEAR_VERSION, cli_opts.progname,
+ #if DROPBEAR_CLI_PUBKEY_AUTH
+ DROPBEAR_DEFAULT_CLI_AUTHKEY,
+@@ -329,6 +330,9 @@ void cli_getopts(int argc, char ** argv) {
+ /* compatibility with openssh cli
+ * ("-x" disables X11 forwarding) */
+ break;
++ case 'z':
++ opts.disable_ip_tos = 1;
++ break;
+ default:
+ fprintf(stderr,
+ "WARNING: Ignoring unknown option -%c\n", c);
+diff --git a/netio.c b/netio.c
+index 2ed9bb194d4e..b8aebead81a9 100644
+--- a/netio.c
++++ b/netio.c
+@@ -3,6 +3,7 @@
+ #include "dbutil.h"
+ #include "session.h"
+ #include "debug.h"
++#include "runopts.h"
+
+ struct dropbear_progress_connection {
+ struct addrinfo *res;
+@@ -377,6 +378,7 @@ void set_sock_priority(int sock, enum dropbear_prio prio) {
+ /* Don't log ENOTSOCK errors so that this can harmlessly be called
+ * on a client '-J' proxy pipe */
+
++ if (opts.disable_ip_tos == 0) {
+ #ifdef IP_TOS
+ /* Set the DSCP field for outbound IP packet priority.
+ rfc4594 has some guidance to meanings.
+@@ -409,6 +411,7 @@ void set_sock_priority(int sock, enum dropbear_prio prio) {
+ TRACE(("Couldn't set IP_TOS (%s)", strerror(errno)));
+ }
+ #endif /* IP_TOS */
++ }
+
+ #ifdef HAVE_LINUX_PKT_SCHED_H
+ /* Set scheduling priority within the local Linux network stack */
+diff --git a/runopts.h b/runopts.h
+index 50c51dfbed06..07c44af2c5bd 100644
+--- a/runopts.h
++++ b/runopts.h
+@@ -33,6 +33,7 @@
+
+ typedef struct runopts {
+
++ int disable_ip_tos;
+ #if DROPBEAR_SVR_REMOTETCPFWD || DROPBEAR_CLI_LOCALTCPFWD \
+ || DROPBEAR_CLI_REMOTETCPFWD
+ int listen_fwd_all;
+diff --git a/svr-runopts.c b/svr-runopts.c
+index c15f23b772e9..2aab56174cd9 100644
+--- a/svr-runopts.c
++++ b/svr-runopts.c
+@@ -111,6 +111,7 @@ static void printhelp(const char * progname) {
+ #if DEBUG_TRACE
+ "-v verbose (repeat for more verbose)\n"
+ #endif
++ "-z disable IP Type-Of-Service feature\n"
+ ,DROPBEAR_VERSION, progname,
+ #if DROPBEAR_DSS
+ DSS_PRIV_FILENAME,
+@@ -199,6 +200,7 @@ void svr_getopts(int argc, char ** argv) {
+ #if DROPBEAR_SVR_REMOTETCPFWD
+ opts.listen_fwd_all = 0;
+ #endif
++ opts.disable_ip_tos = 0;
+
+ for (i = 1; i < (unsigned int)argc; i++) {
+ if (argv[i][0] != '-' || argv[i][1] == '\0')
+@@ -319,6 +321,9 @@ void svr_getopts(int argc, char ** argv) {
+ print_version();
+ exit(EXIT_SUCCESS);
+ break;
++ case 'z':
++ opts.disable_ip_tos = 1;
++ break;
+ default:
+ fprintf(stderr, "Invalid option -%c\n", c);
+ printhelp(argv[0]);