From patchwork Fri Mar 26 15:48:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Kanzenbach X-Patchwork-Id: 410534 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham 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 002D7C433C1 for ; Fri, 26 Mar 2021 15:49:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1E78601FC for ; Fri, 26 Mar 2021 15:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbhCZPs7 (ORCPT ); Fri, 26 Mar 2021 11:48:59 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:55690 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhCZPsu (ORCPT ); Fri, 26 Mar 2021 11:48:50 -0400 From: Kurt Kanzenbach DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1616773728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lA6akj0v/6lF/gpbgvcBrn48UemGabieR9KKjZ0EI68=; b=SKzfl0HG29PUGhhd0BrGc1PDRoXephYCPQoxDiVlMCm+musAtucP/xQczIM/wI2SbvSA0y wosAW1NTDMzaXDDVXRPHH+MSAAkif5gMGfgKcTFFokC85DPvH/vUBsf9pl0Fi6zYtHtdeP ba6XVfvwGo8DW3CdDZiKWEfZbBML17BHh6/eUU4UaKjs6p9NLoU2AOlsxVDNTMLBekeBpu Dme5vjE5z8NzJ6Rhfdx5GexAWXR5RYTQXMjfqheA9adrbsx9q2yYPcO9Yi8GaM0B8RYeCB txfnxA81cWtg0GMdFayEt9JVkE/Gpg49ToEQ7TaM1xgJVdjMedgepGFU+lWJrQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1616773728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lA6akj0v/6lF/gpbgvcBrn48UemGabieR9KKjZ0EI68=; b=x+nRxoUAQ2dCOb1TessPC4ityBA9mImBvajX5T6csEHug7iXGWdTgE1TVGp3p5n1FCu7zm p2c8c7YssfRLCUCw== To: "David S. Miller" , Jakub Kicinski Cc: Sebastian Andrzej Siewior , netdev@vger.kernel.org, Kurt Kanzenbach Subject: [PATCH net-next] net/packet: Reset MAC header for direct packet transmission Date: Fri, 26 Mar 2021 16:48:35 +0100 Message-Id: <20210326154835.21296-1-kurt@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Reset MAC header in case of using packet_direct_xmit(), e.g. by specifying PACKET_QDISC_BYPASS. This is needed, because other code such as the HSR layer expects the MAC header to be correctly set. This has been observed using the following setup: |$ ip link add name hsr0 type hsr slave1 lan0 slave2 lan1 supervision 45 version 1 |$ ifconfig hsr0 up |$ ./test hsr0 The test binary is using mmap'ed sockets and is specifying the PACKET_QDISC_BYPASS socket option. This patch resolves the following warning on a non-patched kernel: |[ 112.725394] ------------[ cut here ]------------ |[ 112.731418] WARNING: CPU: 1 PID: 257 at net/hsr/hsr_forward.c:560 hsr_forward_skb+0x484/0x568 |[ 112.739962] net/hsr/hsr_forward.c:560: Malformed frame (port_src hsr0) The MAC header is also reset unconditionally in case of PACKET_QDISC_BYPASS is not used. Signed-off-by: Kurt Kanzenbach --- net/packet/af_packet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 118d585337d7..6325c9b7df38 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -241,6 +241,7 @@ static void __fanout_link(struct sock *sk, struct packet_sock *po); static int packet_direct_xmit(struct sk_buff *skb) { + skb_reset_mac_header(skb); return dev_direct_xmit(skb, packet_pick_tx_queue(skb)); }