Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 2002 23:21:38 +0200
From:      "Mihail Balikov" <misho@interbgc.com>
To:        <freebsd-net@freebsd.org>
Subject:   ip_forward() and ipforward_rt
Message-ID:  <000f01c2926d$250d14a0$e5e709d9@interbgc.com>

next in thread | raw e-mail | index | archive | help
Hello,

In -stable ip_input.c in_forward() we cache last used route in ipforward_rt.

        sin = (struct sockaddr_in *)&ipforward_rt.ro_dst;
        if ((rt = ipforward_rt.ro_rt) == 0 ||
            pkt_dst.s_addr != sin->sin_addr.s_addr) {
                if (ipforward_rt.ro_rt) {
                        RTFREE(ipforward_rt.ro_rt);
                        ipforward_rt.ro_rt = 0;
                }
                sin->sin_family = AF_INET;
                sin->sin_len = sizeof(*sin);
                sin->sin_addr = pkt_dst;

                rtalloc_ign(&ipforward_rt, RTF_PRCLONING);
                if (ipforward_rt.ro_rt == 0) {
                        icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest,
0);
                        return;
                }
                rt = ipforward_rt.ro_rt;
        }

In my opinion, we should verify that ipforward_rt is not last reference to
route and route is UP:

        sin = (struct sockaddr_in *)&ipforward_rt.ro_dst;
        if ((rt = ipforward_rt.ro_rt) == 0 ||
            pkt_dst.s_addr != sin->sin_addr.s_addr ||
            rt->rt_refcnt <= 1 ||
            (rt->rt_flags & RTF_UP) == 0) {
                ....
        }

regards,
Mihail



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000f01c2926d$250d14a0$e5e709d9>