rtalloc()/rtfree() problems on CURRENT
Andre Oppermann
andre at freebsd.org
Tue Feb 24 02:15:07 PST 2004
Gleb Smirnoff wrote:
>
> Dear sirs,
>
> please take a look at the following problem. I've been
> successfully using the following code on STABLE and 5.1-RELEASE:
>
> struct route ro;
> struct sockaddr_in *sin;
>
> bzero((caddr_t)&ro, sizeof(ro));
> sin = (struct sockaddr_in *)&ro.ro_dst;
> sin->sin_len = sizeof(*sin);
> sin->sin_family = AF_INET;
> sin->sin_addr = fle->r.r_dst;
> rtalloc(&ro);
Most of the time, if you don't need a cloned route allocated, you can
just use rtalloc_ign(&ro, RTF_CLONING) to just get a reference to the
existing rtentry. Not allocating a new cloned route saves work and
time for the rtalloc code.
> if (ro.ro_rt != NULL) {
> struct rtentry *rt = ro.ro_rt;
>
> /* here some read-only things are done with rt */
Maybe you do some nasty things to rt here?
> rtfree(ro.ro_rt);
> }
>
> But on CURRENT rtfree() causes panic. Here is backtrace:
...
> Does this mean that something is broken in CURRENT or I am doing something wrong?
rtalloc() and rtfree() are used quite often in the network code and
otherwise work fine. The odds are high that you are doing something
wrong.
--
Andre
More information about the freebsd-net
mailing list