Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp728032imm; Thu, 13 Sep 2018 06:55:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaIKd075DdhPUHw67KfGcNZHaYMVGZk2JnXtjQU9bSsZ/bSnj5dH9jvY+gEgUKenam8R16c X-Received: by 2002:a63:e647:: with SMTP id p7-v6mr7036698pgj.218.1536846942986; Thu, 13 Sep 2018 06:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846942; cv=none; d=google.com; s=arc-20160816; b=CsKDgvIgGI5+1wPb6iCLXcshoRDhQEVOrIuGZ4+ma5BwtVwfITfVU0HzFUoYspyHvF EkGjWbx2W9pPEMqttnCy6ZtqE1YGcL0NbhCzWTe7hxeptYY3TMpY+YBUpCHplGqKiOzv Sks8VrY2P26s7ipYg70qHAp1/VHxdKdRJ4fgvlvGKVWS0v+7++thlWR8nL/z8G/RxJCh U57u0jcw7dmyXoqMMrJgbq+4q5leSKCj8a02bTsPEJEiVv99YigXgy/GAJHoqAY/kHRa zm6hG4VYyK3kNL2DXcdlLp3susx/uW3uig+tuyFCjKuBz/CV5XUxhTO7ygDcUNZvuQG0 3iaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=deDYda4szSWWY9wv56bSvisk8f0ndt36HrsWrKL/IQA=; b=tBITmt16LokKh9VyysvsXn340ClPKf9u3RhqLhkaaczMwW7rmmhrpGJmPTC78dMhlP 5M/3NMRCvW2BU2uFapph7vxM3tpp0YLHFlVIrPTNKjTSLVGMbEuUpYLNpFmVt5MpMEiQ YGYAQRiaJvaf0FZdRw8zfkuCOtjy+XZun404Mly7N9QqkEruhpQ7LKSZvsjko/ejzaCh vhEvfzzZNZddjjtXKTPYagk6l1Ko3HmDMbl4jIvvnTNP88XWvPrV8SAf/9fgIPcRepTV +6mIEpyYiyWDVadJrUJmi48iHLa8yqd2M3GT7NnYt8vLKHcL5eerb9uqQz0WiQUOkALq 6WxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22-v6si4475888plk.443.2018.09.13.06.55.26; Thu, 13 Sep 2018 06:55:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730910AbeIMTEz (ORCPT + 99 others); Thu, 13 Sep 2018 15:04:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33952 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727783AbeIMTEy (ORCPT ); Thu, 13 Sep 2018 15:04:54 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5F65FD19; Thu, 13 Sep 2018 13:55:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Mamedov , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.18 069/197] netfilter: ip6t_rpfilter: set F_IFACE for linklocal addresses Date: Thu, 13 Sep 2018 15:30:18 +0200 Message-Id: <20180913131844.281026884@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit da786717e0894886301ed2536843c13f9e8fd53e ] Roman reports that DHCPv6 client no longer sees replies from server due to ip6tables -t raw -A PREROUTING -m rpfilter --invert -j DROP rule. We need to set the F_IFACE flag for linklocal addresses, they are scoped per-device. Fixes: 47b7e7f82802 ("netfilter: don't set F_IFACE on ipv6 fib lookups") Reported-by: Roman Mamedov Tested-by: Roman Mamedov Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/ipv6/netfilter/ip6t_rpfilter.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/net/ipv6/netfilter/ip6t_rpfilter.c +++ b/net/ipv6/netfilter/ip6t_rpfilter.c @@ -26,6 +26,12 @@ static bool rpfilter_addr_unicast(const return addr_type & IPV6_ADDR_UNICAST; } +static bool rpfilter_addr_linklocal(const struct in6_addr *addr) +{ + int addr_type = ipv6_addr_type(addr); + return addr_type & IPV6_ADDR_LINKLOCAL; +} + static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb, const struct net_device *dev, u8 flags) { @@ -48,7 +54,11 @@ static bool rpfilter_lookup_reverse6(str } fl6.flowi6_mark = flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0; - if ((flags & XT_RPFILTER_LOOSE) == 0) + + if (rpfilter_addr_linklocal(&iph->saddr)) { + lookup_flags |= RT6_LOOKUP_F_IFACE; + fl6.flowi6_oif = dev->ifindex; + } else if ((flags & XT_RPFILTER_LOOSE) == 0) fl6.flowi6_oif = dev->ifindex; rt = (void *)ip6_route_lookup(net, &fl6, skb, lookup_flags);