All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net-next v2] net: allow setting mac address of loopback device
@ 2014-02-12  1:21 Cong Wang
  2014-02-12 11:50 ` Neil Horman
  2014-02-13 22:47 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Cong Wang @ 2014-02-12  1:21 UTC (permalink / raw)
  To: netdev
  Cc: Hannes Frederic Sowa, Neil Horman, Stephen Hemminger,
	Eric Dumazet, David S. Miller, 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.

Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

---
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index c5011e0..e7c1d5f 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -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

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

* Re: [Patch net-next v2] net: allow setting mac address of loopback device
  2014-02-12  1:21 [Patch net-next v2] net: allow setting mac address of loopback device Cong Wang
@ 2014-02-12 11:50 ` Neil Horman
  2014-02-13 22:47 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Neil Horman @ 2014-02-12 11:50 UTC (permalink / raw)
  To: Cong Wang
  Cc: netdev, Hannes Frederic Sowa, Stephen Hemminger, Eric Dumazet,
	David S. Miller

On Tue, Feb 11, 2014 at 05:21:26PM -0800, Cong Wang wrote:
> 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 <hannes@stressinduktion.org>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

> ---
> diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
> index c5011e0..e7c1d5f 100644
> --- a/drivers/net/loopback.c
> +++ b/drivers/net/loopback.c
> @@ -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
> 

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

* Re: [Patch net-next v2] net: allow setting mac address of loopback device
  2014-02-12  1:21 [Patch net-next v2] net: allow setting mac address of loopback device Cong Wang
  2014-02-12 11:50 ` Neil Horman
@ 2014-02-13 22:47 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-02-13 22:47 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, hannes, nhorman, stephen, edumazet

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue, 11 Feb 2014 17:21:26 -0800

> 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 <hannes@stressinduktion.org>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2014-02-13 22:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12  1:21 [Patch net-next v2] net: allow setting mac address of loopback device Cong Wang
2014-02-12 11:50 ` Neil Horman
2014-02-13 22:47 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.