comparison src/event/ngx_event_quic.c @ 8084:eece8e35e64d quic

QUIC: allowed old DCID for initial packets until first ACK. If a packet sent in response to an initial client packet was lost, then successive client initial packets were dropped by nginx with the unexpected dcid message logged. This was because the new DCID generated by the server was not available to the client.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 09 Sep 2020 16:35:29 +0300
parents 702f1d2581a4
children dbcb9d0a3df1
comparison
equal deleted inserted replaced
8083:702f1d2581a4 8084:eece8e35e64d
1989 1989
1990 1990
1991 static ngx_int_t 1991 static ngx_int_t
1992 ngx_quic_check_peer(ngx_quic_connection_t *qc, ngx_quic_header_t *pkt) 1992 ngx_quic_check_peer(ngx_quic_connection_t *qc, ngx_quic_header_t *pkt)
1993 { 1993 {
1994 ngx_str_t *dcid;
1995 ngx_queue_t *q; 1994 ngx_queue_t *q;
1995 ngx_quic_send_ctx_t *ctx;
1996 ngx_quic_client_id_t *cid; 1996 ngx_quic_client_id_t *cid;
1997 1997
1998 dcid = ngx_quic_pkt_zrtt(pkt->flags) ? &qc->odcid : &qc->dcid; 1998 ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_initial);
1999 1999
2000 if (pkt->dcid.len != dcid->len) { 2000 if (ngx_quic_pkt_zrtt(pkt->flags)
2001 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic unexpected quic dcidl"); 2001 || (ngx_quic_pkt_in(pkt->flags) && ctx->largest_ack == (uint64_t) -1))
2002 return NGX_ERROR; 2002 {
2003 } 2003 if (pkt->dcid.len == qc->odcid.len
2004 2004 && ngx_memcmp(pkt->dcid.data, qc->odcid.data, qc->odcid.len) == 0)
2005 if (ngx_memcmp(pkt->dcid.data, dcid->data, dcid->len) != 0) { 2005 {
2006 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic unexpected quic dcid"); 2006 goto found;
2007 return NGX_ERROR; 2007 }
2008 } 2008 }
2009
2010 if (!ngx_quic_pkt_zrtt(pkt->flags)) {
2011 if (pkt->dcid.len == qc->dcid.len
2012 && ngx_memcmp(pkt->dcid.data, qc->dcid.data, qc->dcid.len) == 0)
2013 {
2014 goto found;
2015 }
2016 }
2017
2018 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic unexpected quic dcid");
2019 return NGX_ERROR;
2020
2021 found:
2009 2022
2010 for (q = ngx_queue_head(&qc->client_ids); 2023 for (q = ngx_queue_head(&qc->client_ids);
2011 q != ngx_queue_sentinel(&qc->client_ids); 2024 q != ngx_queue_sentinel(&qc->client_ids);
2012 q = ngx_queue_next(q)) 2025 q = ngx_queue_next(q))
2013 { 2026 {