All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] sockopt: Make SO_BINDTODEVICE readable
@ 2012-10-19  9:55 Pavel Emelyanov
  2012-10-19 10:34 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Pavel Emelyanov @ 2012-10-19  9:55 UTC (permalink / raw)
  To: Linux Netdev List, David Miller

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>

---

diff --git a/net/core/sock.c b/net/core/sock.c
index 8a146cf..c49412c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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;
 	}

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-10-23 21:43 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19  9:55 [PATCH net-next] sockopt: Make SO_BINDTODEVICE readable Pavel Emelyanov
2012-10-19 10:34 ` Eric Dumazet
2012-10-22  0:43 ` David Miller
2012-10-22 10:20   ` Pavel Emelyanov
2012-10-22 18:04 ` Brian Haley
2012-10-22 20:28   ` Pavel Emelyanov
2012-10-22 21:23     ` Brian Haley
2012-10-22 20:45   ` Eric Dumazet
2012-10-22 21:10     ` Pavel Emelyanov
2012-10-22 21:20     ` Brian Haley
2012-10-22 21:37       ` Eric Dumazet
2012-10-22 21:47         ` Brian Haley
2012-10-22 21:52           ` Eric Dumazet
2012-10-22 21:58             ` Ben Hutchings
2012-10-23 21:43             ` Brian Haley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.