* [Drbd-dev] DRBD-8: add (basic) tracing to netlink commands
@ 2006-10-28 21:08 Graham, Simon
2006-10-31 15:40 ` Philipp Reisner
0 siblings, 1 reply; 2+ messages in thread
From: Graham, Simon @ 2006-10-28 21:08 UTC (permalink / raw)
To: drbd-dev
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
The attached patch adds some basic tracing to the netlink interface
using the new TRACE() mechanism and a new trace type. I'd like to add
more detailed tracing of the packets over time (probably based on
generating code from drbd_nl.h).
Simon
[-- Attachment #2: nl-trace.patch --]
[-- Type: application/octet-stream, Size: 3480 bytes --]
Index: drbd/drbd_nl.c
===================================================================
--- drbd/drbd_nl.c (.../trunk) (revision 5989)
+++ drbd/drbd_nl.c (.../branches/panic-2) (revision 5989)
@@ -115,12 +115,52 @@
tags = (unsigned short*)((char*)tags + arg->member ## _len);
#include "linux/drbd_nl.h"
-
extern void drbd_init_set_defaults(drbd_dev *mdev);
void drbd_bcast_ev_helper(drbd_dev *mdev, char* helper_name);
void drbd_nl_send_reply(struct cn_msg *, int);
+char *nl_packet_name(int packet_type) {
+// Generate packet type strings
+#define PACKET(name, number, fields) \
+ [ P_ ## name ] = # name,
+#define INTEGER Argh!
+#define BIT Argh!
+#define INT64 Argh!
+#define STRING Argh!
+ static char *nl_tag_name[P_nl_after_last_packet] = {
+#include "linux/drbd_nl.h"
+ };
+
+ return (packet_type < sizeof(nl_tag_name)/sizeof(nl_tag_name[0])) ?
+ nl_tag_name[packet_type] : "*Unknown*";
+}
+
+void nl_trace_packet(void *data) {
+ struct cn_msg *req = data;
+ struct drbd_nl_cfg_req *nlp = (struct drbd_nl_cfg_req*)req->data;
+
+ printk(KERN_INFO DEVICE_NAME "%d: "
+ "Netlink: << %s (%d) - seq: %x, ack: %x, len: %x\n",
+ nlp->drbd_minor,
+ nl_packet_name(nlp->packet_type),
+ nlp->packet_type,
+ req->seq, req->ack, req->len);
+}
+
+void nl_trace_reply(void *data) {
+ struct cn_msg *req = data;
+ struct drbd_nl_cfg_reply *nlp = (struct drbd_nl_cfg_reply*)req->data;
+
+ printk(KERN_INFO DEVICE_NAME "%d: "
+ "Netlink: >> %s (%d) - seq: %x, ack: %x, len: %x\n",
+ nlp->minor,
+ nlp->packet_type==P_nl_after_last_packet?
+ "Empty-Reply" : nl_packet_name(nlp->packet_type),
+ nlp->packet_type,
+ req->seq, req->ack, req->len);
+}
+
int drbd_khelper(drbd_dev *mdev, char* cmd)
{
char mb[12];
@@ -1508,6 +1548,8 @@
goto fail;
}
+ TRACE(TraceTypeNl, TraceLvlSummary, nl_trace_packet(data););
+
if( nlp->packet_type >= P_nl_after_last_packet ) {
retcode=UnknownNetLinkPacket;
goto fail;
@@ -1535,6 +1577,8 @@
cn_reply->len = sizeof(struct drbd_nl_cfg_reply) + rr;
cn_reply->flags = 0;
+ TRACE(TraceTypeNl, TraceLvlSummary, nl_trace_reply(cn_reply););
+
rr = cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
if(rr && rr != -ESRCH) {
printk(KERN_INFO DEVICE_NAME " cn_netlink_send()=%d\n",rr);
@@ -1577,6 +1621,8 @@
reply->minor = mdev_to_minor(mdev);
reply->ret_code = NoError;
+ TRACE(TraceTypeNl, TraceLvlSummary, nl_trace_reply(cn_reply););
+
cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
}
@@ -1613,6 +1659,8 @@
reply->minor = mdev_to_minor(mdev);
reply->ret_code = NoError;
+ TRACE(TraceTypeNl, TraceLvlSummary, nl_trace_reply(cn_reply););
+
cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
}
@@ -1670,6 +1718,8 @@
reply->minor = ((struct drbd_nl_cfg_req *)req->data)->drbd_minor;
reply->ret_code = ret_code;
+ TRACE(TraceTypeNl, TraceLvlSummary, nl_trace_reply(cn_reply););
+
rr = cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
if(rr && rr != -ESRCH) {
printk(KERN_INFO DEVICE_NAME " cn_netlink_send()=%d\n",rr);
Index: drbd/drbd_int.h
===================================================================
--- drbd/drbd_int.h (.../trunk) (revision 5989)
+++ drbd/drbd_int.h (.../branches/panic-2) (revision 5989)
@@ -1175,6 +1175,7 @@
TraceTypeResync = 0x00000008,
TraceTypeEE = 0x00000010,
TraceTypeUnplug = 0x00000020,
+ TraceTypeNl = 0x00000040,
};
static inline int
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Drbd-dev] DRBD-8: add (basic) tracing to netlink commands
2006-10-28 21:08 [Drbd-dev] DRBD-8: add (basic) tracing to netlink commands Graham, Simon
@ 2006-10-31 15:40 ` Philipp Reisner
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Reisner @ 2006-10-31 15:40 UTC (permalink / raw)
To: drbd-dev
Am Samstag, 28. Oktober 2006 23:08 schrieb Graham, Simon:
> The attached patch adds some basic tracing to the netlink interface
> using the new TRACE() mechanism and a new trace type. I'd like to add
> more detailed tracing of the packets over time (probably based on
> generating code from drbd_nl.h).
>
> Simon
Hi Simon,
I will apply that patch, but I have one question before I do ...
Why did you did it ?
Are you looking for a problem in the area of the netlink stuff ?
-Philipp
--
: Dipl-Ing Philipp Reisner Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austria http://www.linbit.com :
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-10-31 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-28 21:08 [Drbd-dev] DRBD-8: add (basic) tracing to netlink commands Graham, Simon
2006-10-31 15:40 ` Philipp Reisner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox