[patch 1/3] af_iucv: add s390dbf debugging support

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

 



From: Ursula Braun <ursula.braun@xxxxxxxxxx>

Add s390dbf entries to facilitate debugging of af_iucv problems.

Signed-off-by: Ursula Braun <ursula.braun@xxxxxxxxxx>
---

 net/iucv/af_iucv.c |  135 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 123 insertions(+), 12 deletions(-)

Index: net-2.6-uschi/net/iucv/af_iucv.c
===================================================================
--- net-2.6-uschi.orig/net/iucv/af_iucv.c
+++ net-2.6-uschi/net/iucv/af_iucv.c
@@ -21,16 +21,17 @@
 #include <net/sock.h>
 #include <asm/ebcdic.h>
 #include <asm/cpcmd.h>
+#include <asm/debug.h>
 #include <linux/kmod.h>
 
 #include <net/iucv/iucv.h>
 #include <net/iucv/af_iucv.h>
 
-#define CONFIG_IUCV_SOCK_DEBUG 1
-
 #define IPRMDATA 0x80
 #define VERSION "1.0"
 
+debug_info_t *afiucv_dbf;
+
 static char iucv_userid[80];
 
 static struct proto_ops iucv_sock_ops;
@@ -80,6 +81,7 @@ static void iucv_sock_timeout(unsigned l
 {
 	struct sock *sk = (struct sock *)arg;
 
+	debug_sprintf_event(afiucv_dbf, 3, "timeout\n");
 	bh_lock_sock(sk);
 	sk->sk_err = ETIMEDOUT;
 	sk->sk_state_change(sk);
@@ -117,6 +119,7 @@ static void iucv_sock_cleanup_listen(str
 {
 	struct sock *sk;
 
+	debug_sprintf_event(afiucv_dbf, 5, "cleanup_listen\n");
 	/* Close non-accepted connections */
 	while ((sk = iucv_accept_dequeue(parent, NULL))) {
 		iucv_sock_close(sk);
@@ -146,6 +149,7 @@ static void iucv_sock_close(struct sock 
 	int err;
 	unsigned long timeo;
 
+	debug_sprintf_event(afiucv_dbf, 2, "close - start\n");
 	iucv_sock_clear_timer(sk);
 	lock_sock(sk);
 
@@ -197,6 +201,7 @@ static void iucv_sock_close(struct sock 
 
 	release_sock(sk);
 	iucv_sock_kill(sk);
+	debug_sprintf_event(afiucv_dbf, 2, "close - end\n");
 }
 
 static void iucv_sock_init(struct sock *sk, struct sock *parent)
@@ -242,6 +247,7 @@ static int iucv_sock_create(struct net *
 {
 	struct sock *sk;
 
+	debug_sprintf_event(afiucv_dbf, 2, "sock_create\n");
 	if (sock->type != SOCK_STREAM)
 		return -ESOCKTNOSUPPORT;
 
@@ -259,6 +265,7 @@ static int iucv_sock_create(struct net *
 
 void iucv_sock_link(struct iucv_sock_list *l, struct sock *sk)
 {
+	debug_sprintf_event(afiucv_dbf, 5, "sock_link\n");
 	write_lock_bh(&l->lock);
 	sk_add_node(sk, &l->head);
 	write_unlock_bh(&l->lock);
@@ -266,6 +273,7 @@ void iucv_sock_link(struct iucv_sock_lis
 
 void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *sk)
 {
+	debug_sprintf_event(afiucv_dbf, 5, "sock_unlink\n");
 	write_lock_bh(&l->lock);
 	sk_del_node_init(sk);
 	write_unlock_bh(&l->lock);
@@ -276,6 +284,7 @@ void iucv_accept_enqueue(struct sock *pa
 	unsigned long flags;
 	struct iucv_sock *par = iucv_sk(parent);
 
+	debug_sprintf_event(afiucv_dbf, 5, "accept_enqueue\n");
 	sock_hold(sk);
 	spin_lock_irqsave(&par->accept_q_lock, flags);
 	list_add_tail(&iucv_sk(sk)->accept_q, &par->accept_q);
@@ -289,6 +298,7 @@ void iucv_accept_unlink(struct sock *sk)
 	unsigned long flags;
 	struct iucv_sock *par = iucv_sk(iucv_sk(sk)->parent);
 
+	debug_sprintf_event(afiucv_dbf, 5, "accept_unlink\n");
 	spin_lock_irqsave(&par->accept_q_lock, flags);
 	list_del_init(&iucv_sk(sk)->accept_q);
 	spin_unlock_irqrestore(&par->accept_q_lock, flags);
@@ -302,6 +312,7 @@ struct sock *iucv_accept_dequeue(struct 
 	struct iucv_sock *isk, *n;
 	struct sock *sk;
 
+	debug_sprintf_event(afiucv_dbf, 3, "accept_dequeue - start\n");
 	list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q) {
 		sk = (struct sock *) isk;
 		lock_sock(sk);
@@ -323,11 +334,14 @@ struct sock *iucv_accept_dequeue(struct 
 				sk->sk_state = IUCV_DISCONN;
 
 			release_sock(sk);
+			debug_sprintf_event(afiucv_dbf, 5,
+				"accept_dequeue - end 1\n");
 			return sk;
 		}
 
 		release_sock(sk);
 	}
+	debug_sprintf_event(afiucv_dbf, 5, "accept_dequeue - end 0\n");
 	return NULL;
 }
 
@@ -337,6 +351,7 @@ int iucv_sock_wait_state(struct sock *sk
 	DECLARE_WAITQUEUE(wait, current);
 	int err = 0;
 
+	debug_sprintf_event(afiucv_dbf, 6, "wait - start\n");
 	add_wait_queue(sk->sk_sleep, &wait);
 	while (sk->sk_state != state && sk->sk_state != state2) {
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -361,6 +376,7 @@ int iucv_sock_wait_state(struct sock *sk
 	}
 	set_current_state(TASK_RUNNING);
 	remove_wait_queue(sk->sk_sleep, &wait);
+	debug_sprintf_event(afiucv_dbf, 6, "wait - end, error %d\n", err);
 	return err;
 }
 
@@ -377,6 +393,7 @@ static int iucv_sock_bind(struct socket 
 	if (!addr || addr->sa_family != AF_IUCV)
 		return -EINVAL;
 
+	debug_sprintf_event(afiucv_dbf, 2, "bind\n");
 	lock_sock(sk);
 	if (sk->sk_state != IUCV_OPEN) {
 		err = -EBADFD;
@@ -408,6 +425,7 @@ done_unlock:
 	write_unlock_bh(&iucv_sk_list.lock);
 done:
 	release_sock(sk);
+	debug_sprintf_event(afiucv_dbf, 2, "bind - end, error %d\n", err);
 	return err;
 }
 
@@ -438,6 +456,7 @@ static int iucv_sock_autobind(struct soc
 
 	memcpy(&iucv->src_name, name, 8);
 
+	debug_sprintf_event(afiucv_dbf, 6, "autobind - error %d\n", err);
 	return err;
 }
 
@@ -451,6 +470,8 @@ static int iucv_sock_connect(struct sock
 	unsigned char user_data[16];
 	int err;
 
+	debug_sprintf_event(afiucv_dbf, 2,
+		"connect - start, flags %d\n", flags);
 	if (addr->sa_family != AF_IUCV || alen < sizeof(struct sockaddr_iucv))
 		return -EINVAL;
 
@@ -468,6 +489,7 @@ static int iucv_sock_connect(struct sock
 			return err;
 	}
 
+	debug_sprintf_event(afiucv_dbf, 6, "connect - before lock\n");
 	lock_sock(sk);
 
 	/* Set the destination information */
@@ -491,6 +513,7 @@ static int iucv_sock_connect(struct sock
 	if (err) {
 		iucv_path_free(iucv->path);
 		iucv->path = NULL;
+		debug_sprintf_event(afiucv_dbf, 6, "connect error %d\n", err);
 		err = -ECONNREFUSED;
 		goto done;
 	}
@@ -501,11 +524,11 @@ static int iucv_sock_connect(struct sock
 	}
 
 	if (sk->sk_state == IUCV_DISCONN) {
-		release_sock(sk);
-		return -ECONNREFUSED;
+		err = -ECONNREFUSED;
 	}
 done:
 	release_sock(sk);
+	debug_sprintf_event(afiucv_dbf, 6, "connect - end, error %d\n", err);
 	return err;
 }
 
@@ -515,6 +538,7 @@ static int iucv_sock_listen(struct socke
 	struct sock *sk = sock->sk;
 	int err;
 
+	debug_sprintf_event(afiucv_dbf, 2, "listen\n");
 	lock_sock(sk);
 
 	err = -EINVAL;
@@ -540,10 +564,13 @@ static int iucv_sock_accept(struct socke
 	long timeo;
 	int err = 0;
 
+	debug_sprintf_event(afiucv_dbf, 2, "accept - start \n");
 	lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
 
 	if (sk->sk_state != IUCV_LISTEN) {
 		err = -EBADFD;
+		debug_sprintf_event(afiucv_dbf, 2,
+			"accept - not in listen state\n");
 		goto done;
 	}
 
@@ -583,6 +610,8 @@ static int iucv_sock_accept(struct socke
 
 done:
 	release_sock(sk);
+	debug_sprintf_event(afiucv_dbf, 2, "accept - end, err %d, state %d\n",
+		err, newsock->state);
 	return err;
 }
 
@@ -618,28 +647,39 @@ static int iucv_sock_sendmsg(struct kioc
 	struct iucv_message txmsg;
 	int err;
 
+	debug_sprintf_event(afiucv_dbf, 6, "sendmsg - len %d - path %p\n",
+		(int)len, iucv->path);
 	err = sock_error(sk);
-	if (err)
+	if (err) {
+		debug_sprintf_event(afiucv_dbf, 3, "sendmsg - sock_error\n");
 		return err;
+	}
 
-	if (msg->msg_flags & MSG_OOB)
+	if (msg->msg_flags & MSG_OOB) {
+		debug_sprintf_event(afiucv_dbf, 3, "sendmsg - MSG_OOB\n");
 		return -EOPNOTSUPP;
+	}
 
 	lock_sock(sk);
 
 	if (sk->sk_shutdown & SEND_SHUTDOWN) {
 		err = -EPIPE;
+		debug_sprintf_event(afiucv_dbf, 2, "sendmsg - SEND_SHUTDOWN\n");
 		goto out;
 	}
 
 	if (sk->sk_state == IUCV_CONNECTED) {
 		if (!(skb = sock_alloc_send_skb(sk, len,
 						msg->msg_flags & MSG_DONTWAIT,
-						&err)))
+						&err))) {
+			debug_sprintf_event(afiucv_dbf, 2,
+				"sendmsg, alloc failure err%d\n", err);
 			goto out;
-
+		}
 		if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
 			err = -EFAULT;
+			debug_sprintf_event(afiucv_dbf, 2,
+				"sendmsg, memcopy failure\n");
 			goto fail;
 		}
 
@@ -651,6 +691,8 @@ static int iucv_sock_sendmsg(struct kioc
 		err = iucv_message_send(iucv->path, &txmsg, 0, 0,
 					(void *) skb->data, skb->len);
 		if (err) {
+			debug_sprintf_event(afiucv_dbf, 2,
+				"sendmsg, send err %d\n", err);
 			if (err == 3)
 				printk(KERN_ERR "AF_IUCV msg limit exceeded\n");
 			skb_unlink(skb, &iucv->send_skb_q);
@@ -659,11 +701,14 @@ static int iucv_sock_sendmsg(struct kioc
 		}
 
 	} else {
+		debug_sprintf_event(afiucv_dbf, 2, "sendmsg - not connected\n");
 		err = -ENOTCONN;
 		goto out;
 	}
 
 	release_sock(sk);
+	debug_sprintf_event(afiucv_dbf, 6,
+		"sendmsg - end - len %d\n", (int)len);
 	return len;
 
 fail:
@@ -678,6 +723,7 @@ static int iucv_fragment_skb(struct sock
 	int dataleft, size, copied = 0;
 	struct sk_buff *nskb;
 
+	debug_sprintf_event(afiucv_dbf, 6, "fragment, len %d\n", len);
 	dataleft = len;
 	while (dataleft) {
 		if (dataleft >= sk->sk_rcvbuf / 4)
@@ -709,6 +755,9 @@ static void iucv_process_message(struct 
 {
 	int rc;
 
+	debug_sprintf_event(afiucv_dbf, 6,
+		"process_message, flags %d, length %d, path%p\n",
+		msg->flags, msg->length, path);
 	if (msg->flags & IPRMDATA) {
 		skb->data = NULL;
 		skb->len = 0;
@@ -717,6 +766,8 @@ static void iucv_process_message(struct 
 					  msg->length, NULL);
 		if (rc) {
 			kfree_skb(skb);
+			debug_sprintf_event(afiucv_dbf, 2,
+				"process_message, receive failure %d\n", rc);
 			return;
 		}
 		if (skb->truesize >= sk->sk_rcvbuf / 4) {
@@ -725,6 +776,9 @@ static void iucv_process_message(struct 
 			skb = NULL;
 			if (rc) {
 				iucv_path_sever(path, NULL);
+				debug_sprintf_event(afiucv_dbf, 2,
+					"process_message, fragment fail %d\n",
+					rc);
 				return;
 			}
 			skb = skb_dequeue(&iucv_sk(sk)->backlog_skb_q);
@@ -735,8 +789,13 @@ static void iucv_process_message(struct 
 		}
 	}
 
-	if (sock_queue_rcv_skb(sk, skb))
+	if (sock_queue_rcv_skb(sk, skb)) {
 		skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb);
+		debug_sprintf_event(afiucv_dbf, 6,
+			"process_message - backlog\n");
+	}
+	debug_sprintf_event(afiucv_dbf, 6,
+		"process_message - end, path%p\n", path);
 }
 
 static void iucv_process_message_q(struct sock *sk)
@@ -745,6 +804,7 @@ static void iucv_process_message_q(struc
 	struct sk_buff *skb;
 	struct sock_msg_q *p, *n;
 
+	debug_sprintf_event(afiucv_dbf, 6, "process_message_q\n");
 	list_for_each_entry_safe(p, n, &iucv->message_q.list, list) {
 		skb = alloc_skb(p->msg.length, GFP_ATOMIC | GFP_DMA);
 		if (!skb)
@@ -767,6 +827,9 @@ static int iucv_sock_recvmsg(struct kioc
 	struct sk_buff *skb, *rskb, *cskb;
 	int err = 0;
 
+	debug_sprintf_event(afiucv_dbf, 6,
+		"recvmsg - len %d, flags %d, path %p\n",
+		(int)len, flags, iucv->path);
 	if ((sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_SEVERED) &&
 	    skb_queue_empty(&iucv->backlog_skb_q) &&
 	    skb_queue_empty(&sk->sk_receive_queue) &&
@@ -830,6 +893,8 @@ static int iucv_sock_recvmsg(struct kioc
 		skb_queue_head(&sk->sk_receive_queue, skb);
 
 done:
+	debug_sprintf_event(afiucv_dbf, 6, "recvmsg - err %d - copied %d\n",
+		err, copied);
 	return err ? : copied;
 }
 
@@ -841,10 +906,13 @@ static inline unsigned int iucv_accept_p
 	list_for_each_entry_safe(isk, n, &iucv_sk(parent)->accept_q, accept_q) {
 		sk = (struct sock *) isk;
 
-		if (sk->sk_state == IUCV_CONNECTED)
+		if (sk->sk_state == IUCV_CONNECTED) {
+			debug_sprintf_event(afiucv_dbf, 6, "accept_poll - 1\n");
 			return POLLIN | POLLRDNORM;
+		}
 	}
 
+	debug_sprintf_event(afiucv_dbf, 6, "accept_poll - 0\n");
 	return 0;
 }
 
@@ -854,6 +922,7 @@ unsigned int iucv_sock_poll(struct file 
 	struct sock *sk = sock->sk;
 	unsigned int mask = 0;
 
+	debug_sprintf_event(afiucv_dbf, 6, "poll - start\n");
 	poll_wait(file, sk->sk_sleep, wait);
 
 	if (sk->sk_state == IUCV_LISTEN)
@@ -883,6 +952,7 @@ unsigned int iucv_sock_poll(struct file 
 	else
 		set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
 
+	debug_sprintf_event(afiucv_dbf, 6, "poll - mask %u\n", mask);
 	return mask;
 }
 
@@ -895,6 +965,8 @@ static int iucv_sock_shutdown(struct soc
 	u8 prmmsg[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
 
 	how++;
+	debug_sprintf_event(afiucv_dbf, 2, "shutdown socket - how%d\n",
+		how);
 
 	if ((how & ~SHUTDOWN_MASK) || !how)
 		return -EINVAL;
@@ -954,6 +1026,7 @@ static int iucv_sock_release(struct sock
 	if (!sk)
 		return 0;
 
+	debug_sprintf_event(afiucv_dbf, 2, "release socket\n");
 	iucv_sock_close(sk);
 
 	/* Unregister with IUCV base support */
@@ -982,6 +1055,8 @@ static int iucv_callback_connreq(struct 
 
 	memcpy(src_name, ipuser, 8);
 	EBCASC(src_name, 8);
+	debug_sprintf_event(afiucv_dbf, 2, "cb_connreq - start - path%p\n",
+		path);
 	/* Find out if this path belongs to af_iucv. */
 	read_lock(&iucv_sk_list.lock);
 	iucv = NULL;
@@ -997,9 +1072,13 @@ static int iucv_callback_connreq(struct 
 			break;
 		}
 	read_unlock(&iucv_sk_list.lock);
-	if (!iucv)
+	debug_sprintf_event(afiucv_dbf, 5, "cb_connreq - after path verif.\n");
+	if (!iucv) {
 		/* No socket found, not one of our paths. */
+		debug_sprintf_event(afiucv_dbf, 2,
+			"cb_connreq - not our path\n");
 		return -EINVAL;
+	}
 
 	bh_lock_sock(sk);
 
@@ -1009,12 +1088,16 @@ static int iucv_callback_connreq(struct 
 	ASCEBC(user_data, sizeof(user_data));
 	if (sk->sk_state != IUCV_LISTEN) {
 		err = iucv_path_sever(path, user_data);
+		debug_sprintf_event(afiucv_dbf, 2,
+			"cb_connreq - not in listen state\n");
 		goto fail;
 	}
 
 	/* Check for backlog size */
 	if (sk_acceptq_is_full(sk)) {
 		err = iucv_path_sever(path, user_data);
+		debug_sprintf_event(afiucv_dbf, 2,
+			"cb_connreq - accept queue full\n");
 		goto fail;
 	}
 
@@ -1022,6 +1105,8 @@ static int iucv_callback_connreq(struct 
 	nsk = iucv_sock_alloc(NULL, SOCK_STREAM, GFP_ATOMIC);
 	if (!nsk) {
 		err = iucv_path_sever(path, user_data);
+		debug_sprintf_event(afiucv_dbf, 2,
+			"cb_connreq - alloc failure\n");
 		goto fail;
 	}
 
@@ -1045,6 +1130,8 @@ static int iucv_callback_connreq(struct 
 	err = iucv_path_accept(path, &af_iucv_handler, nuser_data, nsk);
 	if (err) {
 		err = iucv_path_sever(path, user_data);
+		debug_sprintf_event(afiucv_dbf, 2,
+			"cb_connreq - accept failure\n");
 		goto fail;
 	}
 
@@ -1056,6 +1143,8 @@ static int iucv_callback_connreq(struct 
 	err = 0;
 fail:
 	bh_unlock_sock(sk);
+	debug_sprintf_event(afiucv_dbf, 2, "cb_connreq - end - path %p\n",
+		path);
 	return 0;
 }
 
@@ -1065,6 +1154,8 @@ static void iucv_callback_connack(struct
 
 	sk->sk_state = IUCV_CONNECTED;
 	sk->sk_state_change(sk);
+	debug_sprintf_event(afiucv_dbf, 2, "cb_connack - path %p\n",
+		path);
 }
 
 static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
@@ -1094,7 +1185,8 @@ static void iucv_callback_rx(struct iucv
 	spin_lock(&iucv->message_q.lock);
 	iucv_process_message(sk, skb, path, msg);
 	spin_unlock(&iucv->message_q.lock);
-
+	debug_sprintf_event(afiucv_dbf, 6, "cb_rx immed - len %d - path %p\n",
+		msg->length, path);
 	return;
 
 save_message:
@@ -1107,6 +1199,8 @@ save_message:
 	spin_lock(&iucv->message_q.lock);
 	list_add_tail(&save_msg->list, &iucv->message_q.list);
 	spin_unlock(&iucv->message_q.lock);
+	debug_sprintf_event(afiucv_dbf, 6, "cb_rx saved - path %p\n",
+		path);
 }
 
 static void iucv_callback_txdone(struct iucv_path *path,
@@ -1144,6 +1238,9 @@ static void iucv_callback_txdone(struct 
 			sk->sk_state_change(sk);
 		}
 	}
+	debug_sprintf_event(afiucv_dbf, 6,
+		"cb_txdone - state %d - path %p - tag %d\n",
+		sk->sk_state, path, msg->tag);
 
 }
 
@@ -1157,6 +1254,8 @@ static void iucv_callback_connrej(struct
 		sk->sk_state = IUCV_DISCONN;
 
 	sk->sk_state_change(sk);
+	debug_sprintf_event(afiucv_dbf, 2, "cb_connrej - state %d - path %p\n",
+		sk->sk_state, path);
 }
 
 static struct proto_ops iucv_sock_ops = {
@@ -1201,6 +1300,14 @@ static int __init afiucv_init(void)
 		goto out;
 	}
 
+	afiucv_dbf = debug_register("af_iucv", 4, 1, 32);
+	if (!afiucv_dbf) {
+		err = -ENOMEM;
+		goto out;
+	}
+	debug_register_view(afiucv_dbf, &debug_sprintf_view);
+	debug_set_level(afiucv_dbf, 2);
+
 	err = iucv_register(&af_iucv_handler, 0);
 	if (err)
 		goto out;
@@ -1210,6 +1317,7 @@ static int __init afiucv_init(void)
 	err = sock_register(&iucv_sock_family_ops);
 	if (err)
 		goto out_proto;
+	debug_sprintf_event(afiucv_dbf, 2, "af_iucv initialized\n");
 	return 0;
 
 out_proto:
@@ -1225,6 +1333,9 @@ static void __exit afiucv_exit(void)
 	sock_unregister(PF_IUCV);
 	proto_unregister(&iucv_proto);
 	iucv_unregister(&af_iucv_handler, 0);
+
+	if (afiucv_dbf)
+		debug_unregister(afiucv_dbf);
 }
 
 module_init(afiucv_init);

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-s390" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux