comparison common-session.c @ 941:5daedffd0769

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.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 16 Jul 2014 22:53:32 +0800
parents e9dfb6d15193
children f7f6c15b0ec3
comparison
equal deleted inserted replaced
940:e9dfb6d15193 941:5daedffd0769
57 57
58 ses.sock_in = sock_in; 58 ses.sock_in = sock_in;
59 ses.sock_out = sock_out; 59 ses.sock_out = sock_out;
60 ses.maxfd = MAX(sock_in, sock_out); 60 ses.maxfd = MAX(sock_in, sock_out);
61 61
62 ses.socket_prio = DROPBEAR_PRIO_DEFAULT;
63 /* Sets it to lowdelay */
64 update_channel_prio();
65
62 now = monotonic_now(); 66 now = monotonic_now();
63 ses.last_packet_time_keepalive_recv = now; 67 ses.last_packet_time_keepalive_recv = now;
64 ses.last_packet_time_idle = now; 68 ses.last_packet_time_idle = now;
65 ses.last_packet_time_any_sent = 0; 69 ses.last_packet_time_any_sent = 0;
66 ses.last_packet_time_keepalive_sent = 0; 70 ses.last_packet_time_keepalive_sent = 0;
510 } 514 }
511 ses.authstate.pw_passwd = m_strdup(passwd_crypt); 515 ses.authstate.pw_passwd = m_strdup(passwd_crypt);
512 } 516 }
513 } 517 }
514 518
519 /* Called when channels are modified */
520 void update_channel_prio() {
521 enum dropbear_prio new_prio;
522 int any = 0;
523 unsigned int i;
524
525 TRACE(("update_channel_prio"))
526
527 new_prio = DROPBEAR_PRIO_BULK;
528 for (i = 0; i < ses.chansize; i++) {
529 struct Channel *channel = ses.channels[i];
530 if (!channel || channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) {
531 if (channel && channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) {
532 TRACE(("update_channel_prio: early %d", channel->index))
533 }
534 continue;
535 }
536 any = 1;
537 if (channel->prio == DROPBEAR_CHANNEL_PRIO_INTERACTIVE)
538 {
539 TRACE(("update_channel_prio: lowdelay %d", channel->index))
540 new_prio = DROPBEAR_PRIO_LOWDELAY;
541 break;
542 } else if (channel->prio == DROPBEAR_CHANNEL_PRIO_UNKNOWABLE
543 && new_prio == DROPBEAR_PRIO_BULK)
544 {
545 TRACE(("update_channel_prio: unknowable %d", channel->index))
546 new_prio = DROPBEAR_PRIO_DEFAULT;
547 }
548 }
549
550 if (any == 0) {
551 /* lowdelay during setup */
552 TRACE(("update_channel_prio: not any"))
553 new_prio = DROPBEAR_PRIO_LOWDELAY;
554 }
555
556 if (new_prio != ses.socket_prio) {
557 TRACE(("Dropbear priority transitioning %4.4s -> %4.4s", (char*)&ses.socket_prio, (char*)&new_prio))
558 set_sock_priority(ses.sock_out, new_prio);
559 ses.socket_prio = new_prio;
560 }
561 }
562