From owner-freebsd-net@FreeBSD.ORG Fri Mar 14 00:40:03 2008 Return-Path: Delivered-To: freebsd-net@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A59A1065671 for ; Fri, 14 Mar 2008 00:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 45ABA8FC12 for ; Fri, 14 Mar 2008 00:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m2E0e3ZG048697 for ; Fri, 14 Mar 2008 00:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m2E0e34m048696; Fri, 14 Mar 2008 00:40:03 GMT (envelope-from gnats) Date: Fri, 14 Mar 2008 00:40:03 GMT Message-Id: <200803140040.m2E0e34m048696@freefall.freebsd.org> To: freebsd-net@FreeBSD.org From: James Snow Cc: Subject: Re: kern/120958: no response to ICMP traffic on interface configured with a link-local address X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: James Snow List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Mar 2008 00:40:03 -0000 The following reply was made to PR kern/120958; it has been noted by GNATS. From: James Snow To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/120958: no response to ICMP traffic on interface configured with a link-local address Date: Thu, 13 Mar 2008 20:23:55 -0400 --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached is a patch that reworks the problematic if statement in sys/netinet/ip_icmp.c and adds two new macros to sys/netinet/in.h. This fixes the problem, and eliminates a duplicate check for loopback addresses. (Although it introduces some redundant ntohl() calls.) -Snow --IS0zKkzwUGydFO0o Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="link-local-icmp.patch" diff -ru /usr/src/sys/netinet/in.h /usr/src.new/sys/netinet/in.h --- /usr/src/sys/netinet/in.h 2007-06-12 16:24:53.000000000 +0000 +++ /usr/src.new/sys/netinet/in.h 2008-03-13 10:44:29.000000000 +0000 @@ -379,6 +379,8 @@ #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) #define IN_LINKLOCAL(i) (((u_int32_t)(i) & 0xffff0000) == 0xa9fe0000) +#define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) +#define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) #define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ diff -ru /usr/src/sys/netinet/ip_icmp.c /usr/src.new/sys/netinet/ip_icmp.c --- /usr/src/sys/netinet/ip_icmp.c 2007-10-07 20:44:23.000000000 +0000 +++ /usr/src.new/sys/netinet/ip_icmp.c 2008-03-13 11:03:44.000000000 +0000 @@ -622,13 +622,14 @@ struct mbuf *opts = 0; int optlen = (ip->ip_hl << 2) - sizeof(struct ip); - if (!in_canforward(ip->ip_src) && - ((ntohl(ip->ip_src.s_addr) & IN_CLASSA_NET) != - (IN_LOOPBACKNET << IN_CLASSA_NSHIFT))) { + if (IN_MULTICAST(ntohl(ip->ip_src.s_addr)) || + IN_EXPERIMENTAL(ntohl(ip->ip_src.s_addr)) || + IN_ZERONET(ntohl(ip->ip_src.s_addr)) ) { m_freem(m); /* Bad return address */ icmpstat.icps_badaddr++; goto done; /* Ip_output() will check for broadcast */ } + t = ip->ip_dst; ip->ip_dst = ip->ip_src; --IS0zKkzwUGydFO0o--