From: Stephen Hemminger <stephen@networkplumber.org>
To: Gur Stavi <gur.stavi@huawei.com>
Cc: <dev@dpdk.org>, "John W. Linville" <linville@tuxdriver.com>
Subject: Re: [PATCH v01] net/af_packet: don't specify protocol on socket create
Date: Wed, 16 Oct 2024 18:38:11 -0700 [thread overview]
Message-ID: <20241016183811.338dc230@hermes.local> (raw)
In-Reply-To: <a6f63e072bea2b3771922b0949b859bfafb660de.1728827368.git.gur.stavi@huawei.com>
On Sun, 13 Oct 2024 16:59:47 +0300
Gur Stavi <gur.stavi@huawei.com> wrote:
> When creating AF_PACKET socket with specified protocol it is
> immediately implicitly bound to any existing interface and
> becomes RUNNING. Calling bind on such socket is affectively unbind
> from "any interface", then bind to the specific interface.
>
> When creating socket with 0 as protocol, it is created in non-RUNNING
> state, then it can be bound to interface and protocol in a single bind
> call and switch to RUNNING state.
>
> Especially with ETH_P_ALL, binding to any interface is not a good idea.
> It is safer and faster to use the 2nd approach.
>
> This patch replaces protocol in socket creation from ETH_P_ALL to 0.
>
> Signed-off-by: Gur Stavi <gur.stavi@huawei.com>
This makes sense see packet(7) man page:
By default, all packets of the specified protocol type are passed to a
packet socket. To get packets only from a specific interface use
bind(2) specifying an address in a struct sockaddr_ll to bind the packet
socket to an interface. Fields used for binding are sll_family (should
be AF_PACKET), sll_protocol, and sll_ifindex.
So there is a small window where the packet socket could pick up junk before
the bind from other interfaces.
prev parent reply other threads:[~2024-10-17 1:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-13 13:59 Gur Stavi
2024-10-16 23:49 ` Ferruh Yigit
2024-10-17 1:38 ` Stephen Hemminger [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=20241016183811.338dc230@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=gur.stavi@huawei.com \
--cc=linville@tuxdriver.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;
as well as URLs for NNTP newsgroup(s).