1631 cksump = IPH_TCPH_CHECKSUMP(ipha, ip_hdr_length);
1632 cksum = IP_TCP_CSUM_COMP;
1633 } else if (protocol == IPPROTO_UDP) {
1634 cksump = IPH_UDPH_CHECKSUMP(ipha, ip_hdr_length);
1635 cksum = IP_UDP_CSUM_COMP;
1636 } else if (protocol == IPPROTO_SCTP) {
1637 sctp_hdr_t *sctph;
1638
1639 ASSERT(MBLKL(mp) >= (ip_hdr_length + sizeof (*sctph)));
1640 sctph = (sctp_hdr_t *)(mp->b_rptr + ip_hdr_length);
1641 /*
1642 * Zero out the checksum field to ensure proper
1643 * checksum calculation.
1644 */
1645 sctph->sh_chksum = 0;
1646 #ifdef DEBUG
1647 if (!skip_sctp_cksum)
1648 #endif
1649 sctph->sh_chksum = sctp_cksum(mp, ip_hdr_length);
1650 goto ip_hdr_cksum;
1651 } else {
1652 goto ip_hdr_cksum;
1653 }
1654
1655 /* ULP puts the checksum field is in the first mblk */
1656 ASSERT(((uchar_t *)cksump) + sizeof (uint16_t) <= mp->b_wptr);
1657
1658 /*
1659 * We accumulate the pseudo header checksum in cksum.
1660 * This is pretty hairy code, so watch close. One
1661 * thing to keep in mind is that UDP and TCP have
1662 * stored their respective datagram lengths in their
1663 * checksum fields. This lines things up real nice.
1664 */
1665 cksum += (dst >> 16) + (dst & 0xFFFF) + (src >> 16) + (src & 0xFFFF);
1666
1667 cksum = IP_CSUM(mp, ip_hdr_length, cksum);
1668 /*
1669 * For UDP/IPv4 a zero means that the packets wasn't checksummed.
1670 * Change to 0xffff
1720 cksump = IPH_TCPH_CHECKSUMP(ipha, ip_hdr_length);
1721 cksum = IP_TCP_CSUM_COMP; /* Pseudo-header cksum */
1722 } else if (protocol == IPPROTO_UDP) {
1723 cksump = IPH_UDPH_CHECKSUMP(ipha, ip_hdr_length);
1724 cksum = IP_UDP_CSUM_COMP; /* Pseudo-header cksum */
1725 } else if (protocol == IPPROTO_SCTP) {
1726 sctp_hdr_t *sctph;
1727
1728 ASSERT(MBLKL(mp) >= (ip_hdr_length + sizeof (*sctph)));
1729 sctph = (sctp_hdr_t *)(mp->b_rptr + ip_hdr_length);
1730 /*
1731 * Zero out the checksum field to ensure proper
1732 * checksum calculation.
1733 */
1734 sctph->sh_chksum = 0;
1735 #ifdef DEBUG
1736 if (!skip_sctp_cksum)
1737 #endif
1738 sctph->sh_chksum = sctp_cksum(mp, ip_hdr_length);
1739 goto ip_hdr_cksum;
1740 } else {
1741 ip_hdr_cksum:
1742 /* Calculate IPv4 header checksum */
1743 ipha->ipha_hdr_checksum = 0;
1744 ipha->ipha_hdr_checksum = ip_csum_hdr(ipha);
1745 return (B_TRUE);
1746 }
1747
1748 /* ULP puts the checksum field is in the first mblk */
1749 ASSERT(((uchar_t *)cksump) + sizeof (uint16_t) <= mp->b_wptr);
1750
1751 /*
1752 * Underlying interface supports hardware checksum offload for
1753 * the payload; leave the payload checksum for the hardware to
1754 * calculate. N.B: We only need to set up checksum info on the
1755 * first mblk.
1756 */
1757 hck_flags = ill->ill_hcksum_capab->ill_hcksum_txflags;
1758
1759 DB_CKSUMFLAGS(mp) &= ~HCK_FLAGS;
|
1631 cksump = IPH_TCPH_CHECKSUMP(ipha, ip_hdr_length);
1632 cksum = IP_TCP_CSUM_COMP;
1633 } else if (protocol == IPPROTO_UDP) {
1634 cksump = IPH_UDPH_CHECKSUMP(ipha, ip_hdr_length);
1635 cksum = IP_UDP_CSUM_COMP;
1636 } else if (protocol == IPPROTO_SCTP) {
1637 sctp_hdr_t *sctph;
1638
1639 ASSERT(MBLKL(mp) >= (ip_hdr_length + sizeof (*sctph)));
1640 sctph = (sctp_hdr_t *)(mp->b_rptr + ip_hdr_length);
1641 /*
1642 * Zero out the checksum field to ensure proper
1643 * checksum calculation.
1644 */
1645 sctph->sh_chksum = 0;
1646 #ifdef DEBUG
1647 if (!skip_sctp_cksum)
1648 #endif
1649 sctph->sh_chksum = sctp_cksum(mp, ip_hdr_length);
1650 goto ip_hdr_cksum;
1651 } else if (protocol == IPPROTO_DCCP) {
1652 cksump = IPH_DCCPH_CHECKSUMP(ipha, ip_hdr_length);
1653 cksum = IP_DCCP_CSUM_COMP;
1654 } else {
1655 goto ip_hdr_cksum;
1656 }
1657
1658 /* ULP puts the checksum field is in the first mblk */
1659 ASSERT(((uchar_t *)cksump) + sizeof (uint16_t) <= mp->b_wptr);
1660
1661 /*
1662 * We accumulate the pseudo header checksum in cksum.
1663 * This is pretty hairy code, so watch close. One
1664 * thing to keep in mind is that UDP and TCP have
1665 * stored their respective datagram lengths in their
1666 * checksum fields. This lines things up real nice.
1667 */
1668 cksum += (dst >> 16) + (dst & 0xFFFF) + (src >> 16) + (src & 0xFFFF);
1669
1670 cksum = IP_CSUM(mp, ip_hdr_length, cksum);
1671 /*
1672 * For UDP/IPv4 a zero means that the packets wasn't checksummed.
1673 * Change to 0xffff
1723 cksump = IPH_TCPH_CHECKSUMP(ipha, ip_hdr_length);
1724 cksum = IP_TCP_CSUM_COMP; /* Pseudo-header cksum */
1725 } else if (protocol == IPPROTO_UDP) {
1726 cksump = IPH_UDPH_CHECKSUMP(ipha, ip_hdr_length);
1727 cksum = IP_UDP_CSUM_COMP; /* Pseudo-header cksum */
1728 } else if (protocol == IPPROTO_SCTP) {
1729 sctp_hdr_t *sctph;
1730
1731 ASSERT(MBLKL(mp) >= (ip_hdr_length + sizeof (*sctph)));
1732 sctph = (sctp_hdr_t *)(mp->b_rptr + ip_hdr_length);
1733 /*
1734 * Zero out the checksum field to ensure proper
1735 * checksum calculation.
1736 */
1737 sctph->sh_chksum = 0;
1738 #ifdef DEBUG
1739 if (!skip_sctp_cksum)
1740 #endif
1741 sctph->sh_chksum = sctp_cksum(mp, ip_hdr_length);
1742 goto ip_hdr_cksum;
1743 } else if (protocol == IPPROTO_DCCP) {
1744 cksump = IPH_DCCPH_CHECKSUMP(ipha, ip_hdr_length);
1745 cksum = IP_DCCP_CSUM_COMP;
1746 } else {
1747 ip_hdr_cksum:
1748 /* Calculate IPv4 header checksum */
1749 ipha->ipha_hdr_checksum = 0;
1750 ipha->ipha_hdr_checksum = ip_csum_hdr(ipha);
1751 return (B_TRUE);
1752 }
1753
1754 /* ULP puts the checksum field is in the first mblk */
1755 ASSERT(((uchar_t *)cksump) + sizeof (uint16_t) <= mp->b_wptr);
1756
1757 /*
1758 * Underlying interface supports hardware checksum offload for
1759 * the payload; leave the payload checksum for the hardware to
1760 * calculate. N.B: We only need to set up checksum info on the
1761 * first mblk.
1762 */
1763 hck_flags = ill->ill_hcksum_capab->ill_hcksum_txflags;
1764
1765 DB_CKSUMFLAGS(mp) &= ~HCK_FLAGS;
|