summaryrefslogtreecommitdiffhomepage
path: root/common-session.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2014-07-16 22:53:32 +0800
committerMatt Johnston <matt@ucc.asn.au>2014-07-16 22:53:32 +0800
commitda57dd13c5352efd63c8692bbc12d19c9f882a2b (patch)
treeec18c7626bb47b3c4540f78d65d2a49b8a2d2fbf /common-session.c
parentf1826ea389bfddb6a0d52314d01e3d8b8f46eec8 (diff)
Set tcp priority as follows:
if (connecting || ptys || x11) tos = LOWDELAY; else if (tcp_forwards) tos = 0; else tos = BULK; TCP forwards could be either lowdelay or bulk, hence the default priority.
Diffstat (limited to 'common-session.c')
-rw-r--r--common-session.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/common-session.c b/common-session.c
index a90673f..cebd787 100644
--- a/common-session.c
+++ b/common-session.c
@@ -59,6 +59,10 @@ void common_session_init(int sock_in, int sock_out) {
ses.sock_out = sock_out;
ses.maxfd = MAX(sock_in, sock_out);
+ ses.socket_prio = DROPBEAR_PRIO_DEFAULT;
+ /* Sets it to lowdelay */
+ update_channel_prio();
+
now = monotonic_now();
ses.last_packet_time_keepalive_recv = now;
ses.last_packet_time_idle = now;
@@ -512,3 +516,47 @@ void fill_passwd(const char* username) {
}
}
+/* Called when channels are modified */
+void update_channel_prio() {
+ enum dropbear_prio new_prio;
+ int any = 0;
+ unsigned int i;
+
+ TRACE(("update_channel_prio"))
+
+ new_prio = DROPBEAR_PRIO_BULK;
+ for (i = 0; i < ses.chansize; i++) {
+ struct Channel *channel = ses.channels[i];
+ if (!channel || channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) {
+ if (channel && channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) {
+ TRACE(("update_channel_prio: early %d", channel->index))
+ }
+ continue;
+ }
+ any = 1;
+ if (channel->prio == DROPBEAR_CHANNEL_PRIO_INTERACTIVE)
+ {
+ TRACE(("update_channel_prio: lowdelay %d", channel->index))
+ new_prio = DROPBEAR_PRIO_LOWDELAY;
+ break;
+ } else if (channel->prio == DROPBEAR_CHANNEL_PRIO_UNKNOWABLE
+ && new_prio == DROPBEAR_PRIO_BULK)
+ {
+ TRACE(("update_channel_prio: unknowable %d", channel->index))
+ new_prio = DROPBEAR_PRIO_DEFAULT;
+ }
+ }
+
+ if (any == 0) {
+ /* lowdelay during setup */
+ TRACE(("update_channel_prio: not any"))
+ new_prio = DROPBEAR_PRIO_LOWDELAY;
+ }
+
+ if (new_prio != ses.socket_prio) {
+ TRACE(("Dropbear priority transitioning %4.4s -> %4.4s", (char*)&ses.socket_prio, (char*)&new_prio))
+ set_sock_priority(ses.sock_out, new_prio);
+ ses.socket_prio = new_prio;
+ }
+}
+