CINXE.COM
LKML: Jay Lan: Re: [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Jay Lan: Re: [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Jay Lan" href="/groupie.php?aid=23604" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/4"> [Apr]</a> 聽 <a class="nb" href="/lkml/2005/4/8"> [8]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/4/8/256" onclick="this.href='/lkml/headers'+'/2005/4/8/256';">[headers]</a>聽 <a href="/lkml/bounce/2005/4/8/256">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/3/31/137">First message in thread</a></li><li><a href="/lkml/2005/4/8/96">Evgeniy Polyakov</a><ul><li><a href="/lkml/2005/4/8/102">Evgeniy Polyakov</a><ul><li class="origin"><a href="/lkml/2005/4/8/277">Jay Lan</a><ul><li><a href="/lkml/2005/4/8/277">Jay Lan</a><ul><li><a href="/lkml/2005/4/8/281">Evgeniy Polyakov</a></li></ul></li></ul></li></ul></li></ul></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Fri, 08 Apr 2005 13:27:44 -0700</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Jay Lan <></td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [patch 2.6.12-rc1-mm4] fork_connector: add a fork connector</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">My workarea was based on 2.6.12-rc1-mm4 plus Guilluame's patch.<br /><br />Your patch caused 5 out of 8 hunks failure at connector.c<br />and one failure at connector.h.<br /><br />Could you generate a new patch based on my version? A tar<br />file of complete source of drivers/connector would work<br />also. :)<br /><br />Thanks!<br /> - jay<br /><br />Evgeniy Polyakov wrote:<br />> Could you give attached patch a try instead of previous one.<br />> It adds gfp mask into cn_netlink_send() call also.<br />> If you need updated CBUS sources, feel free to ask, <br />> I will send updated sources with Andrew's comments resolved too.<br />> <br />> I do not know exactly your connector version, <br />> so patch will probably be applied with fuzz.<br />> <br />> feel free to contact if it does not apply, I will send<br />> the whole sources.<br />> <br />> Thank you.<br />> <br />> * looking for johnpol@2ka.mipt.ru-2004/connector--main--0--patch-38 to compare with<br />> * comparing to johnpol@2ka.mipt.ru-2004/connector--main--0--patch-38<br />> M connector.c<br />> M connector.h<br />> M cbus.c<br />> <br />> * modified files<br />> <br />> --- orig/drivers/connector/connector.c<br />> +++ mod/drivers/connector/connector.c<br />> @@ -70,7 +70,7 @@<br />> * then it is new message.<br />> *<br />> */<br />> -void cn_netlink_send(struct cn_msg *msg, u32 __groups)<br />> +void cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask)<br />> {<br />> struct cn_callback_entry *n, *__cbq;<br />> unsigned int size;<br />> @@ -102,7 +102,7 @@<br />> <br />> size = NLMSG_SPACE(sizeof(*msg) + msg->len);<br />> <br />> - skb = alloc_skb(size, GFP_ATOMIC);<br />> + skb = alloc_skb(size, gfp_mask);<br />> if (!skb) {<br />> printk(KERN_ERR "Failed to allocate new skb with size=%u.\n", size);<br />> return;<br />> @@ -119,11 +119,11 @@<br />> #endif<br />> <br />> NETLINK_CB(skb).dst_groups = groups;<br />> -<br />> - uskb = skb_clone(skb, GFP_ATOMIC);<br />> - if (uskb)<br />> +#if 0<br />> + uskb = skb_clone(skb, gfp_mask);<br />> + if (uskb && 0)<br />> netlink_unicast(dev->nls, uskb, 0, 0);<br />> - <br />> +#endif <br />> netlink_broadcast(dev->nls, skb, 0, groups, GFP_ATOMIC);<br />> <br />> return;<br />> @@ -158,7 +158,7 @@<br />> }<br />> spin_unlock_bh(&dev->cbdev->queue_lock);<br />> <br />> - return found;<br />> + return (found)?0:-ENODEV;<br />> }<br />> <br />> /*<br />> @@ -181,7 +181,6 @@<br />> "requested msg->len=%u[%u], nlh->nlmsg_len=%u, skb->len=%u.\n",<br />> msg->len, NLMSG_SPACE(msg->len + sizeof(*msg)),<br />> nlh->nlmsg_len, skb->len);<br />> - kfree_skb(skb);<br />> return -EINVAL;<br />> }<br />> #if 0<br />> @@ -215,17 +214,18 @@<br />> skb->len, skb->data_len, skb->truesize, skb->protocol,<br />> skb_cloned(skb), skb_shared(skb));<br />> #endif<br />> - while (skb->len >= NLMSG_SPACE(0)) {<br />> + if (skb->len >= NLMSG_SPACE(0)) {<br />> nlh = (struct nlmsghdr *)skb->data;<br />> +<br />> if (nlh->nlmsg_len < sizeof(struct cn_msg) ||<br />> skb->len < nlh->nlmsg_len ||<br />> nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {<br />> -#if 0<br />> +#if 1<br />> printk(KERN_INFO "nlmsg_len=%u, sizeof(*nlh)=%u\n",<br />> nlh->nlmsg_len, sizeof(*nlh));<br />> #endif<br />> kfree_skb(skb);<br />> - break;<br />> + goto out;<br />> }<br />> <br />> len = NLMSG_ALIGN(nlh->nlmsg_len);<br />> @@ -233,22 +233,11 @@<br />> len = skb->len;<br />> <br />> err = __cn_rx_skb(skb, nlh);<br />> - if (err) {<br />> -#if 0<br />> - if (err < 0 && (nlh->nlmsg_flags & NLM_F_ACK))<br />> - netlink_ack(skb, nlh, -err);<br />> -#endif<br />> - break;<br />> - } else {<br />> -#if 0<br />> - if (nlh->nlmsg_flags & NLM_F_ACK)<br />> - netlink_ack(skb, nlh, 0);<br />> -#endif<br />> - break;<br />> - }<br />> - skb_pull(skb, len);<br />> + if (err < 0)<br />> + kfree_skb(skb);<br />> }<br />> - <br />> +<br />> +out:<br />> kfree_skb(__skb);<br />> }<br />> <br />> @@ -310,7 +299,7 @@<br />> m.ack = notify_event;<br />> <br />> memcpy(&m.id, id, sizeof(m.id));<br />> - cn_netlink_send(&m, ctl->group);<br />> + cn_netlink_send(&m, ctl->group, GFP_ATOMIC);<br />> }<br />> }<br />> spin_unlock_bh(&notify_lock);<br />> <br />> <br />> --- orig/include/linux/connector.h<br />> +++ mod/include/linux/connector.h<br />> @@ -148,7 +148,7 @@<br />> <br />> int cn_add_callback(struct cb_id *, char *, void (* callback)(void *));<br />> void cn_del_callback(struct cb_id *);<br />> -void cn_netlink_send(struct cn_msg *, u32);<br />> +void cn_netlink_send(struct cn_msg *, u32, int);<br />> <br />> int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb);<br />> void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);<br />> <br />> <br />> <br />> <br />> <br /><br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo@vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-04-08 22:35 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>