]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
Fixed missing sk reference in af_can.c / deliver().
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Wed, 6 Jun 2007 14:52:51 +0000 (14:52 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Wed, 6 Jun 2007 14:52:51 +0000 (14:52 +0000)
Cosmetics.

git-svn-id: svn://svn.berlios.de//socketcan/trunk@330 030b6a49-0b11-0410-94ab-b0dab22257f2

kernel/2.6/drivers/net/can/vcan.c
kernel/2.6/net/can/af_can.c

index 425287b7959c7933a03bbbd158d6625c80195712..a2ec2bcb15b0a857498d2653b0ecc36e8a4ddf33 100644 (file)
@@ -171,7 +171,8 @@ static int vcan_tx(struct sk_buff *skb, struct net_device *dev)
        /* perform standard loopback handling for CAN network interfaces */
 
        if (loop) {
-               struct sock *sk = skb->sk;
+               struct sock *srcsk = skb->sk;
+
                if (atomic_read(&skb->users) != 1) {
                        struct sk_buff *old_skb = skb;
 
@@ -186,7 +187,7 @@ static int vcan_tx(struct sk_buff *skb, struct net_device *dev)
                        skb_orphan(skb);
 
                /* receive with packet counting */
-               skb->sk = sk;
+               skb->sk = srcsk;
                vcan_rx(skb, dev);
        } else {
                /* no looped packets => no counting */
index 065734fd04af1c896f30f08f7e9c02f3d293a152..61c88b93b1a198bd95973b97e047d6b810113db9 100644 (file)
@@ -273,9 +273,13 @@ int can_send(struct sk_buff *skb, int loop)
                skb->pkt_type = PACKET_LOOPBACK;
 
                /*
-                * The reference to the originating sock may be also required
+                * The reference to the originating sock may be required
                 * by the receiving socket to indicate (and ignore) his own
                 * sent data. Example: can_raw sockopt CAN_RAW_RECV_OWN_MSGS
+                * Therefore we have to ensure that skb->sk remains the
+                * reference to the originating sock by restoring skb->sk
+                * after each skb_clone() or skb_orphan() usage.
+                * skb->sk is usually unused and unset in the rx path.
                 */
 
                /* interface not capabable to do the loopback itself? */
@@ -587,6 +591,7 @@ static inline void deliver(struct sk_buff *skb, struct receiver *r)
 
        DBG("skbuff %p cloned to %p\n", skb, clone);
        if (clone) {
+               clone->sk = skb->sk;
                r->func(clone, r->data);
                r->matches++;
        }