From: Paolo Abeni <pabeni@redhat.com>
To: Damir Mansurov <dnman@oktetlabs.ru>,
netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>
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, 07 May 2018 14:41:30 +0200 [thread overview]
Message-ID: <1525696890.2587.24.camel@redhat.com> (raw)
In-Reply-To: <5a61e34b-75c2-0452-d6e2-6e4ea77d5ac2@oktetlabs.ru>
Hi,
On Mon, 2018-05-07 at 13:19 +0300, Damir Mansurov wrote:
> 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 think that the cause is commit:
commit fb74c27735f0a34e76dbf1972084e984ad2ea145
Author: David Ahern <dsahern@gmail.com>
Date: Mon Aug 7 08:44:16 2017 -0700
net: ipv4: add second dif to udp socket lookups
Something like the following should fix, but I'm unsure it preserves
the intended semathics for 'sdif'. David, can you please have a look?
Thanks!
Paolo
---
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index dd3102a37ef9..0d593d5c33cf 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -401,9 +401,9 @@ static int compute_score(struct sock *sk, struct net *net,
bool dev_match = (sk->sk_bound_dev_if == dif ||
sk->sk_bound_dev_if == sdif);
- if (exact_dif && !dev_match)
+ if (!dev_match)
return -1;
- if (sk->sk_bound_dev_if && dev_match)
+ if (sk->sk_bound_dev_if)
score += 4;
}
next prev parent reply other threads:[~2018-05-07 12:41 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 [this message]
2018-05-07 15:23 ` David Ahern
2018-05-08 22:48 ` David Ahern
2018-05-07 16:14 ` Ben Greear
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=1525696890.2587.24.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=Alexandra.Kossovsky@oktetlabs.ru \
--cc=andrey.dmitrov@oktetlabs.ru \
--cc=dnman@oktetlabs.ru \
--cc=dsahern@gmail.com \
--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).