From: YOSHIFUJI Hideaki Subject: Re: [PATCH net] net: ipv6: Fix ping to link-local addresses. Date: Mon, 15 Aug 2016 16:39:51 +0900 Message-ID: <642d0eef-4f62-f63c-9db5-3d890bb942df@miraclelinux.com> References: <1470642127-574-1-git-send-email-lorenzo@google.com> <20160808.143500.473355495580691289.davem@davemloft.net> <20160808.222030.1314134961786852070.davem@davemloft.net> <04a393c9-39f8-8d73-3476-928732e5b193@cumulusnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: hideaki.yoshifuji@miraclelinux.com, David Ahern , Erik Kline , David Miller , netdev , Hannes Frederic Sowa To: Lorenzo Colitti Return-path: Received: from mail-pf0-f176.google.com ([209.85.192.176]:33292 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752106AbcHOHj4 (ORCPT ); Mon, 15 Aug 2016 03:39:56 -0400 Received: by mail-pf0-f176.google.com with SMTP id y134so15096948pfg.0 for ; Mon, 15 Aug 2016 00:39:55 -0700 (PDT) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: Lorenzo Colitti wrote: > On Wed, Aug 10, 2016 at 7:44 AM, YOSHIFUJI Hideaki > wrote: >> >>>> I could see a point of view that says when bound_if is in play sending >>>> to destinations on/via other interfaces--by any mechanism--should >>>> effectively get ENETUNREACH (or something). >>> >>> VRF uses this capability to send on an enslaved interface. ie., socket is bound to VRF device to limit packets to that L3 domain and then uses PKTINFO to force a packet out a particular interface. >> >> We could extend our code to allow enslave devices, maybe. > > So something like this, then? > > static inline bool inet_check_bound_oif(const struct sock *sk, int oif) > { > if (!oif || !sk->sk_bound_dev_if || oif == sk->sk_bound_dev_if) > return true; > > #ifdef CONFIG_NET_L3_MASTER_DEV > return l3mdev_master_ifindex_by_index(sock_net(sk), oif) == > sk->sk_bound_dev_if; > #endif > > return false; > } > > and then in the various sendmsg functions: > > if (!inet_check_bound_oif(sk, oif)) > return -EINVAL; > Yes, something like that. --yoshfuji