From owner-freebsd-bugs Sun Jun 3 3: 0:12 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C07E237B403 for ; Sun, 3 Jun 2001 03:00:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f53A06b16816; Sun, 3 Jun 2001 03:00:06 -0700 (PDT) (envelope-from gnats) Received: from shadow.otel.net (JuDiCaToR.OTEL.net [212.36.9.113]) by hub.freebsd.org (Postfix) with ESMTP id A19A037B403 for ; Sun, 3 Jun 2001 02:52:48 -0700 (PDT) (envelope-from tbyte@shadow.otel.net) Received: (from tbyte@localhost) by shadow.otel.net (8.11.3/8.11.1) id f539qhc10077; Sun, 3 Jun 2001 12:52:43 +0300 (EEST) (envelope-from tbyte) Message-Id: <200106030952.f539qhc10077@shadow.otel.net> Date: Sun, 3 Jun 2001 12:52:43 +0300 (EEST) From: tbyte@tbyte.org Reply-To: tbyte@tbyte.org To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/27852: Adding default route Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 27852 >Category: kern >Synopsis: Kernel can't add default route from network that none of its int >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jun 03 03:00:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Iasen Kostoff >Release: FreeBSD 4.3-STABLE i386 >Organization: OTEL.net >Environment: System: FreeBSD sat.fury.lan 4.3-STABLE FreeBSD 4.3-STABLE #13: Sun Jun 3 11:23: >Description: You have one interface xl0 with ip 100.1.1.10 and netmask 255.255.255.0 and your gateway is 150.1.1.1. To add this gateway you should add a route to this host lets say: route add -net 150.1.1.0/24 -iface xl0; and then we should add the default : route add default 150.1.1.1. That's the right way but what the kernel say ? - "Network Unreachable" ?!? But we have route to that network , aren't we ? And here is one way this could be done : route add default 100.1.1.10 route add -net 150.1.1.0/24 -iface xl0 route change default 150.1.1.1 Wow everithing works ! :) But do you think that's the right way to be done ? >How-To-Repeat: just try do add default gw from network that none of your interfaces is. >Fix: I looked in the kernel source and found this in rtrequest : if ((ifa = ifa_ifwithroute(flags, dst, gateway)) == 0) senderr(ENETUNREACH); ifa_ifwithroute() can't find a route that exest ? Then I look at ifa_ifwithroute() and saw this : if (ifa == 0) { struct rtentry *rt = rtalloc1(dst, 0, 0UL); Why we search a route to a destination but not to a gateway ? I change it ofcourse and now everything works fine. And this is the changed line just one variable changed : if (ifa == 0) { struct rtentry *rt = rtalloc1(gateway, 0, 0UL); And here is the patch (hum :)) for this : --- route.c.old Thu May 17 02:14:03 2001 +++ route.c Sun Jun 3 11:18:07 2001 @@ -425,7 +425,7 @@ if (ifa == 0) ifa = ifa_ifwithnet(gateway); if (ifa == 0) { - struct rtentry *rt = rtalloc1(dst, 0, 0UL); + struct rtentry *rt = rtalloc1(gateway, 0, 0UL); if (rt == 0) return (0); rt->rt_refcnt--; A long long patch. If you have any sugestions I'd like to hear it as soon as posible because there are some other things in the kernel routing that I want to discuss. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message