public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Jay Lan <jlan@engr.sgi.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Guillaume Thouvenin <guillaume.thouvenin@bull.net>,
	greg@kroah.com, linux-kernel@vger.kernel.org,
	efocht@hpce.nec.com, linuxram@us.ibm.com, gh@us.ibm.com,
	elsa-devel@lists.sourceforge.net, aquynh@gmail.com,
	dean-list-linux-kernel@arctic.org, pj@sgi.com
Subject: Re: [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector
Date: Fri, 08 Apr 2005 14:52:43 +0400	[thread overview]
Message-ID: <1112957563.28858.240.camel@uganda> (raw)
In-Reply-To: <1112955840.28858.236.camel@uganda>

[-- Attachment #1: Type: text/plain, Size: 3760 bytes --]

Could you give attached patch a try instead of previous one.
It adds gfp mask into cn_netlink_send() call also.
If you need updated CBUS sources, feel free to ask, 
I will send updated sources with Andrew's comments resolved too.

I do not know exactly your connector version, 
so patch will probably be applied with fuzz.

feel free to contact if it does not apply, I will send
the whole sources.

Thank you.

* looking for johnpol@2ka.mipt.ru-2004/connector--main--0--patch-38 to compare with
* comparing to johnpol@2ka.mipt.ru-2004/connector--main--0--patch-38
M  connector.c
M  connector.h
M  cbus.c

* modified files

--- orig/drivers/connector/connector.c
+++ mod/drivers/connector/connector.c
@@ -70,7 +70,7 @@
  * then it is new message.
  *
  */
-void cn_netlink_send(struct cn_msg *msg, u32 __groups)
+void cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask)
 {
 	struct cn_callback_entry *n, *__cbq;
 	unsigned int size;
@@ -102,7 +102,7 @@
 
 	size = NLMSG_SPACE(sizeof(*msg) + msg->len);
 
-	skb = alloc_skb(size, GFP_ATOMIC);
+	skb = alloc_skb(size, gfp_mask);
 	if (!skb) {
 		printk(KERN_ERR "Failed to allocate new skb with size=%u.\n", size);
 		return;
@@ -119,11 +119,11 @@
 #endif
 	
 	NETLINK_CB(skb).dst_groups = groups;
-
-	uskb = skb_clone(skb, GFP_ATOMIC);
-	if (uskb)
+#if 0
+	uskb = skb_clone(skb, gfp_mask);
+	if (uskb && 0)
 		netlink_unicast(dev->nls, uskb, 0, 0);
-	
+#endif	
 	netlink_broadcast(dev->nls, skb, 0, groups, GFP_ATOMIC);
 
 	return;
@@ -158,7 +158,7 @@
 	}
 	spin_unlock_bh(&dev->cbdev->queue_lock);
 
-	return found;
+	return (found)?0:-ENODEV;
 }
 
 /*
@@ -181,7 +181,6 @@
 				"requested msg->len=%u[%u], nlh->nlmsg_len=%u, skb->len=%u.\n",
 				msg->len, NLMSG_SPACE(msg->len + sizeof(*msg)),
 				nlh->nlmsg_len, skb->len);
-		kfree_skb(skb);
 		return -EINVAL;
 	}
 #if 0
@@ -215,17 +214,18 @@
 	       skb->len, skb->data_len, skb->truesize, skb->protocol,
 	       skb_cloned(skb), skb_shared(skb));
 #endif
-	while (skb->len >= NLMSG_SPACE(0)) {
+	if (skb->len >= NLMSG_SPACE(0)) {
 		nlh = (struct nlmsghdr *)skb->data;
+
 		if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
 		    skb->len < nlh->nlmsg_len ||
 		    nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
-#if 0
+#if 1
 			printk(KERN_INFO "nlmsg_len=%u, sizeof(*nlh)=%u\n",
 			       nlh->nlmsg_len, sizeof(*nlh));
 #endif
 			kfree_skb(skb);
-			break;
+			goto out;
 		}
 
 		len = NLMSG_ALIGN(nlh->nlmsg_len);
@@ -233,22 +233,11 @@
 			len = skb->len;
 
 		err = __cn_rx_skb(skb, nlh);
-		if (err) {
-#if 0
-			if (err < 0 && (nlh->nlmsg_flags & NLM_F_ACK))
-				netlink_ack(skb, nlh, -err);
-#endif
-			break;
-		} else {
-#if 0
-			if (nlh->nlmsg_flags & NLM_F_ACK)
-				netlink_ack(skb, nlh, 0);
-#endif
-			break;
-		}
-		skb_pull(skb, len);
+		if (err < 0)
+			kfree_skb(skb);
 	}
-			
+
+out:
 	kfree_skb(__skb);
 }
 
@@ -310,7 +299,7 @@
 			m.ack = notify_event;
 
 			memcpy(&m.id, id, sizeof(m.id));
-			cn_netlink_send(&m, ctl->group);
+			cn_netlink_send(&m, ctl->group, GFP_ATOMIC);
 		}
 	}
 	spin_unlock_bh(&notify_lock);


--- orig/include/linux/connector.h
+++ mod/include/linux/connector.h
@@ -148,7 +148,7 @@
 
 int cn_add_callback(struct cb_id *, char *, void (* callback)(void *));
 void cn_del_callback(struct cb_id *);
-void cn_netlink_send(struct cn_msg *, u32);
+void cn_netlink_send(struct cn_msg *, u32, int);
 
 int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb);
 void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);





-- 
        Evgeniy Polyakov

Crash is better than data corruption -- Arthur Grabowski

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-04-08 10:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-31 13:59 [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector Guillaume Thouvenin
2005-03-31 22:44 ` Andrew Morton
2005-04-01  0:10   ` Jay Lan
2005-04-01  7:52     ` Evgeniy Polyakov
2005-04-07 22:40       ` Jay Lan
2005-04-07 22:47         ` Jay Lan
2005-04-08 10:24           ` Evgeniy Polyakov
2005-04-08 10:52             ` Evgeniy Polyakov [this message]
2005-04-08 20:27               ` Jay Lan
2005-04-08 22:08                 ` Jay Lan
2005-04-08 22:18                   ` Evgeniy Polyakov
2005-04-09  3:31                     ` Jay Lan
2005-04-09  6:29                       ` Evgeniy Polyakov
2005-04-11  5:43                         ` Jay Lan
2005-04-11  6:44                           ` Evgeniy Polyakov
2005-04-11  6:51                             ` Andrew Morton
2005-04-11  7:31                               ` Evgeniy Polyakov
2005-03-31 22:53 ` Andrew Morton
2005-04-01 10:56 ` Guillaume Thouvenin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1112957563.28858.240.camel@uganda \
    --to=johnpol@2ka.mipt.ru \
    --cc=akpm@osdl.org \
    --cc=aquynh@gmail.com \
    --cc=dean-list-linux-kernel@arctic.org \
    --cc=efocht@hpce.nec.com \
    --cc=elsa-devel@lists.sourceforge.net \
    --cc=gh@us.ibm.com \
    --cc=greg@kroah.com \
    --cc=guillaume.thouvenin@bull.net \
    --cc=jlan@engr.sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=pj@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox