This patch implements the DHCP Class identifier (see rfc1533) which is
used by DHCP clients to optionally identify the type and configuration of
a DHCP client which is send as a string to the server. For example, the
identifier may encode the client's hardware configuration. If the newly
introduced kernel-parameter 'dhcpclass' is set, then the kernel sends
the given string in its DHCP-request to the server.
If the option is omitted, the behaviour is as before without this patch.
Patch applies to:
Version: 2.6.23.1
File: net/ipv4/ipconfig.c
Signed-off-by: Rainer Jochem <rainer.jochem@mpi-sb.mpg.de>
---
--- net/ipv4/ipconfig.c.orig 2007-11-08 14:54:11.001662860 +0100
+++ net/ipv4/ipconfig.c 2007-11-08 14:54:15.961480524 +0100
@@ -139,6 +139,8 @@ __be32 ic_servaddr = NONE; /* Boot serve
__be32 root_server_addr = NONE; /* Address of NFS server */
u8 root_server_path[256] = { 0, }; /* Path to mount as root */
+char vendor_class_identifier[256] = { 0, }; /* vendor class identifier */
+
/* Persistent data: */
static int ic_proto_used; /* Protocol used, if any */
@@ -620,6 +622,17 @@ ic_dhcp_init_options(u8 *options)
*e++ = sizeof(ic_req_params);
memcpy(e, ic_req_params, sizeof(ic_req_params));
e += sizeof(ic_req_params);
+
+ // Send it only if the according kernel parameter was set
+ if (*vendor_class_identifier) {
+ printk(KERN_INFO "Sending class identifier \"%s\"\n",
+ vendor_class_identifier);
+ *e++ = 60; /* Class-identifier */
+ *e++ = strlen(vendor_class_identifier);
+ memcpy(e, vendor_class_identifier,
+ strlen(vendor_class_identifier));
+ e += strlen(vendor_class_identifier);
+ }
}
*e++ = 255; /* End of the list */
@@ -1507,5 +1520,14 @@ static int __init nfsaddrs_config_setup(
return ip_auto_config_setup(addrs);
}
+static int __init vendor_class_identifier_setup(char *addrs)
+{
+ if (strlcpy(vendor_class_identifier, addrs, 250) > 250)
+ printk(KERN_WARNING "vendorclass too long, ...You could avoid these three strlen calls by using a temporary sizeof(vendor_class_identifier). Why are you using 250 but the -
This information is only sent in the case that the option is actually used.
And in this case it might be useful for the user to see to which string the
option was set.
--- net/ipv4/ipconfig.c.orig 2007-11-14 09:16:15.800566536 +0100
+++ net/ipv4/ipconfig.c 2007-11-14 09:16:20.200403710 +0100
@@ -139,6 +139,8 @@ __be32 ic_servaddr = NONE; /* Boot serve
__be32 root_server_addr = NONE; /* Address of NFS server */
u8 root_server_path[256] = { 0, }; /* Path to mount as root */
+static char vendor_class_identifier[253]; /* vendor class identifier */
+
/* Persistent data: */
static int ic_proto_used; /* Protocol used, if any */
@@ -580,6 +582,7 @@ ic_dhcp_init_options(u8 *options)
u8 mt = ((ic_servaddr == NONE)
? DHCPDISCOVER : DHCPREQUEST);
u8 *e = options;
+ int len = 0;
#ifdef IPCONFIG_DEBUG
printk("DHCP: Sending message type %d\n", mt);
@@ -620,6 +623,16 @@ ic_dhcp_init_options(u8 *options)
*e++ = sizeof(ic_req_params);
memcpy(e, ic_req_params, sizeof(ic_req_params));
e += sizeof(ic_req_params);
+
+ if (*vendor_class_identifier) {
+ printk(KERN_INFO "Sending class identifier \"%s\"\n",
+ vendor_class_identifier);
+ *e++ = 60; /* Class-identifier */
+ len = strlen(vendor_class_identifier);
+ *e++ = len;
+ memcpy(e, vendor_class_identifier, len);
+ e += len;
+ }
}
*e++ = 255; /* End of the list */
@@ -1507,5 +1520,16 @@ static int __init nfsaddrs_config_setup(
return ip_auto_config_setup(addrs);
}
+static int __init vendor_class_identifier_setup(char *addrs)
+{
+ if (strlcpy(vendor_class_identifier, addrs,
+ sizeof(vendor_class_identifier))
+ > sizeof(vendor_class_identifier))
+ printk(KERN_WARNING "vendorclass too long, truncated to \"%s\"",
+ vendor_class_identifier);
+ return 1;
+}
+
__setup("ip=", ip_auto_config_setup);
__setup("nfsaddrs=", nfsaddrs_config_setup);
+__setup("dhcpclass=", vendor_class_identifier_setup);
----
--- ...I don't think its very useful since you can simply get this information from /proc/cmdline in case something goes wrong, but if you insist at Should be >= I think. -
Fixed.
Regards,
Rainer
----
--- net/ipv4/ipconfig.c.orig 2007-11-14 09:16:15.800566536 +0100
+++ net/ipv4/ipconfig.c 2007-11-14 10:34:22.471219274 +0100
@@ -139,6 +139,8 @@ __be32 ic_servaddr = NONE; /* Boot serve
__be32 root_server_addr = NONE; /* Address of NFS server */
u8 root_server_path[256] = { 0, }; /* Path to mount as root */
+static char vendor_class_identifier[253]; /* vendor class identifier */
+
/* Persistent data: */
static int ic_proto_used; /* Protocol used, if any */
@@ -580,6 +582,7 @@ ic_dhcp_init_options(u8 *options)
u8 mt = ((ic_servaddr == NONE)
? DHCPDISCOVER : DHCPREQUEST);
u8 *e = options;
+ int len;
#ifdef IPCONFIG_DEBUG
printk("DHCP: Sending message type %d\n", mt);
@@ -620,6 +623,16 @@ ic_dhcp_init_options(u8 *options)
*e++ = sizeof(ic_req_params);
memcpy(e, ic_req_params, sizeof(ic_req_params));
e += sizeof(ic_req_params);
+
+ if (*vendor_class_identifier) {
+ printk(KERN_INFO "DHCP: sending class identifier \"%s\"\n",
+ vendor_class_identifier);
+ *e++ = 60; /* Class-identifier */
+ len = strlen(vendor_class_identifier);
+ *e++ = len;
+ memcpy(e, vendor_class_identifier, len);
+ e += len;
+ }
}
*e++ = 255; /* End of the list */
@@ -1507,5 +1520,16 @@ static int __init nfsaddrs_config_setup(
return ip_auto_config_setup(addrs);
}
+static int __init vendor_class_identifier_setup(char *addrs)
+{
+ if (strlcpy(vendor_class_identifier, addrs,
+ sizeof(vendor_class_identifier))
+ >= sizeof(vendor_class_identifier))
+ printk(KERN_WARNING "DHCP: vendorclass too long, truncated to \"%s\"",
+ vendor_class_identifier);
+ return 1;
+}
+
__setup("ip=", ip_auto_config_setup);
__setup("nfsaddrs=", nfsaddrs_config_setup);
+__setup("dhcpclass=", vendor_class_identifier_setup);
-
From: Patrick McHardy <kaber@trash.net> Applied to net-2.6.25, thanks everyone. -
Rainer Jochem <rainer.jochem@mpi-sb.mpg.de> : ic_dhcp_init_options is __init. Should it not be __initdata ? -- Ueimor -
From: Francois Romieu <romieu@fr.zoreil.com> I think so and I've made that change in net-2.6.25, thanks. -
No C99 comments please. Though I'm not sure if this comment is that -- i. -
| Greg KH | Og dreams of kernels |
| Jens Axboe | [PATCH 31/33] Fusion: sg chaining support |
| Arnd Bergmann | Re: finding your own dead "CONFIG_" variables |
| Mark Brown | [PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset |
| Tony Breeds | [LGUEST] Look in object dir for .config |
git: | |
| Brian Downing | Re: Git in a Nutshell guide |
| John Benes | Re: master has some toys |
| Matthias Lederhofer | [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree |
| Alexander Sulfrian | [RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set |
| Junio C Hamano | Re: Rss produced by git is not valid xml? |
| Linux Kernel Mailing List | iSeries: fix section mismatch in iseries_veth |
| Linux Kernel Mailing List | ixbge: remove TX lock and redo TX accounting. |
| Linux Kernel Mailing List | ixgbe: fix several counter register errata |
| Linux Kernel Mailing L |
