Re: conf/104884: Add support EtherChannel configuration to rc.conf

[ Available lists | Index of freebsd-rc | Month of Feb 2007 | Week of 8 Feb 2007 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Florent Thoumie <flz@FreeBSD.org>
Date
8 Feb 2007 18:01:44
Subject
Re: conf/104884: Add support EtherChannel configuration to rc.conf
Message-ID
45CB6570.8020809@FreeBSD.org

In reply to

[ Hide this part ]
Norikatsu Shigemura wrote:
> 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.

I've rewritten the patch with the modifications we've discussed earlier
(set default to "" instead of "NO"). I think it's fine now, so this
version is likely to be the one that will hit the tree (in two or three
days unless someone thinks there's something wrong).

I guess a MFC delayed by 3 weeks will be ok. I'll include the "NO"
compatibility at that time.

--
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer


[ Hide this part ]
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 8 Feb 2007 17:57:13 -0000
@@ -178,11 +178,15 @@
sppp_interfaces="" # List of sppp interfaces.
#sppp_interfaces="isp0" # example: sppp over ISDN
#spppconfig_isp0="authproto=chap myauthname=foo myauthsecret='top secret' hisauthname=some-gw hisauthsecret='another secret'"
-gif_interfaces="NO" # List of GIF tunnels (or "NO").
+gif_interfaces="" # List of GIF tunnels.
#gif_interfaces="gif0 gif1" # Examples typically for a router.
# 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="" # List of Fast EtherChannels.
+#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 8 Feb 2007 17:57:13 -0000
@@ -57,6 +57,9 @@
# Create cloned interfaces
clone_up

+ # Create Fast EtherChannel interfaces
+ fec_up
+
# Create IPv6<-->IPv4 tunnels
gif_up

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 8 Feb 2007 17:57:13 -0000
@@ -455,26 +455,82 @@
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] | '')
- ;;
- *)
- for i in ${gif_interfaces}; do
- peers=`get_if_var $i gifconfig_IF`
- case ${peers} in
+ for i in ${gif_interfaces}; do
+ peers=`get_if_var $i gifconfig_IF`
+ case ${peers} in
+ '')
+ continue
+ ;;
+ *)
+ ifconfig $i create >/dev/null 2>&1
+ ifconfig $i tunnel ${peers}
+ ifconfig $i up
+ ;;
+ esac
+ done
+}
+
+# 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() {
+ for i in ${fec_interfaces}; do
+ ng_fec_create $i
+ for j in `get_if_var $i fecconfig_IF`; do
+ case ${j} in
'')
continue
;;
*)
- ifconfig $i create >/dev/null 2>&1
- ifconfig $i tunnel ${peers}
- ifconfig $i up
+ ngctl msg ${i}: add_iface "\"${j}\""
;;
esac
done
- ;;
- esac
+ done
}

#
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 8 Feb 2007 17:57:13 -0000
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD: src/share/man/man5/rc.conf.5,v 1.314 2007/01/24 09:22:56 ceri Exp $
.\"
-.Dd January 23, 2007
+.Dd February 8, 2007
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -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


[ Show this part (application/pgp-signature) ]

Elapsed time: 0.088 seconds