From patchwork Tue Jul 27 08:53:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Baechle X-Patchwork-Id: 12402175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDCD1C4320A for ; Tue, 27 Jul 2021 08:53:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B84EC6121E for ; Tue, 27 Jul 2021 08:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235993AbhG0IxK (ORCPT ); Tue, 27 Jul 2021 04:53:10 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46287 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235885AbhG0IxJ (ORCPT ); Tue, 27 Jul 2021 04:53:09 -0400 Received: (Authenticated sender: ralf@linux-mips.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 5C64F20014; Tue, 27 Jul 2021 08:53:07 +0000 (UTC) Date: Tue, 27 Jul 2021 10:53:05 +0200 From: Ralf Baechle To: linux-man@vger.kernel.org, Michael Kerrisk , Alejandro Colomar Cc: netdev@vger.kernel.org, linux-hams@vger.kernel.org, Thomas Osterried Subject: [PATCH] packet.7: Describe SOCK_PACKET netif name length issues and workarounds. Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Describe the issues with SOCK_PACKET possibly truncating network interface names in results, solutions and possible workarounds. While the issue is know for a long time it appears to have never been documented properly and is has started to bite software antiques badly since the introduction of Predictable Network Interface Names. So let's document it. Signed-off-by: Ralf Baechle --- man7/packet.7 | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/man7/packet.7 b/man7/packet.7 index 706efbb54..7697bbdeb 100644 --- a/man7/packet.7 +++ b/man7/packet.7 @@ -627,6 +627,34 @@ extension is an ugly hack and should be replaced by a control message. There is currently no way to get the original destination address of packets via .BR SOCK_DGRAM . +.PP +The +.I spkt_device +field of +.I sockaddr_pkt +has a size of 14 bytes which is less than the constant +.B IFNAMSIZ +defined in +.I +which is 16 bytes and describes the system limit for a network interface +name. This means the names of network devices longer than 14 bytes will be +truncated to fit into +.I spkt_device . +All these lengths include the terminating null byte (\(aq\e0\(aq)). +.PP +Issues from this with old code typically show up with very long interface +names used by the +.B Predictable Network Interface Names +feature enabled by default in many modern Linux distributions. +.PP +The preferred solution is to rewrite code to avoid +.BR SOCK_PACKET . +Possible user solutions are to disable +.B Predictable Network Interface Names +or to rename the interface to a name of at most 13 bytes, for example using +the +.BR IP (8) +tool. .\" .SH CREDITS .\" This man page was written by Andi Kleen with help from Matthew Wilcox. .\" AF_PACKET in Linux 2.2 was implemented @@ -637,7 +665,8 @@ packets via .BR capabilities (7), .BR ip (7), .BR raw (7), -.BR socket (7) +.BR socket (7), +.BR ip (8), .PP RFC\ 894 for the standard IP Ethernet encapsulation. RFC\ 1700 for the IEEE 802.3 IP encapsulation.