From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
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: Sat, 26 Oct 2024 00:10:09 +0100 [thread overview]
Message-ID: <fb305126-98d3-4b17-9c72-c9eaa456c2f6@amd.com> (raw)
In-Reply-To: <20241016183811.338dc230@hermes.local>
On 10/17/2024 2:38 AM, Stephen Hemminger wrote:
> 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.
>
Thanks, this answers some of my questions in this thread, also I did
some experiment and verified the same.
I agree this change is more close the intention of the driver (driver is
not to get packets from all interfaces), hence:
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
next prev parent reply other threads:[~2024-10-25 23:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-13 13:59 [PATCH v01] net/af_packet: don't specify protocol on socket create Gur Stavi
2024-10-16 23:49 ` Ferruh Yigit
2024-10-17 1:38 ` Stephen Hemminger
2024-10-25 23:10 ` Ferruh Yigit [this message]
2024-10-25 23:47 ` Ferruh Yigit
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=fb305126-98d3-4b17-9c72-c9eaa456c2f6@amd.com \
--to=ferruh.yigit@amd.com \
--cc=dev@dpdk.org \
--cc=gur.stavi@huawei.com \
--cc=linville@tuxdriver.com \
--cc=stephen@networkplumber.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 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.