Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3388871pxk; Mon, 5 Oct 2020 08:29:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqmqiS14YIynh8p6QZKF4DtlLVhgrfiQFX7gj6MvK0zsQQmFPhfahLlCMhCEaXycoUvqOW X-Received: by 2002:a17:907:720f:: with SMTP id dr15mr221660ejc.447.1601911759555; Mon, 05 Oct 2020 08:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601911759; cv=none; d=google.com; s=arc-20160816; b=fsLn6ImhoyX3BsFsa87geyoOujmF4ZFC50gpCsCcsDdOqaz/QBVDq17fMvjSqUjlqZ qnGlu2Og295zubqUNpYhCIO8Us1l8gNmWt95gtmo/NYGZkGYKDvHP5HKyKomgW53vcTR 296gl5YPtlE4++YB5HHIxfbcpRabYSzKaUKKYifXMcMP7zDhwf9I2OT3zxb/Ykykp/Mn q43/gzdduiP5mPAXd4cMwOKRX2k1BbygUP8YCLN88qM65jLzVF0/ep9TYgQIEmM/P9XO 4Ip8T7FvCNJhwGad1+JzYSzQ8EkdoWWBIqCxFiPJIFpRAAHgHmB/PAOPWAU4eEZzO3cC UCoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZXgNOrLYWVsuv+aSq5cZ3b9Ub8OcPmdDkfFVcNqgqvY=; b=OPE10UFO/VtZO9jNj5AwtIvZV97BZ+AmwSKKdoliGeZIAQ/Zw3xz+DAXpPxWRM1vJo nProO9PQW3Oj01qAj/EDx7cpgVRxHgUwROygA7rwnlqv6/ZyRwT1T8MQX11chhi7UWpl n+vqN3TbU5/z0IkbSA6JSZjiO2XrIlex9IfiAd5+o9vldAJhXEi93spUGxWthC7hO5l7 +y4gLfQnM3fZSAyJmkiriSPVV/CW1eB/pMfmx//946RMHOJYVRE6m+ziIx24+4hvdWlw sHueL4LEKi3wwixbvlkylCzzTiIDpuCslg6dapEYp9RobOwRdgtRGc8nuJiulpvYmg3c yudw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I4ms07Ii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si201704edk.20.2020.10.05.08.28.56; Mon, 05 Oct 2020 08:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I4ms07Ii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727219AbgJEP1X (ORCPT + 99 others); Mon, 5 Oct 2020 11:27:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:51684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbgJEP1Q (ORCPT ); Mon, 5 Oct 2020 11:27:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2D3720637; Mon, 5 Oct 2020 15:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601911634; bh=anyxQxcrQLQQxS6ixibolxBz33XPbYUvG7IdvOH4pr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I4ms07IicMJIEcWyszLddjA9pbe1JZZsVG9bprgBU/DSYCL02UrNhp8EsWyRH54HX xMDV3gMJoCwD4n2n7OPlCzzEsTbdXJ4Zs7OFi6apJZVocEMYVc2ZBK9UEWnMjMveZU cik7eEBoWS57MsViHbh7WBfelpuRnirJEuq5s+W8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Halasa , Xie He , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 19/38] drivers/net/wan/hdlc: Set skb->protocol before transmitting Date: Mon, 5 Oct 2020 17:26:36 +0200 Message-Id: <20201005142109.601642891@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005142108.650363140@linuxfoundation.org> References: <20201005142108.650363140@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie He [ Upstream commit 9fb030a70431a2a2a1b292dbf0b2f399cc072c16 ] This patch sets skb->protocol before transmitting frames on the HDLC device, so that a user listening on the HDLC device with an AF_PACKET socket will see outgoing frames' sll_protocol field correctly set and consistent with that of incoming frames. 1. Control frames in hdlc_cisco and hdlc_ppp When these drivers send control frames, skb->protocol is not set. This value should be set to htons(ETH_P_HDLC), because when receiving control frames, their skb->protocol is set to htons(ETH_P_HDLC). When receiving, hdlc_type_trans in hdlc.h is called, which then calls cisco_type_trans or ppp_type_trans. The skb->protocol of control frames is set to htons(ETH_P_HDLC) so that the control frames can be received by hdlc_rcv in hdlc.c, which calls cisco_rx or ppp_rx to process the control frames. 2. hdlc_fr When this driver sends control frames, skb->protocol is set to internal values used in this driver. When this driver sends data frames (from upper stacked PVC devices), skb->protocol is the same as that of the user data packet being sent on the upper PVC device (for normal PVC devices), or is htons(ETH_P_802_3) (for Ethernet-emulating PVC devices). However, skb->protocol for both control frames and data frames should be set to htons(ETH_P_HDLC), because when receiving, all frames received on the HDLC device will have their skb->protocol set to htons(ETH_P_HDLC). When receiving, hdlc_type_trans in hdlc.h is called, and because this driver doesn't provide a type_trans function in struct hdlc_proto, all frames will have their skb->protocol set to htons(ETH_P_HDLC). The frames are then received by hdlc_rcv in hdlc.c, which calls fr_rx to process the frames (control frames are consumed and data frames are re-received on upper PVC devices). Cc: Krzysztof Halasa Signed-off-by: Xie He Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/wan/hdlc_cisco.c | 1 + drivers/net/wan/hdlc_fr.c | 3 +++ drivers/net/wan/hdlc_ppp.c | 1 + 3 files changed, 5 insertions(+) diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c index c169a26e5359a..2c6e3fa6947a0 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c @@ -121,6 +121,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type, skb_put(skb, sizeof(struct cisco_packet)); skb->priority = TC_PRIO_CONTROL; skb->dev = dev; + skb->protocol = htons(ETH_P_HDLC); skb_reset_network_header(skb); dev_queue_xmit(skb); diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index 67f89917277ce..03b5f5cce6f47 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -436,6 +436,8 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) if (pvc->state.fecn) /* TX Congestion counter */ dev->stats.tx_compressed++; skb->dev = pvc->frad; + skb->protocol = htons(ETH_P_HDLC); + skb_reset_network_header(skb); dev_queue_xmit(skb); return NETDEV_TX_OK; } @@ -558,6 +560,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) skb_put(skb, i); skb->priority = TC_PRIO_CONTROL; skb->dev = dev; + skb->protocol = htons(ETH_P_HDLC); skb_reset_network_header(skb); dev_queue_xmit(skb); diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c index 85844f26547dd..20d9b6585fba3 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -254,6 +254,7 @@ static void ppp_tx_cp(struct net_device *dev, u16 pid, u8 code, skb->priority = TC_PRIO_CONTROL; skb->dev = dev; + skb->protocol = htons(ETH_P_HDLC); skb_reset_network_header(skb); skb_queue_tail(&tx_queue, skb); } -- 2.25.1