Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3440980pxk; Mon, 28 Sep 2020 18:33:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCxU6Qu385QpcVQWkcyDxeMu4Y39aDWcdYsgTRLcZQzeM4j4eV31BMoGKsWWEyN+uN0/95 X-Received: by 2002:a17:906:4b18:: with SMTP id y24mr1458464eju.471.1601343225679; Mon, 28 Sep 2020 18:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601343225; cv=none; d=google.com; s=arc-20160816; b=YRdeEM41aU3CE0jR2MgTI9kDV4EiwdgdtdybGd1nlkExaxbP3mm8h765HPsCEtGj/2 RYr70AKJUkv4FF6dtpbFNLvcRt2rywfN8/k/RTgT5plhm1qtnw812uqNtBnRgyB7Rbuv ocIcOp43PS/vHflG7RJ/YtCxwY09ft+S9HFBWZ1B/KHHhwD+OfzEo6eQzEGETv1wGDXE rl7JdYYiMjAxeShZzfTWswn2irvJJa/NR17+ve66SZUnKzLebxdMAy6Kvr4CsA6PGYdv W2KJ0K9K00DfOExBxXNcKRTKmxDV6NLPfcJaKuhlyFi2jaT0N7SZGtAUqajblCbf55Uu mw1Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1CYw/wGu7JAXsBDgzugqPSOfbGlaAOIkGTUqmpUoVs4=; b=x875TRwr4XrfS6U/NmwFn7AUR28ofSHdY/NvUZovD55v30783wN/z6ED6LK0X5HYPf 5dgGItlNNmZttvTQZFVKYsP3bxLBOd4YNoePapcgqd8zrkSpYtdsT+P/5mSjU8G17SSj QcjJuNa03SA3C5B0Kqq5PTbDKrIJwvrjJJNY0YjyJWzcPyFta2M+h23FUxLJuKJbbcqh PuYoCByKcEo2H3u3N/Y7RRb4iN3SsvfUBEuwSkq7RDPeYHGaBrT+Ly1paG7YpISfC+jx pYJhyccFKilYOLdgdlvjVRRkqXvqeFkCxsb/sIdE+MVSDENUjFt/RZ85IYCOhOLE6KBZ jxqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d6bXeH5J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v26si1683463ejr.748.2020.09.28.18.33.17; Mon, 28 Sep 2020 18:33:45 -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=d6bXeH5J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727480AbgI2BbB (ORCPT + 99 others); Mon, 28 Sep 2020 21:31:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:39930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbgI2Baw (ORCPT ); Mon, 28 Sep 2020 21:30:52 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BABE21D7D; Tue, 29 Sep 2020 01:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601343050; bh=cUj5SgROSblXrtlG0+s1tblQ9AzoAgt44FoEKAJYqKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6bXeH5JCmkrYSN+8Obi8I3vNonJ1iPytC8YAMd2JAJZWtKfAVyIJb6VwFC9uxCg1 G/YRI+olJvAfw1hOQGWGX6vU7lo0ZRUTnEfXI7KnqEPR0Y8jcinHYzWo1lJM+spFV3 TTqGaCGf6q0g2h+Sej0mcQMzgOeQfX1cIVovgoU0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xie He , Krzysztof Halasa , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 17/29] drivers/net/wan/hdlc: Set skb->protocol before transmitting Date: Mon, 28 Sep 2020 21:30:14 -0400 Message-Id: <20200929013027.2406344-17-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200929013027.2406344-1-sashal@kernel.org> References: <20200929013027.2406344-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 444130655d8ea..cb5898f7d68c9 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c @@ -118,6 +118,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 12b35404cd8e7..d6cfd51613ed8 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -433,6 +433,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; } @@ -555,6 +557,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 16f33d1ffbfb9..64f8556513369 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -251,6 +251,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