Skip to contentSkip to conversation

net: allow setting mac address of loopback device

PATCH Applied Cong Wang 3 participants 3 messages Feb 12, 2014 – Feb 13, 2014

Subsystems (2)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v2 1/1 net: allow setting mac address of loopback device

We are trying to mirror the local traffic from lo to eth0, allowing setting mac address of lo to eth0 would make the ether addresses in these packets correct, so that we don't have to modify the ether header again.

Since usually no one cares about its mac address (all-zero), it is safe to allow those who care to set its mac address.

Cc Hannes Frederic Sowa <[email protected]>
Cc Neil Horman <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc David S. Miller <[email protected]>

---

drivers/net/loopback.c +2 -0
index c5011e0..e7c1d5f 100644
@@ -160,6 +160,7 @@ static const struct net_device_ops loopback_ops = {
 	.ndo_init      = loopback_dev_init,
 	.ndo_start_xmit= loopback_xmit,
 	.ndo_get_stats64 = loopback_get_stats64,
+	.ndo_set_mac_address = eth_mac_addr,
 };
 
 /*
@@ -174,6 +175,7 @@ static void loopback_setup(struct net_device *dev)
 	dev->tx_queue_len	= 0;
 	dev->type		= ARPHRD_LOOPBACK;	/* 0x0001*/
 	dev->flags		= IFF_LOOPBACK;
+	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE;
 	dev->priv_flags	       &= ~IFF_XMIT_DST_RELEASE;
 	dev->hw_features	= NETIF_F_ALL_TSO | NETIF_F_UFO;
 	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Cong Wang

We are trying to mirror the local traffic from lo to eth0, allowing setting mac address of lo to eth0 would make the ether addresses in these packets correct, so that we don't have to modify the ether header again.

Since usually no one cares about its mac address (all-zero), it is safe to allow those who care to set its mac address.

Quoted 7 lines
Cc Hannes Frederic Sowa <[email protected]>
Cc Neil Horman <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc David S. Miller <[email protected]>
Quoted 22 lines

---

drivers/net/loopback.c +2 -0
index c5011e0..e7c1d5f 100644
@@ -160,6 +160,7 @@ static const struct net_device_ops loopback_ops = {
 	.ndo_init      = loopback_dev_init,
 	.ndo_start_xmit= loopback_xmit,
 	.ndo_get_stats64 = loopback_get_stats64,
+	.ndo_set_mac_address = eth_mac_addr,
 };
 
 /*
@@ -174,6 +175,7 @@ static void loopback_setup(struct net_device *dev)
 	dev->tx_queue_len	= 0;
 	dev->type		= ARPHRD_LOOPBACK;	/* 0x0001*/
 	dev->flags		= IFF_LOOPBACK;
+	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE;
 	dev->priv_flags	       &= ~IFF_XMIT_DST_RELEASE;
 	dev->hw_features	= NETIF_F_ALL_TSO | NETIF_F_UFO;
 	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
maintainer Applied
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Tue, 11 Feb 2014 17:21:26 -0800

Quoted 8 lines

We are trying to mirror the local traffic from lo to eth0, allowing setting mac address of lo to eth0 would make the ether addresses in these packets correct, so that we don't have to modify the ether header again.

Since usually no one cares about its mac address (all-zero), it is safe to allow those who care to set its mac address.

Quoted 6 lines
Cc Hannes Frederic Sowa <[email protected]>
Cc Neil Horman <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc David S. Miller <[email protected]>

Applied, thanks.