From dmitri@opay.ru  Fri Mar 23 16:59:19 2007
Return-Path: <dmitri@opay.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 19E6616A419
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Mar 2007 16:59:19 +0000 (UTC)
	(envelope-from dmitri@opay.ru)
Received: from opay.ru (opay.ru [81.19.78.124])
	by mx1.freebsd.org (Postfix) with ESMTP id 551FD13C468
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Mar 2007 16:59:17 +0000 (UTC)
	(envelope-from dmitri@opay.ru)
Received: by opay.ru (Postfix, from userid 1001)
	id 5C0671EA652; Fri, 23 Mar 2007 20:05:22 +0300 (MSK)
Message-Id: <20070323170522.5C0671EA652@opay.ru>
Date: Fri, 23 Mar 2007 20:05:22 +0300 (MSK)
From: Dmitri Alenitchev <dmitri@dworlds.ru>
Reply-To: Dmitri Alenitchev <dmitri@dworlds.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] support for interface descriptions
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         110720
>Category:       kern
>Synopsis:       [net] [patch] [request] support for interface descriptions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kmacy
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 23 17:00:10 GMT 2007
>Closed-Date:    Wed Apr 27 11:27:54 UTC 2011
>Last-Modified:  Wed Apr 27 11:27:54 UTC 2011
>Originator:     Dmitri Alenitchev
>Release:        
>Organization:
Digital Worlds J.S.C.
>Environment:
>Description:
	support for interface descriptions. this can be used to 
	label interfaces in situations where they may otherwise 
	be difficult to identify (e.g. machines with many active
	interfaces)
>How-To-Repeat:
>Fix:

	

--- interface_descriptions.diff begins here ---
Index: sbin/ifconfig/ifconfig.8
===================================================================
RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.95.2.17
diff -u -r1.95.2.17 ifconfig.8
--- sbin/ifconfig/ifconfig.8	3 Nov 2006 09:14:24 -0000	1.95.2.17
+++ sbin/ifconfig/ifconfig.8	23 Mar 2007 16:49:03 -0000
@@ -245,6 +245,11 @@
 extra console error logging.
 .It Fl debug
 Disable driver dependent debugging code.
+.It Cm description Ar value
+Specify a description of the interface.
+This can be used to label interfaces in situations where they may
+otherwise be difficult to identify
+.Pq e.g. machines with many active interfaces .
 .It Cm promisc
 Put interface into permanently promiscuous mode.
 .It Fl promisc
Index: sbin/ifconfig/ifconfig.c
===================================================================
RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.113.2.5
diff -u -r1.113.2.5 ifconfig.c
--- sbin/ifconfig/ifconfig.c	18 Mar 2006 21:59:22 -0000	1.113.2.5
+++ sbin/ifconfig/ifconfig.c	23 Mar 2007 16:49:04 -0000
@@ -790,6 +790,15 @@
 	printname = 0;
 }
 
