| 571 | } |
| 572 | |
| 573 | static void |
| 574 | tcp_set_le_to_m(struct lro_ctrl *lc, struct lro_entry *le, struct mbuf *m) |
| 575 | { |
| 576 | struct ether_header *eh; |
| 577 | void *l3hdr = NULL; /* Keep compiler happy. */ |
| 578 | struct tcphdr *th; |
| 579 | #ifdef INET6 |
| 580 | struct ip6_hdr *ip6 = NULL; /* Keep compiler happy. */ |
| 581 | #endif |
| 582 | #ifdef INET |
| 583 | struct ip *ip4 = NULL; /* Keep compiler happy. */ |
| 584 | #endif |
| 585 | uint32_t *ts_ptr; |
| 586 | int error, l, ts_failed = 0; |
| 587 | uint16_t tcp_data_len; |
| 588 | uint16_t csum; |
| 589 | |
| 590 | error = -1; |
| 591 | eh = mtod(m, struct ether_header *); |
| 592 | /* |
| 593 | * We must reset the other pointers since the mbuf |
| 594 | * we were pointing too is about to go away. |
| 595 | */ |
| 596 | switch (le->eh_type) { |
| 597 | #ifdef INET6 |
| 598 | case ETHERTYPE_IPV6: |
| 599 | l3hdr = ip6 = (struct ip6_hdr *)(eh + 1); |
| 600 | error = tcp_lro_rx_ipv6(lc, m, ip6, &th); |
| 601 | le->le_ip6 = ip6; |
| 602 | le->source_ip6 = ip6->ip6_src; |
| 603 | le->dest_ip6 = ip6->ip6_dst; |
| 604 | le->p_len = m->m_pkthdr.len - ETHER_HDR_LEN - sizeof(*ip6); |
| 605 | break; |
| 606 | #endif |
| 607 | #ifdef INET |
| 608 | case ETHERTYPE_IP: |
| 609 | l3hdr = ip4 = (struct ip *)(eh + 1); |
| 610 | error = tcp_lro_rx_ipv4(lc, m, ip4, &th); |
| 611 | le->le_ip4 = ip4; |
| 612 | le->source_ip4 = ip4->ip_src.s_addr; |
| 613 | le->dest_ip4 = ip4->ip_dst.s_addr; |
| 614 | le->p_len = m->m_pkthdr.len - ETHER_HDR_LEN; |
| 615 | break; |
| 616 | #endif |
| 617 | } |
| 618 | KASSERT(error == 0, ("%s: le=%p tcp_lro_rx_xxx failed\n", |
| 619 | __func__, le)); |
| 620 | ts_ptr = (uint32_t *)(th + 1); |
| 621 | l = (th->th_off << 2); |
| 622 | l -= sizeof(*th); |
| 623 | if (l != 0 && |
| 624 | (__predict_false(l != TCPOLEN_TSTAMP_APPA) || |
| 625 | (*ts_ptr != ntohl(TCPOPT_NOP<<24|TCPOPT_NOP<<16| |
| 626 | TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)))) { |
| 627 | /* We have failed to find a timestamp some other option? */ |
| 628 | ts_failed = 1; |
| 629 | } |
| 630 | if ((l != 0) && (ts_failed == 0)) { |
no test coverage detected