From: Oliver Hartkopp <oliver@hartkopp.net>
To: David Miller <davem@davemloft.net>
Cc: Urs Thuermann <urs@isnogud.escape.de>,
nautsch@gmail.com, Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH] [2.6.26] [CAN] Fix can_send() handling on dev_queue_xmit() failures
Date: Tue, 06 May 2008 21:49:57 +0200 [thread overview]
Message-ID: <4820B665.6070609@hartkopp.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
from Oliver Hartkopp <oliver@hartkopp.net>
The tx packet counting and the local loopback of CAN frames should
only happen in the case that the CAN frame has been enqueued to the
netdevice tx queue successfully.
Thanks to Andre Naujoks <nautsch@gmail.com> for reporting this issue.
Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>
---
Hello Dave,
this patch should go into 2.6.26 and also applies fine on 2.6.25.1.
IMO this issue is not that 'critical' that it *requires* to become
part of 2.6.25.2. Please forward the patch to Greg at your own opinion.
Many Thanks!
Oliver
[-- Attachment #2: can_send.diff --]
[-- Type: text/x-diff, Size: 1312 bytes --]
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 2759b76..7e8ca28 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -208,6 +208,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
*/
int can_send(struct sk_buff *skb, int loop)
{
+ struct sk_buff *newskb = NULL;
int err;
if (skb->dev->type != ARPHRD_CAN) {
@@ -244,8 +245,7 @@ int can_send(struct sk_buff *skb, int loop)
* If the interface is not capable to do loopback
* itself, we do it here.
*/
- struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
-
+ newskb = skb_clone(skb, GFP_ATOMIC);
if (!newskb) {
kfree_skb(skb);
return -ENOMEM;
@@ -254,7 +254,6 @@ int can_send(struct sk_buff *skb, int loop)
newskb->sk = skb->sk;
newskb->ip_summed = CHECKSUM_UNNECESSARY;
newskb->pkt_type = PACKET_BROADCAST;
- netif_rx(newskb);
}
} else {
/* indication for the CAN driver: no loopback required */
@@ -266,11 +265,20 @@ int can_send(struct sk_buff *skb, int loop)
if (err > 0)
err = net_xmit_errno(err);
+ if (err) {
+ if (newskb)
+ kfree_skb(newskb);
+ return err;
+ }
+
+ if (newskb)
+ netif_rx(newskb);
+
/* update statistics */
can_stats.tx_frames++;
can_stats.tx_frames_delta++;
- return err;
+ return 0;
}
EXPORT_SYMBOL(can_send);
next reply other threads:[~2008-05-06 19:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-06 19:49 Oliver Hartkopp [this message]
2008-05-08 9:50 ` [PATCH] [2.6.26] [CAN] Fix can_send() handling on dev_queue_xmit() failures David Miller
2008-05-08 17:00 ` Oliver Hartkopp
2008-05-08 17:29 ` Sam Ravnborg
2008-05-08 18:27 ` Oliver Hartkopp
2008-05-13 17:46 ` [stable] " Greg KH
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=4820B665.6070609@hartkopp.net \
--to=oliver@hartkopp.net \
--cc=davem@davemloft.net \
--cc=nautsch@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=urs@isnogud.escape.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.