Skip to content

Commit 0953864

Browse files
Stephen Hemmingerdavem330
authored andcommitted
[NETPOLL]: no need to store local_mac
The local_mac is managed by the network device, no need to keep a spare copy and all the management problems that could cause. Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5106930 commit 0953864

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

‎drivers/net/netconsole.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,11 @@ static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
306306

307307
static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
308308
{
309+
struct net_device *dev = nt->np.dev;
310+
309311
DECLARE_MAC_BUF(mac);
310312
return snprintf(buf, PAGE_SIZE, "%s\n",
311-
print_mac(mac, nt->np.local_mac));
313+
print_mac(mac, dev->dev_addr));
312314
}
313315

314316
static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
@@ -667,18 +669,14 @@ static int netconsole_netdev_event(struct notifier_block *this,
667669
struct netconsole_target *nt;
668670
struct net_device *dev = ptr;
669671

670-
if (!(event == NETDEV_CHANGEADDR || event == NETDEV_CHANGENAME))
672+
if (!(event == NETDEV_CHANGENAME))
671673
goto done;
672674

673675
spin_lock_irqsave(&target_list_lock, flags);
674676
list_for_each_entry(nt, &target_list, list) {
675677
netconsole_target_get(nt);
676678
if (nt->np.dev == dev) {
677679
switch (event) {
678-
case NETDEV_CHANGEADDR:
679-
memcpy(nt->np.local_mac, dev->dev_addr, ETH_ALEN);
680-
break;
681-
682680
case NETDEV_CHANGENAME:
683681
strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
684682
break;

‎include/linux/netpoll.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct netpoll {
2020

2121
u32 local_ip, remote_ip;
2222
u16 local_port, remote_port;
23-
u8 local_mac[ETH_ALEN], remote_mac[ETH_ALEN];
23+
u8 remote_mac[ETH_ALEN];
2424
};
2525

2626
struct netpoll_info {

‎net/core/netpoll.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
360360
eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
361361
skb_reset_mac_header(skb);
362362
skb->protocol = eth->h_proto = htons(ETH_P_IP);
363-
memcpy(eth->h_source, np->local_mac, 6);
364-
memcpy(eth->h_dest, np->remote_mac, 6);
363+
memcpy(eth->h_source, np->dev->dev_addr, ETH_ALEN);
364+
memcpy(eth->h_dest, np->remote_mac, ETH_ALEN);
365365

366366
skb->dev = np->dev;
367367

@@ -431,7 +431,7 @@ static void arp_reply(struct sk_buff *skb)
431431

432432
/* Fill the device header for the ARP frame */
433433
if (dev_hard_header(send_skb, skb->dev, ptype,
434-
sha, np->local_mac,
434+
sha, np->dev->dev_addr,
435435
send_skb->len) < 0) {
436436
kfree_skb(send_skb);
437437
return;
@@ -737,9 +737,6 @@ int netpoll_setup(struct netpoll *np)
737737
}
738738
}
739739

740-
if (is_zero_ether_addr(np->local_mac) && ndev->dev_addr)
741-
memcpy(np->local_mac, ndev->dev_addr, 6);
742-
743740
if (!np->local_ip) {
744741
rcu_read_lock();
745742
in_dev = __in_dev_get_rcu(ndev);

0 commit comments

Comments
 (0)