Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Feb 2004 17:13:26 +0300
From:      Gleb Smirnoff <glebius@cell.sick.ru>
To:        Andre Oppermann <andre@freebsd.org>, freebsd-net@freebsd.org
Subject:   Re: rtalloc()/rtfree() problems on CURRENT
Message-ID:  <20040225141326.GA86194@cell.sick.ru>
In-Reply-To: <20040224130408.GA78658@cell.sick.ru>
References:  <20040224080353.GA76272@cell.sick.ru> <403B2423.DABF2E48@freebsd.org> <20040224102113.GB77406@cell.sick.ru> <403B4182.F6BD7101@freebsd.org> <20040224123427.GA78495@cell.sick.ru> <403B47D4.6F783F4F@freebsd.org> <20040224130408.GA78658@cell.sick.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 24, 2004 at 04:04:08PM +0300, Gleb Smirnoff wrote:
T> A> Ah, sorry, forgot that in my last email.  The only thing is to use RTFREE().
T> A> At first I thought your reassigning of rt is a problem, but you free the
T> A> correct ro.ro_rt later.
T> 
T> Thank you! I'll try everything you suggested today night.

Thanks again. Using RTFREE() fixed the problem. It works OK both
on STABLE and CURRENT.

If you don't mind I have one more question, though. Looking through kernel
code, seeking for examples, I have found following in in_gif.c:

                rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL);
                if (!rt || rt->rt_ifp != ifp) {
#if 0
                        log(LOG_WARNING, "%s: packet from 0x%x dropped "
                            "due to ingress filter\n", if_name(&sc->gif_if),
                            (u_int32_t)ntohl(sin.sin_addr.s_addr));
#endif
                        if (rt)
                                rtfree(rt);
                        return 0;
                }
                rtfree(rt);

And it doesn't crash. Looking through the code I understood that
in case of rtalloc()/rtfree() or rtalloc_ign()/rtfree() macro RT_UNLOCK
is called twice, and this leads to panic. But in case of rtalloc1()/rtfree()
everything is OK, since RT_UNLOCK is called once.

So, the question is: if I need some readonly access to routing table can
I use rtalloc1()/rtfree() or not? Will RTFREE be mandatory in future?
This will save some small amount of CPU time, but this code is executed
really often.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040225141326.GA86194>