From: Joe Perches <joe@perches.com>
To: linux-kernel@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH 01/12] ethernet: Add generic ether_<foo>_addr addresses
Date: Sat, 31 Mar 2018 00:05:16 -0700 [thread overview]
Message-ID: <38edb6a91d0ee90f3d656ec2c0030eee440cf355.1522479607.git.joe@perches.com> (raw)
In-Reply-To: <cover.1522479607.git.joe@perches.com>
Treewide there are ~60 declarations of Ethernet broadcast or zero address
use as a 6 byte array that are later used as either an output for vsprintf
extension %pM or as a source array to copy or compare.
Create const globals for these uses with EXPORT_SYMBOL for modules.
Miscellanea:
o Rename and move static const eth_reservd_addr_base from etherdevice.h
to this new ether_addrs.c file so it is no longer oddly declared
as static const in a .h file
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/etherdevice.h | 12 ++++++++----
net/ethernet/Makefile | 2 +-
net/ethernet/ether_addrs.c | 19 +++++++++++++++++++
3 files changed, 28 insertions(+), 5 deletions(-)
create mode 100644 net/ethernet/ether_addrs.c
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 79563840c295..85d2486b2959 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -63,10 +63,14 @@ struct sk_buff **eth_gro_receive(struct sk_buff **head,
struct sk_buff *skb);
int eth_gro_complete(struct sk_buff *skb, int nhoff);
+/* Generic Ethernet addresses */
+extern const u8 ether_broadcast_addr[ETH_ALEN]; /* all 0xff */
+extern const u8 ether_zero_addr[ETH_ALEN]; /* all zeros */
+
/* Reserved Ethernet Addresses per IEEE 802.1Q */
-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
+extern const u8 ether_reserved_addr_base[ETH_ALEN];
+
+#define eth_stp_addr ether_reserved_addr_base
/**
* is_link_local_ether_addr - Determine if given Ethernet address is link-local
@@ -80,7 +84,7 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
static inline bool is_link_local_ether_addr(const u8 *addr)
{
__be16 *a = (__be16 *)addr;
- static const __be16 *b = (const __be16 *)eth_reserved_addr_base;
+ static const __be16 *b = (const __be16 *)ether_reserved_addr_base;
static const __be16 m = cpu_to_be16(0xfff0);
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
diff --git a/net/ethernet/Makefile b/net/ethernet/Makefile
index 323177505404..fbbcfec2ba10 100644
--- a/net/ethernet/Makefile
+++ b/net/ethernet/Makefile
@@ -2,4 +2,4 @@
# Makefile for the Linux Ethernet layer.
#
-obj-y += eth.o
+obj-y += eth.o ether_addrs.o
diff --git a/net/ethernet/ether_addrs.c b/net/ethernet/ether_addrs.c
new file mode 100644
index 000000000000..e0b7a57628e8
--- /dev/null
+++ b/net/ethernet/ether_addrs.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Various const global Ethernet addresses */
+
+#include <linux/etherdevice.h>
+
+const u8 ether_broadcast_addr[ETH_ALEN] __aligned(2) = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+EXPORT_SYMBOL(ether_broadcast_addr);
+
+const u8 ether_zero_addr[ETH_ALEN] __aligned(2) = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(ether_zero_addr);
+
+const u8 ether_reserved_addr_base[ETH_ALEN] __aligned(2) = {
+ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(ether_reserved_addr_base);
--
2.15.0
next prev parent reply other threads:[~2018-03-31 7:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 7:05 [PATCH 00/12] Ethernet: Add and use ether_<type>_addr globals Joe Perches
2018-03-31 7:05 ` Joe Perches [this message]
2018-03-31 7:05 ` [PATCH 02/12] treewide/net: Rename eth_stp_addr to ether_stp_addr Joe Perches
2018-03-31 17:36 ` Andrew Lunn
2018-03-31 18:01 ` Joe Perches
2018-03-31 18:34 ` [PATCH V2] " Joe Perches
2018-04-01 18:07 ` David Miller
2018-04-01 0:18 ` [PATCH 02/12] " kbuild test robot
2018-03-31 7:05 ` [PATCH 03/12] net: mac80211: Use global ether_broadcast_addr Joe Perches
2018-03-31 7:05 ` [PATCH 04/12] bridge: netfilter: Use the new global ether_<foo>_addr arrays Joe Perches
2018-03-31 18:28 ` Pablo Neira Ayuso
2018-03-31 18:40 ` Joe Perches
2018-03-31 7:05 ` [PATCH 05/12] net: atm: Use ether_broadcast_addr Joe Perches
2018-03-31 7:05 ` [PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address Joe Perches
2018-03-31 14:01 ` Pkshih
2018-03-31 14:33 ` Joe Perches
2018-04-05 12:39 ` Kalle Valo
2018-04-05 12:48 ` Kalle Valo
2018-03-31 7:05 ` [PATCH 07/12] brcmfmac: Convert ALLFFMAC to ether_broadcast_addr Joe Perches
2018-04-05 19:00 ` Arend van Spriel
2018-03-31 7:05 ` [PATCH 08/12] iwlegacy: Remove EXPORT_SYMBOL(il_bcast_addr) and use ether_broadcast_addr Joe Perches
2018-03-31 7:05 ` [PATCH 09/12] iwlwifi: Remove local iwl_bcast_addr " Joe Perches
2018-07-07 7:40 ` Luciano Coelho
2018-09-07 10:46 ` Luciano Coelho
2018-03-31 7:05 ` [PATCH 10/12] mvpp2: Use ether_broadcast_addr instead of a local array Joe Perches
2018-03-31 7:05 ` [PATCH 11/12] qlogic: Convert local bcast_addr to global ether_broadcast_addr Joe Perches
2018-03-31 7:05 ` [PATCH 12/12] ethernet: Use ether_zero_addr instead of local statics Joe Perches
2018-04-05 13:27 ` [PATCH 00/12] Ethernet: Add and use ether_<type>_addr globals Felix Fietkau
2018-04-05 13:51 ` Joe Perches
2018-04-05 14:05 ` Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38edb6a91d0ee90f3d656ec2c0030eee440cf355.1522479607.git.joe@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®