1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00

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
This commit is contained in:
Ruslan Ermilov 2002-07-23 00:16:19 +00:00
parent 290006640b
commit 61a875d706
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100537
2 changed files with 24 additions and 8 deletions

View File

@ -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,

View File

@ -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,