comparison src/event/ngx_event_quic_transport.c @ 8275:19660929e8ff quic

Logging cleanup. + Client-related errors (i.e. parsing) are done at INFO level + c->log->action is updated through the process of receiving, parsing. handling packet/payload and generating frames/output.
author Vladimir Homutov <vl@nginx.com>
date Tue, 24 Mar 2020 17:03:39 +0300
parents cb75f194f1f0
children 50db7ce374b7
comparison
equal deleted inserted replaced
8274:ee53bfd8f9ed 8275:19660929e8ff
274 274
275 ngx_quic_hexdump0(pkt->log, "long input", pkt->data, pkt->len); 275 ngx_quic_hexdump0(pkt->log, "long input", pkt->data, pkt->len);
276 276
277 p = ngx_quic_read_uint8(p, end, &pkt->flags); 277 p = ngx_quic_read_uint8(p, end, &pkt->flags);
278 if (p == NULL) { 278 if (p == NULL) {
279 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 279 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
280 "packet is too short to read flags"); 280 "packet is too small to read flags");
281 return NGX_ERROR; 281 return NGX_ERROR;
282 } 282 }
283 283
284 if (!ngx_quic_long_pkt(pkt->flags)) { 284 if (!ngx_quic_long_pkt(pkt->flags)) {
285 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "not a long packet"); 285 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "not a long packet");
286 return NGX_ERROR; 286 return NGX_ERROR;
287 } 287 }
288 288
289 p = ngx_quic_read_uint32(p, end, &pkt->version); 289 p = ngx_quic_read_uint32(p, end, &pkt->version);
290 if (p == NULL) { 290 if (p == NULL) {
291 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 291 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
292 "packet is too short to read version"); 292 "packet is too small to read version");
293 return NGX_ERROR; 293 return NGX_ERROR;
294 } 294 }
295 295
296 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 296 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
297 "quic flags:%xi version:%xD", pkt->flags, pkt->version); 297 "quic flags:%xi version:%xD", pkt->flags, pkt->version);
298 298
299 if (pkt->version != NGX_QUIC_VERSION) { 299 if (pkt->version != NGX_QUIC_VERSION) {
300 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 300 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
301 "unsupported quic version: 0x%xi", pkt->version); 301 "unsupported quic version: 0x%xi", pkt->version);
302 return NGX_ERROR; 302 return NGX_ERROR;
303 } 303 }
304 304
305 p = ngx_quic_read_uint8(p, end, &idlen); 305 p = ngx_quic_read_uint8(p, end, &idlen);
306 if (p == NULL) { 306 if (p == NULL) {
307 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 307 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
308 "packet is too short to read dcid len"); 308 "packet is too small to read dcid len");
309 return NGX_ERROR; 309 return NGX_ERROR;
310 } 310 }
311 311
312 pkt->dcid.len = idlen; 312 pkt->dcid.len = idlen;
313 313
314 p = ngx_quic_read_bytes(p, end, idlen, &pkt->dcid.data); 314 p = ngx_quic_read_bytes(p, end, idlen, &pkt->dcid.data);
315 if (p == NULL) { 315 if (p == NULL) {
316 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 316 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
317 "packet is too short to read dcid"); 317 "packet is too small to read dcid");
318 return NGX_ERROR; 318 return NGX_ERROR;
319 } 319 }
320 320
321 p = ngx_quic_read_uint8(p, end, &idlen); 321 p = ngx_quic_read_uint8(p, end, &idlen);
322 if (p == NULL) { 322 if (p == NULL) {
323 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 323 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
324 "packet is too short to read scid len"); 324 "packet is too small to read scid len");
325 return NGX_ERROR; 325 return NGX_ERROR;
326 } 326 }
327 327
328 pkt->scid.len = idlen; 328 pkt->scid.len = idlen;
329 329
330 p = ngx_quic_read_bytes(p, end, idlen, &pkt->scid.data); 330 p = ngx_quic_read_bytes(p, end, idlen, &pkt->scid.data);
331 if (p == NULL) { 331 if (p == NULL) {
332 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 332 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
333 "packet is too short to read scid"); 333 "packet is too small to read scid");
334 return NGX_ERROR; 334 return NGX_ERROR;
335 } 335 }
336 336
337 pkt->raw->pos = p; 337 pkt->raw->pos = p;
338 338
382 382
383 ngx_quic_hexdump0(pkt->log, "short input", pkt->data, pkt->len); 383 ngx_quic_hexdump0(pkt->log, "short input", pkt->data, pkt->len);
384 384
385 p = ngx_quic_read_uint8(p, end, &pkt->flags); 385 p = ngx_quic_read_uint8(p, end, &pkt->flags);
386 if (p == NULL) { 386 if (p == NULL) {
387 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 387 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
388 "packet is too short to read flags"); 388 "packet is too small to read flags");
389 return NGX_ERROR; 389 return NGX_ERROR;
390 } 390 }
391 391
392 if (!ngx_quic_short_pkt(pkt->flags)) { 392 if (!ngx_quic_short_pkt(pkt->flags)) {
393 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "not a short packet"); 393 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "not a short packet");
394 return NGX_ERROR; 394 return NGX_ERROR;
395 } 395 }
396 396
397 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 397 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
398 "quic flags:%xi", pkt->flags); 398 "quic flags:%xi", pkt->flags);
399 399
400 if (ngx_memcmp(p, dcid->data, dcid->len) != 0) { 400 if (ngx_memcmp(p, dcid->data, dcid->len) != 0) {
401 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "unexpected quic dcid"); 401 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "unexpected quic dcid");
402 return NGX_ERROR; 402 return NGX_ERROR;
403 } 403 }
404 404
405 pkt->dcid.len = dcid->len; 405 pkt->dcid.len = dcid->len;
406 406
407 p = ngx_quic_read_bytes(p, end, dcid->len, &pkt->dcid.data); 407 p = ngx_quic_read_bytes(p, end, dcid->len, &pkt->dcid.data);
408 if (p == NULL) { 408 if (p == NULL) {
409 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 409 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
410 "packet is too short to read dcid"); 410 "packet is too small to read dcid");
411 return NGX_ERROR; 411 return NGX_ERROR;
412 } 412 }
413 413
414 pkt->raw->pos = p; 414 pkt->raw->pos = p;
415 415
429 429
430 pkt->log->action = "parsing quic initial header"; 430 pkt->log->action = "parsing quic initial header";
431 431
432 p = ngx_quic_parse_int(p, end, &varint); 432 p = ngx_quic_parse_int(p, end, &varint);
433 if (p == NULL) { 433 if (p == NULL) {
434 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "failed to parse token length"); 434 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
435 "failed to parse token length");
435 return NGX_ERROR; 436 return NGX_ERROR;
436 } 437 }
437 438
438 pkt->token.len = varint; 439 pkt->token.len = varint;
439 440
440 p = ngx_quic_read_bytes(p, end, pkt->token.len, &pkt->token.data); 441 p = ngx_quic_read_bytes(p, end, pkt->token.len, &pkt->token.data);
441 if (p == NULL) { 442 if (p == NULL) {
442 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 443 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
443 "packet too short to read token data"); 444 "packet too small to read token data");
444 return NGX_ERROR; 445 return NGX_ERROR;
445 } 446 }
446 447
447 p = ngx_quic_parse_int(p, end, &varint); 448 p = ngx_quic_parse_int(p, end, &varint);
448 if (p == NULL) { 449 if (p == NULL) {
449 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "bad packet length"); 450 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "bad packet length");
450 return NGX_ERROR; 451 return NGX_ERROR;
451 } 452 }
452 453
453 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 454 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
454 "quic packet length: %uL", varint); 455 "quic packet length: %uL", varint);
455 456
456 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) { 457 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) {
457 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "truncated initial packet"); 458 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "truncated initial packet");
458 return NGX_ERROR; 459 return NGX_ERROR;
459 } 460 }
460 461
461 pkt->raw->pos = p; 462 pkt->raw->pos = p;
462 pkt->len = varint; 463 pkt->len = varint;
480 481
481 pkt->log->action = "parsing quic handshake header"; 482 pkt->log->action = "parsing quic handshake header";
482 483
483 p = ngx_quic_parse_int(p, end, &plen); 484 p = ngx_quic_parse_int(p, end, &plen);
484 if (p == NULL) { 485 if (p == NULL) {
485 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "bad packet length"); 486 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "bad packet length");
486 return NGX_ERROR; 487 return NGX_ERROR;
487 } 488 }
488 489
489 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 490 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
490 "quic packet length: %uL", plen); 491 "quic packet length: %uL", plen);
491 492
492 if (plen > (uint64_t)((pkt->data + pkt->len) - p)) { 493 if (plen > (uint64_t)((pkt->data + pkt->len) - p)) {
493 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "truncated handshake packet"); 494 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "truncated handshake packet");
494 return NGX_ERROR; 495 return NGX_ERROR;
495 } 496 }
496 497
497 pkt->raw->pos = p; 498 pkt->raw->pos = p;
498 pkt->len = plen; 499 pkt->len = plen;
516 flags = pkt->flags; 517 flags = pkt->flags;
517 p = start; 518 p = start;
518 519
519 p = ngx_quic_parse_int(p, end, &varint); 520 p = ngx_quic_parse_int(p, end, &varint);
520 if (p == NULL) { 521 if (p == NULL) {
521 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 522 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
522 "failed to obtain quic frame type"); 523 "failed to obtain quic frame type");
523 return NGX_ERROR; 524 return NGX_ERROR;
524 } 525 }
525 526
526 f->type = varint; 527 f->type = varint;
533 goto not_allowed; 534 goto not_allowed;
534 } 535 }
535 536
536 p = ngx_quic_parse_int(p, end, &f->u.crypto.offset); 537 p = ngx_quic_parse_int(p, end, &f->u.crypto.offset);
537 if (p == NULL) { 538 if (p == NULL) {
538 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 539 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
539 "failed to parse crypto frame offset"); 540 "failed to parse crypto frame offset");
540 return NGX_ERROR; 541 return NGX_ERROR;
541 } 542 }
542 543
543 p = ngx_quic_parse_int(p, end, &f->u.crypto.len); 544 p = ngx_quic_parse_int(p, end, &f->u.crypto.len);
544 if (p == NULL) { 545 if (p == NULL) {
545 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 546 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
546 "failed to parse crypto frame len"); 547 "failed to parse crypto frame len");
547 return NGX_ERROR; 548 return NGX_ERROR;
548 } 549 }
549 550
550 p = ngx_quic_read_bytes(p, end, f->u.crypto.len, &f->u.crypto.data); 551 p = ngx_quic_read_bytes(p, end, f->u.crypto.len, &f->u.crypto.data);
551 if (p == NULL) { 552 if (p == NULL) {
552 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 553 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
553 "failed to parse crypto frame data"); 554 "failed to parse crypto frame data");
554 return NGX_ERROR; 555 return NGX_ERROR;
555 } 556 }
556 557
557 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 558 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
582 583
583 p = ngx_quic_parse_int_multi(p, end, &f->u.ack.largest, 584 p = ngx_quic_parse_int_multi(p, end, &f->u.ack.largest,
584 &f->u.ack.delay, &f->u.ack.range_count, 585 &f->u.ack.delay, &f->u.ack.range_count,
585 &f->u.ack.first_range, NULL); 586 &f->u.ack.first_range, NULL);
586 if (p == NULL) { 587 if (p == NULL) {
587 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 588 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
588 "failed to parse ack frame"); 589 "failed to parse ack frame");
589 return NGX_ERROR; 590 return NGX_ERROR;
590 } 591 }
591 592
592 if (f->u.ack.range_count) { 593 if (f->u.ack.range_count) {
593 p = ngx_quic_parse_int(p, end, &f->u.ack.ranges[0]); 594 p = ngx_quic_parse_int(p, end, &f->u.ack.ranges[0]);
594 if (p == NULL) { 595 if (p == NULL) {
595 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 596 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
596 "failed to parse ack frame first range"); 597 "failed to parse ack frame first range");
597 return NGX_ERROR; 598 return NGX_ERROR;
598 } 599 }
599 } 600 }
600 601
601 if (f->type == NGX_QUIC_FT_ACK_ECN) { 602 if (f->type == NGX_QUIC_FT_ACK_ECN) {
602 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 603 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
603 "TODO: parse ECN ack frames"); 604 "TODO: parse ECN ack frames");
604 /* TODO: add parsing of such frames */ 605 /* TODO: add parsing of such frames */
605 return NGX_ERROR; 606 return NGX_ERROR;
606 } 607 }
607 608
627 } 628 }
628 629
629 p = ngx_quic_parse_int_multi(p, end, &f->u.ncid.seqnum, 630 p = ngx_quic_parse_int_multi(p, end, &f->u.ncid.seqnum,
630 &f->u.ncid.retire, NULL); 631 &f->u.ncid.retire, NULL);
631 if (p == NULL) { 632 if (p == NULL) {
632 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 633 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
633 "failed to parse new connection id frame"); 634 "failed to parse new connection id frame");
634 return NGX_ERROR; 635 return NGX_ERROR;
635 } 636 }
636 637
637 p = ngx_quic_read_uint8(p, end, &f->u.ncid.len); 638 p = ngx_quic_read_uint8(p, end, &f->u.ncid.len);
638 if (p == NULL) { 639 if (p == NULL) {
639 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 640 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
640 "failed to parse new connection id length"); 641 "failed to parse new connection id length");
641 return NGX_ERROR; 642 return NGX_ERROR;
642 } 643 }
643 644
644 p = ngx_quic_copy_bytes(p, end, f->u.ncid.len, f->u.ncid.cid); 645 p = ngx_quic_copy_bytes(p, end, f->u.ncid.len, f->u.ncid.cid);
645 if (p == NULL) { 646 if (p == NULL) {
646 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 647 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
647 "failed to parse new connection id cid"); 648 "failed to parse new connection id cid");
648 return NGX_ERROR; 649 return NGX_ERROR;
649 } 650 }
650 651
651 p = ngx_quic_copy_bytes(p, end, 16, f->u.ncid.srt); 652 p = ngx_quic_copy_bytes(p, end, 16, f->u.ncid.srt);
652 if (p == NULL) { 653 if (p == NULL) {
653 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 654 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
654 "failed to parse new connection id srt"); 655 "failed to parse new connection id srt");
655 return NGX_ERROR; 656 return NGX_ERROR;
656 } 657 }
657 658
658 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 659 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
674 goto not_allowed; 675 goto not_allowed;
675 } 676 }
676 677
677 p = ngx_quic_parse_int(p, end, &f->u.close.error_code); 678 p = ngx_quic_parse_int(p, end, &f->u.close.error_code);
678 if (p == NULL) { 679 if (p == NULL) {
679 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 680 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
680 "failed to parse close connection frame error code"); 681 "failed to parse close connection frame error code");
681 return NGX_ERROR; 682 return NGX_ERROR;
682 } 683 }
683 684
684 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { 685 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) {
685 p = ngx_quic_parse_int(p, end, &f->u.close.frame_type); 686 p = ngx_quic_parse_int(p, end, &f->u.close.frame_type);
686 if (p == NULL) { 687 if (p == NULL) {
687 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 688 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
688 "failed to parse close connection frame type"); 689 "failed to parse close connection frame type");
689 return NGX_ERROR; 690 return NGX_ERROR;
690 } 691 }
691 } 692 }
692 693
693 p = ngx_quic_parse_int(p, end, &varint); 694 p = ngx_quic_parse_int(p, end, &varint);
694 if (p == NULL) { 695 if (p == NULL) {
695 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 696 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
696 "failed to parse close reason length"); 697 "failed to parse close reason length");
697 return NGX_ERROR; 698 return NGX_ERROR;
698 } 699 }
699 700
700 f->u.close.reason.len = varint; 701 f->u.close.reason.len = varint;
701 702
702 p = ngx_quic_read_bytes(p, end, f->u.close.reason.len, 703 p = ngx_quic_read_bytes(p, end, f->u.close.reason.len,
703 &f->u.close.reason.data); 704 &f->u.close.reason.data);
704 if (p == NULL) { 705 if (p == NULL) {
705 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 706 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
706 "failed to parse close reason"); 707 "failed to parse close reason");
707 return NGX_ERROR; 708 return NGX_ERROR;
708 } 709 }
709 710
710 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { 711 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) {
711 712
712 if (f->u.close.error_code >= NGX_QUIC_ERR_LAST) { 713 if (f->u.close.error_code >= NGX_QUIC_ERR_LAST) {
713 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 714 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
714 "unkown error code: %ui, truncated", 715 "unkown error code: %ui, truncated",
715 f->u.close.error_code); 716 f->u.close.error_code);
716 f->u.close.error_code = NGX_QUIC_ERR_LAST - 1; 717 f->u.close.error_code = NGX_QUIC_ERR_LAST - 1;
717 } 718 }
718 719
749 f->u.stream.len = ngx_quic_stream_bit_len(f->type); 750 f->u.stream.len = ngx_quic_stream_bit_len(f->type);
750 f->u.stream.fin = ngx_quic_stream_bit_fin(f->type); 751 f->u.stream.fin = ngx_quic_stream_bit_fin(f->type);
751 752
752 p = ngx_quic_parse_int(p, end, &f->u.stream.stream_id); 753 p = ngx_quic_parse_int(p, end, &f->u.stream.stream_id);
753 if (p == NULL) { 754 if (p == NULL) {
754 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 755 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
755 "failed to parse stream frame id"); 756 "failed to parse stream frame id");
756 return NGX_ERROR; 757 return NGX_ERROR;
757 } 758 }
758 759
759 if (f->type & 0x04) { 760 if (f->type & 0x04) {
760 p = ngx_quic_parse_int(p, end, &f->u.stream.offset); 761 p = ngx_quic_parse_int(p, end, &f->u.stream.offset);
761 if (p == NULL) { 762 if (p == NULL) {
762 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 763 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
763 "failed to parse stream frame offset"); 764 "failed to parse stream frame offset");
764 return NGX_ERROR; 765 return NGX_ERROR;
765 } 766 }
766 767
767 } else { 768 } else {
769 } 770 }
770 771
771 if (f->type & 0x02) { 772 if (f->type & 0x02) {
772 p = ngx_quic_parse_int(p, end, &f->u.stream.length); 773 p = ngx_quic_parse_int(p, end, &f->u.stream.length);
773 if (p == NULL) { 774 if (p == NULL) {
774 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 775 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
775 "failed to parse stream frame length"); 776 "failed to parse stream frame length");
776 return NGX_ERROR; 777 return NGX_ERROR;
777 } 778 }
778 779
779 } else { 780 } else {
781 } 782 }
782 783
783 p = ngx_quic_read_bytes(p, end, f->u.stream.length, 784 p = ngx_quic_read_bytes(p, end, f->u.stream.length,
784 &f->u.stream.data); 785 &f->u.stream.data);
785 if (p == NULL) { 786 if (p == NULL) {
786 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 787 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
787 "failed to parse stream frame data"); 788 "failed to parse stream frame data");
788 return NGX_ERROR; 789 return NGX_ERROR;
789 } 790 }
790 791
791 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 792 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
805 goto not_allowed; 806 goto not_allowed;
806 } 807 }
807 808
808 p = ngx_quic_parse_int(p, end, &f->u.max_data.max_data); 809 p = ngx_quic_parse_int(p, end, &f->u.max_data.max_data);
809 if (p == NULL) { 810 if (p == NULL) {
810 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 811 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
811 "failed to parse max data frame"); 812 "failed to parse max data frame");
812 return NGX_ERROR; 813 return NGX_ERROR;
813 } 814 }
814 815
815 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 816 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
825 826
826 p = ngx_quic_parse_int_multi(p, end, &f->u.reset_stream.id, 827 p = ngx_quic_parse_int_multi(p, end, &f->u.reset_stream.id,
827 &f->u.reset_stream.error_code, 828 &f->u.reset_stream.error_code,
828 &f->u.reset_stream.final_size, NULL); 829 &f->u.reset_stream.final_size, NULL);
829 if (p == NULL) { 830 if (p == NULL) {
830 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 831 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
831 "failed to parse reset stream frame"); 832 "failed to parse reset stream frame");
832 return NGX_ERROR; 833 return NGX_ERROR;
833 } 834 }
834 835
835 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 836 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
846 } 847 }
847 848
848 p = ngx_quic_parse_int_multi(p, end, &f->u.stop_sending.id, 849 p = ngx_quic_parse_int_multi(p, end, &f->u.stop_sending.id,
849 &f->u.stop_sending.error_code, NULL); 850 &f->u.stop_sending.error_code, NULL);
850 if (p == NULL) { 851 if (p == NULL) {
851 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 852 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
852 "failed to parse stop sending frame"); 853 "failed to parse stop sending frame");
853 return NGX_ERROR; 854 return NGX_ERROR;
854 } 855 }
855 856
856 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 857 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
866 goto not_allowed; 867 goto not_allowed;
867 } 868 }
868 869
869 p = ngx_quic_parse_int(p, end, &f->u.streams_blocked.limit); 870 p = ngx_quic_parse_int(p, end, &f->u.streams_blocked.limit);
870 if (p == NULL) { 871 if (p == NULL) {
871 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 872 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
872 "failed to parse streams blocked frame limit"); 873 "failed to parse streams blocked frame limit");
873 return NGX_ERROR; 874 return NGX_ERROR;
874 } 875 }
875 876
876 f->u.streams_blocked.bidi = 877 f->u.streams_blocked.bidi =
893 goto not_allowed; 894 goto not_allowed;
894 } 895 }
895 896
896 /* TODO: implement */ 897 /* TODO: implement */
897 898
898 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 899 ngx_log_error(NGX_LOG_ALERT, pkt->log, 0,
899 "unimplemented frame type 0x%xi in packet", f->type); 900 "unimplemented frame type 0x%xi in packet", f->type);
900 901
901 break; 902 break;
902 903
903 case NGX_QUIC_FT_MAX_STREAMS: 904 case NGX_QUIC_FT_MAX_STREAMS:
907 goto not_allowed; 908 goto not_allowed;
908 } 909 }
909 910
910 p = ngx_quic_parse_int(p, end, &f->u.max_streams.limit); 911 p = ngx_quic_parse_int(p, end, &f->u.max_streams.limit);
911 if (p == NULL) { 912 if (p == NULL) {
912 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 913 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
913 "failed to parse max streams frame limit"); 914 "failed to parse max streams frame limit");
914 return NGX_ERROR; 915 return NGX_ERROR;
915 } 916 }
916 917
917 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0; 918 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0;
929 } 930 }
930 931
931 p = ngx_quic_parse_int_multi(p, end, &f->u.max_stream_data.id, 932 p = ngx_quic_parse_int_multi(p, end, &f->u.max_stream_data.id,
932 &f->u.max_stream_data.limit, NULL); 933 &f->u.max_stream_data.limit, NULL);
933 if (p == NULL) { 934 if (p == NULL) {
934 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 935 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
935 "failed to parse max stream data frame"); 936 "failed to parse max stream data frame");
936 return NGX_ERROR; 937 return NGX_ERROR;
937 } 938 }
938 939
939 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 940 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
948 goto not_allowed; 949 goto not_allowed;
949 } 950 }
950 951
951 p = ngx_quic_parse_int(p, end, &f->u.data_blocked.limit); 952 p = ngx_quic_parse_int(p, end, &f->u.data_blocked.limit);
952 if (p == NULL) { 953 if (p == NULL) {
953 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 954 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
954 "failed to parse data blocked frame limit"); 955 "failed to parse data blocked frame limit");
955 return NGX_ERROR; 956 return NGX_ERROR;
956 } 957 }
957 958
958 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 959 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
967 } 968 }
968 969
969 p = ngx_quic_parse_int_multi(p, end, &f->u.stream_data_blocked.id, 970 p = ngx_quic_parse_int_multi(p, end, &f->u.stream_data_blocked.id,
970 &f->u.stream_data_blocked.limit, NULL); 971 &f->u.stream_data_blocked.limit, NULL);
971 if (p == NULL) { 972 if (p == NULL) {
972 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 973 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
973 "failed to parse tream data blocked frame"); 974 "failed to parse tream data blocked frame");
974 return NGX_ERROR; 975 return NGX_ERROR;
975 } 976 }
976 977
977 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 978 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
986 goto not_allowed; 987 goto not_allowed;
987 } 988 }
988 989
989 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number); 990 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number);
990 if (p == NULL) { 991 if (p == NULL) {
991 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 992 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
992 "failed to parse retire connection id" 993 "failed to parse retire connection id"
993 " frame sequence number"); 994 " frame sequence number");
994 return NGX_ERROR; 995 return NGX_ERROR;
995 } 996 }
996 997
1005 goto not_allowed; 1006 goto not_allowed;
1006 } 1007 }
1007 1008
1008 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data); 1009 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data);
1009 if (p == NULL) { 1010 if (p == NULL) {
1010 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 1011 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
1011 "failed to get path challenge frame data"); 1012 "failed to get path challenge frame data");
1012 return NGX_ERROR; 1013 return NGX_ERROR;
1013 } 1014 }
1014 1015
1015 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1016 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1025 goto not_allowed; 1026 goto not_allowed;
1026 } 1027 }
1027 1028
1028 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data); 1029 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data);
1029 if (p == NULL) { 1030 if (p == NULL) {
1030 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 1031 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
1031 "failed to get path response frame data"); 1032 "failed to get path response frame data");
1032 return NGX_ERROR; 1033 return NGX_ERROR;
1033 } 1034 }
1034 1035
1035 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1036 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1038 ngx_quic_hexdump0(pkt->log, "path response data", 1039 ngx_quic_hexdump0(pkt->log, "path response data",
1039 f->u.path_response.data, 8); 1040 f->u.path_response.data, 8);
1040 break; 1041 break;
1041 1042
1042 default: 1043 default:
1043 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 1044 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
1044 "unknown frame type 0x%xi in packet", f->type); 1045 "unknown frame type 0x%xi in packet", f->type);
1045 1046
1046 return NGX_ERROR; 1047 return NGX_ERROR;
1047 } 1048 }
1048 1049