From owner-freebsd-hackers@FreeBSD.ORG Mon May 5 22:29:34 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD5C437B401 for ; Mon, 5 May 2003 22:29:34 -0700 (PDT) Received: from priv-edtnes44.telusplanet.net (outbound05.telus.net [199.185.220.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id F2C5643FBD for ; Mon, 5 May 2003 22:29:33 -0700 (PDT) (envelope-from sh@planetquake.com) Received: from antalus ([154.5.106.237]) by priv-edtnes44.telusplanet.net (InterMail vM.5.01.05.17 201-253-122-126-117-20021021) with SMTP id <20030506052933.IKJK3906.priv-edtnes44.telusplanet.net@antalus> for ; Mon, 5 May 2003 23:29:33 -0600 Message-ID: <011901c31390$7aef5730$0300000a@antalus> From: "Sean Hamilton" To: Date: Mon, 5 May 2003 22:29:35 -0700 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0116_01C31355.CE5041E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Bridge config in /etc/rc (patch) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2003 05:29:35 -0000 This is a multi-part message in MIME format. ------=_NextPart_000_0116_01C31355.CE5041E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Greetings, As I manage three FreeBSD bridges, I found it somewhat irritating that there was no convenient way of doing so. Thus, this patch. Should it get approved, I'll write diffs for the man pages, /etc/defaults/rc.conf, and anything else which needs it. I've updated both the old /etc/rc.network and the new rcng stuff, though only the latter is tested. Configuration goes like this: bridge_enable="YES" bridge_ifaces="fxp0,fxp1,fxp2" or, for multiple bridges bridge_enable="YES" bridge0_ifaces="fxp3,fxp4,fxp5" bridge1_ifaces="rl0,rl1,dc0" Both comma-separated and space-separated lists are accepted. Also allowed: bridge_ipfw="YES" bridge_ipfilter="YES" I've also added an option, "ip_any_interface=YES" which sets net.inet.ip.check_interface to 0. This felt more natural than having the option, "ip_check_interface=NO". This is a first for me on several counts, so hopefully I've got everything right. Or should I be submitting this as a PR? It's not really a problem, so... sh ------=_NextPart_000_0116_01C31355.CE5041E0 Content-Type: application/octet-stream; name="rcbridge.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="rcbridge.diff" diff -Nru etcorig/rc.d/bridge etc/rc.d/bridge=0A= --- etcorig/rc.d/bridge Wed Dec 31 16:00:00 1969=0A= +++ etc/rc.d/bridge Mon May 5 22:08:11 2003=0A= @@ -0,0 +1,85 @@=0A= +#!/bin/sh -x=0A= +=0A= +# PROVIDE: bridge=0A= +# REQUIRE: ipfw ip6fw ipfilter=0A= +# KEYWORD: FreeBSD=0A= +=0A= +. /etc/rc.subr=0A= +=0A= +name=3D"bridge"=0A= +start_cmd=3D"bridge_start"=0A= +stop_cmd=3D"bridge_stop"=0A= +=0A= +bridge_start()=0A= +{=0A= + case ${bridge_enable} in=0A= + [Yy][Ee][Ss])=0A= +=0A= + bridge_in_kernel=3D1=0A= +=0A= + if ! sysctl net.link.ether.bridge >/dev/null 2>&1; then=0A= + if kldload bridge; then=0A= + echo 'Bridge module loaded'=0A= + else=0A= + echo 'Warning: Bridge module failed to load.'=0A= + bridge_in_kernel=3D0=0A= + fi=0A= + fi=0A= +=0A= + if [ "${bridge_in_kernel}" -eq 1 ]; then=0A= +=0A= + bridgenum=3D=0A= + bridgecfg=3D=0A= +=0A= + while : ; do=0A= + eval bridge_args=3D\$bridge${bridgenum}_ifaces=0A= + if [ -n "${bridge_args}" ]; then=0A= + bridge_args=3D`echo -n "${bridge_args}" | sed 's/,/ /'`=0A= + for iface in ${bridge_args}; do=0A= + if [ -n "${bridgecfg}" ]; then=0A= + bridgecfg=3D${bridgecfg},=0A= + fi=0A= + bridgecfg=3D${bridgecfg}${iface}:$((${bridgenum:--1} + 1))=0A= + done=0A= + else=0A= + if [ -n "${bridgenum}" ]; then=0A= + break;=0A= + fi=0A= + fi=0A= + bridgenum=3D$((${bridgenum:--1} + 1))=0A= + done=0A= +=0A= + case ${bridge_ipfw} in=0A= + [Yy][Ee][Ss])=0A= + sysctl net.link.ether.bridge_ipfw=3D1 >/dev/null=0A= + ;;=0A= + esac=0A= +=0A= + case ${bridge_ipfilter} in=0A= + [Yy][Ee][Ss])=0A= + sysctl net.link.ether.bridge_ipf=3D1 >/dev/null=0A= + ;;=0A= + esac=0A= +=0A= + sysctl net.link.ether.bridge_cfg=3D"${bridgecfg}" >/dev/null=0A= + sysctl net.link.ether.bridge=3D1 >/dev/null=0A= + fi=0A= + ;;=0A= + esac=0A= +}=0A= +=0A= +bridge_stop()=0A= +{=0A= + sysctl net.link.ether.bridge=3D0 >/dev/null=0A= + sysctl net.link.ether.bridge_cfg=3D >/dev/null=0A= + sysctl net.link.ether.bridge_ipfw=3D0 >/dev/null=0A= + sysctl net.link.ether.bridge_ipf=3D0 >/dev/null=0A= +=0A= + if kldstat -n bridge >/dev/null 2>&1; then=0A= + kldunload bridge=0A= + fi=0A= +}=0A= +=0A= +load_rc_config $name=0A= +run_rc_command "$1"=0A= +=0A= diff -Nru etcorig/rc.d/network2 etc/rc.d/network2=0A= --- etcorig/rc.d/network2 Mon May 5 22:05:19 2003=0A= +++ etc/rc.d/network2 Mon May 5 22:05:42 2003=0A= @@ -115,6 +115,13 @@=0A= ;;=0A= esac=0A= =0A= + case ${ip_any_interface} in=0A= + [Yy][Ee][Ss])=0A= + echo -n ' any interface=3DYES'=0A= + sysctl net.inet.ip.check_interface=3D0 >/dev/null=0A= + ;;=0A= + esac=0A= +=0A= case ${ip_portrange_first} in=0A= [Nn][Oo] | '')=0A= ;;=0A= diff -Nru etcorig/rc.network etc/rc.network=0A= --- etcorig/rc.network Mon May 5 21:58:12 2003=0A= +++ etc/rc.network Mon May 5 21:59:50 2003=0A= @@ -393,6 +393,66 @@=0A= ;;=0A= esac=0A= =0A= + # Bridge=0A= + #=0A= + case ${bridge_enable} in=0A= + [Yy][Ee][Ss])=0A= +=0A= + bridge_in_kernel=3D1=0A= + if ! sysctl net.link.ether.bridge >/dev/null 2>&1; then=0A= + if kldload bridge; then=0A= + echo 'Bridge module loaded'=0A= + else=0A= + echo 'Warning: Bridge module failed to load.'=0A= + bridge_in_kernel=3D0=0A= + fi=0A= + fi=0A= +=0A= + if [ "${bridge_in_kernel}" -eq 1 ]; then=0A= + bridgenum=3D=0A= + bridgecfg=3D=0A= + while : ; do=0A= + eval bridge_args=3D\$bridge${bridgenum}_ifaces=0A= + if [ -n "${bridge_args}" ]; then=0A= + bridge_args=3D`echo -n "${bridge_args}" | sed 's/,/ /'`=0A= + for iface in ${bridge_args}; do=0A= + if [ -n "${bridgecfg}" ]; then=0A= + bridgecfg=3D${bridgecfg},=0A= + fi=0A= + bridgecfg=3D${bridgecfg}${iface}:$((${bridgenum:--1} + 1))=0A= + done=0A= + else=0A= + if [ -n "${bridgenum}" ]; then=0A= + break;=0A= + fi=0A= + fi=0A= + bridgenum=3D$((${bridgenum:--1} + 1))=0A= + done=0A= +=0A= + case ${bridge_ipfw} in=0A= + [Yy][Ee][Ss])=0A= + sysctl net.link.ether.bridge_ipfw=3D1 >/dev/null=0A= + ;;=0A= + esac=0A= +=0A= + case ${bridge_ipfilter} in=0A= + [Yy][Ee][Ss])=0A= + sysctl net.link.ether.bridge_ipf=3D1 >/dev/null=0A= + ;;=0A= + esac=0A= +=0A= + sysctl net.link.ether.bridge_cfg=3D"${bridgecfg}" >/dev/null=0A= + sysctl net.link.ether.bridge=3D1 >/dev/null=0A= + fi=0A= + ;;=0A= + esac=0A= +=0A= + case ${ip_any_interface} in=0A= + [Yy][Ee][Ss])=0A= + sysctl net.inet.ip.check_interface=3D0 >/dev/null=0A= + ;;=0A= + esac=0A= +=0A= # Additional ATM interface configuration=0A= #=0A= if [ -n "${atm_pass1_done}" ]; then=0A= ------=_NextPart_000_0116_01C31355.CE5041E0--