netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr
@ 2021-10-22 23:20 Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 1/8] net: core: constify mac addrs in selftests Jakub Kicinski
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:20 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Constify references to netdev->dev_addr and
use appropriate helpers.

v2: s/got/go/

Jakub Kicinski (8):
  net: core: constify mac addrs in selftests
  net: rtnetlink: use __dev_addr_set()
  net: phy: constify netdev->dev_addr references
  net: bonding: constify and use dev_addr_set()
  net: hsr: get ready for const netdev->dev_addr
  net: caif: get ready for const netdev->dev_addr
  net: drivers: get ready for const netdev->dev_addr
  net: atm: use address setting helpers

 drivers/net/bonding/bond_alb.c    | 28 +++++++++++++---------------
 drivers/net/bonding/bond_main.c   |  2 +-
 drivers/net/macsec.c              |  2 +-
 drivers/net/macvlan.c             |  3 ++-
 drivers/net/phy/dp83867.c         |  4 ++--
 drivers/net/phy/dp83869.c         |  4 ++--
 drivers/net/vmxnet3/vmxnet3_drv.c |  4 ++--
 net/atm/br2684.c                  |  4 +++-
 net/atm/lec.c                     |  5 ++---
 net/caif/caif_usb.c               |  2 +-
 net/core/rtnetlink.c              |  4 ++--
 net/core/selftests.c              |  8 ++++----
 net/hsr/hsr_framereg.c            |  4 ++--
 net/hsr/hsr_framereg.h            |  4 ++--
 14 files changed, 39 insertions(+), 39 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 1/8] net: core: constify mac addrs in selftests
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
@ 2021-10-22 23:20 ` Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 2/8] net: rtnetlink: use __dev_addr_set() Jakub Kicinski
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:20 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/core/selftests.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/core/selftests.c b/net/core/selftests.c
index 9077fa969892..acb1ee97bbd3 100644
--- a/net/core/selftests.c
+++ b/net/core/selftests.c
@@ -15,8 +15,8 @@
 #include <net/udp.h>
 
 struct net_packet_attrs {
-	unsigned char *src;
-	unsigned char *dst;
+	const unsigned char *src;
+	const unsigned char *dst;
 	u32 ip_src;
 	u32 ip_dst;
 	bool tcp;
@@ -173,8 +173,8 @@ static int net_test_loopback_validate(struct sk_buff *skb,
 				      struct net_device *orig_ndev)
 {
 	struct net_test_priv *tpriv = pt->af_packet_priv;
-	unsigned char *src = tpriv->packet->src;
-	unsigned char *dst = tpriv->packet->dst;
+	const unsigned char *src = tpriv->packet->src;
+	const unsigned char *dst = tpriv->packet->dst;
 	struct netsfhdr *shdr;
 	struct ethhdr *ehdr;
 	struct udphdr *uhdr;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 2/8] net: rtnetlink: use __dev_addr_set()
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 1/8] net: core: constify mac addrs in selftests Jakub Kicinski
@ 2021-10-22 23:20 ` Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 3/8] net: phy: constify netdev->dev_addr references Jakub Kicinski
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:20 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 79477dcae7c2..2af8aeeadadf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3204,8 +3204,8 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname,
 		dev->mtu = mtu;
 	}
 	if (tb[IFLA_ADDRESS]) {
-		memcpy(dev->dev_addr, nla_data(tb[IFLA_ADDRESS]),
-				nla_len(tb[IFLA_ADDRESS]));
+		__dev_addr_set(dev, nla_data(tb[IFLA_ADDRESS]),
+			       nla_len(tb[IFLA_ADDRESS]));
 		dev->addr_assign_type = NET_ADDR_SET;
 	}
 	if (tb[IFLA_BROADCAST])
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 3/8] net: phy: constify netdev->dev_addr references
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 1/8] net: core: constify mac addrs in selftests Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 2/8] net: rtnetlink: use __dev_addr_set() Jakub Kicinski
@ 2021-10-22 23:20 ` Jakub Kicinski
  2021-10-22 23:20 ` [PATCH net-next v2 4/8] net: bonding: constify and use dev_addr_set() Jakub Kicinski
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:20 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, Andrew Lunn, hkallweit1, linux

