Finally I've found some time to look at this again... On 12.09.2022 17:28:15, Vincent Mailhol wrote: > Also, I was assuming that can_fixup_bittiming() was already doing the > out of range check: > https://elixir.bootlin.com/linux/v6.0-rc1/source/drivers/net/can/dev/bittiming.c#L27 > > But in reality, only one of either can_calc_bittiming(), > can_fixup_bittiming() or can_validate_bitrate() is being called. And > thus, can_validate_bitrate() might be called with out of range values > and in that case the neltink interface should return -ERANGE (for > example if sjw > sjw_max). > > Sees that there is more work to do here than initially anticipated. I've converted the existing netdev_err() NL_SET_ERR_MSG_FMT(). This means the error message is transported via netlink to user space and printed by the "ip" tool. | # ip link set flexcan0 txqueuelen 10 type can bitrate 2200000 | Warning: bitrate error 2.5%. | | # ip link set flexcan0 txqueuelen 10 type can bitrate 22000000 | Error: bitrate error 80.5% too high. This is the error message for the SJW check: | # ip link set flexcan0 txqueuelen 10 type can bitrate 500000 sjw 3 | Error: SJW 3 bigger than phase_seg1 6 and/or phase_seg2 2. Maybe add a '=' between the phase_seg and the actual number: | Error: SJW 3 bigger than phase_seg1=6 and/or phase_seg2=2. 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