comparison netio.c @ 1859:1d86a58fb52d

Leave non-interactive at default QoS class Lower class levels are less well defined, and non-interactive SSH can carry various different types of applications. This change also sets lowdelay class (AF21) earlier in an an outbound dbclient session
author Matt Johnston <matt@ucc.asn.au>
date Thu, 27 Jan 2022 14:34:10 +0800
parents 6022df862942
children 5001e9c5641f
comparison
equal deleted inserted replaced
1857:6022df862942 1859:1d86a58fb52d
18 18
19 int sock; 19 int sock;
20 20
21 char* errstring; 21 char* errstring;
22 char *bind_address, *bind_port; 22 char *bind_address, *bind_port;
23 enum dropbear_prio prio;
23 }; 24 };
24 25
25 /* Deallocate a progress connection. Removes from the pending list if iter!=NULL. 26 /* Deallocate a progress connection. Removes from the pending list if iter!=NULL.
26 Does not close sockets */ 27 Does not close sockets */
27 static void remove_connect(struct dropbear_progress_connection *c, m_list_elem *iter) { 28 static void remove_connect(struct dropbear_progress_connection *c, m_list_elem *iter) {
108 } 109 }
109 } 110 }
110 111
111 ses.maxfd = MAX(ses.maxfd, c->sock); 112 ses.maxfd = MAX(ses.maxfd, c->sock);
112 set_sock_nodelay(c->sock); 113 set_sock_nodelay(c->sock);
114 set_sock_priority(c->sock, c->prio);
113 setnonblocking(c->sock); 115 setnonblocking(c->sock);
114 116
115 #if DROPBEAR_CLIENT_TCP_FAST_OPEN 117 #if DROPBEAR_CLIENT_TCP_FAST_OPEN
116 fastopen = (c->writequeue != NULL); 118 fastopen = (c->writequeue != NULL);
117 119
170 } 172 }
171 } 173 }
172 174
173 /* Connect via TCP to a host. */ 175 /* Connect via TCP to a host. */
174 struct dropbear_progress_connection *connect_remote(const char* remotehost, const char* remoteport, 176 struct dropbear_progress_connection *connect_remote(const char* remotehost, const char* remoteport,
175 connect_callback cb, void* cb_data, 177 connect_callback cb, void* cb_data,
176 const char* bind_address, const char* bind_port) 178 const char* bind_address, const char* bind_port, enum dropbear_prio prio)
177 { 179 {
178 struct dropbear_progress_connection *c = NULL; 180 struct dropbear_progress_connection *c = NULL;
179 int err; 181 int err;
180 struct addrinfo hints; 182 struct addrinfo hints;
181 183
183 c->remotehost = m_strdup(remotehost); 185 c->remotehost = m_strdup(remotehost);
184 c->remoteport = m_strdup(remoteport); 186 c->remoteport = m_strdup(remoteport);
185 c->sock = -1; 187 c->sock = -1;
186 c->cb = cb; 188 c->cb = cb;
187 c->cb_data = cb_data; 189 c->cb_data = cb_data;
190 c->prio = prio;
188 191
189 list_append(&ses.conn_pending, c); 192 list_append(&ses.conn_pending, c);
190 193
191 #if DROPBEAR_FUZZ 194 #if DROPBEAR_FUZZ
192 if (fuzz.fuzzing) { 195 if (fuzz.fuzzing) {
376 379
377 #ifdef IPTOS_DSCP_AF21 380 #ifdef IPTOS_DSCP_AF21
378 /* Set the DSCP field for outbound IP packet priority. 381 /* Set the DSCP field for outbound IP packet priority.
379 rfc4594 has some guidance to meanings. 382 rfc4594 has some guidance to meanings.
380 383
381 We set AF21 as "Low-Latency" class for interactive (tty session). 384 We set AF21 as "Low-Latency" class for interactive (tty session,
382 Set AF11 "High-Throughput" for bulk data (which includes things 385 also handshake/setup packets). Other traffic is left at the default.
383 such as git over ssh). We usually want higher priority than
384 CS1/LE least effort.
385 386
386 OpenSSH at present uses AF21/CS1, rationale 387 OpenSSH at present uses AF21/CS1, rationale
387 https://cvsweb.openbsd.org/src/usr.bin/ssh/readconf.c#rev1.284 388 https://cvsweb.openbsd.org/src/usr.bin/ssh/readconf.c#rev1.284
388 389
389 Old Dropbear/OpenSSH and Debian/Ubuntu OpenSSH (at Jan 2022) use 390 Old Dropbear/OpenSSH and Debian/Ubuntu OpenSSH (at Jan 2022) use
390 IPTOS_LOWDELAY/IPTOS_THROUGHPUT 391 IPTOS_LOWDELAY/IPTOS_THROUGHPUT
391 */ 392 */
392 if (prio == DROPBEAR_PRIO_LOWDELAY) { 393 if (prio == DROPBEAR_PRIO_LOWDELAY) {
393 val = IPTOS_DSCP_AF21; 394 val = IPTOS_DSCP_AF21;
394 } else if (prio == DROPBEAR_PRIO_BULK) {
395 val = IPTOS_DSCP_AF11;
396 } else { 395 } else {
397 val = 0; /* default */ 396 val = 0; /* default */
398 } 397 }
399 #if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) 398 #if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS)
400 rc = setsockopt(sock, IPPROTO_IPV6, IPV6_TCLASS, (void*)&val, sizeof(val)); 399 rc = setsockopt(sock, IPPROTO_IPV6, IPV6_TCLASS, (void*)&val, sizeof(val));
410 409
411 #ifdef HAVE_LINUX_PKT_SCHED_H 410 #ifdef HAVE_LINUX_PKT_SCHED_H
412 /* Set scheduling priority within the local Linux network stack */ 411 /* Set scheduling priority within the local Linux network stack */
413 if (prio == DROPBEAR_PRIO_LOWDELAY) { 412 if (prio == DROPBEAR_PRIO_LOWDELAY) {
414 val = TC_PRIO_INTERACTIVE; 413 val = TC_PRIO_INTERACTIVE;
415 } else if (prio == DROPBEAR_PRIO_BULK) {
416 val = TC_PRIO_BULK;
417 } else { 414 } else {
418 val = 0; 415 val = 0;
419 } 416 }
420 /* linux specific, sets QoS class. see tc-prio(8) */ 417 /* linux specific, sets QoS class. see tc-prio(8) */
421 rc = setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &val, sizeof(val)); 418 rc = setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &val, sizeof(val));