From patchwork Fri Oct 19 09:55:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Emelyanov X-Patchwork-Id: 192626 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3CA532C0091 for ; Fri, 19 Oct 2012 20:56:09 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758227Ab2JSJ4H (ORCPT ); Fri, 19 Oct 2012 05:56:07 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:28611 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756911Ab2JSJ4F (ORCPT ); Fri, 19 Oct 2012 05:56:05 -0400 Received: from [10.24.37.185] ([10.24.37.185]) (authenticated bits=0) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id q9J9tuBA003580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Oct 2012 13:55:57 +0400 (MSK) Message-ID: <508123AC.5080208@parallels.com> Date: Fri, 19 Oct 2012 13:55:56 +0400 From: Pavel Emelyanov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Linux Netdev List , David Miller Subject: [PATCH net-next] sockopt: Make SO_BINDTODEVICE readable Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Eric Dumazet --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }