Commit 45f850c1 authored by David S. Miller's avatar David S. Miller

Merge branch 'dev_addr-dont-write'

Jakub Kicinski says:

====================
don't write directly to netdev->dev_addr

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

v2: s/got/go/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4973056c d6b3daf2
...@@ -50,7 +50,7 @@ struct arp_pkt { ...@@ -50,7 +50,7 @@ struct arp_pkt {
#pragma pack() #pragma pack()
/* Forward declaration */ /* 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); bool strict_match);
static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp); static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp);
static void rlb_src_unlink(struct bonding *bond, u32 index); static void rlb_src_unlink(struct bonding *bond, u32 index);
...@@ -353,7 +353,8 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond) ...@@ -353,7 +353,8 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
* *
* Caller must hold RTNL * 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); 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) ...@@ -904,7 +905,7 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
/*********************** tlb/rlb shared functions *********************/ /*********************** 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) __be16 vlan_proto, u16 vid)
{ {
struct learning_pkt pkt; struct learning_pkt pkt;
...@@ -940,7 +941,7 @@ static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[], ...@@ -940,7 +941,7 @@ static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
struct alb_walk_data { struct alb_walk_data {
struct bonding *bond; struct bonding *bond;
struct slave *slave; struct slave *slave;
u8 *mac_addr; const u8 *mac_addr;
bool strict_match; bool strict_match;
}; };
...@@ -949,9 +950,9 @@ static int alb_upper_dev_walk(struct net_device *upper, ...@@ -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; struct alb_walk_data *data = (struct alb_walk_data *)priv->data;
bool strict_match = data->strict_match; bool strict_match = data->strict_match;
const u8 *mac_addr = data->mac_addr;
struct bonding *bond = data->bond; struct bonding *bond = data->bond;
struct slave *slave = data->slave; struct slave *slave = data->slave;
u8 *mac_addr = data->mac_addr;
struct bond_vlan_tag *tags; struct bond_vlan_tag *tags;
if (is_vlan_dev(upper) && if (is_vlan_dev(upper) &&
...@@ -982,7 +983,7 @@ static int alb_upper_dev_walk(struct net_device *upper, ...@@ -982,7 +983,7 @@ static int alb_upper_dev_walk(struct net_device *upper,
return 0; 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) bool strict_match)
{ {
struct bonding *bond = bond_get_bond_by_slave(slave); 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[], ...@@ -1006,14 +1007,14 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
rcu_read_unlock(); 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) unsigned int len)
{ {
struct net_device *dev = slave->dev; struct net_device *dev = slave->dev;
struct sockaddr_storage ss; struct sockaddr_storage ss;
if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { if (BOND_MODE(slave->bond) == BOND_MODE_TLB) {
memcpy(dev->dev_addr, addr, len); __dev_addr_set(dev, addr, len);
return 0; return 0;
} }
...@@ -1242,8 +1243,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr) ...@@ -1242,8 +1243,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
res = dev_set_mac_address(slave->dev, addr, NULL); res = dev_set_mac_address(slave->dev, addr, NULL);
/* restore net_device's hw address */ /* restore net_device's hw address */
bond_hw_addr_copy(slave->dev->dev_addr, tmp_addr, dev_addr_set(slave->dev, tmp_addr);
slave->dev->addr_len);
if (res) if (res)
goto unwind; goto unwind;
...@@ -1263,8 +1263,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr) ...@@ -1263,8 +1263,7 @@ static int alb_set_mac_address(struct bonding *bond, void *addr)
rollback_slave->dev->addr_len); rollback_slave->dev->addr_len);
dev_set_mac_address(rollback_slave->dev, dev_set_mac_address(rollback_slave->dev,
(struct sockaddr *)&ss, NULL); (struct sockaddr *)&ss, NULL);
bond_hw_addr_copy(rollback_slave->dev->dev_addr, tmp_addr, dev_addr_set(rollback_slave->dev, tmp_addr);
rollback_slave->dev->addr_len);
} }
return res; return res;
...@@ -1727,8 +1726,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave ...@@ -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, dev_set_mac_address(new_slave->dev, (struct sockaddr *)&ss,
NULL); NULL);
bond_hw_addr_copy(new_slave->dev->dev_addr, tmp_addr, dev_addr_set(new_slave->dev, tmp_addr);
new_slave->dev->addr_len);
} }
/* curr_active_slave must be set before calling alb_swap_mac_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) ...@@ -1761,7 +1759,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
if (res) if (res)
return 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. /* 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 * Otherwise we'll need to pass the new address to it and handle
......
...@@ -923,7 +923,7 @@ static int bond_set_dev_addr(struct net_device *bond_dev, ...@@ -923,7 +923,7 @@ static int bond_set_dev_addr(struct net_device *bond_dev,
if (err) if (err)
return 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; bond_dev->addr_assign_type = NET_ADDR_STOLEN;
call_netdevice_notifiers(NETDEV_CHANGEADDR, bond_dev); call_netdevice_notifiers(NETDEV_CHANGEADDR, bond_dev);
return 0; return 0;
......
...@@ -250,7 +250,7 @@ static bool send_sci(const struct macsec_secy *secy) ...@@ -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); (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; sci_t sci;
......
...@@ -698,7 +698,8 @@ static int macvlan_stop(struct net_device *dev) ...@@ -698,7 +698,8 @@ static int macvlan_stop(struct net_device *dev)
return 0; 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 macvlan_dev *vlan = netdev_priv(dev);
struct net_device *lowerdev = vlan->lowerdev; struct net_device *lowerdev = vlan->lowerdev;
......
...@@ -182,7 +182,7 @@ static int dp83867_set_wol(struct phy_device *phydev, ...@@ -182,7 +182,7 @@ static int dp83867_set_wol(struct phy_device *phydev,
{ {
struct net_device *ndev = phydev->attached_dev; struct net_device *ndev = phydev->attached_dev;
u16 val_rxcfg, val_micr; u16 val_rxcfg, val_micr;
u8 *mac; const u8 *mac;
val_rxcfg = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG); val_rxcfg = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG);
val_micr = phy_read(phydev, MII_DP83867_MICR); val_micr = phy_read(phydev, MII_DP83867_MICR);
...@@ -193,7 +193,7 @@ static int dp83867_set_wol(struct phy_device *phydev, ...@@ -193,7 +193,7 @@ static int dp83867_set_wol(struct phy_device *phydev,
val_micr |= MII_DP83867_MICR_WOL_INT_EN; val_micr |= MII_DP83867_MICR_WOL_INT_EN;
if (wol->wolopts & WAKE_MAGIC) { if (wol->wolopts & WAKE_MAGIC) {
mac = (u8 *)ndev->dev_addr; mac = (const u8 *)ndev->dev_addr;
if (!is_valid_ether_addr(mac)) if (!is_valid_ether_addr(mac))
return -EINVAL; return -EINVAL;
......
...@@ -246,7 +246,7 @@ static int dp83869_set_wol(struct phy_device *phydev, ...@@ -246,7 +246,7 @@ static int dp83869_set_wol(struct phy_device *phydev,
{ {
struct net_device *ndev = phydev->attached_dev; struct net_device *ndev = phydev->attached_dev;
int val_rxcfg, val_micr; int val_rxcfg, val_micr;
u8 *mac; const u8 *mac;
int ret; int ret;
val_rxcfg = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_RXFCFG); val_rxcfg = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_RXFCFG);
...@@ -264,7 +264,7 @@ static int dp83869_set_wol(struct phy_device *phydev, ...@@ -264,7 +264,7 @@ static int dp83869_set_wol(struct phy_device *phydev,
if (wol->wolopts & WAKE_MAGIC || if (wol->wolopts & WAKE_MAGIC ||
wol->wolopts & WAKE_MAGICSECURE) { wol->wolopts & WAKE_MAGICSECURE) {
mac = (u8 *)ndev->dev_addr; mac = (const u8 *)ndev->dev_addr;
if (!is_valid_ether_addr(mac)) if (!is_valid_ether_addr(mac))
return -EINVAL; return -EINVAL;
......
...@@ -46,7 +46,7 @@ MODULE_DEVICE_TABLE(pci, vmxnet3_pciid_table); ...@@ -46,7 +46,7 @@ MODULE_DEVICE_TABLE(pci, vmxnet3_pciid_table);
static int enable_mq = 1; static int enable_mq = 1;
static void 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 * Enable/Disable the given intr
...@@ -2806,7 +2806,7 @@ vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter) ...@@ -2806,7 +2806,7 @@ vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter)
static void 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; u32 tmp;
......
...@@ -577,10 +577,12 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg) ...@@ -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); pr_debug("vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps, brvcc);
if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) { if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) {
unsigned char *esi = atmvcc->dev->esi; unsigned char *esi = atmvcc->dev->esi;
const u8 one = 1;
if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5]) if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5])
dev_addr_set(net_dev, esi); dev_addr_set(net_dev, esi);
else else
net_dev->dev_addr[2] = 1; dev_addr_mod(net_dev, 2, &one, 1);
} }
list_add(&brvcc->brvccs, &brdev->brvccs); list_add(&brvcc->brvccs, &brdev->brvccs);
write_unlock_irq(&devs_lock); write_unlock_irq(&devs_lock);
......
...@@ -340,12 +340,12 @@ static int lec_close(struct net_device *dev) ...@@ -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 int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
{ {
static const u8 zero_addr[ETH_ALEN] = {};
unsigned long flags; unsigned long flags;
struct net_device *dev = (struct net_device *)vcc->proto_data; struct net_device *dev = (struct net_device *)vcc->proto_data;
struct lec_priv *priv = netdev_priv(dev); struct lec_priv *priv = netdev_priv(dev);
struct atmlec_msg *mesg; struct atmlec_msg *mesg;
struct lec_arp_table *entry; struct lec_arp_table *entry;
int i;
char *tmp; /* FIXME */ char *tmp; /* FIXME */
WARN_ON(refcount_sub_and_test(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc)); 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) ...@@ -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); eth_hw_addr_set(dev, mesg->content.normal.mac_addr);
break; break;
case l_del_mac_addr: case l_del_mac_addr:
for (i = 0; i < 6; i++) eth_hw_addr_set(dev, zero_addr);
dev->dev_addr[i] = 0;
break; break;
case l_addr_delete: case l_addr_delete:
lec_addr_delete(priv, mesg->content.normal.atm_addr, lec_addr_delete(priv, mesg->content.normal.atm_addr,
......
...@@ -81,7 +81,7 @@ static void cfusbl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, ...@@ -81,7 +81,7 @@ static void cfusbl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
layr->up->ctrlcmd(layr->up, ctrl, layr->id); 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]) u8 braddr[ETH_ALEN])
{ {
struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC); struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC);
......
...@@ -3204,7 +3204,7 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname, ...@@ -3204,7 +3204,7 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname,
dev->mtu = mtu; dev->mtu = mtu;
} }
if (tb[IFLA_ADDRESS]) { if (tb[IFLA_ADDRESS]) {
memcpy(dev->dev_addr, nla_data(tb[IFLA_ADDRESS]), __dev_addr_set(dev, nla_data(tb[IFLA_ADDRESS]),
nla_len(tb[IFLA_ADDRESS])); nla_len(tb[IFLA_ADDRESS]));
dev->addr_assign_type = NET_ADDR_SET; dev->addr_assign_type = NET_ADDR_SET;
} }
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include <net/udp.h> #include <net/udp.h>
struct net_packet_attrs { struct net_packet_attrs {
unsigned char *src; const unsigned char *src;
unsigned char *dst; const unsigned char *dst;
u32 ip_src; u32 ip_src;
u32 ip_dst; u32 ip_dst;
bool tcp; bool tcp;
...@@ -173,8 +173,8 @@ static int net_test_loopback_validate(struct sk_buff *skb, ...@@ -173,8 +173,8 @@ static int net_test_loopback_validate(struct sk_buff *skb,
struct net_device *orig_ndev) struct net_device *orig_ndev)
{ {
struct net_test_priv *tpriv = pt->af_packet_priv; struct net_test_priv *tpriv = pt->af_packet_priv;
unsigned char *src = tpriv->packet->src; const unsigned char *src = tpriv->packet->src;
unsigned char *dst = tpriv->packet->dst; const unsigned char *dst = tpriv->packet->dst;
struct netsfhdr *shdr; struct netsfhdr *shdr;
struct ethhdr *ehdr; struct ethhdr *ehdr;
struct udphdr *uhdr; struct udphdr *uhdr;
......
...@@ -76,8 +76,8 @@ static struct hsr_node *find_node_by_addr_A(struct list_head *node_db, ...@@ -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. * frames from self that's been looped over the HSR ring.
*/ */
int hsr_create_self_node(struct hsr_priv *hsr, int hsr_create_self_node(struct hsr_priv *hsr,
unsigned char addr_a[ETH_ALEN], const unsigned char addr_a[ETH_ALEN],
unsigned char addr_b[ETH_ALEN]) const unsigned char addr_b[ETH_ALEN])
{ {
struct list_head *self_node_db = &hsr->self_node_db; struct list_head *self_node_db = &hsr->self_node_db;
struct hsr_node *node, *oldnode; struct hsr_node *node, *oldnode;
......
...@@ -48,8 +48,8 @@ int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node, ...@@ -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); void hsr_prune_nodes(struct timer_list *t);
int hsr_create_self_node(struct hsr_priv *hsr, int hsr_create_self_node(struct hsr_priv *hsr,
unsigned char addr_a[ETH_ALEN], const unsigned char addr_a[ETH_ALEN],
unsigned char addr_b[ETH_ALEN]); const unsigned char addr_b[ETH_ALEN]);
void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos, void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
unsigned char addr[ETH_ALEN]); unsigned char addr[ETH_ALEN]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment