From owner-freebsd-net@FreeBSD.ORG Wed Aug 6 23:09:18 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 94CB9481 for ; Wed, 6 Aug 2014 23:09:18 +0000 (UTC) Received: from web01.jbserver.net (web01.jbserver.net [IPv6:2a00:8240:6:a::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E69B2784 for ; Wed, 6 Aug 2014 23:09:17 +0000 (UTC) Received: from cl-1071.udi-01.br.sixxs.net ([2001:1291:200:42e::2]) by web01.jbserver.net with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.83) (envelope-from ) id 1XFAKY-0001D5-5P; Thu, 07 Aug 2014 01:09:14 +0200 Message-ID: <53E2B586.3080700@gont.com.ar> Date: Wed, 06 Aug 2014 19:08:54 -0400 From: Fernando Gont User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: FreeBSD Net Subject: Routing IPv6 packets towards oneself with routing sockets? Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Aug 2014 23:09:18 -0000 Folks, I've found a "tricky" scenario when consulting the IPv6 routing table with routing sockets. Short version of the question: I'm currently consulting the IPv6 routing table with raw sockets. My own host is assigned the address fc00:1::1, and it is directly connected to fc00:1::/64 with em0. The corresponding entries from its routing table are: fc00:1::/64 link#1 U em0 fc00:1::1 link#1 UHS lo0 Essentially, packets sent to fc00:1::1 don't go through em0 but rather go through the loopback interface (if you ping6 fc00:1::1, you'll see the packets on lo0 rather than em0). However, whenever I lookup an entry for fc00:1::1 with routing sockets, the only entry I obtain is fc00:1::/64 (a network route) rather than fc00:1::1/128 (a host route). As a result, I kind of have to figure out that since fc00:1::1 is my own address, I must override whatever I learned via routing sockets, and just send my packets to loopback. I would assume that I must be doing something wrong, since I would expect the host-specific route (i.e. longest-matching route) to be route learned via routing sockets. And that I shouldn't be implementing this "is the dst address my own address?" hack. Any thoughts? P.S.: I can provide a code snippet if that'd be of any help. Thanks! Best regards, -- Fernando Gont e-mail: fernando@gont.com.ar || fgont@si6networks.com PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1