From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A287A45B45; Thu, 17 Oct 2024 03:38:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 639DB4021F; Thu, 17 Oct 2024 03:38:17 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 7796040144 for ; Thu, 17 Oct 2024 03:38:15 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20cbcd71012so3926215ad.3 for ; Wed, 16 Oct 2024 18:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729129094; x=1729733894; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Xc+PGtwx+yM4h1FK64bljsNFpGd4TXkpoS5sf5rg35w=; b=zZHQcV+3HpPZWWD9TJrJIdJ+unHMWOjcTT7Je5bl1R3C8dkvyeDSaqY975vj3CP1Mh Gudfy+pLs9shD6LK438gmH8K+qwsX2sDzn/cP71py6kwxCj8dEXwuPWPqTdSfmFmKJor NgMZt3kl++T5x42aGt9m/eDPD+pWbRwmJnUdFt4B/GvuyvzQsMStv4s6i6bxDMdmy+rO 8s9MoW/oR4BmTnjGvsytiMxy/y47gwwQAFq3qLiBXgLGNlbV5832vJf5Fuc/LDEVUz4R zlPGq5xRpZln7INecQmkM7PVp33rigBVmviYPb+wEgPUYOAn8ZdeRakzkR4fatgMgFwE qArQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729129094; x=1729733894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xc+PGtwx+yM4h1FK64bljsNFpGd4TXkpoS5sf5rg35w=; b=Ni8AXvYCsexNqDtZNXq7GykjxZQq7SqE13DfY/JkeRtcgQmrEWelckSschrXZseIVD Gp3xYota9qqrixzY0CpbZ+9vsmq2V3Ljwanep4EZie1zZoQolXyC9Q8D4+K7Alq1OyQa wHkQeFppbPuQQK3D2VlHdcr5k6B2lP6NX7C4wGPZd8H4UJi2URByefRHccZC0+BqCBrV sW+e2yTbf1kV9+73PtsP9EUeUKvQmPZKFnG4CDO53ofT236I83UsPjpI8PqPW5n3ztxx Uj7slIlG7mAKTYx10IX6CN8qen7tdNPvaTDTRaykESR9dQW6DuJFe1c3dZ+89RzR2RV5 uIlA== X-Gm-Message-State: AOJu0YxRcmUHcWIjrVTgqO3I9+5fpTyo6cK4duk9Kr6KTr2Aj3ja/O6h S9sU7mb242+6KehmnepQ/JvV5df6xmspTdDjZWCdS6Q8qaUXQISxFujF6fO0UbM= X-Google-Smtp-Source: AGHT+IFEPm/sLAfbnhc3Cd9ClRVoxnBlSJaW1sdDOEzcnJ6VnCxBxRFCEzYvmvpfbWo0ELVgAdW8vQ== X-Received: by 2002:a17:902:e548:b0:20c:968e:4dcd with SMTP id d9443c01a7336-20cbb1a9879mr314072295ad.7.1729129094341; Wed, 16 Oct 2024 18:38:14 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20d1805cc65sm34421285ad.279.2024.10.16.18.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 18:38:14 -0700 (PDT) Date: Wed, 16 Oct 2024 18:38:11 -0700 From: Stephen Hemminger To: Gur Stavi Cc: , "John W. Linville" Subject: Re: [PATCH v01] net/af_packet: don't specify protocol on socket create Message-ID: <20241016183811.338dc230@hermes.local> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Sun, 13 Oct 2024 16:59:47 +0300 Gur Stavi 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 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.