From 326b00612baa3c05ca8f66d72ca7e5269d299815 Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 1 Sep 2000 12:33:03 +0000 Subject: Fixed broken ICMP error generation, unified conversion of IP header fields between host and network byte order. The details: o icmp_error() now does not add IP header length. This fixes the problem when icmp_error() is called from ip_forward(). In this case the ip_len of the original IP datagram returned with ICMP error was wrong. o icmp_error() expects all three fields, ip_len, ip_id and ip_off in host byte order, so DTRT and convert these fields back to network byte order before sending a message. This fixes the problem described in PR 16240 and PR 20877 (ip_id field was returned in host byte order). o ip_ttl decrement operation in ip_forward() was moved down to make sure that it does not corrupt the copy of original IP datagram passed later to icmp_error(). o A copy of original IP datagram in ip_forward() was made a read-write, independent copy. This fixes the problem I first reported to Garrett Wollman and Bill Fenner and later put in audit trail of PR 16240: ip_output() (not always) converts fields of original datagram to network byte order, but because copy (mcopy) and its original (m) most likely share the same mbuf cluster, ip_output()'s manipulations on original also corrupted the copy. o ip_output() now expects all three fields, ip_len, ip_off and (what is significant) ip_id in host byte order. It was a headache for years that ip_id was handled differently. The only compatibility issue here is the raw IP socket interface with IP_HDRINCL socket option set and a non-zero ip_id field, but ip.4 manual page was unclear on whether in this case ip_id field should be in host or network byte order. --- sys/netinet/ip_divert.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sys/netinet/ip_divert.c') diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index b2f92b8..12acdfd 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -293,6 +293,7 @@ div_output(so, m, addr, control) /* Convert fields to host order for ip_output() */ NTOHS(ip->ip_len); + NTOHS(ip->ip_id); NTOHS(ip->ip_off); /* Send packet to output processing */ -- cgit v1.1