[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210122114751.scp23qtyqmsol5h5@hardanger.blackshift.org>
Date: Fri, 22 Jan 2021 12:47:51 +0100
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>,
"David S. Miller" <davem@...emloft.net>,
Oliver Hartkopp <socketcan@...tkopp.net>,
Robin van der Gracht <robin@...tonic.nl>,
syzbot+5138c4dd15a0401bec7b@...kaller.appspotmail.com,
kernel@...gutronix.de, linux-can@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH net 1/2] net: introduce CAN specific pointer in the
struct net_device
On Fri, Jan 15, 2021 at 04:07:23PM -0800, Jakub Kicinski wrote:
> On Fri, 15 Jan 2021 15:30:35 +0100 Oleksij Rempel wrote:
> > Since 20dd3850bcf8 ("can: Speed up CAN frame receiption by using
> > ml_priv") the CAN framework uses per device specific data in the AF_CAN
> > protocol. For this purpose the struct net_device->ml_priv is used. Later
> > the ml_priv usage in CAN was extended for other users, one of them being
> > CAN_J1939.
> >
> > Later in the kernel ml_priv was converted to an union, used by other
> > drivers. E.g. the tun driver started storing it's stats pointer.
> >
> > Since tun devices can claim to be a CAN device, CAN specific protocols
> > will wrongly interpret this pointer, which will cause system crashes.
> > Mostly this issue is visible in the CAN_J1939 stack.
> >
> > To fix this issue, we request a dedicated CAN pointer within the
> > net_device struct.
>
> No strong objection, others already added their pointers, but
> I wonder if we can't save those couple of bytes by adding a
> ml_priv_type, to check instead of dev->type? And leave it 0
> for drivers using stats?
Sounds good.
If we want to save even more bytes, it might be possible, to move the
wireless and wpan pointers to ml_priv.
struct wireless_dev *ieee80211_ptr;
struct wpan_dev *ieee802154_ptr;
> That way other device types which are limited by all being
> ARPHDR_ETHER can start using ml_priv as well?
>
> > +#if IS_ENABLED(CONFIG_CAN)
> > + struct can_ml_priv *can;
> > +#endif
>
> Perhaps put it next to all the _ptr fields?
Makes sense. Oleksij will resping the series.
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 |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists