aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/etherdevice.h
diff options
context:
space:
mode:
authorTao Ren <taoren@fb.com>2019-04-23 21:43:32 -0400
committerDavid S. Miller <davem@davemloft.net>2019-04-24 00:15:15 -0400
commit1c5c12ee308aacf635c8819cd4baa3bd58f8a8b7 (patch)
tree1c1ca7d6585c26d35d0e5f06288c9337a4052243 /include/linux/etherdevice.h
parentffbf9870dcf1342592a1a26f4cf70bda39046134 (diff)
net/ncsi: handle overflow when incrementing mac address
Previously BMC's MAC address is calculated by simply adding 1 to the last byte of network controller's MAC address, and it produces incorrect result when network controller's MAC address ends with 0xFF. The problem can be fixed by calling eth_addr_inc() function to increment MAC address; besides, the MAC address is also validated before assigning to BMC. Fixes: cb10c7c0dfd9 ("net/ncsi: Add NCSI Broadcom OEM command") Signed-off-by: Tao Ren <taoren@fb.com> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/etherdevice.h')
-rw-r--r--include/linux/etherdevice.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index e2f3b21cd72a..aa8bfd6f738c 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -449,6 +449,18 @@ static inline void eth_addr_dec(u8 *addr)
449} 449}
450 450
451/** 451/**
452 * eth_addr_inc() - Increment the given MAC address.
453 * @addr: Pointer to a six-byte array containing Ethernet address to increment.
454 */
455static inline void eth_addr_inc(u8 *addr)
456{
457 u64 u = ether_addr_to_u64(addr);
458
459 u++;
460 u64_to_ether_addr(u, addr);
461}
462
463/**
452 * is_etherdev_addr - Tell if given Ethernet address belongs to the device. 464 * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
453 * @dev: Pointer to a device structure 465 * @dev: Pointer to a device structure
454 * @addr: Pointer to a six-byte array containing the Ethernet address 466 * @addr: Pointer to a six-byte array containing the Ethernet address