Skip to content

Commit

Permalink
sockopt: Make SO_BINDTODEVICE readable
Browse files Browse the repository at this point in the history
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: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Oct 22, 2012
1 parent 0da5f7c commit f7b86bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
case SO_NOFCS:
v.val = sock_flag(sk, SOCK_NOFCS);
break;
case SO_BINDTODEVICE:
v.val = sk->sk_bound_dev_if;
break;
default:
return -ENOPROTOOPT;
}
Expand Down

0 comments on commit f7b86bf

Please sign in to comment.