netdev->dev_addr will become a const soon(ish),
constify the local variables referring to it.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: hkallweit1@gmail.com
CC: linux@armlinux.org.uk
---
 drivers/net/phy/dp83867.c | 4 ++--
 drivers/net/phy/dp83869.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 914619f3f0e3..8561f2d4443b 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -182,7 +182,7 @@ static int dp83867_set_wol(struct phy_device *phydev,
 {
 	struct net_device *ndev = phydev->attached_dev;
 	u16 val_rxcfg, val_micr;
-	u8 *mac;
+	const u8 *mac;
 
 	val_rxcfg = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG);
 	val_micr = phy_read(phydev, MII_DP83867_MICR);
@@ -193,7 +193,7 @@ static int dp83867_set_wol(struct phy_device *phydev,
 		val_micr |= MII_DP83867_MICR_WOL_INT_EN;
 
 		if (wol->wolopts & WAKE_MAGIC) {
-			mac = (u8 *)ndev->dev_addr;
+			mac = (const u8 *)ndev->dev_addr;
 
 			if (!is_valid_ether_addr(mac))
 				return -EINVAL;
diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
index 755220c6451f..7113925606f7 100644
--- a/drivers/net/phy/dp83869.c
+++ b/drivers/net/phy/dp83869.c
@@ -246,7 +246,7 @@ static int dp83869_set_wol(struct phy_device *phydev,
 {
 	struct net_device *ndev = phydev->attached_dev;
 	int val_rxcfg, val_micr;
-	u8 *mac;
+	const u8 *mac;
 	int ret;
 
 	val_rxcfg = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_RXFCFG);
@@ -264,7 +264,7 @@ static int dp83869_set_wol(struct phy_device *phydev,
 
 		if (wol->wolopts & WAKE_MAGIC ||
 		    wol->wolopts & WAKE_MAGICSECURE) {
-			mac = (u8 *)ndev->dev_addr;
+			mac = (const u8 *)ndev->dev_addr;
 
 			if (!is_valid_ether_addr(mac))
 				return -EINVAL;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 4/8] net: bonding: constify and use dev_addr_set()
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (2 preceding siblings ...)
  2021-10-22 23:20 ` [PATCH net-next v2 3/8] net: phy: constify netdev->dev_addr references Jakub Kicinski
@ 2021-10-22 23:20 ` Jakub Kicinski
  2021-10-22 23:21 ` [PATCH net-next v2 5/8] net: hsr: get ready for const netdev->dev_addr Jakub Kicinski
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:20 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, j.vosburgh, vfalico, andy

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it go through appropriate helpers.

Make sure local references to netdev->dev_addr are constant.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: j.vosburgh@gmail.com
CC: vfalico@gmail.com
CC: andy@greyhouse.net
---
 drivers/net/bonding/bond_alb.c  | 28 +++++++++++++---------------
 drivers/net/bonding/bond_main.c |  2 +-
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 7d3752cbf761..2ec8e015c7b3 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -50,7 +50,7 @@ struct arp_pkt {
 #pragma pack()
 
 /* Forward declaration */
-static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
+static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[],
 				      bool strict_match);
 static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp);
 static void rlb_src_unlink(struct bonding *bond, u32 index);
@@ -353,7 +353,8 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
  *
  * Caller must hold RTNL
  */
-static void rlb_teach_disabled_mac_on_primary(struct bonding *bond, u8 addr[])
+static void rlb_teach_disabled_mac_on_primary(struct bonding *bond,
+					      const u8 addr[])
 {
 	struct slave *curr_active = rtnl_dereference(bond->curr_active_slave);
 
@@ -904,7 +905,7 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
 
 /*********************** tlb/rlb shared functions *********************/
 
-static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
+static void alb_send_lp_vid(struct slave *slave, const u8 mac_addr[],
 			    __be16 vlan_proto, u16 vid)
 {
 	struct learning_pkt pkt;
@@ -940,7 +941,7 @@ static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
 struct alb_walk_data {
 	struct bonding *bond;
 	struct slave *slave;
-	u8 *mac_addr;
+	const u8 *mac_addr;
 	bool strict_match;
 };
 
@@ -949,9 +950,9 @@ static int alb_upper_dev_walk(struct net_device *upper,
 {
 	struct alb_walk_data *data = (struct alb_walk_data *)priv->data;
 	bool strict_match = data->strict_match;
+	const u8 *mac_addr = data->mac_addr;
 	struct bonding *bond = data->bond;
 	struct slave *slave = data->slave;
-	u8 *mac_addr = data->mac_addr;
 	struct bond_vlan_tag *tags;
 
 	if (is_vlan_dev(upper) &&
@@ -982,7 +983,7 @@ static int alb_upper_dev_walk(struct net_device *upper,
 	return 0;
 }
 
-static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
+static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[],
 				      bool strict_match)
 {
 	struct bonding *bond = bond_get_bond_by_slave(slave);
@@ -1006,14 +1007,14 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
 	rcu_read_unlock();
 }
 
-static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[],
+static int alb_set_slave_mac_addr(struct slave *slave, const u8 addr[],
 				  unsigned int len)
 {
 	struct net_device *dev = slave->dev;
 	struct sockaddr_storage ss;
 
 	if (BOND_MODE(slave->bond) == BOND_MODE_TLB) {
-		memcpy(dev->dev_addr, addr, len);
+		__dev_addr_set(dev, addr, len);
 		return 0;
 	}
 
@@ -1242,8 +1243,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
 		res = dev_set_mac_address(slave->dev, addr, NULL);
 
 		/* restore net_device's hw address */
-		bond_hw_addr_copy(slave->dev->dev_addr, tmp_addr,
-				  slave->dev->addr_len);
+		dev_addr_set(slave->dev, tmp_addr);
 
 		if (res)
 			goto unwind;
@@ -1263,8 +1263,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
 				  rollback_slave->dev->addr_len);
 		dev_set_mac_address(rollback_slave->dev,
 				    (struct sockaddr *)&ss, NULL);
-		bond_hw_addr_copy(rollback_slave->dev->dev_addr, tmp_addr,
-				  rollback_slave->dev->addr_len);
+		dev_addr_set(rollback_slave->dev, tmp_addr);
 	}
 
 	return res;
@@ -1727,8 +1726,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
 		dev_set_mac_address(new_slave->dev, (struct sockaddr *)&ss,
 				    NULL);
 
-		bond_hw_addr_copy(new_slave->dev->dev_addr, tmp_addr,
-				  new_slave->dev->addr_len);
+		dev_addr_set(new_slave->dev, tmp_addr);
 	}
 
 	/* curr_active_slave must be set before calling alb_swap_mac_addr */
@@ -1761,7 +1759,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
 	if (res)
 		return res;
 
-	bond_hw_addr_copy(bond_dev->dev_addr, ss->__data, bond_dev->addr_len);
+	dev_addr_set(bond_dev, ss->__data);
 
 	/* If there is no curr_active_slave there is nothing else to do.
 	 * Otherwise we'll need to pass the new address to it and handle
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 0c52612cb8e9..ff8da720a33a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -923,7 +923,7 @@ static int bond_set_dev_addr(struct net_device *bond_dev,
 	if (err)
 		return err;
 
-	memcpy(bond_dev->dev_addr, slave_dev->dev_addr, slave_dev->addr_len);
+	__dev_addr_set(bond_dev, slave_dev->dev_addr, slave_dev->addr_len);
 	bond_dev->addr_assign_type = NET_ADDR_STOLEN;
 	call_netdevice_notifiers(NETDEV_CHANGEADDR, bond_dev);
 	return 0;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 5/8] net: hsr: get ready for const netdev->dev_addr
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (3 preceding siblings ...)
  2021-10-22 23:20 ` [PATCH net-next v2 4/8] net: bonding: constify and use dev_addr_set() Jakub Kicinski
@ 2021-10-22 23:21 ` Jakub Kicinski
  2021-10-22 23:21 ` [PATCH net-next v2 6/8] net: caif: " Jakub Kicinski
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, george.mccollister, marco.wenzel

hsr_create_self_node() may get netdev->dev_addr
passed as argument, netdev->dev_addr will be
const soon.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: george.mccollister@gmail.com
CC: marco.wenzel@a-eberle.de
---
 net/hsr/hsr_framereg.c | 4 ++--
 net/hsr/hsr_framereg.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index e31949479305..91292858a63b 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -76,8 +76,8 @@ static struct hsr_node *find_node_by_addr_A(struct list_head *node_db,
  * frames from self that's been looped over the HSR ring.
  */
 int hsr_create_self_node(struct hsr_priv *hsr,
-			 unsigned char addr_a[ETH_ALEN],
-			 unsigned char addr_b[ETH_ALEN])
+			 const unsigned char addr_a[ETH_ALEN],
+			 const unsigned char addr_b[ETH_ALEN])
 {
 	struct list_head *self_node_db = &hsr->self_node_db;
 	struct hsr_node *node, *oldnode;
diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
index d9628e7a5f05..bdbb8c822ba1 100644
--- a/net/hsr/hsr_framereg.h
+++ b/net/hsr/hsr_framereg.h
@@ -48,8 +48,8 @@ int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
 void hsr_prune_nodes(struct timer_list *t);
 
 int hsr_create_self_node(struct hsr_priv *hsr,
-			 unsigned char addr_a[ETH_ALEN],
-			 unsigned char addr_b[ETH_ALEN]);
+			 const unsigned char addr_a[ETH_ALEN],
+			 const unsigned char addr_b[ETH_ALEN]);
 
 void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
 			unsigned char addr[ETH_ALEN]);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 6/8] net: caif: get ready for const netdev->dev_addr
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (4 preceding siblings ...)
  2021-10-22 23:21 ` [PATCH net-next v2 5/8] net: hsr: get ready for const netdev->dev_addr Jakub Kicinski
@ 2021-10-22 23:21 ` Jakub Kicinski
  2021-10-22 23:21 ` [PATCH net-next v2 7/8] net: drivers: " Jakub Kicinski
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/caif/caif_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/caif/caif_usb.c b/net/caif/caif_usb.c
index b02e1292f7f1..4be6b04879a1 100644
--- a/net/caif/caif_usb.c
+++ b/net/caif/caif_usb.c
@@ -81,7 +81,7 @@ static void cfusbl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
 		layr->up->ctrlcmd(layr->up, ctrl, layr->id);
 }
 
-static struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN],
+static struct cflayer *cfusbl_create(int phyid, const u8 ethaddr[ETH_ALEN],
 				      u8 braddr[ETH_ALEN])
 {
 	struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 7/8] net: drivers: get ready for const netdev->dev_addr
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (5 preceding siblings ...)
  2021-10-22 23:21 ` [PATCH net-next v2 6/8] net: caif: " Jakub Kicinski
@ 2021-10-22 23:21 ` Jakub Kicinski
  2021-10-22 23:21 ` [PATCH net-next v2 8/8] net: atm: use address setting helpers Jakub Kicinski
  2021-10-25 12:10 ` [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr patchwork-bot+netdevbpf
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, doshir, pv-drivers

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it go through appropriate helpers. We will make
netdev->dev_addr a const.

Make sure local references to netdev->dev_addr are constant.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: doshir@vmware.com
CC: pv-drivers@vmware.com
---
 drivers/net/macsec.c              | 2 +-
 drivers/net/macvlan.c             | 3 ++-
 drivers/net/vmxnet3/vmxnet3_drv.c | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 18b6dba9394e..16aa3a478e9e 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -250,7 +250,7 @@ static bool send_sci(const struct macsec_secy *secy)
 		(secy->n_rx_sc > 1 && !tx_sc->end_station && !tx_sc->scb);
 }
 
-static sci_t make_sci(u8 *addr, __be16 port)
+static sci_t make_sci(const u8 *addr, __be16 port)
 {
 	sci_t sci;
 
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 6189acb33973..d2f830ec2969 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -698,7 +698,8 @@ static int macvlan_stop(struct net_device *dev)
 	return 0;
 }
 
-static int macvlan_sync_address(struct net_device *dev, unsigned char *addr)
+static int macvlan_sync_address(struct net_device *dev,
+				const unsigned char *addr)
 {
 	struct macvlan_dev *vlan = netdev_priv(dev);
 	struct net_device *lowerdev = vlan->lowerdev;
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 7a205ddf0060..3e1b7746cce4 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -46,7 +46,7 @@ MODULE_DEVICE_TABLE(pci, vmxnet3_pciid_table);
 static int enable_mq = 1;
 
 static void
-vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, u8 *mac);
+vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, const u8 *mac);
 
 /*
  *    Enable/Disable the given intr
@@ -2806,7 +2806,7 @@ vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter)
 
 
 static void
-vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, u8 *mac)
+vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, const u8 *mac)
 {
 	u32 tmp;
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 8/8] net: atm: use address setting helpers
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (6 preceding siblings ...)
  2021-10-22 23:21 ` [PATCH net-next v2 7/8] net: drivers: " Jakub Kicinski
@ 2021-10-22 23:21 ` Jakub Kicinski
  2021-10-25 12:10 ` [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr patchwork-bot+netdevbpf
  8 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2021-10-22 23:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/atm/br2684.c | 4 +++-
 net/atm/lec.c    | 5 ++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 11854fde52db..f666f2f98ba5 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -577,10 +577,12 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
 	pr_debug("vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps, brvcc);
 	if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) {
 		unsigned char *esi = atmvcc->dev->esi;
+		const u8 one = 1;
+
 		if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5])
 			dev_addr_set(net_dev, esi);
 		else
-			net_dev->dev_addr[2] = 1;
+			dev_addr_mod(net_dev, 2, &one, 1);
 	}
 	list_add(&brvcc->brvccs, &brdev->brvccs);
 	write_unlock_irq(&devs_lock);
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 8eaea4a4bbd6..6257bf12e5a0 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -340,12 +340,12 @@ static int lec_close(struct net_device *dev)
 
 static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
 {
+	static const u8 zero_addr[ETH_ALEN] = {};
 	unsigned long flags;
 	struct net_device *dev = (struct net_device *)vcc->proto_data;
 	struct lec_priv *priv = netdev_priv(dev);
 	struct atmlec_msg *mesg;
 	struct lec_arp_table *entry;
-	int i;
 	char *tmp;		/* FIXME */
 
 	WARN_ON(refcount_sub_and_test(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc));
@@ -358,8 +358,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
 		eth_hw_addr_set(dev, mesg->content.normal.mac_addr);
 		break;
 	case l_del_mac_addr:
-		for (i = 0; i < 6; i++)
-			dev->dev_addr[i] = 0;
+		eth_hw_addr_set(dev, zero_addr);
 		break;
 	case l_addr_delete:
 		lec_addr_delete(priv, mesg->content.normal.atm_addr,
-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr
  2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (7 preceding siblings ...)
  2021-10-22 23:21 ` [PATCH net-next v2 8/8] net: atm: use address setting helpers Jakub Kicinski
@ 2021-10-25 12:10 ` patchwork-bot+netdevbpf
  8 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-25 12:10 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 22 Oct 2021 16:20:55 -0700 you wrote:
> Constify references to netdev->dev_addr and
> use appropriate helpers.
> 
> v2: s/got/go/
> 
> Jakub Kicinski (8):
>   net: core: constify mac addrs in selftests
>   net: rtnetlink: use __dev_addr_set()
>   net: phy: constify netdev->dev_addr references
>   net: bonding: constify and use dev_addr_set()
>   net: hsr: get ready for const netdev->dev_addr
>   net: caif: get ready for const netdev->dev_addr
>   net: drivers: get ready for const netdev->dev_addr
>   net: atm: use address setting helpers
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/8] net: core: constify mac addrs in selftests
    https://git.kernel.org/netdev/net-next/c/5fd348a050f7
  - [net-next,v2,2/8] net: rtnetlink: use __dev_addr_set()
    https://git.kernel.org/netdev/net-next/c/efd38f75bb04
  - [net-next,v2,3/8] net: phy: constify netdev->dev_addr references
    https://git.kernel.org/netdev/net-next/c/86466cbed173
  - [net-next,v2,4/8] net: bonding: constify and use dev_addr_set()
    https://git.kernel.org/netdev/net-next/c/6f238100d098
  - [net-next,v2,5/8] net: hsr: get ready for const netdev->dev_addr
    https://git.kernel.org/netdev/net-next/c/39c19fb9b4f9
  - [net-next,v2,6/8] net: caif: get ready for const netdev->dev_addr
    https://git.kernel.org/netdev/net-next/c/5520fb42a0a1
  - [net-next,v2,7/8] net: drivers: get ready for const netdev->dev_addr
    https://git.kernel.org/netdev/net-next/c/8bc7823ed3bd
  - [net-next,v2,8/8] net: atm: use address setting helpers
    https://git.kernel.org/netdev/net-next/c/d6b3daf24e75

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-25 12:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 23:20 [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr Jakub Kicinski
2021-10-22 23:20 ` [PATCH net-next v2 1/8] net: core: constify mac addrs in selftests Jakub Kicinski
2021-10-22 23:20 ` [PATCH net-next v2 2/8] net: rtnetlink: use __dev_addr_set() Jakub Kicinski
2021-10-22 23:20 ` [PATCH net-next v2 3/8] net: phy: constify netdev->dev_addr references Jakub Kicinski
2021-10-22 23:20 ` [PATCH net-next v2 4/8] net: bonding: constify and use dev_addr_set() Jakub Kicinski
2021-10-22 23:21 ` [PATCH net-next v2 5/8] net: hsr: get ready for const netdev->dev_addr Jakub Kicinski
2021-10-22 23:21 ` [PATCH net-next v2 6/8] net: caif: " Jakub Kicinski
2021-10-22 23:21 ` [PATCH net-next v2 7/8] net: drivers: " Jakub Kicinski
2021-10-22 23:21 ` [PATCH net-next v2 8/8] net: atm: use address setting helpers Jakub Kicinski
2021-10-25 12:10 ` [PATCH net-next v2 0/8] don't write directly to netdev->dev_addr patchwork-bot+netdevbpf

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).