Skip to content

Commit 78cd408

Browse files
Stanislav Fomichevkuba-moo
authored andcommitted
net: add missing instance lock to dev_set_promiscuity
Accidentally spotted while trying to understand what else needs to be renamed to netif_ prefix. Most of the calls to dev_set_promiscuity are adjacent to dev_set_allmulti or dev_disable_lro so it should be safe to add the lock. Note that new netif_set_promiscuity is currently unused, the locked paths call __dev_set_promiscuity directly. Fixes: ad7c7b2 ("net: hold netdev instance lock during sysfs operations") Signed-off-by: Stanislav Fomichev <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 08e9f2d commit 78cd408

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,6 +4972,7 @@ static inline void __dev_mc_unsync(struct net_device *dev,
49724972

49734973
/* Functions used for secondary unicast and multicast support */
49744974
void dev_set_rx_mode(struct net_device *dev);
4975+
int netif_set_promiscuity(struct net_device *dev, int inc);
49754976
int dev_set_promiscuity(struct net_device *dev, int inc);
49764977
int netif_set_allmulti(struct net_device *dev, int inc, bool notify);
49774978
int dev_set_allmulti(struct net_device *dev, int inc);

net/core/dev.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9193,18 +9193,7 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify)
91939193
return 0;
91949194
}
91959195

9196-
/**
9197-
* dev_set_promiscuity - update promiscuity count on a device
9198-
* @dev: device
9199-
* @inc: modifier
9200-
*
9201-
* Add or remove promiscuity from a device. While the count in the device
9202-
* remains above zero the interface remains promiscuous. Once it hits zero
9203-
* the device reverts back to normal filtering operation. A negative inc
9204-
* value is used to drop promiscuity on the device.
9205-
* Return 0 if successful or a negative errno code on error.
9206-
*/
9207-
int dev_set_promiscuity(struct net_device *dev, int inc)
9196+
int netif_set_promiscuity(struct net_device *dev, int inc)
92089197
{
92099198
unsigned int old_flags = dev->flags;
92109199
int err;
@@ -9216,7 +9205,6 @@ int dev_set_promiscuity(struct net_device *dev, int inc)
92169205
dev_set_rx_mode(dev);
92179206
return err;
92189207
}
9219-
EXPORT_SYMBOL(dev_set_promiscuity);
92209208

92219209
int netif_set_allmulti(struct net_device *dev, int inc, bool notify)
92229210
{

net/core/dev_api.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,29 @@ void dev_disable_lro(struct net_device *dev)
267267
}
268268
EXPORT_SYMBOL(dev_disable_lro);
269269

270+
/**
271+
* dev_set_promiscuity() - update promiscuity count on a device
272+
* @dev: device
273+
* @inc: modifier
274+
*
275+
* Add or remove promiscuity from a device. While the count in the device
276+
* remains above zero the interface remains promiscuous. Once it hits zero
277+
* the device reverts back to normal filtering operation. A negative inc
278+
* value is used to drop promiscuity on the device.
279+
* Return 0 if successful or a negative errno code on error.
280+
*/
281+
int dev_set_promiscuity(struct net_device *dev, int inc)
282+
{
283+
int ret;
284+
285+
netdev_lock_ops(dev);
286+
ret = netif_set_promiscuity(dev, inc);
287+
netdev_unlock_ops(dev);
288+
289+
return ret;
290+
}
291+
EXPORT_SYMBOL(dev_set_promiscuity);
292+
270293
/**
271294
* dev_set_allmulti() - update allmulti count on a device
272295
* @dev: device

0 commit comments

Comments
 (0)