comparison src/event/ngx_event_quic.c @ 8083:702f1d2581a4 quic

QUIC: eliminated idle timeout restart for dropped packets.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 08 Sep 2020 15:54:02 +0300
parents dcbb58e7ed11
children eece8e35e64d
comparison
equal deleted inserted replaced
8082:26a5bd4aff57 8083:702f1d2581a4
864 /* pos is at header end, adjust by actual packet length */ 864 /* pos is at header end, adjust by actual packet length */
865 pkt->raw->pos += pkt->len; 865 pkt->raw->pos += pkt->len;
866 866
867 (void) ngx_quic_skip_zero_padding(pkt->raw); 867 (void) ngx_quic_skip_zero_padding(pkt->raw);
868 868
869 return ngx_quic_input(c, pkt->raw); 869 rc = ngx_quic_input(c, pkt->raw);
870
871 if (rc == NGX_ERROR) {
872 return NGX_ERROR;
873 }
874
875 /* rc == NGX_OK || rc == NGX_DECLINED */
876
877 return NGX_OK;
870 } 878 }
871 879
872 880
873 static ngx_int_t 881 static ngx_int_t
874 ngx_quic_negotiate_version(ngx_connection_t *c, ngx_quic_header_t *inpkt) 882 ngx_quic_negotiate_version(ngx_connection_t *c, ngx_quic_header_t *inpkt)
1288 1296
1289 static void 1297 static void
1290 ngx_quic_input_handler(ngx_event_t *rev) 1298 ngx_quic_input_handler(ngx_event_t *rev)
1291 { 1299 {
1292 ssize_t n; 1300 ssize_t n;
1301 ngx_int_t rc;
1293 ngx_buf_t b; 1302 ngx_buf_t b;
1294 ngx_connection_t *c; 1303 ngx_connection_t *c;
1295 ngx_quic_connection_t *qc; 1304 ngx_quic_connection_t *qc;
1296 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; 1305 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE];
1297 1306
1335 } 1344 }
1336 1345
1337 b.last += n; 1346 b.last += n;
1338 qc->received += n; 1347 qc->received += n;
1339 1348
1340 if (ngx_quic_input(c, &b) != NGX_OK) { 1349 rc = ngx_quic_input(c, &b);
1350
1351 if (rc == NGX_ERROR) {
1341 ngx_quic_close_connection(c, NGX_ERROR); 1352 ngx_quic_close_connection(c, NGX_ERROR);
1342 return; 1353 return;
1343 } 1354 }
1355
1356 if (rc == NGX_DECLINED) {
1357 return;
1358 }
1359
1360 /* rc == NGX_OK */
1344 1361
1345 qc->send_timer_set = 0; 1362 qc->send_timer_set = 0;
1346 ngx_add_timer(rev, qc->tp.max_idle_timeout); 1363 ngx_add_timer(rev, qc->tp.max_idle_timeout);
1347 } 1364 }
1348 1365
1595 static ngx_int_t 1612 static ngx_int_t
1596 ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b) 1613 ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b)
1597 { 1614 {
1598 u_char *p; 1615 u_char *p;
1599 ngx_int_t rc; 1616 ngx_int_t rc;
1617 ngx_uint_t good;
1600 ngx_quic_header_t pkt; 1618 ngx_quic_header_t pkt;
1619
1620 good = 0;
1601 1621
1602 p = b->pos; 1622 p = b->pos;
1603 1623
1604 while (p < b->last) { 1624 while (p < b->last) {
1605 c->log->action = "processing quic packet"; 1625 c->log->action = "processing quic packet";
1635 rc = ngx_quic_app_input(c, &pkt); 1655 rc = ngx_quic_app_input(c, &pkt);
1636 } 1656 }
1637 1657
1638 if (rc == NGX_ERROR) { 1658 if (rc == NGX_ERROR) {
1639 return NGX_ERROR; 1659 return NGX_ERROR;
1660 }
1661
1662 if (rc == NGX_OK) {
1663 good = 1;
1640 } 1664 }
1641 1665
1642 /* NGX_OK || NGX_DECLINED */ 1666 /* NGX_OK || NGX_DECLINED */
1643 1667
1644 /* 1668 /*
1661 /* b->pos is at header end, adjust by actual packet length */ 1685 /* b->pos is at header end, adjust by actual packet length */
1662 b->pos += pkt.len; 1686 b->pos += pkt.len;
1663 p = ngx_quic_skip_zero_padding(b); 1687 p = ngx_quic_skip_zero_padding(b);
1664 } 1688 }
1665 1689
1666 return NGX_OK; 1690 return good ? NGX_OK : NGX_DECLINED;
1667 } 1691 }
1668 1692
1669 1693
1670 /* firefox workaround: skip zero padding at the end of quic packet */ 1694 /* firefox workaround: skip zero padding at the end of quic packet */
1671 static ngx_inline u_char * 1695 static ngx_inline u_char *