Re: [RFC PATCH v6 3/7] can: set CANFD_FDF flag in all CAN FD frame structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24.07.2022 09:43:58, Oliver Hartkopp wrote:
> To simplify the testing in user space all struct canfd_frame's provided by
> the CAN subsystem of the Linux kernel now have the CANFD_FDF flag set in
> canfd_frame::flags.
> 
> NB: Handcrafted ETH_P_CANFD frames introduced via PF_PACKET socket might
> not set this bit correctly.

Can you add a fixup for PF_PACKET to can_skb_headroom_valid()?

Or better move the "if (skb->ip_summed == CHECKSUM_NONE)" into a
separate function first e.g. can_skb_fixup_pf_packet() first.

| static bool can_skb_headroom_valid(struct net_device *dev, struct sk_buff *skb)
| {
| 	/* af_packet creates a headroom of HH_DATA_MOD bytes which is fine */
| 	if (WARN_ON_ONCE(skb_headroom(skb) < sizeof(struct can_skb_priv)))
| 		return false;
| 
| 	/* af_packet does not apply CAN skb specific settings */
| 	if (skb->ip_summed == CHECKSUM_NONE) {
| 		/* init headroom */
| 		can_skb_prv(skb)->ifindex = dev->ifindex;
| 		can_skb_prv(skb)->skbcnt = 0;
| 
| 		skb->ip_summed = CHECKSUM_UNNECESSARY;
| 
| 		/* perform proper loopback on capable devices */
| 		if (dev->flags & IFF_ECHO)
| 			skb->pkt_type = PACKET_LOOPBACK;
| 		else
| 			skb->pkt_type = PACKET_HOST;
| 
| 		skb_reset_mac_header(skb);
| 		skb_reset_network_header(skb);
| 		skb_reset_transport_header(skb);
| 	}
| 
| 	return true;
| }

And call can_skb_fixup_pf_packet() from can_dropped_invalid_skb().

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux