mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-03-03 18:28:01 +01:00
To remove the private CAN bus skb headroom infrastructure 8 bytes need to be stored in the skb. The skb extensions are a common pattern and an easy and efficient way to hold private data travelling along with the skb. We only need the skb_ext_add() and skb_ext_find() functions to allocate and access CAN specific content as the skb helpers to copy/clone/free skbs automatically take care of skb extensions and their final removal. This patch introduces the complete CAN skb extensions infrastructure: - add struct can_skb_ext in new file include/net/can.h - add include/net/can.h in MAINTAINERS - add SKB_EXT_CAN to skbuff.c and skbuff.h - select SKB_EXTENSIONS in Kconfig when CONFIG_CAN is enabled - check for existing CAN skb extensions in can_rcv() in af_can.c - add CAN skb extensions allocation at every skb_alloc() location - duplicate the skb extensions if cloning outgoing skbs (framelen/gw_hops) - introduce can_skb_ext_add() and can_skb_ext_find() helpers The patch also corrects an indention issue in the original code from 2018: Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202602010426.PnGrYAk3-lkp@intel.com/ Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://patch.msgid.link/20260201-can_skb_ext-v8-2-3635d790fe8b@hartkopp.net Signed-off-by: Paolo Abeni <pabeni@redhat.com>
29 lines
663 B
C
29 lines
663 B
C
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
|
|
/*
|
|
* net/can.h
|
|
*
|
|
* Definitions for the CAN network socket buffer extensions
|
|
*
|
|
* Copyright (C) 2026 Oliver Hartkopp <socketcan@hartkopp.net>
|
|
*
|
|
*/
|
|
|
|
#ifndef _NET_CAN_H
|
|
#define _NET_CAN_H
|
|
|
|
/**
|
|
* struct can_skb_ext - skb extensions for CAN specific content
|
|
* @can_iif: ifindex of the first interface the CAN frame appeared on
|
|
* @can_framelen: cached echo CAN frame length for bql
|
|
* @can_gw_hops: can-gw CAN frame time-to-live counter
|
|
* @can_ext_flags: CAN skb extensions flags
|
|
*/
|
|
struct can_skb_ext {
|
|
int can_iif;
|
|
u16 can_framelen;
|
|
u8 can_gw_hops;
|
|
u8 can_ext_flags;
|
|
};
|
|
|
|
#endif /* _NET_CAN_H */
|