]>
Commit | Line | Data |
---|---|---|
49b6d164 AD |
1 | From patchwork Wed May 9 10:42:34 2018 |
2 | Content-Type: text/plain; charset="utf-8" | |
3 | MIME-Version: 1.0 | |
4 | Content-Transfer-Encoding: 7bit | |
5 | Subject: [net] udp: fix SO_BINDTODEVICE | |
6 | X-Patchwork-Submitter: Paolo Abeni <pabeni@redhat.com> | |
7 | X-Patchwork-Id: 910747 | |
8 | X-Patchwork-Delegate: davem@davemloft.net | |
9 | Message-Id: <9445dd5d149af16463df4d0502b2667ee2b6f4e8.1525862461.git.pabeni@redhat.com> | |
10 | To: netdev@vger.kernel.org | |
11 | Cc: Damir Mansurov <dnman@oktetlabs.ru>, David Ahern <dsahern@gmail.com>, | |
12 | David Miller <davem@davemloft.net> | |
13 | Date: Wed, 9 May 2018 12:42:34 +0200 | |
14 | From: Paolo Abeni <pabeni@redhat.com> | |
15 | List-Id: <netdev.vger.kernel.org> | |
16 | ||
17 | Damir reported a breakage of SO_BINDTODEVICE for UDP sockets. | |
18 | In absence of VRF devices, after commit fb74c27735f0 ("net: | |
19 | ipv4: add second dif to udp socket lookups") the dif mismatch | |
20 | isn't fatal anymore for UDP socket lookup with non null | |
21 | sk_bound_dev_if, breaking SO_BINDTODEVICE semantics. | |
22 | ||
23 | This changeset addresses the issue making the dif match mandatory | |
24 | again in the above scenario. | |
25 | ||
26 | Reported-by: Damir Mansurov <dnman@oktetlabs.ru> | |
27 | Fixes: fb74c27735f0 ("net: ipv4: add second dif to udp socket lookups") | |
28 | Fixes: 1801b570dd2a ("net: ipv6: add second dif to udp socket lookups") | |
29 | Signed-off-by: Paolo Abeni <pabeni@redhat.com> | |
30 | Acked-by: David Ahern <dsahern@gmail.com> | |
31 | --- | |
32 | net/ipv4/udp.c | 4 ++-- | |
33 | net/ipv6/udp.c | 4 ++-- | |
34 | 2 files changed, 4 insertions(+), 4 deletions(-) | |
35 | ||
36 | diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c | |
37 | index 24b5c59b1c53..c2a292dfd137 100644 | |
38 | --- a/net/ipv4/udp.c | |
39 | +++ b/net/ipv4/udp.c | |
40 | @@ -401,9 +401,9 @@ static int compute_score(struct sock *sk, struct net *net, | |
41 | bool dev_match = (sk->sk_bound_dev_if == dif || | |
42 | sk->sk_bound_dev_if == sdif); | |
43 | ||
44 | - if (exact_dif && !dev_match) | |
45 | + if (!dev_match) | |
46 | return -1; | |
47 | - if (sk->sk_bound_dev_if && dev_match) | |
48 | + if (sk->sk_bound_dev_if) | |
49 | score += 4; | |
50 | } | |
51 | ||
52 | diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c | |
53 | index 4ec76a87aeb8..ea0730028e5d 100644 | |
54 | --- a/net/ipv6/udp.c | |
55 | +++ b/net/ipv6/udp.c | |
56 | @@ -148,9 +148,9 @@ static int compute_score(struct sock *sk, struct net *net, | |
57 | bool dev_match = (sk->sk_bound_dev_if == dif || | |
58 | sk->sk_bound_dev_if == sdif); | |
59 | ||
60 | - if (exact_dif && !dev_match) | |
61 | + if (!dev_match) | |
62 | return -1; | |
63 | - if (sk->sk_bound_dev_if && dev_match) | |
64 | + if (sk->sk_bound_dev_if) | |
65 | score++; | |
66 | } | |
67 |