Skip to content

Commit

Permalink
isotp: reserve common space for CAN related skb's
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
  • Loading branch information
hartkopp committed Dec 16, 2018
1 parent 6003f99 commit f9fcd45
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions net/can/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 flowstatus)
struct canfd_frame *ncf;
struct isotp_sock *so = isotp_sk(sk);

nskb = alloc_skb(so->ll.mtu, gfp_any());
nskb = alloc_skb(so->ll.mtu + sizeof(struct can_skb_priv), gfp_any());
if (!nskb)
return 1;

Expand All @@ -211,6 +211,11 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 flowstatus)
kfree_skb(nskb);
return 1;
}

can_skb_reserve(nskb);
can_skb_prv(nskb)->ifindex = dev->ifindex;
can_skb_prv(nskb)->skbcnt = 0;

nskb->dev = dev;
isotp_skb_set_owner(nskb, sk);
ncf = (struct canfd_frame *) nskb->data;
Expand Down Expand Up @@ -775,12 +780,17 @@ static void isotp_tx_timer_tsklet(unsigned long data)
break;

isotp_tx_burst:
skb = alloc_skb(so->ll.mtu, gfp_any());
skb = alloc_skb(so->ll.mtu + sizeof(struct can_skb_priv),
gfp_any());
if (!skb) {
dev_put(dev);
break;
}

can_skb_reserve(skb);
can_skb_prv(skb)->ifindex = dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;

cf = (struct canfd_frame *)skb->data;
skb_put(skb, so->ll.mtu);

Expand Down Expand Up @@ -892,13 +902,17 @@ static int isotp_sendmsg(struct kiocb *iocb, struct socket *sock,
if (!dev)
return -ENXIO;

skb = sock_alloc_send_skb(sk, so->ll.mtu,
skb = sock_alloc_send_skb(sk, so->ll.mtu + sizeof(struct can_skb_priv),
msg->msg_flags & MSG_DONTWAIT, &err);
if (!skb) {
dev_put(dev);
return err;
}

can_skb_reserve(skb);
can_skb_prv(skb)->ifindex = dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;

so->tx.state = ISOTP_SENDING;
so->tx.len = size;
so->tx.idx = 0;
Expand Down

0 comments on commit f9fcd45

Please sign in to comment.