]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0012-net-udp-fix-SO_BINDTODEVICE.patch
vrf patches
[pve-kernel.git] / patches / kernel / 0012-net-udp-fix-SO_BINDTODEVICE.patch
CommitLineData
49b6d164
AD
1From patchwork Wed May 9 10:42:34 2018
2Content-Type: text/plain; charset="utf-8"
3MIME-Version: 1.0
4Content-Transfer-Encoding: 7bit
5Subject: [net] udp: fix SO_BINDTODEVICE
6X-Patchwork-Submitter: Paolo Abeni <pabeni@redhat.com>
7X-Patchwork-Id: 910747
8X-Patchwork-Delegate: davem@davemloft.net
9Message-Id: <9445dd5d149af16463df4d0502b2667ee2b6f4e8.1525862461.git.pabeni@redhat.com>
10To: netdev@vger.kernel.org
11Cc: Damir Mansurov <dnman@oktetlabs.ru>, David Ahern <dsahern@gmail.com>,
12 David Miller <davem@davemloft.net>
13Date: Wed, 9 May 2018 12:42:34 +0200
14From: Paolo Abeni <pabeni@redhat.com>
15List-Id: <netdev.vger.kernel.org>
16
17Damir reported a breakage of SO_BINDTODEVICE for UDP sockets.
18In absence of VRF devices, after commit fb74c27735f0 ("net:
19ipv4: add second dif to udp socket lookups") the dif mismatch
20isn't fatal anymore for UDP socket lookup with non null
21sk_bound_dev_if, breaking SO_BINDTODEVICE semantics.
22
23This changeset addresses the issue making the dif match mandatory
24again in the above scenario.
25
26Reported-by: Damir Mansurov <dnman@oktetlabs.ru>
27Fixes: fb74c27735f0 ("net: ipv4: add second dif to udp socket lookups")
28Fixes: 1801b570dd2a ("net: ipv6: add second dif to udp socket lookups")
29Signed-off-by: Paolo Abeni <pabeni@redhat.com>
30Acked-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
36diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
37index 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
52diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
53index 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