diff options
Diffstat (limited to 'net/ethernet/eth.c')
-rw-r--r-- | net/ethernet/eth.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index bc39c8c8f589..a36c85eab5b4 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
@@ -272,6 +272,36 @@ void eth_header_cache_update(struct hh_cache *hh, | |||
272 | EXPORT_SYMBOL(eth_header_cache_update); | 272 | EXPORT_SYMBOL(eth_header_cache_update); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | * eth_prepare_mac_addr_change - prepare for mac change | ||
276 | * @dev: network device | ||
277 | * @p: socket address | ||
278 | */ | ||
279 | int eth_prepare_mac_addr_change(struct net_device *dev, void *p) | ||
280 | { | ||
281 | struct sockaddr *addr = p; | ||
282 | |||
283 | if (!(dev->priv_flags & IFF_LIVE_ADDR_CHANGE) && netif_running(dev)) | ||
284 | return -EBUSY; | ||
285 | if (!is_valid_ether_addr(addr->sa_data)) | ||
286 | return -EADDRNOTAVAIL; | ||
287 | return 0; | ||
288 | } | ||
289 | EXPORT_SYMBOL(eth_prepare_mac_addr_change); | ||
290 | |||
291 | /** | ||
292 | * eth_commit_mac_addr_change - commit mac change | ||
293 | * @dev: network device | ||
294 | * @p: socket address | ||
295 | */ | ||
296 | void eth_commit_mac_addr_change(struct net_device *dev, void *p) | ||
297 | { | ||
298 | struct sockaddr *addr = p; | ||
299 | |||
300 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | ||
301 | } | ||
302 | EXPORT_SYMBOL(eth_commit_mac_addr_change); | ||
303 | |||
304 | /** | ||
275 | * eth_mac_addr - set new Ethernet hardware address | 305 | * eth_mac_addr - set new Ethernet hardware address |
276 | * @dev: network device | 306 | * @dev: network device |
277 | * @p: socket address | 307 | * @p: socket address |
@@ -283,13 +313,12 @@ EXPORT_SYMBOL(eth_header_cache_update); | |||
283 | */ | 313 | */ |
284 | int eth_mac_addr(struct net_device *dev, void *p) | 314 | int eth_mac_addr(struct net_device *dev, void *p) |
285 | { | 315 | { |
286 | struct sockaddr *addr = p; | 316 | int ret; |
287 | 317 | ||
288 | if (!(dev->priv_flags & IFF_LIVE_ADDR_CHANGE) && netif_running(dev)) | 318 | ret = eth_prepare_mac_addr_change(dev, p); |
289 | return -EBUSY; | 319 | if (ret < 0) |
290 | if (!is_valid_ether_addr(addr->sa_data)) | 320 | return ret; |
291 | return -EADDRNOTAVAIL; | 321 | eth_commit_mac_addr_change(dev, p); |
292 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | ||
293 | return 0; | 322 | return 0; |
294 | } | 323 | } |
295 | EXPORT_SYMBOL(eth_mac_addr); | 324 | EXPORT_SYMBOL(eth_mac_addr); |