From owner-freebsd-net Fri Nov 22 13:22: 2 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D833A37B401 for ; Fri, 22 Nov 2002 13:22:00 -0800 (PST) Received: from ns1.interbgc.com (mail.interbgc.com [217.9.224.3]) by mx1.FreeBSD.org (Postfix) with SMTP id C559643EAA for ; Fri, 22 Nov 2002 13:21:56 -0800 (PST) (envelope-from misho@interbgc.com) Received: (qmail 37426 invoked by uid 1005); 22 Nov 2002 21:21:40 -0000 Received: from misho@interbgc.com by keeper.interbgc.com by uid 1002 with qmail-scanner-1.14 (uvscan: v4.1.60/v4234. Clear:. Processed in 0.850673 secs); 22 Nov 2002 21:21:40 -0000 Received: from unknown (HELO misho) (217.9.231.229) by mail.interbgc.com with SMTP; 22 Nov 2002 21:21:39 -0000 Message-ID: <000f01c2926d$250d14a0$e5e709d9@interbgc.com> Reply-To: "Mihail Balikov" From: "Mihail Balikov" To: Subject: ip_forward() and ipforward_rt Date: Fri, 22 Nov 2002 23:21:38 +0200 Organization: Inter-Bg-Com Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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