From owner-svn-src-stable-11@freebsd.org Wed Feb 7 09:28:24 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B37E8EECF1D; Wed, 7 Feb 2018 09:28:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 56F977EF98; Wed, 7 Feb 2018 09:28:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43C0C24F16; Wed, 7 Feb 2018 09:28:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w179SOu1072938; Wed, 7 Feb 2018 09:28:24 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w179SOej072937; Wed, 7 Feb 2018 09:28:24 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201802070928.w179SOej072937@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 7 Feb 2018 09:28:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328968 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netpfil/ipfw X-SVN-Commit-Revision: 328968 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 09:28:24 -0000 Author: ae Date: Wed Feb 7 09:28:23 2018 New Revision: 328968 URL: https://svnweb.freebsd.org/changeset/base/328968 Log: MFC r328326: When IPv6 packet is handled by O_REJECT opcode, convert ICMP code specified in the arg1 into ICMPv6 destination unreachable code according to RFC7915. Obtained from: Yandex LLC Sponsored by: Yandex LLC Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw2.c Wed Feb 7 06:29:07 2018 (r328967) +++ stable/11/sys/netpfil/ipfw/ip_fw2.c Wed Feb 7 09:28:23 2018 (r328968) @@ -710,6 +710,32 @@ is_icmp6_query(int icmp6_type) return (0); } +static int +map_icmp_unreach(int code) +{ + + /* RFC 7915 p4.2 */ + switch (code) { + case ICMP_UNREACH_NET: + case ICMP_UNREACH_HOST: + case ICMP_UNREACH_SRCFAIL: + case ICMP_UNREACH_NET_UNKNOWN: + case ICMP_UNREACH_HOST_UNKNOWN: + case ICMP_UNREACH_TOSNET: + case ICMP_UNREACH_TOSHOST: + return (ICMP6_DST_UNREACH_NOROUTE); + case ICMP_UNREACH_PORT: + return (ICMP6_DST_UNREACH_NOPORT); + default: + /* + * Map the rest of codes into admit prohibited. + * XXX: unreach proto should be mapped into ICMPv6 + * parameter problem, but we use only unreach type. + */ + return (ICMP6_DST_UNREACH_ADMIN); + } +} + static void send_reject6(struct ip_fw_args *args, int code, u_int hlen, struct ip6_hdr *ip6) { @@ -2570,9 +2596,12 @@ do { \ (proto != IPPROTO_ICMPV6 || (is_icmp6_query(icmp6_type) == 1)) && !(m->m_flags & (M_BCAST|M_MCAST)) && - !IN6_IS_ADDR_MULTICAST(&args->f_id.dst_ip6)) { - send_reject6( - args, cmd->arg1, hlen, + !IN6_IS_ADDR_MULTICAST( + &args->f_id.dst_ip6)) { + send_reject6(args, + cmd->opcode == O_REJECT ? + map_icmp_unreach(cmd->arg1): + cmd->arg1, hlen, (struct ip6_hdr *)ip); m = args->m; }