NetBSD Problem Report #7818
Received: (qmail 4318 invoked from network); 20 Jun 1999 09:16:02 -0000
Message-Id: <199906200915.TAA18380@merlin.reed.wattle.id.au>
Date: Sun, 20 Jun 1999 19:15:31 +1000 (EST)
From: darrenr@pobox.com
Reply-To: darrenr@pobox.com
To: gnats-bugs@gnats.netbsd.org
Subject: ICMP protocol packets are not handled for localhost
X-Send-Pr-Version: 3.95
>Number: 7818
>Category: kern
>Synopsis: ICMP protocol packets are not handled for localhost
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 20 02:20:01 +0000 1999
>Closed-Date: Sat May 06 02:15:58 +0000 2000
>Last-Modified: Sat May 06 02:15:58 +0000 2000
>Originator: Darren Reed
>Release: NetBSD-1.4
>Organization:
>Environment:
System: NetBSD merlin.reed.wattle.id.au 1.4 NetBSD 1.4 (MERLIN) #3: Sun May 23 19:58:14 EST 1999 darrenr@merlin.reed.wattle.id.au:/usr/src/sys/arch/arm32/compile/MERLIN arm32
>Description:
ICMP protocol packets on the localhost interface (i.e. lo0) are not
handled/delivered and get counted as unknown protocol packets.
>How-To-Repeat:
A good example is to:
1. ensure that named is not running on the machine;
2. the "hosts:" entry in /etc/nsswitch.conf reads "dns files"
3. run tcpdump with "tcpdump -i lo0";
4. remove/rename /etc/resolv.conf so that it attempts to use the local box
for DNS;
5. "netstat -s > /root/netstat.1" (safely save netstat output to a file)
6. "telnet localhost"
7. observe from tcpdump that udp packets are generated in an attempt to
lookup the hostname for 127.0.0.1 and the resulting ICMP errors due to
there being no named running (port unreachables);
8. "netstat -s > /root/netstat.2" (safely save netstat output to a file)
9. observe differences in /root/netstat.[12], including increased unknown
protocol count.
A hack to print out the protocol number and source/destination pairs was
used to identify that this is actually a problem in raw_ip.c.
>Fix:
>Release-Note:
>Audit-Trail:
From: Darren Reed <darrenr@reed.wattle.id.au>
To: tech-net@netbsd.org
Cc: Subject: kern/7818: ICMP protocol packets are not handled for localhost
Date: Sun, 20 Jun 1999 20:00:30 +1000 (EST)
Folks,
I've submitted a PR on bad ICMP behaviour and in researching a fix,
found that the bug which causes the "unknown protocol" counter to get
increased is what (on BSD) makes the UDP traceroute possible. The bug
appears to be that in ip_icmp.c, at about line 363 (in the code section
after the "deliver" label) there's a "break" rather than a "return". The
subsequent effect is to let the packet drop through to the "raw" label
and get fed into rip_input() and hence traceroute is able to get it. I'm
sure there's a good reason to pass processed packets on to rip_input()
that have already been processed...I'm just not sure I understand what
that would be and if so, why it would be limited to ICMP (other than to
support traceroute). Anyway, the easiest fix I can think of which won't
disturb anything (except for correcting the "unknown protocol" statistics
count) is to add another mbuf flag - M_DELIVERED (0x800) - set that in
icmp_input() before calling rip_input() and not fiddle with the statistics
counters in the tail end of rip_input() if M_DELIVERED is set. If this
is an acceptable patch, I'd like for it to be pulled up into 1.4.1.
Darren
*** sys/mbuf.h.dist Sun Jun 20 19:53:16 1999
--- sys/mbuf.h Sun Jun 20 19:55:30 1999
***************
*** 171,176 ****
--- 171,178 ----
#define M_MCAST 0x0200 /* send/received as link-level multicast */
#define M_CANFASTFWD 0x0400 /* used by filters to indicate packet can
be fast-forwarded */
+ #define M_DELIVERED 0x0800 /* used to tell rip_input that it isn't an
+ unknown packet and has been delivered */
#define M_LINK0 0x1000 /* link layer specific flag */
#define M_LINK1 0x2000 /* link layer specific flag */
#define M_LINK2 0x4000 /* link layer specific flag */
*** netinet/ip_icmp.c.dist Sun Jun 20 19:53:23 1999
--- netinet/ip_icmp.c Sun Jun 20 19:56:38 1999
***************
*** 458,463 ****
--- 458,464 ----
}
raw:
+ m->m_flags |= M_DELIVERED;
rip_input(m);
return;
*** netinet/raw_ip.c.dist Sun Jun 20 19:53:27 1999
--- netinet/raw_ip.c Sun Jun 20 19:54:42 1999
***************
*** 160,168 ****
} else
sorwakeup(last->inp_socket);
} else {
m_freem(m);
- ipstat.ips_noproto++;
- ipstat.ips_delivered--;
}
}
--- 160,170 ----
} else
sorwakeup(last->inp_socket);
} else {
+ if ((m->m_flags & M_DELIVERED) == 0) {
+ ipstat.ips_noproto++;
+ ipstat.ips_delivered--;
+ }
m_freem(m);
}
}
State-Changed-From-To: open->feedback
State-Changed-By: itojun
State-Changed-When: Fri May 5 02:59:31 PDT 2000
State-Changed-Why:
sys/netinet/raw_ip.c 1.43 -> 1.44 seems to cope with this one.
does 1.44 fix the issue?
State-Changed-From-To: feedback->closed
State-Changed-By: darrenr
State-Changed-When: Fri May 5 19:14:06 PDT 2000
State-Changed-Why:
patch from 1.43 -> 1.44 fixed this problem.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.