From: Danny Kukawka <hidden> Date: 2012-02-29 16:08:50
Validate the given MAC address directly in dev_set_mac_address()
if a .ndo_validate_addr function is available before calling
the .ndo_set_mac_address function.
Changed .ndo_validate_addr to take a second parameter containing
a sockaddr struct to be checked instead of the net_device dev_addr.
The behaviour of .ndo_validate_addr is now: if the second parameter
is NULL the net_device->dev_addr gets validate, if != NULL
the given parameter/sockaddr gets validated instead.
This patch series include adaptations for some drivers which
use .ndo_set_mac_address functions directly - to prevent double
checks and to enable validations via .ndo_validate_addr.
If these patches get accepted, an other series will follow
to cleanup the validation checks in the .ndo_set_mac_address
functions.
Note: resend for ML's
Danny Kukawka (8):
net: validate MAC address directly in dev_set_mac_address()
bnx2x: adopt bnx2x_validate_addr() to .ndo_validate_addr changes
cris/eth_v10: use dev_set_mac_address() instead of
e100_set_mac_address()
bcm63xx_enet: use dev_set_mac_address() instead of
bcm_enet_set_mac_address()
ethoc: add .ndo_validate_addr to net_device_ops
lantiq_etop: use dev_set_mac_address() instead of
ltq_etop_set_mac_address()
neterion/s2io: fix s2io_set_mac_addr() to prevent double checks
octeon: use dev_set_mac_address() instead of
octeon_mgmt_set_mac_address()
drivers/net/cris/eth_v10.c | 3 +--
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 2 +-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 13 ++++++++++---
drivers/net/ethernet/ethoc.c | 4 +---
drivers/net/ethernet/lantiq_etop.c | 4 ++--
drivers/net/ethernet/neterion/s2io.c | 5 +----
drivers/net/ethernet/octeon/octeon_mgmt.c | 6 ++----
include/linux/etherdevice.h | 2 +-
include/linux/netdevice.h | 7 +++++--
net/core/dev.c | 7 ++++++-
net/ethernet/eth.c | 12 +++++++++---
11 files changed, 39 insertions(+), 26 deletions(-)
--
1.7.8.3
From: Danny Kukawka <hidden> Date: 2012-02-29 15:43:14
Fix s2io_set_mac_addr() to prevent double validation checks from
dev_set_mac_address().
Don't use s2io_set_mac_addr() in s2io_io_resume() since it makes
no sense to copy netdev->dev_addr to itself. Use do_s2io_prog_unicast()
instead since this is what's needed and checked here.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/neterion/s2io.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
@@ -5247,9 +5247,6 @@ static int s2io_set_mac_addr(struct net_device *dev, void *p){structsockaddr*addr=p;-if(!is_valid_ether_addr(addr->sa_data))-return-EADDRNOTAVAIL;-memcpy(dev->dev_addr,addr->sa_data,dev->addr_len);/* store the MAC address in CAM */
@@ -8658,7 +8655,7 @@ static void s2io_io_resume(struct pci_dev *pdev)return;}-if(s2io_set_mac_addr(netdev,netdev->dev_addr)==FAILURE){+if(do_s2io_prog_unicast(netdev,netdev->dev_addr)==FAILURE){s2io_card_down(sp);pr_err("Can't restore mac addr after reset.\n");return;
From: Danny Kukawka <hidden> Date: 2012-02-29 15:43:17
Use dev_set_mac_address() instead of ltq_etop_set_mac_address() directly
to get validation checks for free.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/lantiq_etop.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
@@ -650,11 +650,11 @@ ltq_etop_init(struct net_device *dev)random_mac=true;}-err=ltq_etop_set_mac_address(dev,&mac);+err=dev_set_mac_address(dev,&mac);if(err)gotoerr_netdev;-/* Set addr_assign_type here, ltq_etop_set_mac_address would reset it. */+/* Set addr_assign_type here, dev_set_mac_address would reset it. */if(random_mac)dev->addr_assign_type|=NET_ADDR_RANDOM;
From: Danny Kukawka <hidden> Date: 2012-02-29 15:43:19
Use dev_set_mac_address() instead of bcm_enet_set_mac_address() directly
to get validation checks for free.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
From: Danny Kukawka <hidden> Date: 2012-02-29 15:43:21
Validate the given MAC address directly in dev_set_mac_address()
if a .ndo_validate_addr function is available before calling
the .ndo_set_mac_address function.
Changed .ndo_validate_addr to take a second parameter containing
a sockaddr struct to be checked instead of the net_device dev_addr.
The behaviour of .ndo_validate_addr is now: if the second parameter
is NULL the net_device->dev_addr gets validate, if != NULL
the given parameter/sockaddr gets validated instead.
Removed is_valid_ether_addr() check from eth_mac_addr() since
this is now done in dev_set_mac_address(). Adapted eth_validate_addr()
to the changes.
Signed-off-by: Danny Kukawka <redacted>
---
include/linux/etherdevice.h | 2 +-
include/linux/netdevice.h | 7 +++++--
net/core/dev.c | 7 ++++++-
net/ethernet/eth.c | 12 +++++++++---
4 files changed, 21 insertions(+), 7 deletions(-)
@@ -285,8 +285,6 @@ int eth_mac_addr(struct net_device *dev, void *p)if(netif_running(dev))return-EBUSY;-if(!is_valid_ether_addr(addr->sa_data))-return-EADDRNOTAVAIL;memcpy(dev->dev_addr,addr->sa_data,ETH_ALEN);/* if device marked as NET_ADDR_RANDOM, reset it */dev->addr_assign_type&=~NET_ADDR_RANDOM;
@@ -311,8 +309,16 @@ int eth_change_mtu(struct net_device *dev, int new_mtu)}EXPORT_SYMBOL(eth_change_mtu);-inteth_validate_addr(structnet_device*dev)+inteth_validate_addr(structnet_device*dev,void*addr){+structsockaddr*saddr;++if(addr){+saddr=addr;+if(!is_valid_ether_addr(saddr->sa_data))+return-EADDRNOTAVAIL;+}+if(!is_valid_ether_addr(dev->dev_addr))return-EADDRNOTAVAIL;
From: Danny Kukawka <hidden> Date: 2012-02-29 15:43:47
Use dev_set_mac_address() instead of octeon_mgmt_set_mac_address() directly
to get validation checks for free.
Add .ndo_validate_addr = eth_validate_addr to enable validation.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/octeon/octeon_mgmt.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
From: Danny Kukawka <hidden> Date: 2012-02-29 15:44:09
Add eth_validate_addr() to .ndo_validate_addr to get validation
checks in dev_set_mac_address() working. Remove
is_valid_ether_addr() from ethoc_set_mac_address() to prevent
double check.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/ethoc.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
From: Danny Kukawka <hidden> Date: 2012-02-29 15:44:45
Use dev_set_mac_address() instead of e100_set_mac_address() directly
to get validation checks for free.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/cris/eth_v10.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
From: Danny Kukawka <hidden> Date: 2012-02-29 15:45:41
Adopted bnx2x_validate_addr() to changes in .ndo_validate_addr,
handle second parameter to be validated.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
From: Ben Hutchings <hidden> Date: 2012-02-29 15:58:58
On Wed, 2012-02-29 at 16:42 +0100, Danny Kukawka wrote:
Validate the given MAC address directly in dev_set_mac_address()
if a .ndo_validate_addr function is available before calling
the .ndo_set_mac_address function.
Changed .ndo_validate_addr to take a second parameter containing
a sockaddr struct to be checked instead of the net_device dev_addr.
The behaviour of .ndo_validate_addr is now: if the second parameter
is NULL the net_device->dev_addr gets validate, if != NULL
the given parameter/sockaddr gets validated instead.
This patch series include adaptations for some drivers which
use .ndo_set_mac_address functions directly - to prevent double
checks and to enable validations via .ndo_validate_addr.
[...]
You have to do this as a single patch. The kernel and drivers should
still build at each stage.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
From: Danny Kukawka <hidden> Date: 2012-02-29 16:15:47
On Mittwoch, 29. Februar 2012, you wrote:
On Wed, 2012-02-29 at 16:42 +0100, Danny Kukawka wrote:
quoted
Validate the given MAC address directly in dev_set_mac_address()
if a .ndo_validate_addr function is available before calling
the .ndo_set_mac_address function.
Changed .ndo_validate_addr to take a second parameter containing
a sockaddr struct to be checked instead of the net_device dev_addr.
The behaviour of .ndo_validate_addr is now: if the second parameter
is NULL the net_device->dev_addr gets validate, if != NULL
the given parameter/sockaddr gets validated instead.
This patch series include adaptations for some drivers which
use .ndo_set_mac_address functions directly - to prevent double
checks and to enable validations via .ndo_validate_addr.
[...]
You have to do this as a single patch. The kernel and drivers should
still build at each stage.
Okay. In this case only patch 1 and 2 needs to be merged into one commit/patch
since the other will even work with out patch one or two. I will send a new
version of the series as soon as I get more comments on the content.
Danny
On Wed, 2012-02-29 at 16:42 +0100, Danny Kukawka wrote:
quoted hunk
Adopted bnx2x_validate_addr() to changes in .ndo_validate_addr,
handle second parameter to be validated.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
From: Danny Kukawka <hidden> Date: 2012-02-29 16:25:11
On Mittwoch, 29. Februar 2012, Danny Kukawka wrote:
On Mittwoch, 29. Februar 2012, you wrote:
quoted
On Wed, 2012-02-29 at 16:42 +0100, Danny Kukawka wrote:
quoted
Validate the given MAC address directly in dev_set_mac_address()
if a .ndo_validate_addr function is available before calling
the .ndo_set_mac_address function.
Changed .ndo_validate_addr to take a second parameter containing
a sockaddr struct to be checked instead of the net_device dev_addr.
The behaviour of .ndo_validate_addr is now: if the second parameter
is NULL the net_device->dev_addr gets validate, if != NULL
the given parameter/sockaddr gets validated instead.
This patch series include adaptations for some drivers which
use .ndo_set_mac_address functions directly - to prevent double
checks and to enable validations via .ndo_validate_addr.
[...]
You have to do this as a single patch. The kernel and drivers should
still build at each stage.
Okay. In this case only patch 1 and 2 needs to be merged into one
commit/patch since the other will even work with out patch one or two. I
will send a new version of the series as soon as I get more comments on the
content.
I have to send a new version anyway since I've accidently forgot to run
checkpatch.pl. Sorry.
Danny
From: Danny Kukawka <hidden> Date: 2012-02-29 17:09:41
On Mittwoch, 29. Februar 2012, Dmitry Kravkov wrote:
On Wed, 2012-02-29 at 16:42 +0100, Danny Kukawka wrote:
quoted
Adopted bnx2x_validate_addr() to changes in .ndo_validate_addr,
handle second parameter to be validated.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
Isn't it preferred to calculate the correct address for test and then
call bnx2x_is_valid_ether_addr() at the end?
Do you mean something like this:
int eth_validate_addr(struct net_device *dev, void *addr)
{
u8 *vaddr;
if (addr)
vaddr = ((struct sockaddr *) addr)->sa_data;
else
vaddr = dev->dev_addr;
if (!is_valid_ether_addr(vaddr))
return -EADDRNOTAVAIL;
return 0;
}
On Wed, 2012-02-29 at 18:08 +0100, Danny Kukawka wrote:
Do you mean something like this:
int eth_validate_addr(struct net_device *dev, void *addr)
{
u8 *vaddr;
if (addr)
vaddr = ((struct sockaddr *) addr)->sa_data;
else
vaddr = dev->dev_addr;
if (!is_valid_ether_addr(vaddr))
return -EADDRNOTAVAIL;
return 0;
}
On Wed, 2012-02-29 at 18:08 +0100, Danny Kukawka wrote:
On Mittwoch, 29. Februar 2012, Dmitry Kravkov wrote:
quoted
On Wed, 2012-02-29 at 16:42 +0100, Danny Kukawka wrote:
quoted
Adopted bnx2x_validate_addr() to changes in .ndo_validate_addr,
handle second parameter to be validated.
Signed-off-by: Danny Kukawka <redacted>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)