summaryrefslogtreecommitdiff
path: root/include/net/inet_sock.h
diff options
context:
space:
mode:
authorRobert Shearman <rshearma@vyatta.att-mail.com>2018-11-07 18:36:02 +0300
committerDavid S. Miller <davem@davemloft.net>2018-11-08 03:12:38 +0300
commit3c82a21f4320c8d54cf6456b27c8d49e5ffb722e (patch)
treea281d34b7cdb8bf01fe13c387ab95bce8bd87e81 /include/net/inet_sock.h
parentf601a85bd7883708f48911d8c88e69fe5bde2b4d (diff)
downloadlinux-3c82a21f4320c8d54cf6456b27c8d49e5ffb722e.tar.xz
net: allow binding socket in a VRF when there's an unbound socket
Change the inet socket lookup to avoid packets arriving on a device enslaved to an l3mdev from matching unbound sockets by removing the wildcard for non sk_bound_dev_if and instead relying on check against the secondary device index, which will be 0 when the input device is not enslaved to an l3mdev and so match against an unbound socket and not match when the input device is enslaved. Change the socket binding to take the l3mdev into account to allow an unbound socket to not conflict sockets bound to an l3mdev given the datapath isolation now guaranteed. Signed-off-by: Robert Shearman <rshearma@vyatta.att-mail.com> Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com> Reviewed-by: David Ahern <dsahern@gmail.com> Tested-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet_sock.h')
-rw-r--r--include/net/inet_sock.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index a80fd0ac4563..ed3f723af00b 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -130,6 +130,19 @@ static inline int inet_request_bound_dev_if(const struct sock *sk,
return sk->sk_bound_dev_if;
}
+static inline int inet_sk_bound_l3mdev(const struct sock *sk)
+{
+#ifdef CONFIG_NET_L3_MASTER_DEV
+ struct net *net = sock_net(sk);
+
+ if (!net->ipv4.sysctl_tcp_l3mdev_accept)
+ return l3mdev_master_ifindex_by_index(net,
+ sk->sk_bound_dev_if);
+#endif
+
+ return 0;
+}
+
struct inet_cork {
unsigned int flags;
__be32 addr;