From owner-freebsd-net Fri Nov 23 8:11:22 2001 Delivered-To: freebsd-net@freebsd.org Received: from bazooka.trit.org (bazooka.trit.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id F30A937B41A for ; Fri, 23 Nov 2001 08:11:19 -0800 (PST) Received: by bazooka.trit.org (Postfix, from userid 1000) id B9BA13F86; Fri, 23 Nov 2001 16:11:19 +0000 (UTC) Received: from bazooka (localhost [127.0.0.1]) by bazooka.trit.org (Postfix) with ESMTP id B86143C140 for ; Fri, 23 Nov 2001 16:11:19 +0000 (UTC) To: net@freebsd.org Subject: Fix icmp_reflect if no addresses are configured Date: Fri, 23 Nov 2001 16:11:14 +0000 From: Dima Dorfman Message-Id: <20011123161119.B9BA13F86@bazooka.trit.org> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Please review the following change, from NetBSD: In icmp_reflect(): If the packet was not addressed to us and was received on an interface without an IP address, try to find a non-loopback AF_INET address to use. If that fails, drop it. Previously, we used the address at the top of the in_ifaddrhead list, which didn't make much sense, and would cause a panic if there were no AF_INET addresses configured on the system. This fixes PRs 29337 and 30524. Thanks. Index: ip_icmp.c =================================================================== RCS file: /ref/cvsf/src/sys/netinet/ip_icmp.c,v retrieving revision 1.62 diff -u -r1.62 ip_icmp.c --- ip_icmp.c 2001/10/25 05:56:30 1.62 +++ ip_icmp.c 2001/11/23 15:55:41 @@ -623,10 +623,25 @@ (struct sockaddr *)&icmpdst, m->m_pkthdr.rcvif); /* * The following happens if the packet was not addressed to us, - * and was received on an interface with no IP address. + * and was received on an interface with no IP address: + * We find the first AF_INET address on the first non-loopback + * interface. */ if (ia == NULL) - ia = TAILQ_FIRST(&in_ifaddrhead); + TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) { + if (ia->ia_ifp->if_flags & IFF_LOOPBACK) + continue; + break; + } + + /* + * If we still didn't find an address, punt. We could have an + * interface up and (and receiving packets) with no address. + */ + if (ia == NULL) { + m_freem(m); + goto done; + } match: t = IA_SIN(ia)->sin_addr; ip->ip_src = t; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message