Subject: Re: [PATCH net] dsa: fix promiscuity leak on slave dev open error

From: Andrew Lunn <[email-masked]>
Date: Sun, 28 Jun 2015 19:09:53 +0200

> It has occurred to me that dev_set_promiscuity() and its brethren
> dev_set_allmulti() may not be the best of interfaces:
> 
> - On cursory inspection of code using these function their name
> implies the value of the relevant counter is set to the value passed
> as parameter, not incremented by it.
> - No caller I've managed to spot passes anything but -1 or 1
> 
> It seems an interface of
> 
> int dev_set_promiscuity(struct net_device *dev, bool on);
> 
> int dev_set_allmulti(struct net_device *dev, bool on);

on suggests it is an absolute, when in fact you are passing an
increment, so i don't think it is much of an improvement.

Adding #define, PROMISC_INC and PROMISC_DEC might be clearer, and
since this is not a fast path, you could consider parameter
validation. Or dev_get_promiscuity(), det_put_promiscuity().
 
> would be as functional (for current users), more readable and less
> error prone but I am not sure such a tiny problem (if you can call
> this a problem) is worth the churn...

There was only one instance of it wrong, so it is not a very big
problem. I would say it is not worth the churn.

	 Andrew