can: add destructor for self generated skbs
Self generated skbuffs in net/can/bcm.c are setting a skb->sk reference but
no explicit destructor which is enforced since Linux 3.11 with commit
376c7311bd
(net: add a temporary sanity check in skb_orphan()).
This patch adds some helper functions to make sure that a destructor is
properly defined when a sock reference is assigned to a CAN related skb.
To create an unshared skb owned by the original sock a common helper function
has been introduced to replace open coded functions to create CAN echo skbs.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tested-by: Andre Naujoks <nautsch2@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
920a0fde5a
commit
0ae89beb28
@@ -57,6 +57,7 @@
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/can.h>
|
||||
#include <linux/can/core.h>
|
||||
#include <linux/can/skb.h>
|
||||
#include <linux/ratelimit.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/sock.h>
|
||||
@@ -290,7 +291,7 @@ int can_send(struct sk_buff *skb, int loop)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
newskb->sk = skb->sk;
|
||||
can_skb_set_owner(newskb, skb->sk);
|
||||
newskb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
newskb->pkt_type = PACKET_BROADCAST;
|
||||
}
|
||||
|
@@ -268,7 +268,7 @@ static void bcm_can_tx(struct bcm_op *op)
|
||||
|
||||
/* send with loopback */
|
||||
skb->dev = dev;
|
||||
skb->sk = op->sk;
|
||||
can_skb_set_owner(skb, op->sk);
|
||||
can_send(skb, 1);
|
||||
|
||||
/* update statistics */
|
||||
@@ -1223,7 +1223,7 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
|
||||
|
||||
can_skb_prv(skb)->ifindex = dev->ifindex;
|
||||
skb->dev = dev;
|
||||
skb->sk = sk;
|
||||
can_skb_set_owner(skb, sk);
|
||||
err = can_send(skb, 1); /* send with loopback */
|
||||
dev_put(dev);
|
||||
|
||||
|
Reference in New Issue
Block a user