From owner-freebsd-net@FreeBSD.ORG Thu Feb 17 08:46:33 2005 Return-Path: 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 3CA6016A4CE for ; Thu, 17 Feb 2005 08:46:33 +0000 (GMT) Received: from relay.bestcom.ru (relay.bestcom.ru [217.72.144.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 11DA943D1F for ; Thu, 17 Feb 2005 08:46:32 +0000 (GMT) (envelope-from glebius@freebsd.org) Received: from cell.sick.ru (root@cell.sick.ru [217.72.144.68]) by relay.bestcom.ru (8.13.1/8.12.9) with ESMTP id j1H8kUI1032714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 17 Feb 2005 11:46:31 +0300 (MSK) (envelope-from glebius@freebsd.org) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.11/8.12.8) with ESMTP id j1H8kUx0095188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 17 Feb 2005 11:46:30 +0300 (MSK) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.sick.ru (8.12.11/8.12.11/Submit) id j1H8kU22095187 for net@freebsd.org; Thu, 17 Feb 2005 11:46:30 +0300 (MSK) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.sick.ru: glebius set sender to glebius@freebsd.org using -f Date: Thu, 17 Feb 2005 11:46:29 +0300 From: Gleb Smirnoff To: net@freebsd.org Message-ID: <20050217084629.GB95106@cell.sick.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.5.6i X-Virus-Scanned: ClamAV version devel-20050125, clamav-milter version 0.80ff on relay.bestcom.ru X-Virus-Status: Clean Subject: in_pcbconnect_setup() question X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2005 08:46:33 -0000 Dear networkers, I've noticed a small oddity in in_pcbconnect_setup(). According to SuS, in case of connection-less socket layer, e.g. SOCK_DGRAM, the connect() syscall should only choose local address and that's all. To server this purposes a route lookup is done in in_pcbconnect_setup(). However, if route is pointing to a loopback interface, it is not accepted. (Not clear to me) comment is also present: /* * If we found a route, use the address * corresponding to the outgoing interface * unless it is the loopback (in case a route * to our address on another net goes to loopback). */ if (sro.ro_rt && !(sro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK)) ia = ifatoia(sro.ro_rt->rt_ifa); if (sro.ro_rt) RTFREE(sro.ro_rt); For example, this breaks connect() of a UDP socket to a blackhole-routed IP address, which shouldn't return an error. I'd like to change this block to the following: /* * If we found a route, use the address * corresponding to the outgoing interface. */ if (sro.ro_rt) { ia = ifatoia(sro.ro_rt->rt_ifa); RTFREE(sro.ro_rt); } Is there any hidden obstacles? Can someone explain me this comment? -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE