/* 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;
skb_orphan(skb);
/* receive with packet counting */
- skb->sk = sk;
+ skb->sk = srcsk;
vcan_rx(skb, dev);
} else {
/* no looped packets => no counting */
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? */
DBG("skbuff %p cloned to %p\n", skb, clone);
if (clone) {
+ clone->sk = skb->sk;
r->func(clone, r->data);
r->matches++;
}