Date: Thu, 8 Feb 2007 02:18:10 +0900 From: Norikatsu Shigemura <nork@FreeBSD.org> To: Florent Thoumie <flz@FreeBSD.org> Cc: freebsd-rc@FreeBSD.org, Norikatsu Shigemura <nork@FreeBSD.org> Subject: Re: conf/104884: Add support EtherChannel configuration to rc.conf Message-ID: <20070208021810.6bc5ccb1.nork@FreeBSD.org> In-Reply-To: <200702051930.l15JUS8O064334@freefall.freebsd.org> References: <200702051930.l15JUS8O064334@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 5 Feb 2007 19:30:28 GMT Florent Thoumie <flz@freebsd.org> wrote: > I just noticed two other things. > > +# fec_up ifn > ^^^ > fec_up uses fec_interfaces, not $1, so this is wrong. > > +# Configure Fast EtherChannel for interface $ifn. Returns 0 if FEC > > +# arguments were found and configured; returns 1 otherwise. > fec_up is never called with an argument anyway at the moment. It > wouldn't be hard to do: work on $1 or $fec_interfaces if $1 is empty. I > guess we could use both 'fec_up $ifn' and 'gif_up $ifn' in rc.d/netif. Yes. This is ng_fec_create's comment. I rewrote my patch. Please check following patch. > The newly introduced variables also need to be documented in rc.conf.5. > Could you please provide a patch for this? I made it, but please fix my broken English:-). > I also noticed we don't have gif_down (hence no fec_down). I noticed. But it's too hard how should we do. Index: src/etc/network.subr =================================================================== RCS file: /home/ncvs/src/etc/network.subr,v retrieving revision 1.176 diff -u -r1.176 network.subr --- src/etc/network.subr 29 Oct 2006 13:29:49 -0000 1.176 +++ src/etc/network.subr 7 Feb 2007 17:16:21 -0000 @@ -455,6 +455,25 @@ debug "Destroyed clones: ${_list}" } +# Create netgraph nodes. +# +ng_mkpeer() { + ngctl -f - 2> /dev/null <<EOF +mkpeer $* +msg dummy nodeinfo +EOF +} + +ng_create_one() { + ng_mkpeer $* | while read line; do + t=`expr "${line}" : '.* name="\([a-z]*[0-9]*\)" .*'` + if [ -n "${t}" ]; then + echo ${t} + return + fi + done +} + gif_up() { case ${gif_interfaces} in [Nn][Oo] | '') @@ -477,6 +496,55 @@ esac } +# ng_fec_create ifn +# Configure Fast EtherChannel for interface $ifn. Returns 0 if FEC +# arguments were found and configured; returns !0 otherwise. +ng_fec_create() { + local req_iface iface bogus + req_iface="$1" + + ngctl shutdown ${req_iface}: > /dev/null 2>&1 + + bogus="" + while true; do + iface=`ng_create_one fec dummy fec` + if [ -z "${iface}" ]; then + exit 2 + fi + if [ "${iface}" = "${req_iface}" ]; then + echo ${iface} + break + fi + bogus="${bogus} ${iface}" + done + + for iface in ${bogus}; do + ngctl shutdown ${iface}: + done +} + +fec_up() { + case ${fec_interfaces} in + [Nn][Oo] | '') + ;; + *) + for i in ${fec_interfaces}; do + ng_fec_create $i + for j in `get_if_var $i fecconfig_IF`; do + case ${j} in + '') + continue + ;; + *) + ngctl msg ${i}: add_iface "\"${j}\"" + ;; + esac + done + done + ;; + esac +} + # # ipx_up ifn # Configure any IPX addresses for interface $ifn. Returns 0 if IPX Index: src/etc/defaults/rc.conf =================================================================== RCS file: /home/ncvs/src/etc/defaults/rc.conf,v retrieving revision 1.303 diff -u -r1.303 rc.conf --- src/etc/defaults/rc.conf 20 Jan 2007 04:24:19 -0000 1.303 +++ src/etc/defaults/rc.conf 7 Feb 2007 17:16:22 -0000 @@ -183,6 +183,10 @@ # Choose correct tunnel addrs. #gifconfig_gif0="10.1.1.1 10.1.2.1" # Examples typically for a router. #gifconfig_gif1="10.1.1.2 10.1.2.2" # Examples typically for a router. +fec_interfaces="NO" # List of Fast EtherChannels (or "NO") +#fec_interfaces="fec0 fec1" +#fecconfig_fec0="fxp0 dc0" # Examples typically for two NICs +#fecconfig_fec1="em0 em1 bge0 bge1" # Examples typically for four NICs # User ppp configuration. ppp_enable="NO" # Start user-ppp (or NO). Index: src/etc/rc.d/netif =================================================================== RCS file: /home/ncvs/src/etc/rc.d/netif,v retrieving revision 1.21 diff -u -r1.21 netif --- src/etc/rc.d/netif 30 Dec 2006 22:53:20 -0000 1.21 +++ src/etc/rc.d/netif 7 Feb 2007 17:16:22 -0000 @@ -57,6 +57,9 @@ # Create cloned interfaces clone_up + # Create Fast EtherChannel interfaces + fec_up + # Create IPv6<-->IPv4 tunnels gif_up Index: src/share/man/man5/rc.conf.5 =================================================================== RCS file: /home/ncvs/src/share/man/man5/rc.conf.5,v retrieving revision 1.314 diff -u -r1.314 rc.conf.5 --- src/share/man/man5/rc.conf.5 24 Jan 2007 09:22:56 -0000 1.314 +++ src/share/man/man5/rc.conf.5 7 Feb 2007 17:16:22 -0000 @@ -1163,6 +1163,33 @@ are automatically appended to .Va network_interfaces for configuration. +.It Va fec_interfaces +.Pq Vt str +Set to the list of +.Xr ng_fec 4 +Fast EtherChannel interfaces to configure on this host. +A +.Va fecconfig_ Ns Aq Ar interface +variable is assumed to exist for each value of +.Ar interface . +The value of this variable is used to configure link aggregated interfaces +according to the syntax of the +.Cm NGM_FEC_ADD_IFACE +to +.Xr ngctl 8 +msg. +Additionally, this option ensures that each listed interface is created +via the +.Cm mkpeer +command to +.Xr ngctl 8 +before attempting to configure it. +For example: +.Bd -literal +fec_interfaces="fec0" +fecconfig_fec0="em0 em1" +ifconfig_fec0="DHCP" +.Ed .It Va gif_interfaces .Pq Vt str Set to the list of
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070208021810.6bc5ccb1.nork>