diff options
author | ru <ru@FreeBSD.org> | 2002-07-23 00:16:19 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2002-07-23 00:16:19 +0000 |
commit | 7bd1d4e8de5727f9c13675ff5ab143c5dd5bb66e (patch) | |
tree | 239ebd6adc2d0fbcbb27b26f33d09ff7415b46cc /sys/netinet | |
parent | c9f6925854845df524541d066473b45091e6042b (diff) | |
download | FreeBSD-src-7bd1d4e8de5727f9c13675ff5ab143c5dd5bb66e.zip FreeBSD-src-7bd1d4e8de5727f9c13675ff5ab143c5dd5bb66e.tar.gz |
Don't forget to recalculate the IP checksum of the original
IP datagram embedded into ICMP error message.
Spotted by: tcpdump 3.7.1 (-vvv)
MFC after: 3 days
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/libalias/alias.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c index a491f07..467f371 100644 --- a/sys/netinet/libalias/alias.c +++ b/sys/netinet/libalias/alias.c @@ -352,7 +352,7 @@ IcmpAliasIn2(struct ip *pip) if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) { u_short *sptr; - int accumulate; + int accumulate, accumulate2; struct in_addr original_address; u_short original_port; @@ -368,7 +368,11 @@ IcmpAliasIn2(struct ip *pip) accumulate -= *sptr; accumulate += ud->uh_sport; accumulate -= original_port; - ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); + accumulate2 = accumulate; + accumulate2 += ip->ip_sum; + ADJUST_CHECKSUM(accumulate, ip->ip_sum); + accumulate2 -= ip->ip_sum; + ADJUST_CHECKSUM(accumulate2, ic->icmp_cksum); /* Un-alias address in IP header */ DifferentialChecksum(&pip->ip_sum, @@ -385,7 +389,7 @@ fragment contained in ICMP data section */ else if (ip->ip_p == IPPROTO_ICMP) { u_short *sptr; - int accumulate; + int accumulate, accumulate2; struct in_addr original_address; u_short original_id; @@ -401,7 +405,11 @@ fragment contained in ICMP data section */ accumulate -= *sptr; accumulate += ic2->icmp_id; accumulate -= original_id; - ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); + accumulate2 = accumulate; + accumulate2 += ip->ip_sum; + ADJUST_CHECKSUM(accumulate, ip->ip_sum); + accumulate2 -= ip->ip_sum; + ADJUST_CHECKSUM(accumulate2, ic->icmp_cksum); /* Un-alias address in IP header */ DifferentialChecksum(&pip->ip_sum, |