Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "can: raw: instantly reject unsupported CAN frames"

This reverts commit 1a620a723853a0f49703c317d52dc6b9602cbaa8

and its follow-up fixes for the introduced dependency issues.

commit 1a620a723853 ("can: raw: instantly reject unsupported CAN frames")
commit cb2dc6d2869a ("can: Kconfig: select CAN driver infrastructure by default")
commit 6abd4577bccc ("can: fix build dependency")
commit 5a5aff6338c0 ("can: fix build dependency")

The entire problem was caused by the requirement that a new network layer
feature needed to know about the protocol capabilities of the CAN devices.
Instead of accessing CAN device internal data structures which caused the
dependency problems a better approach has been developed which makes use of
CAN specific ml_priv data which is accessible from both sides.

Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://patch.msgid.link/20260109144135.8495-2-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Oliver Hartkopp and committed by
Marc Kleine-Budde
4650ff58 3879cffd

+17 -58
+5 -2
drivers/net/can/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 3 menuconfig CAN_DEV 4 - bool "CAN Device Drivers" 4 + tristate "CAN Device Drivers" 5 5 default y 6 6 depends on CAN 7 7 help ··· 17 17 virtual ones. If you own such devices or plan to use the virtual CAN 18 18 interfaces to develop applications, say Y here. 19 19 20 - if CAN_DEV && CAN 20 + To compile as a module, choose M here: the module will be called 21 + can-dev. 22 + 23 + if CAN_DEV 21 24 22 25 config CAN_VCAN 23 26 tristate "Virtual Local CAN Interface (vcan)"
+1 -1
drivers/net/can/Makefile
··· 7 7 obj-$(CONFIG_CAN_VXCAN) += vxcan.o 8 8 obj-$(CONFIG_CAN_SLCAN) += slcan/ 9 9 10 - obj-$(CONFIG_CAN_DEV) += dev/ 10 + obj-y += dev/ 11 11 obj-y += esd/ 12 12 obj-y += rcar/ 13 13 obj-y += rockchip/
+3 -2
drivers/net/can/dev/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - obj-$(CONFIG_CAN) += can-dev.o 3 + obj-$(CONFIG_CAN_DEV) += can-dev.o 4 4 5 - can-dev-$(CONFIG_CAN_DEV) += skb.o 5 + can-dev-y += skb.o 6 + 6 7 can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o 7 8 can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o 8 9 can-dev-$(CONFIG_CAN_NETLINK) += dev.o
-7
include/linux/can/dev.h
··· 111 111 void free_candev(struct net_device *dev); 112 112 113 113 /* a candev safe wrapper around netdev_priv */ 114 - #if IS_ENABLED(CONFIG_CAN_NETLINK) 115 114 struct can_priv *safe_candev_priv(struct net_device *dev); 116 - #else 117 - static inline struct can_priv *safe_candev_priv(struct net_device *dev) 118 - { 119 - return NULL; 120 - } 121 - #endif 122 115 123 116 int open_candev(struct net_device *dev); 124 117 void close_candev(struct net_device *dev);
+8 -46
net/can/raw.c
··· 892 892 } 893 893 } 894 894 895 - static inline bool raw_dev_cc_enabled(struct net_device *dev, 896 - struct can_priv *priv) 895 + static unsigned int raw_check_txframe(struct raw_sock *ro, struct sk_buff *skb, int mtu) 897 896 { 898 - /* The CANXL-only mode disables error-signalling on the CAN bus 899 - * which is needed to send CAN CC/FD frames 900 - */ 901 - if (priv) 902 - return !can_dev_in_xl_only_mode(priv); 903 - 904 - /* virtual CAN interfaces always support CAN CC */ 905 - return true; 906 - } 907 - 908 - static inline bool raw_dev_fd_enabled(struct net_device *dev, 909 - struct can_priv *priv) 910 - { 911 - /* check FD ctrlmode on real CAN interfaces */ 912 - if (priv) 913 - return (priv->ctrlmode & CAN_CTRLMODE_FD); 914 - 915 - /* check MTU for virtual CAN FD interfaces */ 916 - return (READ_ONCE(dev->mtu) >= CANFD_MTU); 917 - } 918 - 919 - static inline bool raw_dev_xl_enabled(struct net_device *dev, 920 - struct can_priv *priv) 921 - { 922 - /* check XL ctrlmode on real CAN interfaces */ 923 - if (priv) 924 - return (priv->ctrlmode & CAN_CTRLMODE_XL); 925 - 926 - /* check MTU for virtual CAN XL interfaces */ 927 - return can_is_canxl_dev_mtu(READ_ONCE(dev->mtu)); 928 - } 929 - 930 - static unsigned int raw_check_txframe(struct raw_sock *ro, struct sk_buff *skb, 931 - struct net_device *dev) 932 - { 933 - struct can_priv *priv = safe_candev_priv(dev); 934 - 935 - /* Classical CAN */ 936 - if (can_is_can_skb(skb) && raw_dev_cc_enabled(dev, priv)) 897 + /* Classical CAN -> no checks for flags and device capabilities */ 898 + if (can_is_can_skb(skb)) 937 899 return CAN_MTU; 938 900 939 - /* CAN FD */ 901 + /* CAN FD -> needs to be enabled and a CAN FD or CAN XL device */ 940 902 if (ro->fd_frames && can_is_canfd_skb(skb) && 941 - raw_dev_fd_enabled(dev, priv)) 903 + (mtu == CANFD_MTU || can_is_canxl_dev_mtu(mtu))) 942 904 return CANFD_MTU; 943 905 944 - /* CAN XL */ 906 + /* CAN XL -> needs to be enabled and a CAN XL device */ 945 907 if (ro->xl_frames && can_is_canxl_skb(skb) && 946 - raw_dev_xl_enabled(dev, priv)) 908 + can_is_canxl_dev_mtu(mtu)) 947 909 return CANXL_MTU; 948 910 949 911 return 0; ··· 961 999 err = -EINVAL; 962 1000 963 1001 /* check for valid CAN (CC/FD/XL) frame content */ 964 - txmtu = raw_check_txframe(ro, skb, dev); 1002 + txmtu = raw_check_txframe(ro, skb, READ_ONCE(dev->mtu)); 965 1003 if (!txmtu) 966 1004 goto free_skb; 967 1005