diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-23 02:27:12 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-23 02:27:12 +0000 |
commit | c2aa68d2ac00ee99e6cd348159b9357e348772df (patch) | |
tree | f76ac23aa90872946925525300f770dcad012bfb /sys/netinet/ip_output.c | |
parent | b8794969a7662bd38ddaacd86161705cfdd40e16 (diff) |
TCP, UDP, IPv4 input hardware checksumming processing; also IPv4
output hardware checksumming. Not tested yet, but should be done
tonight.
Remain to be solved: interactions with bridge, TCP/UDP output
checksumming, interactions of TCP/UDP checksumming with routing
changes.
Diffstat (limited to 'sys/netinet/ip_output.c')
-rw-r--r-- | sys/netinet/ip_output.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 9a52a837e2d..c6ca2c6e493 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.104 2001/06/19 18:49:53 jasoni Exp $ */ +/* $OpenBSD: ip_output.c,v 1.105 2001/06/23 02:27:10 angelos Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -592,12 +592,29 @@ sendit: if ((u_int16_t)ip->ip_len <= ifp->if_mtu) { ip->ip_len = htons((u_int16_t)ip->ip_len); ip->ip_off = htons((u_int16_t)ip->ip_off); - ip->ip_sum = 0; - ip->ip_sum = in_cksum(m, hlen); + if (ifp->if_capabilities & IFCAP_CSUM_IPv4) + m->m_pkthdr.csum |= M_IPV4_CSUM_OUT; + else { + ip->ip_sum = 0; + ip->ip_sum = in_cksum(m, hlen); + } error = (*ifp->if_output)(ifp, m, sintosa(dst), ro->ro_rt); goto done; } + /* Catch routing changes. */ + if (m->m_pkthdr.csum & M_TCPV4_CSUM_OUT && + !(ifp->if_capabilities & IFCAP_CSUM_TCPv4)) { + /* XXX Compute TCP checksum */ + m->m_pkthdr.csum &= ~M_TCPV4_CSUM_OUT; /* Clear */ + } + + if (m->m_pkthdr.csum & M_UDPV4_CSUM_OUT && + !(ifp->if_capabilities & IFCAP_CSUM_UDPv4)) { + /* XXX Compute UDP checksum */ + m->m_pkthdr.csum &= ~M_UDPV4_CSUM_OUT; /* Clear */ + } + /* * Too large for interface; fragment if possible. * Must be able to put at least 8 bytes per fragment. @@ -659,8 +676,12 @@ sendit: m->m_pkthdr.len = mhlen + len; m->m_pkthdr.rcvif = (struct ifnet *)0; mhip->ip_off = htons((u_int16_t)mhip->ip_off); - mhip->ip_sum = 0; - mhip->ip_sum = in_cksum(m, mhlen); + if (ifp->if_capabilities & IFCAP_CSUM_IPv4) + m->m_pkthdr.csum |= M_IPV4_CSUM_OUT; + else { + mhip->ip_sum = 0; + mhip->ip_sum = in_cksum(m, mhlen); + } ipstat.ips_ofragments++; } /* @@ -672,8 +693,12 @@ sendit: m->m_pkthdr.len = hlen + firstlen; ip->ip_len = htons((u_int16_t)m->m_pkthdr.len); ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF)); - ip->ip_sum = 0; - ip->ip_sum = in_cksum(m, hlen); + if (ifp->if_capabilities & IFCAP_CSUM_IPv4) + m->m_pkthdr.csum |= M_IPV4_CSUM_OUT; + else { + ip->ip_sum = 0; + ip->ip_sum = in_cksum(m, hlen); + } sendorfree: for (m = m0; m; m = m0) { m0 = m->m_nextpkt; |