From 2864c3d15499ac133b4fffbc27787671c11939d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= 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 --- 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 8df1b7a..07fce1b 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, @@ -325,6 +326,9 @@ void cli_getopts(int argc, char ** argv) { case 'b': next = &bind_arg; 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 2ed9bb1..b8aebea 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 48a768c..1675836 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 7b76dca..aae4ca1 100644 --- a/svr-runopts.c +++ b/svr-runopts.c @@ -112,6 +112,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, @@ -201,6 +202,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') @@ -324,6 +326,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]);