Re: Examine route.c! -- two bugs fixed -- patch attached!

Dr. Werner Fink (werner@suse.de)
Fri, 5 Dec 1997 10:09:22 +0100


> Maybe it is worth just to see what happens if the inline function in net/route.h
> is changed as the version in route.c by adding
>
> /* If this rtable entry is not in the cache, we'd better free it once the
> * refcnt goes to zero, because nobody else will... */
> if ( rt && (rt->rt_flags & RTF_NOTCACHED) && (!rt->rt_refcnt) )
> rt_free(rt);

Than you should remove static from the defintion of rt_free() in route.c
... and a declaration in route.h is also needed. By doing this you will lose
the inline advantage ... therefore it easier to replace inlined version of
ip_rt_put with its extern declaration only.

[...]

> In 2.0.30 there seems to be no uncached routes... Therefor I assume that both
> changes are related and made by the same person. As I don't have the
> pre-patches for 2.0.31 any more, I cannot say when this has been added.

Only chached route will handled by rt_garbage_collect.

>
> If this is a leak it should happen if ip_rt_slow_route is called with the
> third
> argument != NULL. This is the case if ip_rt_route is called with the
> third argument != 0 and the entry is not found in the cache. ip_rt_route
> is again called from ip_check_route with third argument != NULL if it is
> itself called with third argument != NULL.
>
> If we assume not to use sockets bound to a certain device, I think this is
> only
> done by ip_build_header in ip_output.c if a device is supplied as argument.
> And this seems to be done under certain circumstances in tcp_send_reset (if
> dev = &loopback_dev;
> tmp = prot->build_header(buff,sk->saddr, sk->daddr, &dev,
> IPPROTO_TCP, sk->opt,
> sizeof(struct tcphdr),sk->ip_tos,sk->ip_ttl,&sk->ip_route_cache);
> gets executed) and maybe tcp_write_wakeup, further maybe in do_tcp_sendmsg.
>
> Seems to me that RTF_NOTCACHED-feature was added for binding a device to a
> socket and has some sideeffects on tcp and cacheing routes. But I don't know
> if this can lead to a such memory loss.

SO_BINDTODEVICE with some side effects :-}

Werner