net: introduce a list of device addresses dev_addr_list (v6)
v5 -> v6 (current): -removed so far unused static functions -corrected dev_addr_del_multiple to call del instead of add v4 -> v5: -added device address type (suggested by davem) -removed refcounting (better to have simplier code then safe potentially few bytes) v3 -> v4: -changed kzalloc to kmalloc in __hw_addr_add_ii() -ASSERT_RTNL() avoided in dev_addr_flush() and dev_addr_init() v2 -> v3: -removed unnecessary rcu read locking -moved dev_addr_flush() calling to ensure no null dereference of dev_addr v1 -> v2: -added forgotten ASSERT_RTNL to dev_addr_init and dev_addr_flush -removed unnecessary rcu_read locking in dev_addr_init -use compare_ether_addr_64bits instead of compare_ether_addr -use L1_CACHE_BYTES as size for allocating struct netdev_hw_addr -use call_rcu instead of rcu_synchronize -moved is_etherdev_addr into __KERNEL__ ifdef This patch introduces a new list in struct net_device and brings a set of functions to handle the work with device address list. The list is a replacement for the original dev_addr field and because in some situations there is need to carry several device addresses with the net device. To be backward compatible, dev_addr is made to point to the first member of the list so original drivers sees no difference. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b6907b0c70
commit
f001fde5ea
@ -182,6 +182,33 @@ static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2],
|
||||
return compare_ether_addr(addr1, addr2);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* is_etherdev_addr - Tell if given Ethernet address belongs to the device.
|
||||
* @dev: Pointer to a device structure
|
||||
* @addr: Pointer to a six-byte array containing the Ethernet address
|
||||
*
|
||||
* Compare passed address with all addresses of the device. Return true if the
|
||||
* address if one of the device addresses.
|
||||
*
|
||||
* Note that this function calls compare_ether_addr_64bits() so take care of
|
||||
* the right padding.
|
||||
*/
|
||||
static inline bool is_etherdev_addr(const struct net_device *dev,
|
||||
const u8 addr[6 + 2])
|
||||
{
|
||||
struct netdev_hw_addr *ha;
|
||||
int res = 1;
|
||||
|
||||
rcu_read_lock();
|
||||
for_each_dev_addr(dev, ha) {
|
||||
res = compare_ether_addr_64bits(addr, ha->addr);
|
||||
if (!res)
|
||||
break;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return !res;
|
||||
}
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user