Skip to contentSkip to conversation

: Macvlan update

PATCH Applied Patrick McHardy 2 participants 5 messages Nov 15, 2007 – Nov 20, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover : Macvlan update

These two patches remove an unnecessary check in macvlan_broadcast() and add the ability to change the mac address while the device is up.

Please apply, thanks.

 drivers/net/macvlan.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

Patrick McHardy (2):
[MACVLAN]: Remove unnecessary IFF_UP check [MACVLAN]: Allow setting mac address while device is up

#1 lore raw

PATCH 1/2 : Remove unnecessary IFF_UP check

[MACVLAN]: Remove unnecessary IFF_UP check

Only devices that are UP are in the hash, so macvlan_broadcast() doesn't need to check for IFF_UP.

---
commit e2d06a34b52a999e8c539d1cdef51ff523e2f2c2
tree f95a5eef37c421950ddc7318797909c0031ee948
parent 86aa441a13a474e66d484af38575609d9a0ff8ec
author Patrick McHardy <[email protected]> Thu, 15 Nov 2007 16:33:24 +0100 committer Patrick McHardy <[email protected]> Thu, 15 Nov 2007 16:33:24 +0100

 drivers/net/macvlan.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/net/macvlan.c +0 -2
index 2e4bcd5..461149c 100644
@@ -73,8 +73,6 @@ static void macvlan_broadcast(struct sk_buff *skb,
 	for (i = 0; i < MACVLAN_HASH_SIZE; i++) {
 		hlist_for_each_entry_rcu(vlan, n, &port->vlan_hash[i], hlist) {
 			dev = vlan->dev;
-			if (unlikely(!(dev->flags & IFF_UP)))
-				continue;
 
 			nskb = skb_clone(skb, GFP_ATOMIC);
 			if (nskb == NULL) {
maintainer Applied
#2 lore raw

Re: [MACVLAN 01/02]: Remove unnecessary IFF_UP check

From: Patrick McHardy <[email protected]>
Date: Thu, 15 Nov 2007 16:54:30 +0100 (MET)

Quoted 6 lines

[MACVLAN]: Remove unnecessary IFF_UP check

Only devices that are UP are in the hash, so macvlan_broadcast() doesn't need to check for IFF_UP.

Applied to net-2.6.25, thanks!

#3 lore raw

PATCH 2/2 : Allow setting mac address while device is up

In reply to Patrick McHardy

[MACVLAN]: Allow setting mac address while device is up

---
commit 3c50588260810d735231220f9a8ebaa6a6e8fb1e
tree 48ee2625502caf2454263a05b5a9869648de3aed
parent e2d06a34b52a999e8c539d1cdef51ff523e2f2c2
author Patrick McHardy <[email protected]> Thu, 15 Nov 2007 16:38:06 +0100 committer Patrick McHardy <[email protected]> Thu, 15 Nov 2007 16:38:06 +0100

 drivers/net/macvlan.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
drivers/net/macvlan.c +24 -0
index 461149c..3acf8cd 100644
@@ -213,6 +213,29 @@ static int macvlan_stop(struct net_device *dev)
 	return 0;
 }
 
+static int macvlan_set_mac_address(struct net_device *dev, void *p)
+{
+	struct macvlan_dev *vlan = netdev_priv(dev);
+	struct net_device *lowerdev = vlan->lowerdev;
+	struct sockaddr *addr = p;
+	int err;
+
+	if (!is_valid_ether_addr(addr->sa_data))
+		return -EADDRNOTAVAIL;
+
+	if (!(dev->flags & IFF_UP))
+		goto out;
+
+	err = dev_unicast_add(lowerdev, addr->sa_data, ETH_ALEN);
+	if (err < 0)
+		return err;
+	dev_unicast_delete(lowerdev, dev->dev_addr, ETH_ALEN);
+
+out:
+	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+	return 0;
+}
+
 static void macvlan_change_rx_flags(struct net_device *dev, int change)
 {
 	struct macvlan_dev *vlan = netdev_priv(dev);
@@ -300,6 +323,7 @@ static void macvlan_setup(struct net_device *dev)
 	dev->stop		= macvlan_stop;
 	dev->change_mtu		= macvlan_change_mtu;
 	dev->change_rx_flags	= macvlan_change_rx_flags;
+	dev->set_mac_address	= macvlan_set_mac_address;
 	dev->set_multicast_list	= macvlan_set_multicast_list;
 	dev->hard_start_xmit	= macvlan_hard_start_xmit;
 	dev->destructor		= free_netdev;
maintainer
#4 lore raw

Re: [MACVLAN 02/02]: Allow setting mac address while device is up

From: Patrick McHardy <[email protected]>
Date: Thu, 15 Nov 2007 16:54:32 +0100 (MET)

Quoted 3 lines

[MACVLAN]: Allow setting mac address while device is up

I'll apply this to net-2.6.25 as well, thanks!