Thread (5 messages) flat view 5 messages, 5 authors, 3d ago

Re: [PATCH net-next] ethtool: tsconfig: reject zero-valued tx_type and rx_filter bitsets

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-08-12 16:27:46

On Wed, Aug 12, 2026 at 09:22:30AM -0700, Jakub Kicinski wrote:
The ffs()/fls() guard in ethnl_set_tsconfig() was meant to enforce
that the user selects exactly one tx_type (and one rx_filter)
at a time (off / none are explicit types with non-zero values).
However, both ffs(0) and fls(0) return 0, so the guard passes
a zero-valued bitset through.

The subsequent ffs(req_tx_type) - 1 would produce -1, if user selected
no bit. net_hwtstamp_validate() catches the invalid -1 downstream,
but returns a generic error (-ERANGE) without telling the user
what went wrong. Return -EINVAL + extack instead.

Replace the ffs()/fls() comparison with a hweight32() == 1 check.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help