From nobody@FreeBSD.org  Tue Aug 11 18:32:18 2009
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 59211106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Aug 2009 18:32:18 +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 3D7168FC41
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Aug 2009 18:32:18 +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 n7BIWHc4018471
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Aug 2009 18:32:17 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n7BIWHT4018469;
	Tue, 11 Aug 2009 18:32:17 GMT
	(envelope-from nobody)
Message-Id: <200908111832.n7BIWHT4018469@www.freebsd.org>
Date: Tue, 11 Aug 2009 18:32:17 GMT
From: Tom Judge <tom@tomjudge.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch]Libstands bootp/dhcp code always uses PXEClient as the vendor identifyer this adds cpu type and FreeBSD version to the identifer.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         137678
>Category:       kern
>Synopsis:       [libstand] [patch] libstand's bootp/dhcp code always uses PXEClient as the vendor identifier; this adds cpu type and FreeBSD version to the identifer.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 11 18:40:05 UTC 2009
>Closed-Date:    
>Last-Modified:  Sun Sep 02 17:05:49 UTC 2012
>Originator:     Tom Judge
>Release:        7.1
>Organization:
Mintel
>Environment:
FreeBSD dev-tj-7-1.XXXXXXXX 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
When the pxeboot loader sends the dhcp request to the server to get the
configuration it currently always sets the vendor identifier to PXEClient.

This is not very useful when trying to setup PXE environment to install
multiple releases on different architectures.

The attached patch changes the identifier to look like:

PXEClient:FBSD:i386:701000

i386 is substituted for amd64 on amd64 hosts and omited on other architectures.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: bootp.c
===================================================================
--- bootp.c	(revision 723)
+++ bootp.c	(revision 727)
@@ -39,6 +39,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
+#include <osreldate.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 
@@ -75,6 +76,7 @@
 #ifdef SUPPORT_DHCP
 static char expected_dhcpmsgtype = -1, dhcp_ok;
 struct in_addr dhcp_serverip;
+static void vend_ident(u_char *);
 #endif
 
 /* Fetch required bootp infomation */
@@ -93,7 +95,9 @@
 		u_char header[HEADER_SIZE];
 		struct bootp rbootp;
 	} rbuf;
-
+#ifdef SUPPORT_DHCP
+	char *vendor_ident;
+#endif
 #ifdef BOOTP_DEBUG
  	if (debug)
 		printf("bootp: socket=%d\n", sock);
@@ -132,9 +136,12 @@
 	 */
 	if (flag & BOOTP_PXE) {
 		bp->bp_vend[7] = TAG_CLASSID;
-		bp->bp_vend[8] = 9;
-		bcopy("PXEFBSD71", &bp->bp_vend[9], 9);
-		bp->bp_vend[18] = TAG_END;
+		vendor_ident=malloc(1024);
+		vend_ident(vendor_ident);
+		bp->bp_vend[8] = strlen(vendor_ident);
+		bcopy(vendor_ident, &bp->bp_vend[9], bp->bp_vend[8]);
+		free(vendor_ident);
+		bp->bp_vend[(9 + bp->bp_vend[8])] = TAG_END;
 	} else
 		bp->bp_vend[7] = TAG_END;
 #else
@@ -175,9 +182,12 @@
 		bcopy(&leasetime, &bp->bp_vend[21], 4);
 		if (flag & BOOTP_PXE) {
 			bp->bp_vend[25] = TAG_CLASSID;
-			bp->bp_vend[26] = 9;
-			bcopy("PXEClient", &bp->bp_vend[27], 9);
-			bp->bp_vend[36] = TAG_END;
+			vendor_ident=malloc(1024);
+			vend_ident(vendor_ident);
+			bp->bp_vend[8] = strlen(vendor_ident);
+			bcopy(vendor_ident, &bp->bp_vend[27], bp->bp_vend[26]);
+			free(vendor_ident);
+			bp->bp_vend[(27 + bp->bp_vend[26])] = TAG_END;
 		} else
 			bp->bp_vend[25] = TAG_END;
 
@@ -390,6 +400,21 @@
 	}
 	return(0);
 }
