diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-24 23:38:49 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-24 23:38:49 +0000 |
commit | 033a42cbd2200a951448b4643610a2f12c7ed64f (patch) | |
tree | 4e06d78092d60a196de529f030ec3234bea6a1bb | |
parent | a7b5337771613beb74161b84bc754858a8f73490 (diff) |
Sync in4_cksum() with NetBSD, and change its use in in_delayed_cksum.
-rw-r--r-- | sys/netinet/in4_cksum.c | 28 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 4 |
2 files changed, 17 insertions, 15 deletions
diff --git a/sys/netinet/in4_cksum.c b/sys/netinet/in4_cksum.c index 90c2ff4b8ed..8ec10ab9f4a 100644 --- a/sys/netinet/in4_cksum.c +++ b/sys/netinet/in4_cksum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in4_cksum.c,v 1.2 2001/02/16 08:48:04 itojun Exp $ */ +/* $OpenBSD: in4_cksum.c,v 1.3 2001/06/24 23:38:47 angelos Exp $ */ /* $NetBSD: in_cksum.c,v 1.13 1996/10/13 02:03:03 christos Exp $ */ @@ -111,18 +111,20 @@ in4_cksum(m, nxt, off, len) u_int32_t l; } l_util; - /* pseudo header */ - if (off < sizeof(struct ipovly)) - panic("offset too short"); - bzero(&ipov, sizeof(ipov)); - ipov.ih_len = htons(len); - ipov.ih_pr = nxt; - ipov.ih_src = mtod(m, struct ip *)->ip_src; - ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - w = (u_int16_t *)&ipov; - /* assumes sizeof(ipov) == 20 */ - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; - sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; + if (nxt != 0) { + /* pseudo header */ + if (off < sizeof(struct ipovly)) + panic("offset too short"); + bzero(&ipov, sizeof(ipov)); + ipov.ih_len = htons(len); + ipov.ih_pr = nxt; + ipov.ih_src = mtod(m, struct ip *)->ip_src; + ipov.ih_dst = mtod(m, struct ip *)->ip_dst; + w = (u_int16_t *)&ipov; + /* assumes sizeof(ipov) == 20 */ + sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; + sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; + } /* skip unnecessary part */ while (m && off > 0) { diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 1df223e972e..e1fadadcf73 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.117 2001/06/24 23:33:56 angelos Exp $ */ +/* $OpenBSD: ip_output.c,v 1.118 2001/06/24 23:38:48 angelos Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1829,7 +1829,7 @@ in_delayed_cksum(struct mbuf *m) ip = mtod(m, struct ip *); offset = ip->ip_hl << 2; - csum = in4_cksum(m, ip->ip_p, offset, ntohs(ip->ip_len) - offset); + csum = in4_cksum(m, 0, offset, ntohs(ip->ip_len) - offset); if (csum == 0 && ip->ip_p == IPPROTO_UDP) csum = 0xffff; |