netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Gur Stavi <gur.stavi@huawei.com>,
	 'Willem de Bruijn' <willemdebruijn.kernel@gmail.com>
Cc: davem@davemloft.net,  edumazet@google.com,  kuba@kernel.org,
	 linux-kernel@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	 netdev@vger.kernel.org,  pabeni@redhat.com,  shuah@kernel.org
Subject: RE: [PATCH net-next v02 1/2] af_packet: allow fanout_add when socket is not RUNNING
Date: Fri, 11 Oct 2024 15:08:42 -0400	[thread overview]
Message-ID: <670977bac8b03_247429294f6@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <000401db1c00$bd86afe0$38940fa0$@huawei.com>

Gur Stavi wrote:
> > Gur Stavi wrote:
> > > >
> > > > If we don't care about opening up fanout groups to ETH_P_NONE, then
> > > > patch v2 seems sufficient. If explicitly blocking this, the ENXIO
> > > > return can be added, but ideally without touching the other lines.
> > >
> > > I don't think that allowing ETH_P_NONE is relevant.
> > > In my opinion the 2 options that should be considered to fail
> > > fanout_add are:
> > > 1. Testing proto == 0
> > > 2. Testing proto == 0 || ifindex == -1
> > >
> > > The only corner case that is caught by [2] and missed by [1] is
> > > the "unlisted" case during do_bind. It is such a rare case that
> > > probably no one will ever encounter bind "unlisted" followed by
> > > FANOUT_ADD. And this is not a dangerous corner case that leads to
> > > system crash.
> > >
> > > However, being a purist, I see the major goal of code review to promote
> > > correctness by identifying corner cases while improving style is a
> > > secondary priority. Since we did identify this corner case in our
> > > discussion I think we should still use [2].
> > > I don't consider the code complex. In fact, to me, the ifindex clause
> > > is a more understandable direct reason for failure than the proto which
> > > is indirect. Having the ifindex clause helps figuring out the proto
> > > clause.
> > 
> > It's interesting that the unlisted fix does not return ENODEV, but
> > returns success and leaves the socket in an unbound state, equivalent
> > to binding to ETH_P_NONE and ifindex 0. This seems surprising behavior
> > to the caller.
> > 
> > On rereading that, I still do not see a purpose of special ifindex -1.
> > 
> >
> 
> Can this code be relevant?
> 
> 		case NETDEV_UP:
> 			if (dev->ifindex == po->ifindex) {
> 				spin_lock(&po->bind_lock);
> 				if (po->num)
> 					register_prot_hook(sk);
> 				spin_unlock(&po->bind_lock);
> 			}
> 			break;
> 
> Perhaps, although the socket failed to (re) find the device, the device
> is still aware of the socket and we need the ifindex condition to fail.

But the behavior is the same for ifindex -1 and 0. Devices always have
an ifindex >= 1.

  reply	other threads:[~2024-10-11 19:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 10:27 [PATCH net-next v02 0/2] net: af_packet: allow joining a fanout when link is down Gur Stavi
2024-10-08 10:27 ` [PATCH net-next v02 1/2] af_packet: allow fanout_add when socket is not RUNNING Gur Stavi
2024-10-08 14:26   ` Willem de Bruijn
2024-10-09  6:58     ` Gur Stavi
2024-10-09 13:51       ` Willem de Bruijn
2024-10-09 18:03         ` Gur Stavi
2024-10-10  0:30           ` Willem de Bruijn
2024-10-10  7:08             ` Gur Stavi
2024-10-10 14:21               ` Willem de Bruijn
2024-10-10 16:14                 ` Gur Stavi
2024-10-10 22:12                   ` Willem de Bruijn
2024-10-11  5:17                     ` Gur Stavi
2024-10-11 14:24                       ` Willem de Bruijn
2024-10-11  9:02                     ` Gur Stavi
2024-10-11 14:35                       ` Willem de Bruijn
2024-10-11 17:12                         ` Gur Stavi
2024-10-11 19:08                           ` Willem de Bruijn [this message]
2024-10-10 11:49             ` Gur Stavi
2024-10-08 10:27 ` [PATCH net-next v02 2/2] selftests: net/psock_fanout: socket joins fanout when link is down Gur Stavi

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=670977bac8b03_247429294f6@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gur.stavi@huawei.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).