dropbear: make IP Type-Of-Service feature optional staging
authorPetr Štetiar <ynezz@true.cz>
Fri, 26 Aug 2022 07:16:27 +0000 (09:16 +0200)
committerPetr Štetiar <ynezz@true.cz>
Fri, 26 Aug 2022 07:16:27 +0000 (09:16 +0200)
TODO

https://github.com/openwrt/openwrt/issues/10405
Signed-off-by: Petr Štetiar <ynezz@true.cz>
package/network/services/dropbear/files/dropbear.config
package/network/services/dropbear/files/dropbear.init
package/network/services/dropbear/patches/920-Make-IP-Type-Of-Service-feature-optional.patch [new file with mode: 0644]

index 2139ba0bbeaac71ccb88fce7f5c490198d7d5cd0..e42d9bd704cea70430f8b2e5daad2c3d08352f5d 100644 (file)
@@ -2,4 +2,5 @@ config dropbear
        option PasswordAuth 'on'
        option RootPasswordAuth 'on'
        option Port         '22'
+       option DisableIPToS 'off'
 #      option BannerFile   '/etc/banner'
index ea4cad2a8d5489500186b52c68c13bd0ea54a31d..4c84a293e205ae04d4231bbe5e75c53580f7a738 100755 (executable)
@@ -129,7 +129,8 @@ validate_section_dropbear()
                'IdleTimeout:uinteger:0' \
                'MaxAuthTries:uinteger:3' \
                'RecvWindowSize:uinteger:0' \
-               'mdns:bool:1'
+               'mdns:bool:1' \
+               'DisableIPToS:bool:0'
 }
 
 dropbear_instance()
@@ -160,6 +161,7 @@ dropbear_instance()
        [ "${GatewayPorts}" -eq 1 ] && procd_append_param command -a
        [ "${RootPasswordAuth}" -eq 0 ] && procd_append_param command -g
        [ "${RootLogin}" -eq 0 ] && procd_append_param command -w
+       [ "${DisableIPToS}" -eq 1 ] && procd_append_param command -z
        if [ -n "${rsakeyfile}" ]; then
                logger -t ${NAME} -p daemon.warn \
                        "option 'rsakeyfile' is considered to be deprecated and" \
diff --git a/package/network/services/dropbear/patches/920-Make-IP-Type-Of-Service-feature-optional.patch b/package/network/services/dropbear/patches/920-Make-IP-Type-Of-Service-feature-optional.patch
new file mode 100644 (file)
index 0000000..a6c86d5
--- /dev/null
@@ -0,0 +1,112 @@
+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]);