+#ifdef SUPPORT_DHCP
+static void
+vend_ident(cp)
+	u_char *cp;
+{
+	char default_vendor_ident[] = "PXEClient:FBSD";
+#ifdef __i386__
+	sprintf(cp,"%s:i386:%d",default_vendor_ident,__FreeBSD_version);
+#elif __amd64__
+	sprintf(cp,"%s:amd64:%d",default_vendor_ident,__FreeBSD_version);
+#else
+	sprintf(cp,"%s:%d",default_vendor_ident,__FreeBSD_version);
+#endif
+}
+#endif
 
 #ifdef BOOTP_VEND_CMU
 static void


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sat May 12 03:15:30 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

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

From: Tom Judge <tom@tomjudge.com>
To: bug-followup@FreeBSD.org,
 tom@tomjudge.com
Cc:  
Subject: Re: kern/137678: [libstand] [patch] libstand&#39;s bootp/dhcp code always uses PXEClient as the vendor identifier; this adds cpu type and FreeBSD version to the identifer.
Date: Fri, 11 May 2012 23:25:51 -0400

 --Apple-Mail=_536B7B78-36BA-4591-9948-C8328DA54442
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 Updated patch attached.
 
 --Apple-Mail=_536B7B78-36BA-4591-9948-C8328DA54442
 Content-Disposition: attachment;
 	filename=bootp.c.patch
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="bootp.c.patch"
 Content-Transfer-Encoding: 7bit
 
 Index: bootp.c
 ===================================================================
 --- bootp.c	(revision 235276)
 +++ bootp.c	(working copy)
 @@ -39,6 +39,7 @@
  __FBSDID("$FreeBSD$");
  
  #include <sys/types.h>
 +#include <osreldate.h>
  #include <netinet/in.h>
  #include <netinet/in_systm.h>
  
 @@ -88,6 +89,7 @@
  #ifdef SUPPORT_DHCP
  static char expected_dhcpmsgtype = -1, dhcp_ok;
  struct in_addr dhcp_serverip;
 +static void vend_ident(u_char *);
  #endif
  
  /* Fetch required bootp infomation */
 @@ -106,7 +108,9 @@
  		u_char header[HEADER_SIZE];
  		struct bootp rbootp;
  	} rbuf;
 -
 +#ifdef SUPPORT_DHCP
 +	char *vendor_ident;
 +#endif
  #ifdef BOOTP_DEBUG
   	if (debug)
  		printf("bootp: socket=%d\n", sock);
 @@ -188,9 +192,12 @@
  		bcopy(&leasetime, &bp->bp_vend[21], 4);
  		if (flag & BOOTP_PXE) {
  			bp->bp_vend[25] = TAG_CLASSID;
 -			bp->bp_vend[26] = 9;
 -			bcopy("PXEClient", &bp->bp_vend[27], 9);
 -			bp->bp_vend[36] = TAG_END;
 +			vendor_ident=malloc(1024);
 +			vend_ident(vendor_ident);
 +			bp->bp_vend[8] = strlen(vendor_ident);
 +			bcopy(vendor_ident, &bp->bp_vend[27], bp->bp_vend[26]);
 +			free(vendor_ident);
 +			bp->bp_vend[(27 + bp->bp_vend[26])] = TAG_END;
  		} else
  			bp->bp_vend[25] = TAG_END;
  
 @@ -405,6 +412,21 @@
  	}
  	return(0);
  }
 +#ifdef SUPPORT_DHCP
 +static void
 +vend_ident(cp)
 +	u_char *cp;
 +{
 +	char default_vendor_ident[] = "PXEClient:FBSD";
 +#ifdef __i386__
 +	sprintf(cp,"%s:i386:%d",default_vendor_ident,__FreeBSD_version);
 +#elif __amd64__
 +	sprintf(cp,"%s:amd64:%d",default_vendor_ident,__FreeBSD_version);
 +#else
 +	sprintf(cp,"%s:%d",default_vendor_ident,__FreeBSD_version);
 +#endif
 +}
 +#endif
  
  #ifdef BOOTP_VEND_CMU
  static void
 
 --Apple-Mail=_536B7B78-36BA-4591-9948-C8328DA54442
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 
 Tom Judge
 
 
 
 
 
 --Apple-Mail=_536B7B78-36BA-4591-9948-C8328DA54442--
Responsible-Changed-From-To: eadler->freebsd-bugs 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Sep 2 17:05:46 UTC 2012 
Responsible-Changed-Why:  
I won't be looking at this PR for a while and I need to clear some out 
of my queue 

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