From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 5/9] net: constify netdev->dev_addr
Date: Wed, 17 Nov 2021 20:14:57 -0800 [thread overview]
Message-ID: <20211118041501.3102861-6-kuba@kernel.org> (raw)
In-Reply-To: <20211118041501.3102861-1-kuba@kernel.org>
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. We converted all users to make modifications via appropriate
helpers, make netdev->dev_addr const.
The update helpers need to upcast from the buffer to
struct netdev_hw_addr.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
include/linux/netdevice.h | 14 +++++---------
net/core/dev_addr_lists.c | 10 ++++++++++
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 4f4a299e92de..2462195784a9 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2117,7 +2117,7 @@ struct net_device {
* Cache lines mostly used on receive path (including eth_type_trans())
*/
/* Interface address info used in eth_type_trans() */
- unsigned char *dev_addr;
+ const unsigned char *dev_addr;
struct netdev_rx_queue *_rx;
unsigned int num_rx_queues;
@@ -4268,10 +4268,13 @@ void __hw_addr_unsync_dev(struct netdev_hw_addr_list *list,
void __hw_addr_init(struct netdev_hw_addr_list *list);
/* Functions used for device addresses handling */
+void dev_addr_mod(struct net_device *dev, unsigned int offset,
+ const void *addr, size_t len);
+
static inline void
__dev_addr_set(struct net_device *dev, const void *addr, size_t len)
{
- memcpy(dev->dev_addr, addr, len);
+ dev_addr_mod(dev, 0, addr, len);
}
static inline void dev_addr_set(struct net_device *dev, const u8 *addr)
@@ -4279,13 +4282,6 @@ static inline void dev_addr_set(struct net_device *dev, const u8 *addr)
__dev_addr_set(dev, addr, dev->addr_len);
}
-static inline void
-dev_addr_mod(struct net_device *dev, unsigned int offset,
- const void *addr, size_t len)
-{
- memcpy(&dev->dev_addr[offset], addr, len);
-}
-
int dev_addr_add(struct net_device *dev, const unsigned char *addr,
unsigned char addr_type);
int dev_addr_del(struct net_device *dev, const unsigned char *addr,
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index f0cb38344126..ae8b1ef00fec 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -549,6 +549,16 @@ int dev_addr_init(struct net_device *dev)
}
EXPORT_SYMBOL(dev_addr_init);
+void dev_addr_mod(struct net_device *dev, unsigned int offset,
+ const void *addr, size_t len)
+{
+ struct netdev_hw_addr *ha;
+
+ ha = container_of(dev->dev_addr, struct netdev_hw_addr, addr[0]);
+ memcpy(&ha->addr[offset], addr, len);
+}
+EXPORT_SYMBOL(dev_addr_mod);
+
/**
* dev_addr_add - Add a device address
* @dev: device
--
2.31.1
next prev parent reply other threads:[~2021-11-18 4:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 4:14 [PATCH net-next 0/9] net: constify netdev->dev_addr Jakub Kicinski
2021-11-18 4:14 ` [PATCH net-next 1/9] net: ax88796c: don't write to netdev->dev_addr directly Jakub Kicinski
2021-11-18 12:09 ` Lukasz Stelmach
2021-11-18 4:14 ` [PATCH net-next 2/9] mlxsw: constify address in mlxsw_sp_port_dev_addr_set Jakub Kicinski
2021-11-18 7:27 ` Ido Schimmel
2021-11-18 4:14 ` [PATCH net-next 3/9] wilc1000: copy address before calling wilc_set_mac_address Jakub Kicinski
2021-11-18 5:35 ` Kalle Valo
2021-11-18 4:14 ` [PATCH net-next 4/9] ipw2200: constify address in ipw_send_adapter_address Jakub Kicinski
2021-11-18 5:36 ` Kalle Valo
2021-11-18 4:14 ` Jakub Kicinski [this message]
2021-11-18 6:15 ` [PATCH net-next 5/9] net: constify netdev->dev_addr kernel test robot
2021-11-18 11:36 ` kernel test robot
2021-11-18 14:12 ` kernel test robot
2021-11-18 4:14 ` [PATCH net-next 6/9] net: unexport dev_addr_init() & dev_addr_flush() Jakub Kicinski
2021-11-18 4:14 ` [PATCH net-next 7/9] dev_addr: add a modification check Jakub Kicinski
2021-11-18 4:15 ` [PATCH net-next 8/9] dev_addr_list: put the first addr on the tree Jakub Kicinski
2021-11-18 4:15 ` [PATCH net-next 9/9] net: kunit: add a test for dev_addr_lists Jakub Kicinski
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=20211118041501.3102861-6-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--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;
as well as URLs for NNTP newsgroup(s).