OpenVZ Forum


Home » Mailing lists » Devel » [PATCH][NET-2.6.24] Remove double dev->flags checking when calling dev_close()
[PATCH][NET-2.6.24] Remove double dev->flags checking when calling dev_close() [message #21452] Tue, 09 October 2007 10:50 Go to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
The unregister_netdevice() and dev_change_net_namespace() 
both check for dev->flags to be IFF_UP before calling the 
dev_close(), but the dev_close() checks for IFF_UP itself, 
so remove those unneeded checks.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/core/dev.c b/net/core/dev.c
index e7e728a..1e169a5 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3893,8 +3893,7 @@ void unregister_netdevice(struct net_dev
 	BUG_ON(dev->reg_state != NETREG_REGISTERED);
 
 	/* If device is running, close it first. */
-	if (dev->flags & IFF_UP)
-		dev_close(dev);
+	dev_close(dev);
 
 	/* And unlink it from device chain. */
 	unlist_netdevice(dev);
@@ -4018,8 +4017,7 @@ int dev_change_net_namespace(struct net_
 	 */
 
 	/* If device is running close it first. */
-	if (dev->flags & IFF_UP)
-		dev_close(dev);
+	dev_close(dev);
 
 	/* And unlink it from device chain */
 	err = -ENODEV;
Re: [PATCH][NET-2.6.24] Remove double dev->flags checking when calling dev_close() [message #21456 is a reply to message #21452] Tue, 09 October 2007 11:44 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
Jeff Garzik wrote:
> Pavel Emelyanov wrote:
>> The unregister_netdevice() and dev_change_net_namespace() 
>> both check for dev->flags to be IFF_UP before calling the 
>> dev_close(), but the dev_close() checks for IFF_UP itself, 
>> so remove those unneeded checks.
>>
>> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
>>
>> ---
>>
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index e7e728a..1e169a5 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -3893,8 +3893,7 @@ void unregister_netdevice(struct net_dev
>>  	BUG_ON(dev->reg_state != NETREG_REGISTERED);
>>  
>>  	/* If device is running, close it first. */
>> -	if (dev->flags & IFF_UP)
>> -		dev_close(dev);
>> +	dev_close(dev);
>>  
>>  	/* And unlink it from device chain. */
>>  	unlist_netdevice(dev);
>> @@ -4018,8 +4017,7 @@ int dev_change_net_namespace(struct net_
>>  	 */
>>  
>>  	/* If device is running close it first. */
>> -	if (dev->flags & IFF_UP)
>> -		dev_close(dev);
>> +	dev_close(dev);
>>  
>>  	/* And unlink it from device chain */
>>  	err = -ENODEV;
> 
> One side effect of this patch:  might_sleep() is now called unconditionally.

That's not a big deal - see, the synchronize_net() is called further
in both places unconditionally (!) and also calls might_sleep(), so
this is OK.

> If that is irrelevant... ACK.

Thanks :)

> 
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Re: [PATCH][NET-2.6.24] Remove double dev->flags checking when calling dev_close() [message #21459 is a reply to message #21452] Tue, 09 October 2007 11:33 Go to previous messageGo to next message
Jeff Garzik is currently offline  Jeff Garzik
Messages: 9
Registered: February 2006
Junior Member
Pavel Emelyanov wrote:
> The unregister_netdevice() and dev_change_net_namespace() 
> both check for dev->flags to be IFF_UP before calling the 
> dev_close(), but the dev_close() checks for IFF_UP itself, 
> so remove those unneeded checks.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> 
> ---
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index e7e728a..1e169a5 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3893,8 +3893,7 @@ void unregister_netdevice(struct net_dev
>  	BUG_ON(dev->reg_state != NETREG_REGISTERED);
>  
>  	/* If device is running, close it first. */
> -	if (dev->flags & IFF_UP)
> -		dev_close(dev);
> +	dev_close(dev);
>  
>  	/* And unlink it from device chain. */
>  	unlist_netdevice(dev);
> @@ -4018,8 +4017,7 @@ int dev_change_net_namespace(struct net_
>  	 */
>  
>  	/* If device is running close it first. */
> -	if (dev->flags & IFF_UP)
> -		dev_close(dev);
> +	dev_close(dev);
>  
>  	/* And unlink it from device chain */
>  	err = -ENODEV;

One side effect of this patch:  might_sleep() is now called unconditionally.

If that is irrelevant... ACK.
Re: [PATCH][NET-2.6.24] Remove double dev->flags checking when calling dev_close() [message #21501 is a reply to message #21459] Wed, 10 October 2007 01:33 Go to previous messageGo to next message
Herbert Xu is currently offline  Herbert Xu
Messages: 45
Registered: April 2007
Member
Jeff Garzik <jeff@garzik.org> wrote:
>
> One side effect of this patch:  might_sleep() is now called unconditionally.

That would be seem to be a good thing :)
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH][NET-2.6.24] Remove double dev->flags checking when calling dev_close() [message #21516 is a reply to message #21452] Wed, 10 October 2007 09:49 Go to previous message
davem is currently offline  davem
Messages: 463
Registered: February 2006
Senior Member
From: Pavel Emelyanov <xemul@openvz.org>
Date: Tue, 09 Oct 2007 14:50:54 +0400

> The unregister_netdevice() and dev_change_net_namespace() 
> both check for dev->flags to be IFF_UP before calling the 
> dev_close(), but the dev_close() checks for IFF_UP itself, 
> so remove those unneeded checks.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Applied, thanks Pavel.
Previous Topic: [PATCH 0/6][NET-2.6.24] Consolidate private allocations in seq files
Next Topic: [PATCH] Rewrite proc seq operations via seq_list_xxx ones
Goto Forum:
  


Current Time: Fri Dec 01 19:19:12 GMT 2023

Total time taken to generate the page: 0.04200 seconds