From owner-dev-commits-src-all@freebsd.org Tue May 18 21:01:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4A626579F8; Tue, 18 May 2021 21:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fl7hX4CvTz3JQL; Tue, 18 May 2021 21:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7A39C2678E; Tue, 18 May 2021 21:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14IL1GxA054230; Tue, 18 May 2021 21:01:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IL1Gki054229; Tue, 18 May 2021 21:01:16 GMT (envelope-from git) Date: Tue, 18 May 2021 21:01:16 GMT Message-Id: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3d846e48227e2e78c1e7b35145f57353ffda56ba Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 21:01:16 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=3d846e48227e2e78c1e7b35145f57353ffda56ba commit 3d846e48227e2e78c1e7b35145f57353ffda56ba Author: Zhenlei Huang AuthorDate: 2021-05-18 20:51:37 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-18 20:59:46 +0000 Do not forward datagrams originated by link-local addresses The current implement of ip_input() reject packets destined for 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local addresses. Fix to fully respect RFC 3927 section 2.7. PR: 255388 Reviewed by: donner, rgrimes, karels MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D29968 --- sys/netinet/ip_input.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 43d375c2385f..1139e3a5abfa 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -738,15 +738,10 @@ passin: } ia = NULL; } - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { - IPSTAT_INC(ips_cantforward); - m_freem(m); - return; - } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { MROUTER_RLOCK(); - if (V_ip_mrouter) { + /* Do not forward packets from IN_LINKLOCAL. */ + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { /* * If we are acting as a multicast router, all * incoming multicast packets are passed to the @@ -785,6 +780,13 @@ passin: goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) goto ours; + /* Do not forward packets to or from IN_LINKLOCAL. */ + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { + IPSTAT_INC(ips_cantforward); + m_freem(m); + return; + } /* * Not for us; forward if possible and desirable.