The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: Ethan Ferguson <ethanf108@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	 Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: remove CONFIG_NETDEVICES requirement for SO_BINDTODEVICE and SO_BINDTOIFINDEX
Date: Sat, 14 Nov 2026 06:25:43 +0000	[thread overview]
Message-ID: <avf-PdwTjpqN7d0D@google.com> (raw)
In-Reply-To: <20261110204524.82341-1-ethanf108@gmail.com>

On Tue, 10 Nov 2026 15:45:24 -0500, Ethan Ferguson wrote:
> The SO_BINDTODEVICE and SO_BINDTOIFINDEX sockopts return -ENOPROTOOPT
> if CONFIG_NETDEVICES is disabled, even if the lo interface exists. I
> believe it would be prudent to allow for valid bindings even if
> CONFIG_NETDEVICES were disabled, as an error here would be inconsistent.
> 
> Signed-off-by: Ethan Ferguson <ethanf108@gmail.com>
> 
> ---
>  net/core/sock.c | 56 +++++++++++++------------------------------------
>  1 file changed, 15 insertions(+), 41 deletions(-)
> 
> diff --git a/net/core/sock.c b/net/core/sock.c
> index e8551df8330f..d2da59700ecf 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -634,18 +634,14 @@ EXPORT_SYMBOL(sk_dst_check);
>  
>  static int sock_bindtoindex_locked(struct sock *sk, int ifindex)
>  {
> -	int ret = -ENOPROTOOPT;
> -#ifdef CONFIG_NETDEVICES
>  	struct net *net = sock_net(sk);
>  
>  	/* Sorry... */
> -	ret = -EPERM;
>  	if (sk->sk_bound_dev_if && !ns_capable(net->user_ns, CAP_NET_RAW))
> -		goto out;
> +		return -EPERM;
>  
> -	ret = -EINVAL;
>  	if (ifindex < 0)
> -		goto out;
> +		return -EINVAL;
>  
>  	/* Paired with all READ_ONCE() done locklessly. */
>  	WRITE_ONCE(sk->sk_bound_dev_if, ifindex);
> @@ -654,12 +650,7 @@ static int sock_bindtoindex_locked(struct sock *sk, int ifindex)
>  		sk->sk_prot->rehash(sk);
>  	sk_dst_reset(sk);
>  
> -	ret = 0;
> -
> -out:
> -#endif
> -
> -	return ret;
> +	return 0;
>  }
>  
>  int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk)
> @@ -678,15 +669,12 @@ EXPORT_SYMBOL(sock_bindtoindex);
>  
>  static int sock_setbindtodevice(struct sock *sk, sockptr_t optval, int optlen)
>  {
> -	int ret = -ENOPROTOOPT;
> -#ifdef CONFIG_NETDEVICES
> +	int ret, index;
>  	struct net *net = sock_net(sk);
>  	char devname[IFNAMSIZ];
> -	int index;

nit: keep the reverse xmas tree order.

Also, please specify the target tree in the Subject.

  [PATCH net-next v2] ....

See Documentation/process/maintainer-netdev.rst

---
pw-bot: cr

      reply	other threads:[~2026-11-14  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 20:45 [PATCH] net: remove CONFIG_NETDEVICES requirement for SO_BINDTODEVICE and SO_BINDTOIFINDEX Ethan Ferguson
2026-11-14  6:25 ` Kuniyuki Iwashima [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avf-PdwTjpqN7d0D@google.com \
    --to=kuniyu@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ethanf108@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox