From: Ralf Lici <[email protected]>

Use the socket’s bound network interface if it’s explicitly specified
via the --bind-dev option in openvpn.

Signed-off-by: Ralf Lici <[email protected]>
Signed-off-by: Antonio Quartulli <[email protected]>
---
 drivers/net/ovpn/udp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c
index d6a0f7a0b75d..328819f27e1e 100644
--- a/drivers/net/ovpn/udp.c
+++ b/drivers/net/ovpn/udp.c
@@ -154,6 +154,7 @@ static int ovpn_udp4_output(struct ovpn_peer *peer, struct 
ovpn_bind *bind,
                .fl4_dport = bind->remote.in4.sin_port,
                .flowi4_proto = sk->sk_protocol,
                .flowi4_mark = sk->sk_mark,
+               .flowi4_oif = sk->sk_bound_dev_if,
        };
        int ret;
 
@@ -231,7 +232,8 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct 
ovpn_bind *bind,
                .fl6_dport = bind->remote.in6.sin6_port,
                .flowi6_proto = sk->sk_protocol,
                .flowi6_mark = sk->sk_mark,
-               .flowi6_oif = bind->remote.in6.sin6_scope_id,
+               .flowi6_oif = sk->sk_bound_dev_if ?:
+                                     bind->remote.in6.sin6_scope_id,
        };
 
        local_bh_disable();
-- 
2.51.2


Reply via email to