Re: [PATCH] crash: add dev_base_head support for net command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Dave Anderson wrote:
> > Eugene Teo wrote:
> >
> >    Hi Dave,
> >
> >    I found that the net command in crash 4.0-6.1 does not work with Fedora
> >    kernel 2.6.23.14-115.fc8. There was a rework on dev_base[1] to replace
> >    the use of dev_base variable, and dev->next pointer with for_each_netdev
> >    loop. This patch fixes this problem.
>
>
> Thanks Eugene -- queued for the next release.
>
> BTW, the patch looks to have a short shelf-life.  In 2.6.24, the
> new dev_base_head list_head that your patch looks for no longer
> exists.  So for now I've also updated the error message in
> show_net_devices() to complain if both dev_base and dev_base_head
> don't exist.
>
> I'll update the TODO list with the newer net command issue
> if anybody wants to take a shot at fixing it.
>
> Thanks,
>   Dave

The attached patch addresses the same issue for 2.6.24 and later kernels,
and which applies on top of Eugene's patch.

Dave


Index: defs.h
===================================================================
RCS file: /nfs/projects/cvs/crash/defs.h,v
retrieving revision 1.342
diff -u -r1.342 defs.h
--- defs.h	17 Mar 2008 14:22:22 -0000	1.342
+++ defs.h	17 Mar 2008 20:58:30 -0000
@@ -1235,6 +1235,7 @@
 	long net_device_addr_len;
 	long net_device_ip_ptr;
 	long net_device_dev_list;
+	long net_dev_base_head;
 	long device_next;
 	long device_name;
 	long device_type;
Index: net.c
===================================================================
RCS file: /nfs/projects/cvs/crash/net.c,v
retrieving revision 1.24
diff -u -r1.24 net.c
--- net.c	17 Mar 2008 14:22:22 -0000	1.24
+++ net.c	17 Mar 2008 20:58:26 -0000
@@ -66,6 +66,7 @@
 
 static void show_net_devices(void);
 static void show_net_devices_v2(void);
+static void show_net_devices_v3(void);
 static void print_neighbour_q(ulong, int);
 static void get_netdev_info(ulong, struct devinfo *);
 static void get_device_name(ulong, char *);
@@ -113,6 +114,7 @@
 		net->dev_ip_ptr = MEMBER_OFFSET_INIT(net_device_ip_ptr,
 			"net_device", "ip_ptr");
 		MEMBER_OFFSET_INIT(net_device_dev_list, "net_device", "dev_list");
+		MEMBER_OFFSET_INIT(net_dev_base_head, "net", "dev_base_head");
 		ARRAY_LENGTH_INIT(net->net_device_name_index,
 			net_device_name, "net_device.name", NULL, sizeof(char));
 		net->flags |= (NETDEV_INIT|STRUCT_NET_DEVICE);
@@ -360,10 +362,13 @@
 	if (symbol_exists("dev_base_head")) {
 		show_net_devices_v2();
 		return;
+	} else if (symbol_exists("init_net")) {
+		show_net_devices_v3();
+		return;
 	}
 
 	if (!symbol_exists("dev_base"))
-		error(FATAL, "dev_base or dev_base_head do not exist!\n");
+		error(FATAL, "dev_base, dev_base_head or init_net do not exist!\n");
 
 	get_symbol_data("dev_base", sizeof(void *), &next);
 
@@ -444,6 +449,62 @@
 	FREEBUF(net_device_buf);
 }
 
+static void
+show_net_devices_v3(void)
+{
+	struct list_data list_data, *ld;
+	char *net_device_buf;
+	char buf[BUFSIZE];
+	ulong *ndevlist;
+	int ndevcnt, i;
+	long flen;
+
+	if (!net->netdevice) /* initialized in net_init() */
+		return;
+
+	flen = MAX(VADDR_PRLEN, strlen(net->netdevice));
+
+	fprintf(fp, "%s  NAME   IP ADDRESS(ES)\n",
+		mkstring(upper_case(net->netdevice, buf), 
+			flen, CENTER|LJUST, NULL));
+
+	net_device_buf = GETBUF(SIZE(net_device));
+
+	ld =  &list_data;
+	BZERO(ld, sizeof(struct list_data));
+	ld->start = ld->end =
+		 symbol_value("init_net") + OFFSET(net_dev_base_head);
+	ld->list_head_offset = OFFSET(net_device_dev_list);
+
+	hq_open();
+	ndevcnt = do_list(ld);
+	ndevlist = (ulong *)GETBUF(ndevcnt * sizeof(ulong));
+	ndevcnt = retrieve_list(ndevlist, ndevcnt);
+	hq_close();
+
+	/*
+	 *  Skip the first entry (init_net).
+	 */
+	for (i = 1; i < ndevcnt; ++i) {
+		readmem(ndevlist[i], KVADDR, net_device_buf,
+			SIZE(net_device), "net_device buffer",
+			FAULT_ON_ERROR);
+
+                fprintf(fp, "%s  ",
+			mkstring(buf, flen, CENTER|RJUST|LONG_HEX,
+			MKSTR(ndevlist[i])));
+
+		get_device_name(ndevlist[i], buf);
+		fprintf(fp, "%-6s ", buf);
+
+		get_device_address(ndevlist[i], buf);
+		fprintf(fp, "%s\n", buf);
+	}
+	
+	FREEBUF(ndevlist);
+	FREEBUF(net_device_buf);
+}
+
 /*
  * Perform the actual work of dumping the ARP table...
  */
Index: symbols.c
===================================================================
RCS file: /nfs/projects/cvs/crash/symbols.c,v
retrieving revision 1.159
diff -u -r1.159 symbols.c
--- symbols.c	26 Feb 2008 16:35:23 -0000	1.159
+++ symbols.c	17 Mar 2008 20:58:34 -0000
@@ -6629,6 +6629,11 @@
         	OFFSET(net_device_addr_len));
 	fprintf(fp, "             net_device_ip_ptr: %ld\n",
         	OFFSET(net_device_ip_ptr));
+	fprintf(fp, "           net_device_dev_list: %ld\n",
+		OFFSET(net_device_dev_list));
+	fprintf(fp, "             net_dev_base_head: %ld\n",
+		OFFSET(net_dev_base_head));
+
 	fprintf(fp, "                   device_next: %ld\n",
         	OFFSET(device_next));
 	fprintf(fp, "                   device_name: %ld\n",
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux