Commit 400f17d3 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-use-dev_addr_set-in-hamradio-and-ip-tunnels'

Jakub Kicinski says:

====================
net: use dev_addr_set() in hamradio and ip tunnels

Commit 406f42fa ("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 got through appropriate helpers.
====================

Link: https://lore.kernel.org/r/20211012160634.4152690-1-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents fe83fe73 5a1b7e1a
...@@ -288,7 +288,7 @@ static int sp_set_mac_address(struct net_device *dev, void *addr) ...@@ -288,7 +288,7 @@ static int sp_set_mac_address(struct net_device *dev, void *addr)
netif_tx_lock_bh(dev); netif_tx_lock_bh(dev);
netif_addr_lock(dev); netif_addr_lock(dev);
memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN); __dev_addr_set(dev, &sa->sax25_call, AX25_ADDR_LEN);
netif_addr_unlock(dev); netif_addr_unlock(dev);
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
...@@ -317,7 +317,7 @@ static void sp_setup(struct net_device *dev) ...@@ -317,7 +317,7 @@ static void sp_setup(struct net_device *dev)
/* Only activated in AX.25 mode */ /* Only activated in AX.25 mode */
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); dev_addr_set(dev, (u8 *)&ax25_defaddr);
dev->flags = 0; dev->flags = 0;
} }
...@@ -726,7 +726,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file, ...@@ -726,7 +726,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
} }
netif_tx_lock_bh(dev); netif_tx_lock_bh(dev);
memcpy(dev->dev_addr, &addr, AX25_ADDR_LEN); __dev_addr_set(dev, &addr, AX25_ADDR_LEN);
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
err = 0; err = 0;
break; break;
......
...@@ -1159,7 +1159,7 @@ static void baycom_probe(struct net_device *dev) ...@@ -1159,7 +1159,7 @@ static void baycom_probe(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */ dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */
dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */ dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &null_ax25_address, AX25_ADDR_LEN); dev_addr_set(dev, (u8 *)&null_ax25_address);
dev->tx_queue_len = 16; dev->tx_queue_len = 16;
/* New style flags */ /* New style flags */
......
...@@ -457,9 +457,6 @@ static void bpq_setup(struct net_device *dev) ...@@ -457,9 +457,6 @@ static void bpq_setup(struct net_device *dev)
dev->netdev_ops = &bpq_netdev_ops; dev->netdev_ops = &bpq_netdev_ops;
dev->needs_free_netdev = true; dev->needs_free_netdev = true;
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
dev->flags = 0; dev->flags = 0;
dev->features = NETIF_F_LLTX; /* Allow recursion */ dev->features = NETIF_F_LLTX; /* Allow recursion */
...@@ -472,6 +469,8 @@ static void bpq_setup(struct net_device *dev) ...@@ -472,6 +469,8 @@ static void bpq_setup(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; dev->mtu = AX25_DEF_PACLEN;
dev->addr_len = AX25_ADDR_LEN; dev->addr_len = AX25_ADDR_LEN;
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
dev_addr_set(dev, (u8 *)&ax25_defaddr);
} }
/* /*
......
...@@ -426,7 +426,7 @@ static void __init dev_setup(struct net_device *dev) ...@@ -426,7 +426,7 @@ static void __init dev_setup(struct net_device *dev)
dev->addr_len = AX25_ADDR_LEN; dev->addr_len = AX25_ADDR_LEN;
dev->tx_queue_len = 64; dev->tx_queue_len = 64;
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); dev_addr_set(dev, (u8 *)&ax25_defaddr);
} }
static const struct net_device_ops scc_netdev_ops = { static const struct net_device_ops scc_netdev_ops = {
......
...@@ -675,7 +675,7 @@ static void hdlcdrv_setup(struct net_device *dev) ...@@ -675,7 +675,7 @@ static void hdlcdrv_setup(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */ dev->mtu = AX25_DEF_PACLEN; /* eth_mtu is the default */
dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */ dev->addr_len = AX25_ADDR_LEN; /* sizeof an ax.25 address */
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); dev_addr_set(dev, (u8 *)&ax25_defaddr);
dev->tx_queue_len = 16; dev->tx_queue_len = 16;
} }
......
...@@ -344,7 +344,7 @@ static int ax_set_mac_address(struct net_device *dev, void *addr) ...@@ -344,7 +344,7 @@ static int ax_set_mac_address(struct net_device *dev, void *addr)
netif_tx_lock_bh(dev); netif_tx_lock_bh(dev);
netif_addr_lock(dev); netif_addr_lock(dev);
memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN); __dev_addr_set(dev, &sa->sax25_call, AX25_ADDR_LEN);
netif_addr_unlock(dev); netif_addr_unlock(dev);
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
...@@ -647,7 +647,7 @@ static void ax_setup(struct net_device *dev) ...@@ -647,7 +647,7 @@ static void ax_setup(struct net_device *dev)
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); dev_addr_set(dev, (u8 *)&ax25_defaddr);
dev->flags = IFF_BROADCAST | IFF_MULTICAST; dev->flags = IFF_BROADCAST | IFF_MULTICAST;
} }
...@@ -850,7 +850,7 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file, ...@@ -850,7 +850,7 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
} }
netif_tx_lock_bh(dev); netif_tx_lock_bh(dev);
memcpy(dev->dev_addr, addr, AX25_ADDR_LEN); __dev_addr_set(dev, addr, AX25_ADDR_LEN);
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
err = 0; err = 0;
......
...@@ -1563,9 +1563,6 @@ static void scc_net_setup(struct net_device *dev) ...@@ -1563,9 +1563,6 @@ static void scc_net_setup(struct net_device *dev)
dev->netdev_ops = &scc_netdev_ops; dev->netdev_ops = &scc_netdev_ops;
dev->header_ops = &ax25_header_ops; dev->header_ops = &ax25_header_ops;
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
dev->flags = 0; dev->flags = 0;
dev->type = ARPHRD_AX25; dev->type = ARPHRD_AX25;
...@@ -1573,6 +1570,8 @@ static void scc_net_setup(struct net_device *dev) ...@@ -1573,6 +1570,8 @@ static void scc_net_setup(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; dev->mtu = AX25_DEF_PACLEN;
dev->addr_len = AX25_ADDR_LEN; dev->addr_len = AX25_ADDR_LEN;
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
dev_addr_set(dev, (u8 *)&ax25_defaddr);
} }
/* ----> open network device <---- */ /* ----> open network device <---- */
......
...@@ -1107,7 +1107,7 @@ static void yam_setup(struct net_device *dev) ...@@ -1107,7 +1107,7 @@ static void yam_setup(struct net_device *dev)
dev->mtu = AX25_MTU; dev->mtu = AX25_MTU;
dev->addr_len = AX25_ADDR_LEN; dev->addr_len = AX25_ADDR_LEN;
memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); dev_addr_set(dev, (u8 *)&ax25_defaddr);
} }
static int __init yam_init_driver(void) static int __init yam_init_driver(void)
......
...@@ -4643,7 +4643,7 @@ void __hw_addr_init(struct netdev_hw_addr_list *list); ...@@ -4643,7 +4643,7 @@ void __hw_addr_init(struct netdev_hw_addr_list *list);
/* Functions used for device addresses handling */ /* Functions used for device addresses handling */
static inline void static inline void
__dev_addr_set(struct net_device *dev, const u8 *addr, size_t len) __dev_addr_set(struct net_device *dev, const void *addr, size_t len)
{ {
memcpy(dev->dev_addr, addr, len); memcpy(dev->dev_addr, addr, len);
} }
...@@ -4655,7 +4655,7 @@ static inline void dev_addr_set(struct net_device *dev, const u8 *addr) ...@@ -4655,7 +4655,7 @@ static inline void dev_addr_set(struct net_device *dev, const u8 *addr)
static inline void static inline void
dev_addr_mod(struct net_device *dev, unsigned int offset, dev_addr_mod(struct net_device *dev, unsigned int offset,
const u8 *addr, size_t len) const void *addr, size_t len)
{ {
memcpy(&dev->dev_addr[offset], addr, len); memcpy(&dev->dev_addr[offset], addr, len);
} }
......
...@@ -986,7 +986,7 @@ static int ipgre_tunnel_init(struct net_device *dev) ...@@ -986,7 +986,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
__gre_tunnel_init(dev); __gre_tunnel_init(dev);
memcpy(dev->dev_addr, &iph->saddr, 4); __dev_addr_set(dev, &iph->saddr, 4);
memcpy(dev->broadcast, &iph->daddr, 4); memcpy(dev->broadcast, &iph->daddr, 4);
dev->flags = IFF_NOARP; dev->flags = IFF_NOARP;
......
...@@ -834,7 +834,7 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn, ...@@ -834,7 +834,7 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn,
t->parms.i_key = p->i_key; t->parms.i_key = p->i_key;
t->parms.o_key = p->o_key; t->parms.o_key = p->o_key;
if (dev->type != ARPHRD_ETHER) { if (dev->type != ARPHRD_ETHER) {
memcpy(dev->dev_addr, &p->iph.saddr, 4); __dev_addr_set(dev, &p->iph.saddr, 4);
memcpy(dev->broadcast, &p->iph.daddr, 4); memcpy(dev->broadcast, &p->iph.daddr, 4);
} }
ip_tunnel_add(itn, t); ip_tunnel_add(itn, t);
......
...@@ -425,7 +425,7 @@ static int vti_tunnel_init(struct net_device *dev) ...@@ -425,7 +425,7 @@ static int vti_tunnel_init(struct net_device *dev)
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
struct iphdr *iph = &tunnel->parms.iph; struct iphdr *iph = &tunnel->parms.iph;
memcpy(dev->dev_addr, &iph->saddr, 4); __dev_addr_set(dev, &iph->saddr, 4);
memcpy(dev->broadcast, &iph->daddr, 4); memcpy(dev->broadcast, &iph->daddr, 4);
dev->flags = IFF_NOARP; dev->flags = IFF_NOARP;
......
...@@ -380,7 +380,7 @@ static int ipip_tunnel_init(struct net_device *dev) ...@@ -380,7 +380,7 @@ static int ipip_tunnel_init(struct net_device *dev)
{ {
struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel *tunnel = netdev_priv(dev);
memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4); __dev_addr_set(dev, &tunnel->parms.iph.saddr, 4);
memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
tunnel->tun_hlen = 0; tunnel->tun_hlen = 0;
......
...@@ -1088,7 +1088,7 @@ static void ip6gre_tnl_link_config_common(struct ip6_tnl *t) ...@@ -1088,7 +1088,7 @@ static void ip6gre_tnl_link_config_common(struct ip6_tnl *t)
struct flowi6 *fl6 = &t->fl.u.ip6; struct flowi6 *fl6 = &t->fl.u.ip6;
if (dev->type != ARPHRD_ETHER) { if (dev->type != ARPHRD_ETHER) {
memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); __dev_addr_set(dev, &p->laddr, sizeof(struct in6_addr));
memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr)); memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));
} }
...@@ -1521,7 +1521,7 @@ static int ip6gre_tunnel_init(struct net_device *dev) ...@@ -1521,7 +1521,7 @@ static int ip6gre_tunnel_init(struct net_device *dev)
if (tunnel->parms.collect_md) if (tunnel->parms.collect_md)
return 0; return 0;
memcpy(dev->dev_addr, &tunnel->parms.laddr, sizeof(struct in6_addr)); __dev_addr_set(dev, &tunnel->parms.laddr, sizeof(struct in6_addr));
memcpy(dev->broadcast, &tunnel->parms.raddr, sizeof(struct in6_addr)); memcpy(dev->broadcast, &tunnel->parms.raddr, sizeof(struct in6_addr));
if (ipv6_addr_any(&tunnel->parms.raddr)) if (ipv6_addr_any(&tunnel->parms.raddr))
......
...@@ -1449,7 +1449,7 @@ static void ip6_tnl_link_config(struct ip6_tnl *t) ...@@ -1449,7 +1449,7 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
unsigned int mtu; unsigned int mtu;
int t_hlen; int t_hlen;
memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); __dev_addr_set(dev, &p->laddr, sizeof(struct in6_addr));
memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr)); memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));
/* Set up flowi template */ /* Set up flowi template */
......
...@@ -660,7 +660,7 @@ static void vti6_link_config(struct ip6_tnl *t, bool keep_mtu) ...@@ -660,7 +660,7 @@ static void vti6_link_config(struct ip6_tnl *t, bool keep_mtu)
struct net_device *tdev = NULL; struct net_device *tdev = NULL;
int mtu; int mtu;
memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); __dev_addr_set(dev, &p->laddr, sizeof(struct in6_addr));
memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr)); memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));
p->flags &= ~(IP6_TNL_F_CAP_XMIT | IP6_TNL_F_CAP_RCV | p->flags &= ~(IP6_TNL_F_CAP_XMIT | IP6_TNL_F_CAP_RCV |
......
...@@ -204,7 +204,7 @@ static int ipip6_tunnel_create(struct net_device *dev) ...@@ -204,7 +204,7 @@ static int ipip6_tunnel_create(struct net_device *dev)
struct sit_net *sitn = net_generic(net, sit_net_id); struct sit_net *sitn = net_generic(net, sit_net_id);
int err; int err;
memcpy(dev->dev_addr, &t->parms.iph.saddr, 4); __dev_addr_set(dev, &t->parms.iph.saddr, 4);
memcpy(dev->broadcast, &t->parms.iph.daddr, 4); memcpy(dev->broadcast, &t->parms.iph.daddr, 4);
if ((__force u16)t->parms.i_flags & SIT_ISATAP) if ((__force u16)t->parms.i_flags & SIT_ISATAP)
...@@ -1149,7 +1149,7 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p, ...@@ -1149,7 +1149,7 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p,
synchronize_net(); synchronize_net();
t->parms.iph.saddr = p->iph.saddr; t->parms.iph.saddr = p->iph.saddr;
t->parms.iph.daddr = p->iph.daddr; t->parms.iph.daddr = p->iph.daddr;
memcpy(t->dev->dev_addr, &p->iph.saddr, 4); __dev_addr_set(t->dev, &p->iph.saddr, 4);
memcpy(t->dev->broadcast, &p->iph.daddr, 4); memcpy(t->dev->broadcast, &p->iph.daddr, 4);
ipip6_tunnel_link(sitn, t); ipip6_tunnel_link(sitn, t);
t->parms.iph.ttl = p->iph.ttl; t->parms.iph.ttl = p->iph.ttl;
......
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