diff options
Diffstat (limited to 'include/linux/etherdevice.h')
-rw-r--r-- | include/linux/etherdevice.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index a1f17abba7dc..3d7a6687d247 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h | |||
@@ -182,6 +182,33 @@ static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2], | |||
182 | return compare_ether_addr(addr1, addr2); | 182 | return compare_ether_addr(addr1, addr2); |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | |||
186 | /** | ||
187 | * is_etherdev_addr - Tell if given Ethernet address belongs to the device. | ||
188 | * @dev: Pointer to a device structure | ||
189 | * @addr: Pointer to a six-byte array containing the Ethernet address | ||
190 | * | ||
191 | * Compare passed address with all addresses of the device. Return true if the | ||
192 | * address if one of the device addresses. | ||
193 | * | ||
194 | * Note that this function calls compare_ether_addr_64bits() so take care of | ||
195 | * the right padding. | ||
196 | */ | ||
197 | static inline bool is_etherdev_addr(const struct net_device *dev, | ||
198 | const u8 addr[6 + 2]) | ||
199 | { | ||
200 | struct netdev_hw_addr *ha; | ||
201 | int res = 1; | ||
202 | |||
203 | rcu_read_lock(); | ||
204 | for_each_dev_addr(dev, ha) { | ||
205 | res = compare_ether_addr_64bits(addr, ha->addr); | ||
206 | if (!res) | ||
207 | break; | ||
208 | } | ||
209 | rcu_read_unlock(); | ||
210 | return !res; | ||
211 | } | ||
185 | #endif /* __KERNEL__ */ | 212 | #endif /* __KERNEL__ */ |
186 | 213 | ||
187 | /** | 214 | /** |