From: Ben Greear <greearb@candelatech.com>
To: Damir Mansurov <dnman@oktetlabs.ru>, netdev@vger.kernel.org
Cc: Konstantin Ushakov <kostik@oktetlabs.ru>,
"Alexandra N. Kossovsky" <Alexandra.Kossovsky@oktetlabs.ru>,
Andrey Dmitrov <andrey.dmitrov@oktetlabs.ru>
Subject: Re: The SO_BINDTODEVICE was set to the desired interface, but packets are received from all interfaces.
Date: Mon, 7 May 2018 09:14:17 -0700 [thread overview]
Message-ID: <5361bef8-bdf9-af3d-12ae-a128b6502d2e@candelatech.com> (raw)
In-Reply-To: <5a61e34b-75c2-0452-d6e2-6e4ea77d5ac2@oktetlabs.ru>
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.
Thanks,
Ben
>
>
> PC-1 PC-2
> ------------------- -------------------
> | b2d_send | | b2d_recv |
> | | | |
> | ------| |------ |
> | | eth0 |---------------| eth0 | |
> | ------| |------ |
> | | | |
> | ------| |------ |
> | | eth1 |---------------| eth1 | |
> | ------| |------ |
> | | | |
> ------------------- -------------------
>
> Steps:
> 1. Copy b2d_recv.c to PC-2, compile it ("gcc -o b2d_recv b2d_recv.c") and run "./b2d_recv eth0 23777" to get derived data only from eth0 interface. Port number
> in this example is 23777 only for sample.
>
> 2. Copy b2d_send.c to PC-1, compile it ("gcc -o b2d_send b2d_send.c") and run "./b2d_send ip1 ip2 23777" where ip1 and ip2 are ip addresses of interfaces eth0
> and eth1 of PC-2.
>
> 3. Result:
> - b2d_recv prints out data from eth0 and eth1 on linux kernels from 4.14 up to 4.16.
> - b2d_recv prints out data from only eth0 on linux kernels below 4.14.
>
>
> ******************
> Thanks,
> Damir Mansurov
> dnman@oktetlabs.ru
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
next prev parent reply other threads:[~2018-05-07 16:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-07 10:19 The SO_BINDTODEVICE was set to the desired interface, but packets are received from all interfaces Damir Mansurov
2018-05-07 12:41 ` Paolo Abeni
2018-05-07 15:23 ` David Ahern
2018-05-08 22:48 ` David Ahern
2018-05-07 16:14 ` Ben Greear [this message]
2018-05-07 21:20 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5361bef8-bdf9-af3d-12ae-a128b6502d2e@candelatech.com \
--to=greearb@candelatech.com \
--cc=Alexandra.Kossovsky@oktetlabs.ru \
--cc=andrey.dmitrov@oktetlabs.ru \
--cc=dnman@oktetlabs.ru \
--cc=kostik@oktetlabs.ru \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).