Re: [patch] netconsole-2.4.10-B1

Randy.Dunlap (rddunlap@osdlab.org)
Mon, 01 Oct 2001 09:58:07 -0700


This is a multi-part message in MIME format.
--------------00741BC33BCD832C57A99F68
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Andreas Dilger wrote:
>
> A few minor changes to the code, after testing it a bit locally (note that I
> am using kernel patch C1):
>
> First, a patch to change the MAC address kernel parameter to be in the
> standard XX:XX:XX:XX:XX:XX form, instead of separate bytes. It also
> fixes the output of the IP addresses to be unsigned ints. Isn't there
> a function in the kernel to format IP addresses for output already?

Not quite for formatting, but NIPQUAD(ipaddr) passes 4 octets of IP
address to <anywhere>.

Here's a patch/replacement for the IP address printing in the
netconsole
kernel module, using NIPQUAD(). Against netconsole version C2.

BTW, in linux/include/linux/kernel.h, isn't HIPQUAD() totally useless
(and also unused)? It looks very little-endian-specific.
Well, it can be used on little-endian systems if the ipaddr is
in host-order.

~Randy
--------------00741BC33BCD832C57A99F68
Content-Type: text/plain; charset=us-ascii;
name="netcon-ipaddr.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="netcon-ipaddr.patch"

--- linux/drivers/net/netconsole.c.save Mon Oct 1 07:43:31 2001
+++ linux/drivers/net/netconsole.c Mon Oct 1 09:28:57 2001
@@ -263,25 +263,20 @@
printk(KERN_ERR "netconsole: network device %s is not an IP protocol device, aborting.\n", dev);
return -1;
}
- source_ip = ntohl(in_dev->ifa_list->ifa_local);
+ source_ip = in_dev->ifa_list->ifa_local;
if (!source_ip) {
printk(KERN_ERR "netconsole: network device %s has no local address, aborting.\n", dev);
return -1;
}
-#define IP(x) ((char *)&source_ip)[x]
- printk(KERN_INFO "netconsole: using source IP %i.%i.%i.%i\n",
- IP(3), IP(2), IP(1), IP(0));
-#undef IP
- source_ip = htonl(source_ip);
+ printk(KERN_INFO "netconsole: using source IP %u.%u.%u.%u\n", NIPQUAD(source_ip));
+
+ target_ip = htonl(target_ip);
if (!target_ip) {
printk(KERN_ERR "netconsole: target_ip parameter not specified, aborting.\n");
return -1;
}
-#define IP(x) ((char *)&target_ip)[x]
- printk(KERN_INFO "netconsole: using target IP %i.%i.%i.%i\n",
- IP(3), IP(2), IP(1), IP(0));
-#undef IP
- target_ip = htonl(target_ip);
+ printk(KERN_INFO "netconsole: using target IP %u.%u.%u.%u\n", NIPQUAD(target_ip));
+
if (!source_port) {
printk(KERN_ERR "netconsole: source_port parameter not specified, aborting.\n");
return -1;

--------------00741BC33BCD832C57A99F68--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/