+static void
+setifdesc(const char *val, int dummy __unused, int s,
+    const struct afswtch *afp)
+{
+	ifr.ifr_data = strdup(val);
+	if (ioctl(s, SIOCSIFDESCR, (caddr_t)&ifr) < 0)
+		warn("SIOCSIFDESCR");
+}
+
 /*
  * Expand the compacted form of addresses as returned via the
  * configuration read via sysctl().
@@ -1050,6 +1059,8 @@
 	DEF_CMD("noicmp",	IFF_LINK1,	setifflags),
 	DEF_CMD_ARG("mtu",			setifmtu),
 	DEF_CMD_ARG("name",			setifname),
+	DEF_CMD_ARG("description",		setifdesc),
+	DEF_CMD_ARG("descr",			setifdesc),
 };
 
 static __constructor void
Index: sbin/ifconfig/ifmedia.c
===================================================================
RCS file: /home/ncvs/src/sbin/ifconfig/ifmedia.c,v
retrieving revision 1.19.2.2
diff -u -r1.19.2.2 ifmedia.c
--- sbin/ifconfig/ifmedia.c	31 Aug 2006 21:01:41 -0000	1.19.2.2
+++ sbin/ifconfig/ifmedia.c	23 Mar 2007 16:49:05 -0000
@@ -106,7 +106,16 @@
 media_status(int s)
 {
 	struct ifmediareq ifmr;
+	struct ifreq ifrdesc;
 	int *media_list, i;
+	char *ifdescr[IFDESCRSIZE];
+
+	(void) memset(&ifrdesc, 0, sizeof(ifrdesc));
+	(void) strlcpy(ifrdesc.ifr_name, name, sizeof(ifrdesc.ifr_name));
+	ifrdesc.ifr_data = (caddr_t)&ifdescr;
+	if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0 &&
+	    strlen(ifrdesc.ifr_data))
+		printf("\tdescription: %s\n", ifrdesc.ifr_data);
 
 	(void) memset(&ifmr, 0, sizeof(ifmr));
 	(void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
Index: sys/net/if.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if.c,v
retrieving revision 1.234.2.17
diff -u -r1.234.2.17 if.c
--- sys/net/if.c	6 Oct 2006 20:26:05 -0000	1.234.2.17
+++ sys/net/if.c	23 Mar 2007 16:49:22 -0000
@@ -1233,7 +1233,9 @@
 	int error = 0;
 	int new_flags, temp_flags;
 	size_t namelen, onamelen;
+	size_t bytesdone;
 	char new_name[IFNAMSIZ];
+	char ifdescrbuf[IFDESCRSIZE];
 	struct ifaddr *ifa;
 	struct sockaddr_dl *sdl;
 
@@ -1497,6 +1499,23 @@
 		    ifr->ifr_addr.sa_data, ifr->ifr_addr.sa_len);
 		break;
 
+	case SIOCGIFDESCR:
+		strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE);
+		error = copyout(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE);
+		break;
+
+	case SIOCSIFDESCR:
+		error = suser(td);
+		if (error)
+			return (error);
+		error = copyinstr(ifr->ifr_data, ifdescrbuf,
+		    IFDESCRSIZE, &bytesdone);
+		if (error == 0) {
+			(void)memset(ifp->if_description, 0, IFDESCRSIZE);
+			strlcpy(ifp->if_description, ifdescrbuf, IFDESCRSIZE);
+		}	
+		break;
+
 	default:
 		error = ENOIOCTL;
 		break;
Index: sys/net/if.h
===================================================================
RCS file: /home/ncvs/src/sys/net/if.h,v
retrieving revision 1.96.2.4
diff -u -r1.96.2.4 if.h
--- sys/net/if.h	15 Feb 2006 03:37:15 -0000	1.96.2.4
+++ sys/net/if.h	23 Mar 2007 16:49:22 -0000
@@ -63,6 +63,11 @@
 #if __BSD_VISIBLE
 
 /*
+ * Length of interface description, including terminating '\0'.
+ */
+#define		IFDESCRSIZE	64
+
+/*
  * Structure used to query names of interface cloners.
  */
 
Index: sys/net/if_var.h
===================================================================
RCS file: /home/ncvs/src/sys/net/if_var.h,v
retrieving revision 1.98.2.6
diff -u -r1.98.2.6 if_var.h
--- sys/net/if_var.h	6 Oct 2006 20:26:05 -0000	1.98.2.6
+++ sys/net/if_var.h	23 Mar 2007 16:49:22 -0000
@@ -136,6 +136,7 @@
 	u_short	if_nvlans;		/* number of active vlans */
 	int	if_flags;		/* up/down, broadcast, etc. */
 	int	if_capabilities;	/* interface capabilities */
+	char	if_description[IFDESCRSIZE]; /* interface description */
 	int	if_capenable;		/* enabled features */
 	void	*if_linkmib;		/* link-type-specific MIB data */
 	size_t	if_linkmiblen;		/* length of above data */
Index: sys/sys/sockio.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/sockio.h,v
retrieving revision 1.28.2.1
diff -u -r1.28.2.1 sockio.h
--- sys/sys/sockio.h	15 Feb 2006 03:37:15 -0000	1.28.2.1
+++ sys/sys/sockio.h	23 Mar 2007 16:49:24 -0000
@@ -117,4 +117,7 @@
 #define	SIOCIFDESTROY	 _IOW('i', 121, struct ifreq)	/* destroy clone if */
 #define	SIOCIFGCLONERS	_IOWR('i', 120, struct if_clonereq) /* get cloners */
 
+#define	SIOCSIFDESCR	 _IOW('i', 128, struct ifreq)	/* set ifnet descr */
+#define	SIOCGIFDESCR	_IOWR('i', 129, struct ifreq)	/* get ifnet descr */
+
 #endif /* !_SYS_SOCKIO_H_ */
--- interface_descriptions.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Mar 23 18:44:02 UTC 2007 
Responsible-Changed-Why:  
Over to mailing list for evaluation. 

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

