| 672 | } |
| 673 | |
| 674 | static void |
| 675 | sctp_add_to_tail_pointer(struct sctp_queued_to_read *control, struct mbuf *m, uint32_t *added) |
| 676 | { |
| 677 | struct mbuf *prev = NULL; |
| 678 | struct sctp_tcb *stcb; |
| 679 | |
| 680 | stcb = control->stcb; |
| 681 | if (stcb == NULL) { |
| 682 | #ifdef INVARIANTS |
| 683 | panic("Control broken"); |
| 684 | #else |
| 685 | return; |
| 686 | #endif |
| 687 | } |
| 688 | if (control->tail_mbuf == NULL) { |
| 689 | /* TSNH */ |
| 690 | sctp_m_freem(control->data); |
| 691 | control->data = m; |
| 692 | sctp_setup_tail_pointer(control); |
| 693 | return; |
| 694 | } |
| 695 | control->tail_mbuf->m_next = m; |
| 696 | while (m) { |
| 697 | if (SCTP_BUF_LEN(m) == 0) { |
| 698 | /* Skip mbufs with NO length */ |
| 699 | if (prev == NULL) { |
| 700 | /* First one */ |
| 701 | control->tail_mbuf->m_next = sctp_m_free(m); |
| 702 | m = control->tail_mbuf->m_next; |
| 703 | } else { |
| 704 | SCTP_BUF_NEXT(prev) = sctp_m_free(m); |
| 705 | m = SCTP_BUF_NEXT(prev); |
| 706 | } |
| 707 | if (m == NULL) { |
| 708 | control->tail_mbuf = prev; |
| 709 | } |
| 710 | continue; |
| 711 | } |
| 712 | prev = m; |
| 713 | if (control->on_read_q) { |
| 714 | /* |
| 715 | * On read queue so we must increment the SB stuff, |
| 716 | * we assume caller has done any locks of SB. |
| 717 | */ |
| 718 | sctp_sballoc(stcb, &stcb->sctp_socket->so_rcv, m); |
| 719 | } |
| 720 | *added += SCTP_BUF_LEN(m); |
| 721 | atomic_add_int(&control->length, SCTP_BUF_LEN(m)); |
| 722 | m = SCTP_BUF_NEXT(m); |
| 723 | } |
| 724 | if (prev) { |
| 725 | control->tail_mbuf = prev; |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | static void |
| 730 | sctp_build_readq_entry_from_ctl(struct sctp_queued_to_read *nc, struct sctp_queued_to_read *control) |
no test coverage detected