Skip to content

Commit db01868

Browse files
vladimirolteanPaolo Abeni
authored andcommitted
net: introduce iterators over synced hw addresses
Some network drivers use __dev_mc_sync()/__dev_uc_sync() and therefore program the hardware only with addresses with a non-zero sync_cnt. Some of the above drivers also need to save/restore the address filtering lists when certain events happen, and they need to walk through the struct net_device :: uc and struct net_device :: mc lists. But these lists contain unsynced addresses too. To keep the appearance of an elementary form of data encapsulation, provide iterators through these lists that only look at entries with a non-zero sync_cnt, instead of filtering entries out from device drivers. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 42e53b4 commit db01868

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/linux/netdevice.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,17 @@ struct netdev_hw_addr_list {
253253
#define netdev_uc_empty(dev) netdev_hw_addr_list_empty(&(dev)->uc)
254254
#define netdev_for_each_uc_addr(ha, dev) \
255255
netdev_hw_addr_list_for_each(ha, &(dev)->uc)
256+
#define netdev_for_each_synced_uc_addr(_ha, _dev) \
257+
netdev_for_each_uc_addr((_ha), (_dev)) \
258+
if ((_ha)->sync_cnt)
256259

257260
#define netdev_mc_count(dev) netdev_hw_addr_list_count(&(dev)->mc)
258261
#define netdev_mc_empty(dev) netdev_hw_addr_list_empty(&(dev)->mc)
259262
#define netdev_for_each_mc_addr(ha, dev) \
260263
netdev_hw_addr_list_for_each(ha, &(dev)->mc)
264+
#define netdev_for_each_synced_mc_addr(_ha, _dev) \
265+
netdev_for_each_mc_addr((_ha), (_dev)) \
266+
if ((_ha)->sync_cnt)
261267

262268
struct hh_cache {
263269
unsigned int hh_len;

0 commit comments

Comments
 (0)