From: Roman Bogorodskiy <novel@FreeBSD.org>
To: bug-followup@FreeBSD.org, dmitri@dworlds.ru
Cc:  
Subject: Re: kern/110720: [net] [patch] support for interface descriptions
Date: Mon, 26 Mar 2007 10:52:20 +0400

 --FL5UXtIhxfXey3p5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 I wrote that two years ago...
 
 mailto:bug-followup@FreeBSD.org,dmitri%40dworlds.ru?subject=Re:%20kern/110720:%20%5Bnet%5D%20%5Bpatch%5D%20support%20for%20interface%20descriptions
 
 brooks@ left some comments recently, though I have not had enough time
 to take a look at it...
 
 Roman Bogorodskiy
 
 --FL5UXtIhxfXey3p5
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (FreeBSD)
 
 iQCVAwUBRgdtpIB0WzgdqspGAQJJZAQAkbS1UX8mIxIjhsUuQRJnJpFfOQvoM4RL
 25fiFNumPw+nXGAA51mGpf/0BCXsV1dkbvNVTAPaqJZzPdH7uyNor826hYM1FPD4
 OCmnDIIpDo7fIcYtpxTBbfoq7QfIZGM4RGJHW57ZeWxcXZMOsYNwkT2Ad/ohv7SE
 MkvV/C8pkTc=
 =1OzW
 -----END PGP SIGNATURE-----
 
 --FL5UXtIhxfXey3p5--

From: Roman Bogorodskiy <novel@FreeBSD.org>
To: bug-followup@FreeBSD.org, dmitri@dworlds.ru
Cc:  
Subject: Re: kern/110720: [net] [patch] support for interface descriptions
Date: Mon, 26 Mar 2007 11:04:19 +0400

 --i0/AhcQY5QxfSsSZ
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
   Roman Bogorodskiy wrote:
 
 > I wrote that two years ago...
 >=20
 > mailto:bug-followup@FreeBSD.org,dmitri%40dworlds.ru?subject=3DRe:%20kern/=
 110720:%20%5Bnet%5D%20%5Bpatch%5D%20support%20for%20interface%20descriptions
 
 Doh, I copy-pasted wrong link.
 
 http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dkern/83622
 
 > brooks@ left some comments recently, though I have not had enough time
 > to take a look at it...
 >=20
 > Roman Bogorodskiy
 
 
 Roman Bogorodskiy
 
 --i0/AhcQY5QxfSsSZ
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (FreeBSD)
 
 iQCVAwUBRgdwc4B0WzgdqspGAQJZ6wQAnpdEpAR7e+L27AQvbhW2ycge4XBX0VcM
 kNQcy8JHbJbAcgrSwclzZeRPau4ulM89XUOphE5QG3SpGS0vYoX8rewFYgqAa96z
 eeByiRrC+jqqKFZby3R2z50vFQKZ7e3c0qEn5Lvlz+cL4gsU3Cx89/7qDsxVbbXX
 SwoK9f14bYI=
 =Eyes
 -----END PGP SIGNATURE-----
 
 --i0/AhcQY5QxfSsSZ--

From: "Dmitri Alenitchev" <dmitri@dworlds.ru>
To: "Roman Bogorodskiy" <novel@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: kern/110720: [net] [patch] support for interface descriptions
Date: Tue, 27 Mar 2007 12:01:45 +0400

 Roman Bogorodskiy wrote:
 [...]
 > Doh, I copy-pasted wrong link.
 >
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/83622
 >
 > > brooks@ left some comments recently, though I have not had enough time
 > > to take a look at it...
 
 Yes, really.
 
 This PR is duplicated with 83622.
Responsible-Changed-From-To: freebsd-net->andre 
Responsible-Changed-By: andre 
Responsible-Changed-When: Sun May 13 18:39:20 UTC 2007 
Responsible-Changed-Why:  
Take over. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=110720 
Responsible-Changed-From-To: andre->kmacy 
Responsible-Changed-By: kmacy 
Responsible-Changed-When: Fri Nov 16 06:39:04 UTC 2007 
Responsible-Changed-Why:  

Assign to self pending feedback from brooks and sam. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=110720 
State-Changed-From-To: open->feedback 
State-Changed-By: kmacy 
State-Changed-When: Sun Nov 18 21:29:53 UTC 2007 
State-Changed-Why:  

We're open to the idea. However, it needs to not use more than an extra
pointer in ifnet  and not have an arbitrary limit on size. The best way
to go about this is to have the  information in a separate structure and
a flag to indicate that it has been set. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=110720 
State-Changed-From-To: feedback->closed 
State-Changed-By: ae 
State-Changed-When: Wed Apr 27 11:27:33 UTC 2011 
State-Changed-Why:  
The similar functional is already committed to head/ and stable/8 branches. 
Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=110720 
>Unformatted:
