netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fib6_del_route has redundant code
@ 2007-12-27  7:26 Gui Jianfeng
  2007-12-28  5:18 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Gui Jianfeng @ 2007-12-27  7:26 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel

Hi all,
I think the following code in fib6_del_route in the latest kernel is useless.
1125         if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
1126                 fn->leaf = &ip6_null_entry;

ip6_null_entry will never be unlinked from fn->leaf now, that is, fn->leaf == NULL will never meet.

In previous kernel, When adding a default route, ip6_null_entry will be unlinked from fn->leaf.
So, when deleting a default route, it need to check whether the deleted route is the last one,
if so, ip6_null_entry will link to fn->leaf again.

I am not sure if there is another place unlinks ip6_null_entry from fn->leaf.

Regards,
Gui Jiafeng

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fib6_del_route has redundant code
  2007-12-27  7:26 fib6_del_route has redundant code Gui Jianfeng
@ 2007-12-28  5:18 ` David Miller
  2007-12-28  5:58   ` Gui Jianfeng
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2007-12-28  5:18 UTC (permalink / raw)
  To: guijianfeng; +Cc: netdev, linux-kernel

From: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
Date: Thu, 27 Dec 2007 15:26:46 +0800

> I think the following code in fib6_del_route in the latest kernel is useless.
> 1125         if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
> 1126                 fn->leaf = &ip6_null_entry;
> 
> ip6_null_entry will never be unlinked from fn->leaf now, that is,
> fn->leaf == NULL will never meet.

I think you are right, but if it is true the next block of
code is dead too:

	/* If it was last route, expunge its radix tree node */
	if (fn->leaf == NULL) {
		fn->fn_flags &= ~RTN_RTINFO;
		rt6_stats.fib_route_nodes--;
		fn = fib6_repair_tree(fn);
	}

But I am not completely convinced that all of these lines
of code can be removed :-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fib6_del_route has redundant code
  2007-12-28  5:18 ` David Miller
@ 2007-12-28  5:58   ` Gui Jianfeng
  2007-12-28  8:15     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Gui Jianfeng @ 2007-12-28  5:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel

>> I think the following code in fib6_del_route in the latest kernel is useless.
>> 1125         if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
>> 1126                 fn->leaf = &ip6_null_entry;
>>
>> ip6_null_entry will never be unlinked from fn->leaf now, that is,
>> fn->leaf == NULL will never meet.
> 
> I think you are right, but if it is true the next block of
> code is dead too:
> 
> 	/* If it was last route, expunge its radix tree node */
> 	if (fn->leaf == NULL) {
> 		fn->fn_flags &= ~RTN_RTINFO;
> 		rt6_stats.fib_route_nodes--;
> 		fn = fib6_repair_tree(fn);
> 	}
> 
Dave,

I think this block of code can't be removed, because just the root(default route)
fn->leaf always has ip6_null_entry on it. The normal fn->leaf becomes NULL when last
route has been deleted, the radix tree should be expunged.

> But I am not completely convinced that all of these lines
> of code can be removed :-)
> 
> 

-- 


Regards
Gui Jianfeng
--------------------------------------------------
Gui Jianfeng
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F., Civil Defense Building, No.189 Guangzhou Road,
Nanjing, 210029, China
TEL: +86+25-86630566-838
COINS: 79955-838
FAX: +86+25-83317685
MAIL:guijianfeng@cn.fujitsu.com
--------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fib6_del_route has redundant code
  2007-12-28  5:58   ` Gui Jianfeng
@ 2007-12-28  8:15     ` David Miller
  2007-12-28  8:25       ` Gui Jianfeng
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2007-12-28  8:15 UTC (permalink / raw)
  To: guijianfeng; +Cc: netdev, linux-kernel

From: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
Date: Fri, 28 Dec 2007 13:58:21 +0800

> >> I think the following code in fib6_del_route in the latest kernel is useless.
> >> 1125         if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
> >> 1126                 fn->leaf = &ip6_null_entry;
> >>
> >> ip6_null_entry will never be unlinked from fn->leaf now, that is,
> >> fn->leaf == NULL will never meet.
> > 
> > I think you are right, but if it is true the next block of
> > code is dead too:
> > 
> > 	/* If it was last route, expunge its radix tree node */
> > 	if (fn->leaf == NULL) {
> > 		fn->fn_flags &= ~RTN_RTINFO;
> > 		rt6_stats.fib_route_nodes--;
> > 		fn = fib6_repair_tree(fn);
> > 	}
> > 
> 
> I think this block of code can't be removed, because just the
> root(default route) fn->leaf always has ip6_null_entry on it. The
> normal fn->leaf becomes NULL when last route has been deleted, the
> radix tree should be expunged.

But you said (still quoted above) that fn->leaf == NULL will not
occur.

Do you mean this, only in the case that the RTN_TL_ROOT flag is set?

I thought you meant always when the function is called, fn->leaf
cannot ever be NULL.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fib6_del_route has redundant code
  2007-12-28  8:15     ` David Miller
@ 2007-12-28  8:25       ` Gui Jianfeng
  0 siblings, 0 replies; 5+ messages in thread
From: Gui Jianfeng @ 2007-12-28  8:25 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel

> From: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
> Date: Fri, 28 Dec 2007 13:58:21 +0800
> 
>>>> I think the following code in fib6_del_route in the latest kernel is useless.
>>>> 1125         if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
>>>> 1126                 fn->leaf = &ip6_null_entry;
>>>>
>>>> ip6_null_entry will never be unlinked from fn->leaf now, that is,
>>>> fn->leaf == NULL will never meet.
>>> I think you are right, but if it is true the next block of
>>> code is dead too:
>>>
>>> 	/* If it was last route, expunge its radix tree node */
>>> 	if (fn->leaf == NULL) {
>>> 		fn->fn_flags &= ~RTN_RTINFO;
>>> 		rt6_stats.fib_route_nodes--;
>>> 		fn = fib6_repair_tree(fn);
>>> 	}
>>>
>> I think this block of code can't be removed, because just the
>> root(default route) fn->leaf always has ip6_null_entry on it. The
>> normal fn->leaf becomes NULL when last route has been deleted, the
>> radix tree should be expunged.
> 
> But you said (still quoted above) that fn->leaf == NULL will not
> occur.
> 
> Do you mean this, only in the case that the RTN_TL_ROOT flag is set?
  yes, I mean this :-)

> 
> I thought you meant always when the function is called, fn->leaf
> cannot ever be NULL.
  its my fault, sorry for the inconvenient.

> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-12-28  8:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-27  7:26 fib6_del_route has redundant code Gui Jianfeng
2007-12-28  5:18 ` David Miller
2007-12-28  5:58   ` Gui Jianfeng
2007-12-28  8:15     ` David Miller
2007-12-28  8:25       ` Gui Jianfeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).