From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: The SO_BINDTODEVICE was set to the desired interface, but packets are received from all interfaces. Date: Mon, 7 May 2018 15:20:15 -0600 Message-ID: References: <5a61e34b-75c2-0452-d6e2-6e4ea77d5ac2@oktetlabs.ru> <5361bef8-bdf9-af3d-12ae-a128b6502d2e@candelatech.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Konstantin Ushakov , "Alexandra N. Kossovsky" , Andrey Dmitrov To: Ben Greear , Damir Mansurov , netdev@vger.kernel.org Return-path: Received: from mail-pg0-f51.google.com ([74.125.83.51]:38394 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752796AbeEGVUS (ORCPT ); Mon, 7 May 2018 17:20:18 -0400 Received: by mail-pg0-f51.google.com with SMTP id n9-v6so20213767pgq.5 for ; Mon, 07 May 2018 14:20:18 -0700 (PDT) In-Reply-To: <5361bef8-bdf9-af3d-12ae-a128b6502d2e@candelatech.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 5/7/18 10:14 AM, Ben Greear wrote: > On 05/07/2018 03:19 AM, Damir Mansurov wrote: >> >> Greetings, >> >> After successful call of the setsockopt(SO_BINDTODEVICE) function to >> set data reception from only one interface, the data is still received >> from all interfaces. >> Function setsockopt() returns 0 but then recv() receives data from all >> available network interfaces. >> >> The problem is reproducible on linux kernels 4.14 - 4.16, but it does >> not on linux kernels 4.4, 4.13. >> >> I have written C-code to reproduce this issue (see attached files >> b2d_send.c and b2d_recv.c). See below explanation of tested >> configuration. > > Hello, > > I am not sure if this is your problem or not, but if you are using VRF, > then you need > to call SO_BINDTODEVICE before you do the 'normal' bind() call. > This is a different problem -- socket lookup is matching when it should not.