From owner-freebsd-net@FreeBSD.ORG Tue Dec 29 18:54:41 2009 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2996010656A3; Tue, 29 Dec 2009 18:54:41 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id F15768FC1E; Tue, 29 Dec 2009 18:54:40 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id A6B1846B51; Tue, 29 Dec 2009 13:54:40 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id DA0DA8A01F; Tue, 29 Dec 2009 13:54:39 -0500 (EST) From: John Baldwin To: Brooks Davis Date: Tue, 29 Dec 2009 13:54:26 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200912291354.26708.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 29 Dec 2009 13:54:39 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: net@freebsd.org Subject: Add support for vlans to rc.d startup scripts 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: Tue, 29 Dec 2009 18:54:41 -0000 This patch takes the work done for VAP devices for wireless and extends it to support adding VLAN interfaces to network devices more easily. A list of vlan interfaces is specified via 'vlans_'. If the vlan name is just a number, then that number is taken to be a tag and a '.' vlan interface device is created. Otherwise, a 'create_args_' variable must be defined that includes the 'vlan ' in order for the vlan to be successfully created. If one had the following lines in rc.conf for example: vlans_foo="101 bar vlan100" create_args_bar="vlan 102" create_args_vlan100="vlan 104" Then this would result in the following vlan devices being created during boot: foo.101: flags=8842 metric 0 mtu 1500 options=3 ether 00:24:81:40:e3:ef media: Ethernet autoselect vlan: 101 parent interface: foo bar: flags=8842 metric 0 mtu 1500 options=3 ether 00:24:81:40:e3:ef media: Ethernet autoselect vlan: 102 parent interface: foo vlan100: flags=8842 metric 0 mtu 1500 options=3 ether 00:24:81:40:e3:ef media: Ethernet autoselect vlan: 104 parent interface: foo If one uses 'sh /etc/rc.d/netif start foo' then the vlan devices will be created, and if one does 'sh /etc/rc.d/netif stop foo' then the vlan devices will be destroyed. One downside is that similar to the wlan interfaces, the ifconfig output for these devices is not displayed as part of the normal boot messages. Doing so would require some way for ifn_start and ifn_stop to communicate their list of child interfaces along with create/fail status for each back to the main loop in /etc/rc.d/netif. The patch is at http://www.FreeBSD.org/~jhb/patches/vlans_head.patch and is included below. -- John Baldwin