From owner-freebsd-net@FreeBSD.ORG Sun Mar 4 22:25:07 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 89D1E16A403 for ; Sun, 4 Mar 2007 22:25:07 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out5.smtp.messagingengine.com (out5.smtp.messagingengine.com [66.111.4.29]) by mx1.freebsd.org (Postfix) with ESMTP id 4F71113C442 for ; Sun, 4 Mar 2007 22:25:07 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id DBD071F52FE for ; Sun, 4 Mar 2007 17:25:06 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by out1.internal (MEProxy); Sun, 04 Mar 2007 17:25:06 -0500 X-Sasl-enc: ESH+0kSbbjoHl6xwvRfVmfMLMQ9CbLNP0Gln2KT2o/Pw 1173047106 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id B0CC510B50 for ; Sun, 4 Mar 2007 17:25:06 -0500 (EST) Message-ID: <45EB4741.6000102@incunabulum.net> Date: Sun, 04 Mar 2007 22:25:05 +0000 From: Bruce M Simpson User-Agent: Thunderbird 1.5.0.9 (X11/20070125) MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [PATCH] IP_SENDIF option; rework ip_output() source selection logic X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Mar 2007 22:25:07 -0000 Hello, Thanks to andre making a start on this, I have managed to get the IP_SENDIF option implemented today in p4 bms_netdev. Here's a patch against -CURRENT: http://people.freebsd.org/~bms/dump/sendif-20070304.diff For those who are new to this work: IP_SENDIF is broadly an analogue of the Linux socket option SO_BINDTODEVICE. It is used to bypass the traditional BSD source interface selection logic. It is a sledgehammer hack used to output datagrams on a specific interface which may not yet have an address, e.g. for DHCP. Judicious use of this option, together with IP_ONESBCAST, will make it possible for dhclient to run without BPF support in the base system. There are a few remaining issues around this code which need to be dealt with. These are: * Fix IP_SENDIF and IP_SENDSRCADDR for unbound sockets. This goes without saying. For these options to be useful the socket should not have to be bound anywhere. The fact that IP_SENDSRCADDR is currently broken contradicts both our documentation and UNIX Network Programming Vol 1 3rd Edition. * Allow IP_SENDIF to be used from the raw IP output path. Some people might want to do this. * Add a specific privilege level for IP_SENDIF. Currently it requires the 'open raw socket' privilege, as it is Not Normal Behaviour. * Disable hardware checksums on output, if we have to do that. My testing with msk(4) suggests this might not be needed. When/if we adopt NetBSD's source selection policy concept (e.g. for fully supporting link-local IPv4) this code will most likely have to be updated, and/or when/if we adopt equal-cost multipath. The hack IP_ONESBCAST itself may eventually be eliminated by doing things slightly differently in the forwarding trie i.e. using interface preference and/or IP_SENDIF and populating the trie with 255.255.255.255 routes. Regards, BMS