Skip to content

Commit

Permalink
can: isotp: TX-path: ensure that CAN frame flags are initialized
Browse files Browse the repository at this point in the history
The previous patch ensures that the TX flags (struct
can_isotp_ll_options::tx_flags) are 0 for classic CAN frames or a user
configured value for CAN-FD frames.

This patch sets the CAN frames flags unconditionally to the ISO-TP TX
flags, so that they are initialized to a proper value. Otherwise when
running "candump -x" on a classical CAN ISO-TP stream shows wrongly
set "B" and "E" flags.

| $ candump any,0:0,#FFFFFFFF -extA
| [...]
| can0  TX B E  713   [8]  2B 0A 0B 0C 0D 0E 0F 00
| can0  TX B E  713   [8]  2C 01 02 03 04 05 06 07
| can0  TX B E  713   [8]  2D 08 09 0A 0B 0C 0D 0E
| can0  TX B E  713   [8]  2E 0F 00 01 02 03 04 05

Fixes: e057dd3 ("can: add ISO 15765-2:2016 transport protocol")
Link: https://lore.kernel.org/r/[email protected]
Cc: Oliver Hartkopp <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
marckleinebudde committed Mar 16, 2021
1 parent e491245 commit d4eb538
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions net/can/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 flowstatus)
if (ae)
ncf->data[0] = so->opt.ext_address;

if (so->ll.mtu == CANFD_MTU)
ncf->flags = so->ll.tx_flags;
ncf->flags = so->ll.tx_flags;

can_send_ret = can_send(nskb, 1);
if (can_send_ret)
Expand Down Expand Up @@ -790,8 +789,7 @@ static enum hrtimer_restart isotp_tx_timer_handler(struct hrtimer *hrtimer)
so->tx.sn %= 16;
so->tx.bs++;

if (so->ll.mtu == CANFD_MTU)
cf->flags = so->ll.tx_flags;
cf->flags = so->ll.tx_flags;

skb->dev = dev;
can_skb_set_owner(skb, sk);
Expand Down Expand Up @@ -939,8 +937,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
}

/* send the first or only CAN frame */
if (so->ll.mtu == CANFD_MTU)
cf->flags = so->ll.tx_flags;
cf->flags = so->ll.tx_flags;

skb->dev = dev;
skb->sk = sk;
Expand Down

0 comments on commit d4eb538

Please sign in to comment.