diff options
author | tuexen <tuexen@FreeBSD.org> | 2014-10-06 17:08:19 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2014-10-06 17:08:19 +0000 |
commit | 01f551f619a0190f2a22242a9b28a20e72e95685 (patch) | |
tree | 1a7cb000c510b03bf8075a05e3a0a3d0ab5db11a /sys/netinet6/udp6_usrreq.c | |
parent | 88124f9e02fc7803f94dbf3ded02e455d255c479 (diff) | |
download | FreeBSD-src-01f551f619a0190f2a22242a9b28a20e72e95685.zip FreeBSD-src-01f551f619a0190f2a22242a9b28a20e72e95685.tar.gz |
MFC r272404:
Fix the checksum computation for UDPLite/IPv6. This requires the
usage of a function computing the checksum only over a part of the function.
Therefore introduce in6_cksum_partial() and implement in6_cksum() based
on that.
While there, ensure that the UDPLite packet contains at least enough bytes
to contain the header.
Diffstat (limited to 'sys/netinet6/udp6_usrreq.c')
-rw-r--r-- | sys/netinet6/udp6_usrreq.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index a2bcbc7..7eb64fd 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -225,11 +225,16 @@ udp6_input(struct mbuf **mp, int *offp, int proto) nxt = ip6->ip6_nxt; cscov_partial = (nxt == IPPROTO_UDPLITE) ? 1 : 0; - if (nxt == IPPROTO_UDPLITE && (ulen == 0 || ulen == plen)) { + if (nxt == IPPROTO_UDPLITE) { /* Zero means checksum over the complete packet. */ if (ulen == 0) ulen = plen; - cscov_partial = 0; + if (ulen == plen) + cscov_partial = 0; + if ((ulen < sizeof(struct udphdr)) || (ulen > plen)) { + /* XXX: What is the right UDPLite MIB counter? */ + goto badunlocked; + } } if (nxt == IPPROTO_UDP && plen != ulen) { UDPSTAT_INC(udps_badlen); @@ -255,7 +260,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto) m->m_pkthdr.csum_data); uh_sum ^= 0xffff; } else - uh_sum = in6_cksum(m, nxt, off, ulen); + uh_sum = in6_cksum_partial(m, nxt, off, plen, ulen); if (uh_sum != 0) { UDPSTAT_INC(udps_badsum); @@ -842,8 +847,8 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, ip6->ip6_dst = *faddr; if (cscov_partial) { - if ((udp6->uh_sum = in6_cksum(m, 0, - sizeof(struct ip6_hdr), cscov)) == 0) + if ((udp6->uh_sum = in6_cksum_partial(m, nxt, + sizeof(struct ip6_hdr), plen, cscov)) == 0) udp6->uh_sum = 0xffff; } else { udp6->uh_sum = in6_cksum_pseudo(ip6, plen, nxt, 0); |