From nobody@FreeBSD.org  Sun Mar 14 05:12:07 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 23793106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 14 Mar 2010 05:12:07 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 136CE8FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 14 Mar 2010 05:12:07 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o2E5C6xL036781
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 14 Mar 2010 05:12:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o2E5C6no036752;
	Sun, 14 Mar 2010 05:12:06 GMT
	(envelope-from nobody)
Message-Id: <201003140512.o2E5C6no036752@www.freebsd.org>
Date: Sun, 14 Mar 2010 05:12:06 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: network.subr functions accumulate output before r197139
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         144726
>Category:       conf
>Synopsis:       network.subr functions accumulate output before r197139
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    hrs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 14 05:20:03 UTC 2010
>Closed-Date:    
>Last-Modified:  Sun Feb 03 22:28:19 UTC 2013
>Originator:     Garrett Cooper
>Release:        RELENG_8
>Organization:
Cisco Systems, Inc.
>Environment:
FreeBSD foo.localdomain 8.0-STABLE FreeBSD 8.0-STABLE #1 r204854M: Fri Mar 12 22:21:06 PST 2010     root@:/usr/obj/scratch/ip-thinclient-test/releng_8/sys/GENERIC  amd64
>Description:
On a system prior to r197319, any given time that list_net_interfaces is
run more than once, the list grows as the variables in list_net_interfaces
after that commit is a local and not a global variable.

Example (RELENG_8):

# . /etc/rc.subr ; . /etc/network.subr ; . /etc/defaults/rc.conf ; list_net_interfaces
lo0 lo0 lo0 lo0 plip0 bge0 bge1plip0 bge0 bge1plip0 bge0 bge1
# uname -a
FreeBSD foo.localdomain 8.0-STABLE FreeBSD 8.0-STABLE #1 r204854M: Fri Mar 12 22:21:06 PST 2010     root@:/usr/obj/scratch/ip-thinclient-test/releng_8/sys/GENERIC  amd64

Example (9-CURRENT):

[gcooper@bayonetta /scratch/src/head/usr.bin/hexdump]$ . /etc/rc.subr ; . /etc/network.subr ; . /etc/defaults/rc.conf ; list_net_interfaces
lo0 em0 fwe0
[gcooper@bayonetta /scratch/src/head/usr.bin/hexdump]$ uname -a
FreeBSD bayonetta.localdomain 9.0-CURRENT FreeBSD 9.0-CURRENT #2: Thu Mar  4 13:16:39 PST 2010     gcooper@bayonetta.localdomain:/usr/obj/usr/src/sys/BAYONETTA  amd64

It would be nice if this variable scoping was properly backported so
others could use the functions more than once without unsetting the
variables beforehand (it saves me from duplicating network interface
detection in a script I'm using).
>How-To-Repeat:
1. Use a system based off of sources prior to r197319.
2. Execute: . /etc/rc.subr ; . /etc/network.subr ; . /etc/defaults/rc.conf ;
   list_net_interfaces
>Fix:
MFC the code in r197139 (it was supposed to be MFCed after 3 days according
to the commit email: http://svn.freebsd.org/changeset/base/197139 ).

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->hrs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Mar 14 06:44:20 UTC 2010 
Responsible-Changed-Why:  
Assign this request for MFC to committer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144726 

From: Garrett Cooper <yaneurabeya@gmail.com>
To: bug-followup@FreeBSD.org, gcooper@FreeBSD.org
Cc:  
Subject: Re: conf/144726: network.subr functions accumulate output before 
	r197139
Date: Sun, 14 Mar 2010 13:57:14 -0700

 The actual reproduction step is:
 
     . /etc/rc.subr ; . /etc/network.subr ; . /etc/defaults/rc.conf ;
 list_net_interfaces; list_net_interfaces
 
 Sorry 'bout that :/.
 
 Thanks,
 -Garrett
>Unformatted:
