From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ED17C43613 for ; Sun, 23 Jun 2019 00:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E5F320675 for ; Sun, 23 Jun 2019 00:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbfFWAHO (ORCPT ); Sat, 22 Jun 2019 20:07:14 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:33018 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbfFWAHO (ORCPT ); Sat, 22 Jun 2019 20:07:14 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::d71]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 7A9D91540C186; Sat, 22 Jun 2019 17:07:13 -0700 (PDT) Date: Sat, 22 Jun 2019 17:07:12 -0700 (PDT) Message-Id: <20190622.170712.2073255657139689928.davem@davemloft.net> To: nicolas.dichtel@6wind.com Cc: netdev@vger.kernel.org Subject: Re: [PATCH net] ipv6: fix neighbour resolution with raw socket From: David Miller In-Reply-To: <20190620123434.7219-1-nicolas.dichtel@6wind.com> References: <20190620123434.7219-1-nicolas.dichtel@6wind.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sat, 22 Jun 2019 17:07:13 -0700 (PDT) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nicolas Dichtel Date: Thu, 20 Jun 2019 14:34:34 +0200 > The scenario is the following: the user uses a raw socket to send an ipv6 > packet, destinated to a not-connected network, and specify a connected nh. > Here is the corresponding python script to reproduce this scenario: ... > fd00:175::/64 is a connected route and fd00:200::fa is not a connected > host. > > With this scenario, the kernel starts by sending a NS to resolve > fd00:175::2. When it receives the NA, it flushes its queue and try to send > the initial packet. But instead of sending it, it sends another NS to > resolve fd00:200::fa, which obvioulsy fails, thus the packet is dropped. If > the user sends again the packet, it now uses the right nh (fd00:175::2). > > The problem is that ip6_dst_lookup_neigh() uses the rt6i_gateway, which is > :: because the associated route is a connected route, thus it uses the dst > addr of the packet. Let's use rt6_nexthop() to choose the right nh. > > Note that rt and in6addr_any are const in ip6_dst_lookup_neigh(), thus > let's constify rt6_nexthop() to avoid ugly cast. > > Signed-off-by: Nicolas Dichtel Applied and queued up for -stable, thanks.