Commit f7b86bfe authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

sockopt: Make SO_BINDTODEVICE readable

The SO_BINDTODEVICE option is the only SOL_SOCKET one that can be set, but
cannot be get via sockopt API. The only way we can find the device id a
socket is bound to is via sock-diag interface. But the diag works only on
hashed sockets, while the opt in question can be set for yet unhashed one.

That said, in order to know what device a socket is bound to (we do want
to know this in checkpoint-restore project) I propose to make this option
getsockopt-able and report the respective device index.

Another solution to the problem might be to teach the sock-diag reporting
info on unhashed sockets. Should I go this way instead?
Signed-off-by: default avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0da5f7c6
...@@ -1074,6 +1074,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname, ...@@ -1074,6 +1074,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
case SO_NOFCS: case SO_NOFCS:
v.val = sock_flag(sk, SOCK_NOFCS); v.val = sock_flag(sk, SOCK_NOFCS);
break; break;
case SO_BINDTODEVICE:
v.val = sk->sk_bound_dev_if;
break;
default: default:
return -ENOPROTOOPT; return -ENOPROTOOPT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment