[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <027ab4c5-57e8-10b8-816a-17c783f82323@gmail.com>
Date: Tue, 6 Oct 2020 22:10:00 +0200
From: Heiner Kallweit <hkallweit1@...il.com>
To: Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH RFC] net: add helper eth_set_protocol
In all cases I've seen eth_type_trans() is used as in the new helper.
Biggest benefit is improved readability when replacing statements like
the following:
desc->skb->protocol = eth_type_trans(desc->skb, priv->dev);
Coccinelle tells me that using the new helper tree-wide would touch
313 files. Therefore I'd like to check for feedback before bothering
100+ maintainers.
Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
---
include/linux/etherdevice.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 2e5debc03..c7f89b1bf 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -64,6 +64,11 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
#define eth_stp_addr eth_reserved_addr_base
+static inline void eth_set_protocol(struct sk_buff *skb, struct net_device *dev)
+{
+ skb->protocol = eth_type_trans(skb, dev);
+}
+
/**
* is_link_local_ether_addr - Determine if given Ethernet address is link-local
* @addr: Pointer to a six-byte array containing the Ethernet address
--
2.28.0
Powered by blists - more mailing lists